network - Device network base definitions¶
Device(sub-)network abstraction.
It is implemented as a D-Bus service container, bundling one service object per connected network, each service object being in charge of the communications with the devices and acting as a gateway with the D-Bus eventing layer.
The service container can be created for a specific set of coordinator types,
giving the ability to create sub-networks which can be controlled in an
independent way. Refer to DeviceNetworkSvc
documentation for details.
The configuration loading process takes care of taking in account only the equipments for which we have an implementation available. This allows heterogeneous implementation (in terms of programming language for instance), by letting each sub-system of the equipment support software pick only the devices and coordinators it knows how to handle.
-
class
pycstbox.hal.network.
DeviceNetworkSvc
(conn, svc_name, coord_types=None, coord_typemap=None)¶ This class implements a service container gathering all the equipment we know about.
Each sub-network attached to a given interface is represented by an independent service object responsible for managing the connected equipments.
Parameters: - conn (Connection) – the D-Bus connection of the container
- svc_name (str) – the name under which the service will be know on D-Bus
- coord_types (list) – a list of the coordinator types used to filter the device network configuration. If not provided, all know types as provided by the devcfg.Metedata class will be taken in account. The implementation class of the coordinators will be defaulted to CoordinatorServiceObject.
- coord_typemap (dict) – a dictionary providing for each coordinator type the associated implementation class. If both coord_types and coord_typemap parameters are used, coord_types is discarded.
-
log_setLevel
(level)¶ Defines the logging level for the container and its service objects.
Parameters: level – logging level (see module logging
)
-
load_configuration
(cfg)¶ Loads devices configuration.
Parameters: cfg (DeviceNetworkConfiguration) – network configuration
-
class
pycstbox.hal.network.
DeviceListEntry
(id_, cfg, haldev)¶ Named tuple gathering all informations related to a device.
Key id_: the device id Key cfg: the device configuration data, as stored in the network configuration Key haldev: the instance of HalDevice implementing the abstraction for the device -
cfg
¶ Alias for field number 1
-
haldev
¶ Alias for field number 2
-
id_
¶ Alias for field number 0
-
-
class
pycstbox.hal.network.
PollTask
(dev, period)¶ Named tuple describing a polling task for a given device.
Key dev: the instance of the related device Key period: the polling period (in seconds) -
dev
¶ Alias for field number 0
-
period
¶ Alias for field number 1
-
-
class
pycstbox.hal.network.
CoordinatorServiceObject
(cid)¶ DBus service object responsible for managing a given sub-network coordinator.
It provides a generic mechanism for scheduling the poll of the devices using this type of communications.
This class must be overridden most of the time if communication with the network is to be handled at the coordinator level. The only situation where it can be used as is is when device drivers know how to communicate directly with the equipments (such as those based on minimalmodbus for instance).
c_serial.SerialCoordinatorServiceObject is an example of such a sub-class, dealing with network communicating through a serial port in a centralized way.
Parameters: cid (str) – coordinator id -
log_setLevel
(level)¶ Defines the logging level for the container and its service objects.
Parameters: level – logging level (see module logging
)
-
load_configuration
(cfg)¶ Process the configuration data related to the coordinator and the devices attached to it.
Parameters: cfg (dict) – coordinator’s configuration data Raises ValueError: if no or empty configuration passed
-
cfg
¶ Read access to the coordinator and attached devices configuration.
-
send_command
(command, callback=None)¶ Provision for outbounds communication.
To be overridden by sub-class when needed. The default implementation raises a NotImplementedError exception.
Parameters: - command (str) – command to be sent (exact content is implementation dependent)
- callback (method) – an optional method to be called after the command has been sent (can be used for reply synchronous wait for instance)
-
start
()¶ Processing to be done when the service objet is started.
Called automatically by the framework when the service is started.
-
stop
()¶ Processing to be done when the service object is stopped.
Called automatically by the framework when the service is stopped.
-
-
exception
pycstbox.hal.network.
DeviceNetworkError
¶ Specialized exception for device network related errors.
-
class
pycstbox.hal.network.
Schedule
(when, task)¶ Named tuple describing a task schedule.
Key long when: schedule time (in second count from asbolute time origin) Key task: the instance of the task to be executed -
task
¶ Alias for field number 1
-
when
¶ Alias for field number 0
-
-
exception
pycstbox.hal.network.
PollingThreadError
¶ Specialized exception for polling thread errors.