|
Open Model Railroad Network (OpenMRN)
|
Static constants and helper functions for the Traciton protocol family. More...
#include <TractionDefs.hxx>
Public Types | |
| enum | { REQ_SET_SPEED = 0x00 , REQ_SET_FN = 0x01 , REQ_EMERGENCY_STOP = 0x02 , REQ_QUERY_SPEED = 0x10 , REQ_QUERY_FN = 0x11 , REQ_CONTROLLER_CONFIG = 0x20 , REQ_CONSIST_CONFIG = 0x30 , REQ_TRACTION_MGMT = 0x40 , REQ_MASK = 0x7F , REQ_LISTENER = 0x80 , CTRLREQ_ASSIGN_CONTROLLER = 0x01 , CTRLREQ_RELEASE_CONTROLLER = 0x02 , CTRLREQ_QUERY_CONTROLLER = 0x03 , CTRLREQ_NOTIFY_CONTROLLER_CHANGED = 0x04 , CNSTREQ_ATTACH_NODE = 0x01 , CNSTREQ_DETACH_NODE = 0x02 , CNSTREQ_QUERY_NODES = 0x03 , MGMTREQ_RESERVE = 0x01 , MGMTREQ_RELEASE = 0x02 , MGMTREQ_NOOP = 0x03 , RESP_QUERY_SPEED = REQ_QUERY_SPEED , RESP_QUERY_FN = REQ_QUERY_FN , RESP_CONTROLLER_CONFIG = REQ_CONTROLLER_CONFIG , RESP_CONSIST_CONFIG = REQ_CONSIST_CONFIG , RESP_TRACTION_MGMT = REQ_TRACTION_MGMT , SPEEDRESP_STATUS_IS_ESTOP = 1 , CTRLRESP_ASSIGN_CONTROLLER = CTRLREQ_ASSIGN_CONTROLLER , CTRLRESP_QUERY_CONTROLLER = CTRLREQ_QUERY_CONTROLLER , CTRLRESP_NOTIFY_CONTROLLER_CHANGED = CTRLREQ_NOTIFY_CONTROLLER_CHANGED , CTRLRESP_ASSIGN_ERROR_TRAIN = 0x02 , CTRLRESP_ASSIGN_ERROR_CONTROLLER = 0x01 , CNSTRESP_ATTACH_NODE = CNSTREQ_ATTACH_NODE , CNSTRESP_DETACH_NODE = CNSTREQ_DETACH_NODE , CNSTRESP_QUERY_NODES = CNSTREQ_QUERY_NODES , CNSTFLAGS_ALIASVALID = 0x01 , CNSTFLAGS_REVERSE = 0x02 , CNSTFLAGS_LINKF0 = 0x04 , CNSTFLAGS_LINKFN = 0x08 , CNSTFLAGS_HIDE = 0x80 , MGMTRESP_RESERVE = MGMTREQ_RESERVE , MGMTRESP_HEARTBEAT = 0x03 , PROXYREQ_ALLOCATE = 0x01 , PROXYREQ_ATTACH = 0x02 , PROXYREQ_DETACH = 0x03 , PROXYREQ_MANAGE = 0x80 , PROXYRESP_ALLOCATE = PROXYREQ_ALLOCATE , PROXYRESP_ATTACH = PROXYREQ_ATTACH , PROXYRESP_MANAGE = PROXYREQ_MANAGE , PROXYREQ_MANAGE_RESERVE = 0x01 , PROXYREQ_MANAGE_RELEASE = 0x02 , PROXYRESP_MANAGE_RESERVE_REPLY = 0x01 , PROXYTYPE_DCC = 1 , PROXYTYPE_DC = 2 , PROXYTYPE_MARKLIN_DIGITAL = 3 , PROXYTYPE_MARKLIN_DELTA = 4 , PROXYTYPE_MARKLIN_MFX = 5 , PROXYTYPE_SELECTRIX = 6 , PROXYTYPE_MTH_DCS = 7 , PROXYTYPE_LIONEL_TMCC = 8 , FUNCTION_CONFIG_MEMORY_SPACE = 0xF9 , FNCONFIG_FN = 0x0 , FNCONFIG_BINARYSTATE_LONG = 0x1 , FNCONFIG_BINARYSTATE_SHORT = 0x2 , FNCONFIG_ANALOG_OUTPUT = 0x3 } |
Static Public Member Functions | |
| static NodeID | train_node_id_from_legacy (dcc::TrainAddressType type, uint32_t addr) |
| Converts a legacy address to an NMRAnet node ID. | |
| static bool | legacy_address_from_train_node_id (NodeID id, dcc::TrainAddressType *type, uint32_t *addr) |
| Converts a node ID to a legacy address if possible. | |
| static string | train_node_name_from_legacy (dcc::TrainAddressType type, uint32_t addr) |
| Converts a legacy address to a user-visible name. | |
| static string | guess_train_node_name (NodeID node_id) |
| Renders a guess at the traction node name. | |
| static Payload | estop_set_payload () |
| static Payload | speed_set_payload (Velocity v) |
| static Payload | speed_get_payload () |
| static bool | speed_get_parse_last (const Payload &p, Velocity *v, bool *is_estop=nullptr) |
| Parses the response payload of a GET_SPEED packet. | |
| static Payload | fn_set_payload (unsigned address, uint16_t value) |
| static Payload | fn_get_payload (unsigned address) |
| static bool | fn_get_parse (const Payload &p, uint16_t *value, unsigned *address) |
| Parses the response payload of a GET_FN packet. | |
| static Payload | assign_controller_payload (Node *ctrl) |
| static Payload | release_controller_payload (Node *ctrl) |
| static Payload | consist_add_payload (NodeID slave, uint8_t flags) |
| static Payload | consist_add_response (NodeID slave, uint16_t error_code) |
| static Payload | consist_del_payload (NodeID slave) |
| static Payload | consist_del_response (NodeID slave, uint16_t error_code) |
| static Payload | consist_qry_payload () |
| static Payload | consist_qry_payload (uint8_t arg) |
| static Payload | consist_qry_response_short (uint8_t num_entries) |
| static Payload | consist_qry_response_long (uint8_t num_entries, uint8_t index, uint8_t flags, NodeID slave) |
| static Payload | heartbeat_request_payload (uint8_t deadline_sec=3) |
| Generates a Heartbeat Request, to be sent from the train node to the controller. | |
| static Payload | noop_payload () |
| Generates a Noop message, to be sent from the throttle to the train node. | |
Static Public Attributes | |
| static const uint64_t | IS_TRAIN_EVENT = 0x0101000000000303ULL |
| This event should be produced by train nodes. | |
| static const uint64_t | IS_PROXY_EVENT = 0x0101000000000304ULL |
| This event should be produced by traction proxy nodes. | |
| static constexpr uint64_t | ACTIVATE_BASIC_DCC_ACCESSORY_EVENT_BASE = 0x0101020000FF0000ULL |
| Base address of DCC accessory decoder well-known event range (active) | |
| static constexpr uint64_t | INACTIVATE_BASIC_DCC_ACCESSORY_EVENT_BASE = 0x0101020000FE0000ULL |
| Base address of DCC accessory decoder well-known event range (inactive) | |
| static constexpr uint64_t | EXT_DCC_ACCESSORY_EVENT_BASE = 0x0101020001000000ULL |
| Base address of DCC extended accessory decoder well-known event range. | |
| static const uint64_t | NODE_ID_DC_BLOCK = 0x060000000000ULL |
| Node ID space allocated for DC blocks. | |
| static const uint64_t | NODE_ID_DCC = 0x060100000000ULL |
| Node ID space allocated for DCC locomotives. | |
| static const uint16_t | DCC_LONG_SELECTOR = 0xC000 |
| Long addresses should OR this selector to {}. | |
| static const uint64_t | NODE_ID_TMCC = 0x060200000000ULL |
| Node ID space allocated for TMCC protocol. | |
| static const uint64_t | NODE_ID_MARKLIN_MOTOROLA = 0x060300000000ULL |
| Node ID space allocated for the Marklin-Motorola protocol. | |
| static const uint64_t | NODE_ID_MTH_DCS = 0x060400000000ULL |
| Node ID space allocated for the MTH DCS protocol. | |
| static const uint64_t | NODE_ID_MASK = 0xFFFF00000000ULL |
| Node ID space mask. | |
Static constants and helper functions for the Traciton protocol family.
Definition at line 67 of file TractionDefs.hxx.
| anonymous enum |
Definition at line 93 of file TractionDefs.hxx.
Definition at line 424 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 444 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 454 of file TractionDefs.hxx.
Definition at line 464 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 473 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 480 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 488 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 506 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 497 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 333 of file TractionDefs.hxx.
|
inlinestatic |
Parses the response payload of a GET_FN packet.
| p | is the response payload. |
| value | will be set to the output value. |
| address | will be set to the function address. |
Definition at line 407 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 393 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 382 of file TractionDefs.hxx.
|
inlinestatic |
Renders a guess at the traction node name.
If it is a recognized train node range, renders te default name for that protocol, otherwise a mac address format.
| node_id | is the train node OpenLCB node ID |
Definition at line 313 of file TractionDefs.hxx.
|
inlinestatic |
Generates a Heartbeat Request, to be sent from the train node to the controller.
Definition at line 521 of file TractionDefs.hxx.
|
inlinestatic |
Converts a node ID to a legacy address if possible.
| id | is an openLCB NodeID |
| type | (must be not null) will be filled with the legacy train address type |
| addr | (must be not null) will be filled with the legacy train address. |
Definition at line 241 of file TractionDefs.hxx.
|
inlinestatic |
Generates a Noop message, to be sent from the throttle to the train node.
Definition at line 531 of file TractionDefs.hxx.
Definition at line 434 of file TractionDefs.hxx.
|
inlinestatic |
Parses the response payload of a GET_SPEED packet.
| p | is the response payload. |
| v | is the velocity that will be set to the speed value. |
| is_estop | if non-null, will be set to true if the train was last set to estop instead of a speed. |
Definition at line 359 of file TractionDefs.hxx.
|
inlinestatic |
Definition at line 346 of file TractionDefs.hxx.
Definition at line 339 of file TractionDefs.hxx.
|
inlinestatic |
Converts a legacy address to an NMRAnet node ID.
The conversion algorithm chosen here is rather arbitrary, as it is not specified in the standard how the individual reserved blocks are laid out internally to addresses. The only important thing is that for different track bit patterns a different node ID be generated.
| type | defines what address type it is (dcc-short, dcc-long or MM) |
| addr | is the legacy address, the valid values are defined by the specific protocols. |
Definition at line 215 of file TractionDefs.hxx.
|
inlinestatic |
Converts a legacy address to a user-visible name.
| type | defines what address type it is (dcc-short, dcc-long or MM) |
| addr | is the legacy address, the valid values are defined by the specific protocols. |
Definition at line 277 of file TractionDefs.hxx.
|
staticconstexpr |
Base address of DCC accessory decoder well-known event range (active)
Definition at line 73 of file TractionDefs.hxx.
|
static |
Long addresses should OR this selector to {}.
Definition at line 83 of file TractionDefs.hxx.
|
staticconstexpr |
Base address of DCC extended accessory decoder well-known event range.
Definition at line 77 of file TractionDefs.hxx.
|
staticconstexpr |
Base address of DCC accessory decoder well-known event range (inactive)
Definition at line 75 of file TractionDefs.hxx.
|
static |
This event should be produced by traction proxy nodes.
Definition at line 71 of file TractionDefs.hxx.
|
static |
This event should be produced by train nodes.
Definition at line 69 of file TractionDefs.hxx.
|
static |
Node ID space allocated for DC blocks.
Definition at line 79 of file TractionDefs.hxx.
|
static |
Node ID space allocated for DCC locomotives.
Definition at line 81 of file TractionDefs.hxx.
|
static |
Node ID space allocated for the Marklin-Motorola protocol.
Definition at line 87 of file TractionDefs.hxx.
|
static |
Node ID space mask.
Definition at line 91 of file TractionDefs.hxx.
|
static |
Node ID space allocated for the MTH DCS protocol.
Definition at line 89 of file TractionDefs.hxx.
|
static |
Node ID space allocated for TMCC protocol.
Definition at line 85 of file TractionDefs.hxx.