ctrlX Data Layer API for Python  3.3.0
The ctrlX Data Layer API allows access to the ctrlX Data Layer with Python
system.py
1 """
2  System class
3 """
4 import ctrlxdatalayer
5 import ctrlxdatalayer.clib_system
6 from ctrlxdatalayer.converter import Converter
7 from ctrlxdatalayer.factory import Factory
8 
9 
10 class System:
11  """
12  Datalayer System Instance
13 
14  Hint: see python context manager for instance handling
15  """
16  __slots__ = ['__system', '__closed']
17 
18  def __init__(self, ipc_path: str):
19  """
20  Creates a datalayer system
21  @param[in] ipc_path Path for interprocess communication - use null pointer for automatic detection
22  """
23  b_ipc_path = ipc_path.encode('utf-8')
24  self.__system__system = ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemCreate(
25  b_ipc_path)
26  self.__closed__closed = False
27 
28  def __enter__(self):
29  """
30  use the python context manager
31  """
32  return self
33 
34  def __exit__(self, exc_type, exc_val, exc_tb):
35  """
36  use the python context manager
37  """
38  self.closeclose()
39 
40  def close(self):
41  """
42  closes the system instance
43  """
44  if self.__closed__closed:
45  return
46  self.__closed__closed = True
47  self.stopstop(True)
48  ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemDelete(self.__system__system)
49 
50  def get_handle(self):
51  """
52  handle value of system
53  """
54  return self.__system__system
55 
56  def start(self, bo_start_broker: bool):
57  """
58  Starts a datalayer system
59  @param[in] bo_start_broker Use true to start a broker. If you are a user of the datalayer - call with false!
60  """
61  ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemStart(
62  self.__system__system, bo_start_broker)
63 
64  def stop(self, bo_force_provider_stop: bool) -> bool:
65  """
66  Stops a datalayer system
67  @param[in] bo_force_provider_stop Force stop off all created providers for this datalayer system
68  @returns <bool> false if there is a client or provider active
69  """
70  return ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemStop(
71  self.__system__system, bo_force_provider_stop)
72 
73  def factory(self) -> Factory:
74  """
75  Returns the factory to create clients and provider for the datalayer
76  @returns <Factory>
77  """
78  c_factory = ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemFactory(
79  self.__system__system)
80  return Factory(c_factory)
81 
82  def json_converter(self) -> Converter:
83  """
84  Returns converter between JSON and Variant
85  @returns <Converter>
86  """
87  c_converter = ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemJsonConverter(
88  self.__system__system)
89  return Converter(c_converter)
90 
91  def set_bfbs_path(self, path):
92  """
93  Sets the base path to bfbs files
94  @param[in] path Base path to bfbs files
95  """
96  b_path = path.encode('utf-8')
97  ctrlxdatalayer.clib.libcomm_datalayer.DLR_systemSetBfbsPath(
98  self.__system__system, b_path)
Datalayer System Instance.
Definition: system.py:15
def set_bfbs_path(self, path)
Sets the base path to bfbs files.
Definition: system.py:95
def __exit__(self, exc_type, exc_val, exc_tb)
use the python context manager
Definition: system.py:37
Factory factory(self)
Returns the factory to create clients and provider for the datalayer.
Definition: system.py:77
def __enter__(self)
use the python context manager
Definition: system.py:31
def start(self, bool bo_start_broker)
Starts a datalayer system.
Definition: system.py:60
def close(self)
closes the system instance
Definition: system.py:43
def get_handle(self)
handle value of system
Definition: system.py:53
bool stop(self, bool bo_force_provider_stop)
Stops a datalayer system.
Definition: system.py:69
Converter json_converter(self)
Returns converter between JSON and Variant.
Definition: system.py:86
def __init__(self, str ipc_path)
Creates a datalayer system.
Definition: system.py:22