7 from ctrlxdatalayer.clib_provider
import C_DLR_PROVIDER
14 Provider interface to manage provider nodes
15 Hint: see python context manager for instance handling
18 __slots__ = [
'__provider',
'__closed']
20 def __init__(self, c_provider: C_DLR_PROVIDER):
24 self.__provider: C_DLR_PROVIDER = c_provider
29 use the python context manager
33 def __exit__(self, exc_type, exc_val, exc_tb):
35 use the python context manager
41 closes the provider instance
46 ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerStop(self.__provider)
47 ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerDelete(
50 def register_type(self, address: str, pathname: str) -> Result:
52 Register a type to the datalayer
53 @param[in] address Address of the node to register (no wildcards allowed)
54 @param[in] pathname Path to flatbuffer bfbs
55 @returns <Result>, status of function call
57 b_address = address.encode(
'utf-8')
58 b_pathname = pathname.encode(
'utf-8')
59 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerRegisterType(self.__provider, b_address, b_pathname))
63 Unregister a type from the datalayer
64 @param[in] address Address of the node to register (wildcards allowed)
65 @returns <Result>, status of function call
67 b_address = address.encode(
'utf-8')
68 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerUnregisterType(self.__provider, b_address))
70 def register_node(self, address: str, node: ProviderNode) -> Result:
72 Register a node to the datalayer
73 @param[in] address Address of the node to register (wildcards allowed)
74 @param[in] node Node to register
75 @returns <Result>, status of function call
77 b_address = address.encode(
'utf-8')
78 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerRegisterNode(self.__provider, b_address, node.get_handle()))
82 Unregister a node from the datalayer
83 @param[in] address Address of the node to register (wildcards allowed)
84 @returns <Result>, status of function call
86 b_address = address.encode(
'utf-8')
87 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerUnregisterNode(self.__provider, b_address))
91 Set timeout for a node for asynchron requests (default value is 1000ms)
92 @param[in] node Node to set timeout for
93 @param[in] timeoutMS Timeout in milliseconds for this node
94 @returns <Result>, status of function call
98 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerSetTimeoutNode(self.__provider, node.get_handle(), timeout_ms))
100 def start(self) -> Result:
103 @returns <Result>, status of function call
105 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerStart(self.__provider))
107 def stop(self) -> Result:
110 @returns <Result>, status of function call
112 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerStop(self.__provider))
116 returns whether provider is connected
117 @returns status of connection
119 return ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerIsConnected(self.__provider)
123 return the current token of the current request.You can call this function during your onRead, onWrite, ... methods of your ProviderNodes. If there is no current request the method return an empty token
124 @returns <Variant> current token
126 return Variant(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerGetToken(self.__provider))
130 Register a type to the datalayer
131 @param[in] address Address of the node to register (no wildcards allowed)
132 @param[in] data Variant with flatbuffer type
133 @returns <Result>, status of function call
135 b_address = address.encode(
'utf-8')
136 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerRegisterTypeVariant(self.__provider, b_address, data.get_handle()))
139 """get_registered_type
141 Get the variant of a registered type
142 @param[in] address Address of the type to get type (no wildcards allowed)
143 result status of function call and Variant to stored type
145 b_address = address.encode(
'utf-8')
147 result =
Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerGetRegisteredType(self.__provider, b_address, data.get_handle()))
152 """get_registered_node_paths
154 return status of the function call and the current registered node paths
157 result =
Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerGetRegisteredNodePaths(self.__provider, data.get_handle()))
158 if result != Result.OK:
160 return result, data.get_array_string()
163 """get_rejected_node_paths
165 return status of the function call and the current rejected node paths
168 result =
Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerGetRejectedNodePaths(self.__provider, data.get_handle()))
169 if result != Result.OK:
171 return result, data.get_array_string()
173 def publish_event(self, data: Variant, event_type: Variant) -> Result:
177 @param[in] data The payload data of the event. Has to match the type, that is given in the notifyInfo.
178 @param[in] notifyInfo Contains additional info about the event with type event_info.fbs
179 @returns <Result>, status of function call
181 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerPublishEvent(self.__provider, data.get_handle(), event_type.get_handle()))
Variant get_token(self)
return the current token of the current request.You can call this function during your onRead,...
Result stop(self)
Stop the provider.
Result register_type_variant(self, str address, Variant data)
Register a type to the datalayer.
def __exit__(self, exc_type, exc_val, exc_tb)
use the python context manager
def get_rejected_node_paths(self)
get_rejected_node_paths
Result register_type(self, str address, str pathname)
Register a type to the datalayer.
def __enter__(self)
use the python context manager
Result unregister_node(self, str address)
Unregister a node from the datalayer.
Result start(self)
Start the provider.
def close(self)
closes the provider instance
def __init__(self, C_DLR_PROVIDER c_provider)
generate Provider
def get_registered_type(self, str address)
get_registered_type
bool is_connected(self)
returns whether provider is connected
Result unregister_type(self, str address)
Unregister a type from the datalayer.
def get_registered_node_paths(self)
get_registered_node_paths
Result register_node(self, str address, ProviderNode node)
Register a node to the datalayer.
Result set_timeout_node(self, ProviderNode node, int timeout_ms)
Set timeout for a node for asynchron requests (default value is 1000ms)
Result publish_event(self, Variant data, Variant event_type)
publish_event
Variant is a container for a many types of data.