Channel 1 (block) Detector.
This runs on a local block detector MCU.
The PIO code monitors the DCC voltage to detect the cutout.
Although in addition to interpreting channel 1 messages, we could use the rx_pin to monitor the block for occupancy, detecting non RailCom decoders and other loads. This detection would not be as sensitive as other current based detectors as it uses same thresholds as required for RailCom message detection.
It's taken that a decoder may only be in one place at a time, but the implications of this are dealt with elsewhere.
Datagram identifiers for channel 1 are defined in RCN-217 3.1 Table 5.
This inherits from the RailComRead Class.
- Block status may be:
- unknown (start of day)
- no RailCom Channel 1 info available
- RailCom Channel 1 info available
| Method | __init__ |
Inititalise the RailCom block detector. |
| Method | get |
Get Read Count |
| Method | get |
Get Error Counts |
| Method | report |
Report Event |
| Method | reset |
Reset diagnostic information |
| Property | block |
Current block state |
| Property | index |
Block Index Number |
| Async Method | _check |
Coroutine to monitor Ch1 responses |
| Method | _log |
Undocumented |
| Method | _rail |
This is called on termination of the RailCom Channel 1 message receipt window, when a channel 1 reponse has been detected (i.e. length > 0) Any decoder on the associated block returns a channel 1 message. |
| Instance Variable | _blk |
Undocumented |
| Instance Variable | _cb |
Undocumented |
| Instance Variable | _ch1 |
Undocumented |
| Instance Variable | _dcc |
Undocumented |
| Instance Variable | _errors |
Undocumented |
| Instance Variable | _id |
Undocumented |
| Instance Variable | _index |
block state may have channel 1 data if ch1 responses received or None |
| Instance Variable | _rx |
Undocumented |
Inititalise the RailCom block detector.
The RailCom block detector reads channel 1. This initiates a RailCom reader using the supplied block name and index number. This runs on a remote controller and the cutout timing is recovered from the DCC signal. The base RailCom class is initiated with the block name. Hardware pin and state machine allocations are retreived from the hardware configuration.
Note
The RailCom reader will use two sequentially numbered state machines - the first is supplied.
The RailCom reader will use two sequentially numbered GPIO pins for receiving - the first is supplied.
| Parameters | |
| blk | the name of the block |
| i | block index number (0 - 3) |
Get Error Counts
Diagnostic method to retrieve the error counts for detected errors.
| Returns | |
| a dictionary of counts by error code. |
Report Event
This overrides the Device.report_event method. It sets the thread safe flag to indicate block status change.
| Parameters | |
| event | updated Block status code. |
| data | a tuple containing address type, address & orientation |
Current block state
This returns the current block state. The block state is a tuple containing the RailCom information available. If no RailCom information is available block is None.
Block Index Number
The block index number is derived from the blocks position in the configuration list. It's used to identify the Indicator led.
Coroutine to monitor Ch1 responses
This runs a time out timer. The timer is restarted if a Ch1 response is detected. If the timer expires the block is treated as being vacant as far as RailCom is concerned. Occupancy info is cleared.
The coroutine task runs forever.
This is called on termination of the RailCom Channel 1 message receipt window, when a channel 1 reponse has been detected (i.e. length > 0) Any decoder on the associated block returns a channel 1 message.
Calls RailComRead.hw4_2_6b() to translate from raw byte to internal value.
The method overrides that in the base class.
Orientation of decoder wrt the DCC signal is saved as 1 or -1 e.g. s * 2 - 1
Buffer contains 1 or 2 bytes. Zero length reads don't get this far. Longer reads are already truncated.
Overrun errors on 1st byte are quietly ignored. Overrun error on 2nd byte is logged.
If the buffer only 1 byte or one of the bytes is ACK or NAK or reserved in RCN-217 Table2, this is an error and is logged.
The datagram ID must be 1, 2 or 3. Type 3 datagrams are ignored. Other datagram IDs are logged as errors.
As a protection against undetected errors, to be acted on a type 1 or 2 datagram must have the same payload as the preceding datagram of that type.
| Parameters | |
| _ | this paramater is only used for channel 2 |