34#ifndef _OPENLCB_DEFS_HXX_
35#define _OPENLCB_DEFS_HXX_
66 NodeHandle() :
id(0),
alias(0) {}
126 MTI_LEARN_EVENT = 0x0594,
127 MTI_EVENT_REPORT = 0x05B4,
128 MTI_TRACTION_CONTROL_COMMAND = 0x05EB,
129 MTI_TRACTION_CONTROL_REPLY = 0x01E9,
130 MTI_TRACTION_PROXY_COMMAND = 0x05EA,
131 MTI_TRACTION_PROXY_REPLY = 0x01E8,
132 MTI_XPRESSNET = 0x09C0,
170 ERROR_PERMANENT = 0x1000,
171 ERROR_TEMPORARY = 0x2000,
173 ERROR_SRC_NOT_PERMITTED = 0x1020,
174 ERROR_OPENMRN_NOT_FOUND = 0x1030,
175 ERROR_UNIMPLEMENTED = 0x1040,
176 ERROR_INVALID_ARGS = 0x1080,
178 ERROR_OPENLCB_TIMEOUT = 0x2030,
179 ERROR_OUT_OF_ORDER = 0x2040,
181 ERROR_INVALID_ARGS_MESSAGE_TOO_SHORT = ERROR_INVALID_ARGS | 1,
183 ERROR_UNIMPLEMENTED_MTI = ERROR_UNIMPLEMENTED | 3,
184 ERROR_UNIMPLEMENTED_CMD = ERROR_UNIMPLEMENTED | 2,
185 ERROR_UNIMPLEMENTED_SUBCMD = ERROR_UNIMPLEMENTED | 1,
187 ERROR_OPENMRN_ALREADY_EXISTS = ERROR_OPENMRN_NOT_FOUND | 2,
199 ERROR_DST_NOT_FOUND = 0x40000,
201 OPENMRN_TIMEOUT = 0x80000,
202 ERROR_DST_REBOOT = 0x100000,
203 ERROR_REJECTED = 0x200000,
210 SIMPLE_PROTOCOL_SUBSET = 0x800000000000,
211 DATAGRAM = 0x400000000000,
212 STREAM = 0x200000000000,
213 MEMORY_CONFIGURATION = 0x100000000000,
214 RESERVATION = 0x080000000000,
215 EVENT_EXCHANGE = 0x040000000000,
216 IDENTIFICATION = 0x020000000000,
217 LEARN_CONFIGURATION = 0x010000000000,
218 REMOTE_BUTTON = 0x008000000000,
219 ABBREVIATED_DEFAULT_CDI = 0x004000000000,
220 DISPLAY_PROTOCOL = 0x002000000000,
221 SIMPLE_NODE_INFORMATION = 0x001000000000,
222 CDI = 0x000800000000,
223 TRACTION_CONTROL = 0x000400000000,
224 TRACTION_FDI = 0x000200000000,
225 TRACTION_PROXY = 0x000100000000,
226 TRACTION_SIMPLE_TRAIN_INFO
228 FUNCTION_CONFIGURATION = 0x000040000000,
229 FIRMWARE_UPGRADE = 0x000020000000,
230 FIRMWARE_UPGRADE_ACTIVE = 0x000010000000,
231 RESERVED_MASK = 0x00000FFFFFFF
334 case EventState::VALID:
335 return EventState::INVALID;
336 case EventState::INVALID:
337 return EventState::VALID;
347 return state ? EventState::VALID : EventState::INVALID;
354 int code =
static_cast<int>(value);
355 code +=
static_cast<int>(state);
363 value =
static_cast<Defs::MTI>(
static_cast<int>(value) + 1);
370 value =
static_cast<Defs::MTI>(
static_cast<int>(value) + 1);
378 value =
static_cast<Defs::MTI>(
static_cast<int>(value) - 1);
385 value =
static_cast<Defs::MTI>(
static_cast<int>(value) - 1);
Defs::MTI operator+(const Defs::MTI &value, EventState state)
Allows of setting the producer/consumer identified MTI with the event state to set the low bits.
EventState invert_event_state(EventState state)
Returns the inverted event state, switching valid and invalid, but not changing unknown and reserved.
uint64_t NodeID
48-bit NMRAnet Node ID type
Defs::MTI operator++(Defs::MTI &value, int)
Operator overload for post increment.
EventState
Allowed states of producers and consumers.
string Payload
Container that carries the data bytes in an NMRAnet message.
static const NodeAlias NOT_RESPONDING
Guard value put into the the internal node alias maps when a node ID could not be translated to a val...
EventState to_event_state(bool state)
Returns the inverted event state, switching valid and invalid, but not changing unknown and reserved.
Defs::MTI operator--(Defs::MTI &value, int)
Operator overload for post decrement.
uint16_t NodeAlias
Alias to a 48-bit NMRAnet Node ID type.
The generic interface for NMRAnet network interfaces.
static constexpr uint64_t EMERGENCY_STOP_EVENT
"Emergency stop of all operations" The Emergency Stop Event is a request for a node to command all of...
static unsigned int mti_priority(MTI mti)
Get the MTI priority (value 0 through 3).
MTI
Known Message type indicators.
@ MTI_IDENT_INFO_REPLY
node identity reply
@ MTI_RESERVED_SHIFT
reserved shift
@ MTI_VERIFY_NODE_ID_ADDRESSED
verify a Node ID
@ MTI_CONSUMER_IDENTIFIED_INVALID
consumer broadcast, invalid state
@ MTI_PRODUCER_IDENTIFY
query about producers
@ MTI_EVENT_SHIFT
event number present shift
@ MTI_VERIFY_NODE_ID_GLOBAL
verify a Node ID globally
@ MTI_IDENT_INFO_REQUEST
request node identity
@ MTI_DATAGRAM_REJECTED
datagram rejected by receiver
@ MTI_EVENT_MASK
event number present mask
@ MTI_EVENTS_IDENTIFY_GLOBAL
request identify all of every node's events
@ MTI_CONSUMER_IDENTIFIED_RESERVED
reserved for future use
@ MTI_PRODUCER_IDENTIFIED_RANGE
producer broadcast about a range of producers
@ MTI_STREAM_PROCEED
stream flow control
@ MTI_MODIFIER_MASK
modifier within Priority/Type mask
@ MTI_PRODUCER_IDENTIFIED_RESERVED
reserved for future use
@ MTI_SPECIAL_SHIFT
special shift
@ MTI_MODIFIER_SHIFT
modifier within Priority/Type shift
@ MTI_SIMPLE_MASK
simple protocol mask
@ MTI_DATAGRAM_SHIFT
stream or datagram shift
@ MTI_EXACT
match mask for a single MTI
@ MTI_RESERVED_MASK
reserved mask
@ MTI_SIMPLE_SHIFT
simple protocol shift
@ MTI_PROTOCOL_SUPPORT_INQUIRY
inquire on supported protocols
@ MTI_PRIORITY_SHIFT
priority shift
@ MTI_TYPE_MASK
type within priority mask
@ MTI_CONSUMER_IDENTIFIED_UNKNOWN
consumer broadcast, validity unknown
@ MTI_TYPE_SHIFT
type within priority shift
@ MTI_ADDRESS_SHIFT
Address present shift.
@ MTI_PRODUCER_IDENTIFIED_VALID
producer broadcast, valid state
@ MTI_STREAM_INITIATE_REPLY
Stream initiate reply.
@ MTI_VERIFIED_NODE_ID_NUMBER
respond to a verify Node ID request
@ MTI_CONSUMER_IDENTIFY
query about consumers
@ MTI_EVENTS_IDENTIFY_ADDRESSED
request identify all of a node's events
@ MTI_PRODUCER_IDENTIFIED_INVALID
producer broadcast, invalid state
@ MTI_STREAM_INITIATE_REQUEST
Stream initiate request.
@ MTI_DATAGRAM_OK
datagram received okay
@ MTI_STREAM_COMPLETE
stream terminate connection
@ MTI_PRODUCER_IDENTIFIED_UNKNOWN
producer broadcast, validity unknown
@ MTI_PRIORITY_MASK
priority mask
@ MTI_STREAM_DATA
stream data
@ MTI_ADDRESS_MASK
Address present mask.
@ MTI_INITIALIZATION_COMPLETE
initialization complete
@ MTI_CONSUMER_IDENTIFIED_VALID
consumer broadcast, valid state
@ MTI_OPTIONAL_INTERACTION_REJECTED
rejected request
@ MTI_SPECIAL_MASK
special mask
@ MTI_CONSUMER_IDENTIFIED_RANGE
consumer broadcast about a range of consumers
@ MTI_PROTOCOL_SUPPORT_REPLY
reply with supported protocols
@ MTI_DATAGRAM_MASK
stream or datagram mask
@ MTI_TERMINATE_DUE_TO_ERROR
terminate due to some error
Protocols
Bitmask for all potentially supported NMRAnet protocols.
@ ERROR_FIRMWARE_CORRUPTED
The firmware data is invalid or corrupted.
@ ERROR_FIRMWARE_INCOMPATIBLE
The firmware data is incompatible with this hardware node.
@ ERROR_FIRMWARE_CSUM
The firmware written has failed checksum (temporary error).
static constexpr uint64_t EMERGENCY_OFF_EVENT
"Emergency off (de-energize)" Producing this event causes an Emergency Off (de-energize).
static constexpr uint64_t CLEAR_EMERGENCY_STOP_EVENT
"Clear Emergency stop of all operations" Producing this event clears an Emergency Stop.
static constexpr uint64_t NODE_IDENT_BUTTON_EVENT
"Ident button combination pressed" This event can be generated by a node when it is instructed to gen...
LinkStatus
Status of the pysical layer link.
@ LINK_DOWN
link is down and unable to transmit
@ LINK_UP
link is up and ready for transmit
static constexpr uint64_t NODE_POWER_BROWNOUT_EVENT
"Power supply brownout detected below minimum required by node" This event can be generated when a no...
static constexpr uint64_t POWER_STANDARD_BROWNOUT_EVENT
"Power supply brownout detected below minimum required by standard" This event can be generated when ...
Defs()
This struct should not be instantiated.
static bool get_mti_event(MTI mti)
Get the MTI event present value field.
static const size_t MAX_ADDRESSED_SIZE
Maximum size of a static addressed message payload.
static bool get_mti_datagram(MTI mti)
Get the MTI datagram or stream value field.
static bool get_mti_address(MTI mti)
Get the MTI address present value field.
static constexpr uint64_t CLEAR_EMERGENCY_OFF_EVENT
"Clear emergency off (energize)" Producing this event clears an Emergency Off (energize).
Container of both a NodeID and NodeAlias.
NodeID id
48-bit NMRAnet Node ID
NodeAlias alias
alias to NMRAnet Node ID
bool operator==(const NodeHandle &o) const
Compares two NodeHandle instances.
void clear()
Resets node handle to global (broadcast) handle.