class documentation

class RComBlkDet(RailComRead):

Constructor: RComBlkDet(blk_name, i)

View In Hierarchy

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_cb_count Get Read Count
Method get_error_counts Get Error Counts
Method report_event Report Event
Method reset_stats Reset diagnostic information
Property block_state Current block state
Property index Block Index Number
Async Method _check_resp Coroutine to monitor Ch1 responses
Method _log_error Undocumented
Method _rail_com_msg 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_state Undocumented
Instance Variable _cb_count Undocumented
Instance Variable _ch1_dg_rx Undocumented
Instance Variable _dcc_pin Undocumented
Instance Variable _errors Undocumented
Instance Variable _id_val Undocumented
Instance Variable _index block state may have channel 1 data if ch1 responses received or None
Instance Variable _rx_pin Undocumented
def __init__(self, blk_name, i):

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_namethe name of the block
iblock index number (0 - 3)
def get_cb_count(self):

Get Read Count

Returns
the number of times the detector read function has been called.
def get_error_counts(self):

Get Error Counts

Diagnostic method to retrieve the error counts for detected errors.

Returns
a dictionary of counts by error code.
def report_event(self, event, data):

Report Event

This overrides the Device.report_event method. It sets the thread safe flag to indicate block status change.

Parameters
eventupdated Block status code.
dataa tuple containing address type, address & orientation
def reset_stats(self):

Reset diagnostic information

Clears the error counts and set of datagram ids.

@property
block_state =

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.

@property
index =

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.

async def _check_resp(self):

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.

def _log_error(self, error_code):

Undocumented

def _rail_com_msg(self, _):

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
_blk_state =

Undocumented

_cb_count: int =

Undocumented

_ch1_dg_rx =

Undocumented

_dcc_pin =

Undocumented

_errors: dict =

Undocumented

_id_val: dict =

Undocumented

_index =

block state may have channel 1 data if ch1 responses received or None

_rx_pin =

Undocumented