Legrand / Raritan / Server Technology Xerus™ JSON-RPC API
Loading...
Searching...
No Matches
Peripheral Devices

Peripheral devices (external sensors and actuators) are handled by the peripheral.DeviceManager interface. The device manager has a fixed number of slots to which discovered sensors can be associated. Slots hold device settings like names and thresholds, and they define the order in which sensors are listed in other client interfaces like SNMP.

The peripheral device manager can either be accessed via its well-known RID /model/peripheraldevicemanager, or its reference can be retrieved by using the getPeripheralDeviceManager() method of the pdumodel.Pdu interface.

Resource ID Interface
/model/peripheraldevicemanager peripheral.DeviceManager
/model/peripheraldeviceslot/<slot> peripheral.DeviceSlot
/model/peripheraldeviceslot/<slot>/device sensors.NumericSensor
sensors.StateSensor
sensors.Switch

Discovered and Managed Peripherals

The Xerus controller scans for peripheral device packages connected to its sensor ports. Each discovered package implements one or more sensor functions, e.g. a temperature sensor.

The peripheral.DeviceManager interface implements the following methods for querying discovered devices, i.e. those that are currently present:

  • getDiscoveredPackages() returns references to all currently present peripheral device packages.

    The entries in the list are of type peripheral.Package, or a specialized derived interface like peripheral.BatteryPoweredDevicePackage or peripheral.DoorHandleControllerPackage.

  • getDiscoveredPackageInfos() returns a list of package info structures.

    It is equivalent to calling getPackageInfo() on each entry in the list from the previous method.

  • getDiscoveredDevices() returns a list with information about each currently present sensor function. Each entry contains a device ID and a topology position.

    Note: The device member in the structures returned by this method is always a null reference.

Peripherals become "managed" by being assigned to a device slot, either automatically or manually. The slot holds persistent information like names and thresholds. Slot information is always available, regardless of whether the peripheral is currently present of not.

Slot information is queried with the following peripheral.DeviceSlot methods:

  • getSettings() returns the slot settings like name, description and properties.
  • getDevice() returns the peripheral device assigned to this slot.

    For an empty slot, the method returns a null value, otherwise it returns the same structure as getDiscoveredDevices() above. However, in this case the device field contains a reference to the actual sensor interface.

    Depending on the type of the assigned peripheral, the device member can reference a sensors.NumericSensor, sensors.StateSensor or sensors.Switch.

Querying Managed Peripherals

Peripheral devices must be assigned to one of the device manager's slots in order to be used. A device associated with a slot can have settings (like name or location) and a reading.

Settings for a sensor slot can be retrieved with the getSettings() method and written with setSettings(). getDevice() returns information about the device associated with the slot (or null if the slot is unassigned), as well as a reference to the respective NumericSensor or StateSensor instance.

# Python example: Display information about all managed peripheral devices
import raritan.rpc.peripheral
pdm = raritan.rpc.peripheral.DeviceManager("/model/peripheraldevicemanager", agent)
slots = pdm.getDeviceSlots()
for num, slot in enumerate(slots, start=1):
device = slot.getDevice()
if device is None:
print(f"Slot {num}: empty")
else:
settings = slot.getSettings()
print(f"Slot {num}: {settings.name} ({device.deviceID.serial})")
if device.device:
if device.deviceID.type.readingtype == raritan.rpc.sensors.Sensor.NUMERIC:
# device.device is a sensors.NumericSensor
reading = device.device.getReading()
print(" Reading:", reading.value)
else:
# device.device is a sensors.StateSensor or sensors.Switch
state = device.device.getState()
print(" State:", state.value)

Manually Assigning Sensors to Slots

By default, newly discovered sensors are automatically associated with the first available slot. The assignment can be manually overridden with the assign() and unassign() methods of the PeripheralDeviceSlot interface:

# Python example: Assign the first discovered sensor to the third slot
import raritan.rpc.peripheral
pdm = raritan.rpc.peripheral.DeviceManager("/model/peripheraldevicemanager", agent)
discovered_devices = pdm.getDiscoveredDevices()
slots = pdm.getDeviceSlots()
if len(discovered_devices) > 0:
slots[2].assign(discovered_devices[0].deviceID)

Another option is the assignAddress() method, which identifies the assigned peripheral by its package type and an address (topology position and function type. This version has the advantage that it does not depend on concrete serial numbers, so it can be used to bulk-configure multiple setups with the same physical configuration:

# Python example: Assign a slot using topology information
from raritan.rpc import peripheral, sensors
# Package class: first three characters of serial number
package_class = "1EQ" # DX2-T1H1
# Connected to sensor port 1, third position in chain
position = [
peripheral.PosElement(peripheral.PortType.DEV_PORT, "1"),
peripheral.PosElement(peripheral.PortType.ONEWIRE_CHAIN_POS, "3")
]
# Assign the temperature function of the package
typespec = sensors.Sensor.TypeSpec(sensors.Sensor.NUMERIC,
sensors.Sensor.TEMPERATURE,
sensors.Sensor.DEGREE_CELSIUS)
address = peripheral.Address(position, typespec, isActuator=False, channel=-1)
slot = peripheral.DeviceSlot("/model/peripheraldeviceslot/2", agent)
slot.assignAddress(package_class, address)
Peripheral Device Slot.
peripheral device position based address
peripheral device position element, list forms position
Complete sensor type specification.
Definition Sensor.idl:179