pciserverprotocol
Module¶
-
class
cbus.protocol.pciserverprotocol.
PCIServerProtocol
¶ Bases:
cbus.protocol.cbus_protocol.CBusProtocol
Implements an asyncio Protocol for simulating a C-Bus PCI/CNI over TCP or serial.
This presently only implements a subset of the protocol used by PCIProtocol.
-
connection_made
(transport)¶ Called by asyncio a connection is made to the simulated PCI.
This doesn’t get fired in normal serial connections, however we’ll send a power up notification (PUN).
Serial Interface User Guide s4.3.3.4, page 33
-
echo
(data: bytes) → None¶ Called when data needs to be echoed to the underlying transport.
This is only called when running in server mode.
The default implementation is a stub, and needs to be implemented when running in server mode. This should only do something if the virtual PCI is in
basic
mode.
-
handle_cbus_packet
(p: cbus.protocol.base_packet.BasePacket) → None¶ Handles a single CBus packet.
-
lighting_group_off
(source_addr, group_addr)¶ Turns off the lights for the given group_addr.
Parameters: - source_addr (int) – Source address of the event.
- group_addr (int) – Group address to turn the lights on for.
Returns: Single-byte string with code for the confirmation event.
Return type: string
-
lighting_group_on
(source_addr, group_addr)¶ Turns on the lights for the given group_addr.
Parameters: - source_addr (int) – Source address of the event.
- group_addr (int) – Group address to turn the lights on for.
Returns: Single-byte string with code for the confirmation event.
Return type: string
-
lighting_group_ramp
(source_addr, group_addr, duration, level=1.0)¶ Ramps (fades) a group address to a specified lighting level.
Note: CBus only supports a limited number of fade durations, in decreasing accuracy up to 17 minutes (1020 seconds). Durations longer than this will throw an error.
A duration of 0 will ramp “instantly” to the given level.
Parameters: - source_addr (int) – Source address of the event.
- group_addr (int) – The group address to ramp.
- duration (int) – Duration, in seconds, that the ramp should occur over.
- level (float) – An amount between 0.0 and 1.0 indicating the brightness to set.
Returns: Single-byte string with code for the confirmation event.
Return type: string
-
lighting_group_terminate_ramp
(source_addr, group_addr)¶ Stops ramping a group address at the current point.
Parameters: - source_addr (int) – Source address of the event.
- group_addr (int) – Group address to stop ramping of.
Returns: Single-byte string with code for the confirmation event.
Return type: string
-
on_clock_request
()¶ Event called when a clock application “request time” is recieved.
-
on_clock_update
(val)¶ Event called when a clock application “update time” is recieved.
Parameters: - variable (datetime.date or datetime.time) – Clock variable to update.
- val – Clock value
-
on_lighting_group_off
(group_addr)¶ Event called when a lighting application “off” request is recieved.
Parameters: group_addr (int) – Group address being turned off.
-
on_lighting_group_on
(group_addr)¶ Event called when a lighting application “on” request is recieved.
Parameters: group_addr (int) – Group address being turned on.
-
on_lighting_group_ramp
(group_addr, duration, level)¶ Event called when a lighting application ramp (fade) request is recieved.
Parameters: - group_addr (int) – Group address being ramped.
- duration (int) – Duration, in seconds, that the ramp is occurring over.
- level (float) – Target brightness of the ramp (0.0 - 1.0).
-
on_lighting_group_terminate_ramp
(group_addr)¶ Event called when a lighting application “terminate ramp” request is recieved.
Parameters: group_addr (int) – Group address ramp being terminated.
-
on_master_application_status
(group_address: int) → None¶ Event for Status Request for the master application.
This expects a binary status report of the presence of every unit on the network. :param group_address: Group number to start from
-
on_reset
()¶ Event called when the PCI has been hard reset.
-
send_confirmation
(code: bytes, ok: bool = True)¶
-
send_error
()¶
-