IObjectDictionary.ReadObjectByAddress (METH) ¶ METHOD ReadObjectByAddress : ABORT_CODE Used to read an object of the local object dictionary. If ABORT_CODE.SUCCESSFUL is returned pbyData contains the read data. If error occured the corresponding abort code is returned. InOut: Scope Name Type Initial Comment Return ReadObjectByAddress ABORT_CODE ABORT_CODE.SUCCESSFUL : Reading successful, pbyData contains data; ELSE: Reading not permitted Input wIndex WORD Index of object which should be read bySubIndex BYTE Subindex of object xCheckAccess BOOL TRUE TRUE : Access rights should be checked. Reading a writeonly object will fail. FALSE : Ignore access rights and force reading xDataInBusOrder BOOL Specifies in which Byte Order data should be read; TRUE : Data should be read in CANopen Byteorder (Little Endian), FALSE : Data should be read in Host Byte Order pbyData POINTER TO BYTE Pointer to data where the object value should be copied to. Inout udiSize UDINT VAR IN: Size of memory pbyData points to; VAR OUT: Size of Object
IObjectDictionary.GetObject (METH) ¶ METHOD GetObject : IODObject Used to get an object with a specific index. InOut: Scope Name Type Comment Return GetObject IODObject Object with given Index or 0 if no such object Input wIndex WORD Index of object
IObjectDictionary.GetObjectToWrite (METH) ¶ METHOD GetObjectToWrite : ABORT_CODE Used to search for an object and checking general write permission (access rights and data size). Returns ABORT_CODE.SUCCESSFUL if writing is allowed. Only needed if writing permission should be checked without writing immediately to the object. InOut: Scope Name Type Initial Comment Return GetObjectToWrite ABORT_CODE ABORT_CODE.SUCCESSFUL : Object writing permitted; ELSE: Writing not permitted Input wIndex WORD Index of object which should be written bySubIndex BYTE Subindex of object xCheckAccess BOOL TRUE TRUE : Check access rights, FALSE : do not check access rights udiSize UDINT size of data to be written Output itfObject IODObject requested object itfSubObject IODSubObject requested subobject
IObjectDictionary.WriteObject (METH) ¶ METHOD WriteObject : ABORT_CODE Used to write an object in the local object dictionary. If ABORT_CODE.SUCCESSFUL is returned data in pbyData was copied to the object. If error occured the corresponding abort code is returned. Difference to IObjectDictionary.WriteObjectByAddress : Better performance because itfObject is an input variable => no internal binary search necessary. InOut: Scope Name Type Initial Comment Return WriteObject ABORT_CODE ABORT_CODE.SUCCESSFUL : Writing successful, object value was changed according to pbyData; ELSE: Writing not permitted Input itfObject IODObject Object which should be written. bySubIndex BYTE Subindex of object xCheckAccess BOOL TRUE TRUE : Access rights should be checked. Write on readonly object will fail. FALSE : Ignore access rights and force writing. xDataInBusOrder BOOL Specifies Byte Order of data pbyData points to; TRUE : Data in CANopen Byteorder (Little Endian), FALSE : Data in Host Byte Order pbyData POINTER TO BYTE Pointer to data which should be written to the object Inout udiSize UDINT VAR IN: Size of memory pbyData points to; VAR OUT: Size of Object
Iterators ¶ Iterators for simple iterating through the ObjectDictionary of a slave. ObjectIterator (FunctionBlock) Current (Property) MoveNext (Method) ObjectDictionary (Property) Reset (Method) SubObjectIterator (FunctionBlock) Current (Property) MoveNext (Method) Object (Property) Reset (Method)
ObjectIterator (FB) ¶ FUNCTION_BLOCK ObjectIterator IMPLEMENTS IObjectIterator Helps to iterate through the objects of an ObjectDictionary. For using this iterator property ObjectIterator.ObjectDictionary must be set to the IObjectDictionary interface. This interface can be retrieved from the CANopenDevice instance. After setting the Object Dictionary interface the iterator points in front of the first element of the Object Dictionary (==> property ObjectIterator.Current is 0). The iterator can be moved to the next element by calling the ObjectIterator.MoveNext method. If ObjectIterator.MoveNext returns TRUE the object can be retrieved by calling Property ObjectIterator.Current . The iterator can be set back in front of the first element by calling ObjectIterator.Reset . Example Following example iterates through all objects in an Object Dictionary an increments a counter. METHOD CountObjects VAR_INPUT END_VAR VAR_OUTPUT udiObjectCount : UDINT ; udiSubObjCount : UDINT ; END_VAR VAR ObjIterator : _3SCSS.ObjectIterator ; SubObjIterator : _3SCSS.SubObjectIterator ; itfCurObj : _3SCSS.IODObject ; itfCurSubObj : _3SCSS.IODSubObject ; END_VAR //Link Object Iterator to Object Dictionary ObjIterator.ObjectDictionary := _itfOD ; //Go through all objects WHILE ObjIterator.MoveNext () DO itfCurObj := ObjIterator.Current ; //Note: No NULL check necessary here because MoveNext returned TRUE. udiObjectCount := udiObjectCount + 1 ; //Link SubObjIterator with current Object SubObjIterator.Object := itfCurObj ; //Go through all SubObjects WHILE SubObjIterator.MoveNext () DO itfCurSubObj := SubObjIterator.Current ; udiSubObjCount := udiSubObjCount + 1 ; END_WHILE END_WHILE Properties: Current ObjectDictionary Methods: MoveNext Reset Structure: Current (Property) MoveNext (Method) ObjectDictionary (Property) Reset (Method)
ObjectIterator.Current (PROP) ¶ PROPERTY Current : IODObject Gets the object where the iterator points to.
ObjectIterator.MoveNext (METH) ¶ METHOD MoveNext : BOOL Sets the iterator to the next object. This object can be retrieved afterwards by property |ObjectIterator.Current|. Method returns ``TRUE` if iterator was successfully moved. Method returns FALSE e.g. if end of list. InOut: Scope Name Type Comment Return MoveNext BOOL TRUE : Current points to the next object, FALSE : MoveNext failed, e.g. if end of list.
ObjectIterator.ObjectDictionary (PROP) ¶ PROPERTY ObjectDictionary : IObjectDictionary IObjectDictionary where the iterator is connected to. Iterator will be automatically resetted if ObjectDictionary will be set.
ObjectIterator.Reset (METH) ¶ METHOD Reset Resets the iterator. Afterwards iterator points in front of the first element (==> ObjectIterator.Current is 0).