5 from ctrlxdatalayer.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 ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerStop(self.__provider)
45 ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerDelete(
48 def register_type(self, address: str, pathname: str) -> Result:
50 Register a type to the datalayer
51 @param[in] address Address of the node to register (no wildcards allowed)
52 @param[in] pathname Path to flatbuffer bfbs
53 @returns <Result>, status of function call
55 b_address = address.encode(
'utf-8')
56 b_pathname = pathname.encode(
'utf-8')
57 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerRegisterType(self.__provider, b_address, b_pathname))
61 Unregister a type from the datalayer
62 @param[in] address Address of the node to register (wildcards allowed)
63 @returns <Result>, status of function call
65 b_address = address.encode(
'utf-8')
66 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerUnregisterType(self.__provider, b_address))
68 def register_node(self, address: str, node: ProviderNode) -> Result:
70 Register a node to the datalayer
71 @param[in] address Address of the node to register (wildcards allowed)
72 @param[in] node Node to register
73 @returns <Result>, status of function call
75 b_address = address.encode(
'utf-8')
76 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerRegisterNode(self.__provider, b_address, node.get_handle()))
80 Unregister a node from the datalayer
81 @param[in] address Address of the node to register (wildcards allowed)
82 @returns <Result>, status of function call
84 b_address = address.encode(
'utf-8')
85 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerUnregisterNode(self.__provider, b_address))
89 Set timeout for a node for asynchron requests (default value is 1000ms)
90 @param[in] node Node to set timeout for
91 @param[in] timeoutMS Timeout in milliseconds for this node
92 @returns <Result>, status of function call
96 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerSetTimeoutNode(self.__provider, node.get_handle(), timeout_ms))
98 def start(self) -> Result:
101 @returns <Result>, status of function call
103 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerStart(self.__provider))
105 def stop(self) -> Result:
108 @returns <Result>, status of function call
110 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerStop(self.__provider))
114 returns whether provider is connected
115 @returns status of connection
117 return ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerIsConnected(self.__provider)
121 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
122 @returns <Variant> current token
124 return Variant(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerGetToken(self.__provider))
128 Register a type to the datalayer
129 @param[in] address Address of the node to register (no wildcards allowed)
130 @param[in] data Variant with flatbuffer type
131 @returns <Result>, status of function call
133 b_address = address.encode(
'utf-8')
134 return Result(ctrlxdatalayer.clib.libcomm_datalayer.DLR_providerRegisterTypeVariant(self.__provider, b_address, data.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
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
bool is_connected(self)
returns whether provider is connected
Result unregister_type(self, str address)
Unregister a type from the datalayer.
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)
Variant is a container for a many types of data.