Skip to content

Commit

Permalink
Add new section about arbitrary device types to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kretov.vadim committed Oct 28, 2022
1 parent 8ce1ffc commit b979b8b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/alphalogic_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,35 @@ Handlers order example
# 2: Parameters, commands, events created.
# Values from configuration loaded.

Arbitrary object type
---------------------
Alphalogic object has ``type`` attribute. By default, it's set to Python object's class name. For example, an object with Python class ``MyObject`` has ``MyObject`` alphalogic object type.
However, you may want to set an alphalogic type which cannot be represented by Python class name, like ``access.wipepoint``. Such names usually required for ACS adapters.
In this case, two steps should be done to set an arbitrary type attribute.
First, in list returned from parent's ``handle_available_children()`` method, corresponding item should be represented by a tuple with 3 elements where the last element is the required type name.
Second, before creating root object, this type should be registered with ``Manager.add_device("type name", ClassName)`` method.
Example:
::
class AccessWipepoint(Object):
# This device has alphalogic type "access.wipepoint"
pass

class RootDevice(Root):
def handle_get_available_children(self):
# Set additional element in tuple with device type
return [(AccessWipepoint, "access wipepoint device", "access.wipepoint")]

if __name__ == "__main__":
# Add device AccessWipepoint to alphalogic-api with device type "access.wipepoint"
Manager.add_device("access.wipepoint", AccessWipepoint)

# main loop
root = RootDevice()
# ...


If you need to set arbitrary type for the root object, this type must be set in the C++ part of your adapter.

Dynamic object components
-------------------------
Besides adding a component (parameter, command, event) as a class attribute, components can be added dynamically since alphalogic_api v0.0.23.
Expand Down

0 comments on commit b979b8b

Please sign in to comment.