4 pex-driver: PEx Power Control
This driver was written to control the ApolloArt PEx Devices for power and lighting control. Namely, it supports their relays and faders.
4.1 Command Line Arguments
-r, --rpc-endpoint —
Endpoint to receive commands on. Defaults to tcp://127.0.0.1:46103. -p, --pub-endpoint —
Endpoint to push notifications from. Defaults to tcp://127.0.0.1:46203. -i, --identity —
Identity for both endpoints. Defaults to pex.
Apart from these flags, the pex-driver command expects a path to serial port device file to open and an identifier of the bank to scan. For example:
pex-driver --identity power /dev/ttyS3 0
Would open the /dev/ttyS3 device, assume the power identity and scan for relays and faders in the bank number 0.
4.2 Command Messages
To request immediate notification about status of all detected relays and faders on the bus:
(hasheq 'request "status")
To control relay power status:
(hasheq 'request "set-on!" 'relay relay-number 'on? on?) Where relay-number represents a relay identifier reported over the publisher socket, possibly in reply to a "status" request. The on? boolean flag indicates whether the relay should be turned on.
To control power level of a fader:
(hasheq 'request "set-level!" 'fader fader-number 'level level) Where fader-number represents a fader identifier reported over the publisher socket, possibly in reply to a "status" request. The level natural number ranging from 0 to 99 represents the desired power level.
Setting the level to 0 will turn the fader power off completely. Please note that some level settings are ignored by the fader device. It is suggested to experiment with your setup.
To gradually change power level of a fader:
(hasheq 'request "fade-to-level!" 'fader fader-number 'level level) This request is mostly identical to "set-level!", but instead of setting the desired level immediately, fades to the desired level in a single second.
As with "set-level!", some levels might not register. Please experiment with your setup to learn what levels work for you. Also note that it might not be possible to fade out completely.
4.3 Published Messages
Every few seconds, the driver publishes a complete status of all relays and faders found on the bus:
(hasheq 'full (hasheq 'relays (list (hasheq 'id 1 'on? #t) ...) 'faders (list (hasheq 'id 2 'level 50) ...))) When a relay has been toggled or a fader has been adjusted a delta update is emitted:
(hasheq 'delta (hasheq 'relay (hasheq 'id 1 'on? #f))) (hasheq 'delta (hasheq 'fader (hasheq 'id 2 'level 33)))