Welcome, Guest
Username: Password: Remember me

TOPIC: Application against proview db

Application against proview db 4 years 1 month ago #10510

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3170
  • Thank you received: 497
  • Karma: 133
Hi Snarf,

Another question is of you really need an Iv or can use an ordinary attribute of type Int32. The Iv is IO copied and thread safe when used in the plc, but often an Int32 attribute will do as well.

There are a number of functions to traverse the object tree. gdh_GetClassList() and gdh_GetNextObject() will find all objects of a specific class, and it seems that this could be suitable for you.

pwr_sClass_MyClass *p;

for (sts = gdh_GetClassList(pwr_cClass_MyClass, &oid); ODD(sts); sts = gdh_GetNextObject(oid, &oid)) {
sts = gdh_ObjidToPointer(oid, &p); // or gdh_RefObjectInfoAttrref()
...
}

If you want to search all objects from the top hierarchy you can use gdh_GetRootList(), gdh_GetChild() and gdh_GetNextSibling().

/Claes
The administrator has disabled public write access.

Application against proview db 4 years 1 month ago #10513

  • Snarf77
  • Snarf77's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 847
  • Thank you received: 2
  • Karma: 5
Yes you re right, now I'm using only smaller object like int or float but some of my first modules that should be ideally rewritten still contained some Dv, Iv and there are part of our application.

I have finalized my external application now and I used as you mentioned GetRootList, gdh_GetObjectClass and gdh_GetChild / gdh_GetNextSibling to browse all the hierarchy. This works fine but I didn't know about the GetClassList function that I will probably use to make the code more efficient.

Can you please nevertheless provide an example using the gdh_TranslateRtdbPointer with an Actualvalue just for my understanding.

Thank you very much for your precious help as always and have a good week end
Snarf
The administrator has disabled public write access.

Application against proview db 4 years 1 month ago #10515

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3170
  • Thank you received: 497
  • Karma: 133
Your just need to cast ActualValue as an unsigned long.
pwr_tInt32 *p = (pwr_tInt32 *)gdh_TranslateRtdbPointer((unsigned long)iv_ptr->ActualValue);

/Claes
The administrator has disabled public write access.
Time to create page: 8.284 seconds