5 from datalayer.clib_provider
import C_DLR_PROVIDER
12 Provider interface to manage provider nodes
13 Hint: see python context manager for instance handling
16 __slots__ = [
'__provider',
'__closed']
18 def __init__(self, c_provider: C_DLR_PROVIDER):
22 self.__provider: C_DLR_PROVIDER = c_provider
27 use the python context manager
31 def __exit__(self, exc_type, exc_val, exc_tb):
33 use the python context manager
39 closes the provider instance
44 datalayer.clib.libcomm_datalayer.DLR_providerStop(self.__provider)
45 datalayer.clib.libcomm_datalayer.DLR_providerDelete(self.__provider)
47 def register_type(self, address: str, pathname: str) -> Result:
49 Register a type to the datalayer
50 @param[in] address Address of the node to register (no wildcards allowed)
51 @param[in] pathname Path to flatbuffer bfbs
52 @returns <Result>, status of function call
54 b_address = address.encode(
'utf-8')
55 b_pathname = pathname.encode(
'utf-8')
56 return Result(datalayer.clib.libcomm_datalayer.DLR_providerRegisterType(self.__provider, b_address, b_pathname))
60 Unregister a type from the datalayer
61 @param[in] address Address of the node to register (wildcards allowed)
62 @returns <Result>, status of function call
64 b_address = address.encode(
'utf-8')
65 return Result(datalayer.clib.libcomm_datalayer.DLR_providerUnregisterType(self.__provider, b_address))
67 def register_node(self, address: str, node: ProviderNode) -> Result:
69 Register a node to the datalayer
70 @param[in] address Address of the node to register (wildcards allowed)
71 @param[in] node Node to register
72 @returns <Result>, status of function call
74 b_address = address.encode(
'utf-8')
75 return Result(datalayer.clib.libcomm_datalayer.DLR_providerRegisterNode(self.__provider, b_address, node.get_handle()))
79 Unregister a node from the datalayer
80 @param[in] address Address of the node to register (wildcards allowed)
81 @returns <Result>, status of function call
83 b_address = address.encode(
'utf-8')
84 return Result(datalayer.clib.libcomm_datalayer.DLR_providerUnregisterNode(self.__provider, b_address))
88 Set timeout for a node for asynchron requests (default value is 1000ms)
89 @param[in] node Node to set timeout for
90 @param[in] timeoutMS Timeout in milliseconds for this node
91 @returns <Result>, status of function call
95 return Result(datalayer.clib.libcomm_datalayer.DLR_providerSetTimeoutNode(self.__provider, node.get_handle(), timeout_ms))
97 def start(self) -> Result:
100 @returns <Result>, status of function call
102 return Result(datalayer.clib.libcomm_datalayer.DLR_providerStart(self.__provider))
104 def stop(self) -> Result:
107 @returns <Result>, status of function call
109 return Result(datalayer.clib.libcomm_datalayer.DLR_providerStop(self.__provider))
113 returns whether provider is connected
114 @returns status of connection
116 return datalayer.clib.libcomm_datalayer.DLR_providerIsConnected(self.__provider)
120 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
121 @returns <Variant> current token
123 return Variant(datalayer.clib.libcomm_datalayer.DLR_providerGetToken(self.__provider))