Package jmri.jmrix.can.cbus.node
Class CbusNodeEventManager
java.lang.Object
jmri.jmrix.can.cbus.node.CbusNodeEventManager
Class to represent a Processing of CAN Frames for a CbusNode.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new CbusNodeNVManager -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewEvent(CbusNodeEvent newEvent) Add an event to the node, will not overwrite an existing event.voiddeleteEvOnNode(int nn, int en) Send a message to delete an event stored on this nodeGet the Node event ArrayListprotected intgetEventRowFromIndex(int index) Get the Node event Array index from its Index FieldintReturns number of fully loaded events, ie no outstanding event variables.intthe next event index for a CbusDummyNode NODE to allocate, NOT a software tool.getNodeEvent(int nn, int en) Get a Node event from its Event and Node number combinationgetNodeEventByArrayID(int index) Get the Node event by ArrayList Index.getNodeEventByIndex(int index) Get a Node event from its Index FieldintGet the Number of Outstanding Event VariablesintReturns outstanding events from initial event fetch.intReturns total number of node events, including those with outstanding event variables.protected booleanGet if the Node event index is valid.provideNodeEvent(int nn, int en) Provide a Node event from its Event and Node number combinationprotected voidThe last message from the node CMDERR5 indicates that all remaining event variables for a particular event are not required.voidremoveEvent(int nn, int en) Remove an event from the CbusNode, does not update hardware.voidResets Node Events with null array.voidResets Node Events with zero length array.voidsendNewEvSToNode(ArrayList<CbusNodeEvent> evArray) Send and teach updated Events to this nodeprotected voidSend a request for the next unknown Event Variable to the Physical Nodeprotected voidsetEvIndexValid(boolean newval) Set the Node event index flag as valid or invalid.protected voidsetEvVarByIndex(int eventIndex, int eventVarIndex, int newVal) Used in CBUS_NEVAL response from Node.protected voidsetNextEmptyNodeEvent(int nn, int en, int index) Used to process a CBUS_ENRSP response from node If existing index known, use that slot in the event array, else if event array has empty slot for that index, use that slot.protected voidLoop for event teaching, triggered from various placestoString()protected voidupdateNodeFromLearn(int nn, int en, int evvarindex, int evvarval) Update node with new Node Event.
-
Field Details
-
nextEvInArray
-
TEACH_OUTSTANDING_EVS
-
-
Constructor Details
-
CbusNodeEventManager
Create a new CbusNodeNVManager- Parameters:
memo- System connectionnode- The Node
-
-
Method Details
-
getTotalNodeEvents
Returns total number of node events, including those with outstanding event variables.- Returns:
- number of events, -1 if events not set
-
getLoadedNodeEvents
Returns number of fully loaded events, ie no outstanding event variables.- Returns:
- number of loaded events, -1 if events not set
-
getOutstandingIndexNodeEvents
Returns outstanding events from initial event fetch.- Returns:
- number of outstanding index events
-
addNewEvent
Add an event to the node, will not overwrite an existing event. Resets Event Index as Invalid for All Node Events- Parameters:
newEvent- the new event to be added
-
removeEvent
Remove an event from the CbusNode, does not update hardware.- Parameters:
nn- the event Node Numberen- the event Event Number
-
getNodeEvent
Get a Node event from its Event and Node number combination- Parameters:
en- the Event event numbernn- the Event node number- Returns:
- the node event else null if no Event / Node number combination.
-
provideNodeEvent
Provide a Node event from its Event and Node number combinationIf an event for this number pair does not already exist on the node one will be created, else the existing will be returned.
Adds any new CbusNodeEvent to the node event array, which will also be created if it doesn't exist.
- Parameters:
en- the Event event numbernn- the Event node number- Returns:
- the node event
-
updateNodeFromLearn
Update node with new Node Event.- Parameters:
nn- Node Numberen- Event Numberevvarindex- Event Variable Indexevvarval- Event Variable Value
-
getNodeEventByIndex
Get a Node event from its Index FieldThis is NOT the node array index.
- Parameters:
index- the Node event index, as set by a node from a NERD request- Returns:
- the node event, else null if the index is not located
-
getEventRowFromIndex
Get the Node event Array index from its Index Field- Parameters:
index- the Node event index, as set by a node from a NERD request- Returns:
- the array index, else -1 if event index number not found in array
-
getNodeEventByArrayID
Get the Node event by ArrayList Index.- Parameters:
index- the index of the CbusNodeEvent within the ArrayList- Returns:
- the Node Event
-
getEventArray
Get the Node event ArrayList- Returns:
- the list of Node Events
-
getOutstandingEvVars
Get the Number of Outstanding Event VariablesSometimes, the Event Variables have to be initialised with an unknown status, this returns a count of unknown Event Variables for the whole Node.
- Returns:
- -1 if main node events array null, else number Outstanding Ev Vars
-
remainingEvVarsNotNeeded
The last message from the node CMDERR5 indicates that all remaining event variables for a particular event are not required. This sets the remaining ev vars to 0 so are not requested -
sendNextEvVarToFetch
Send a request for the next unknown Event Variable to the Physical NodeIf events are unknown, sends the NERD request and starts that timer, else requests the next Ev Var with unknown status ( represented as int value -1 ) Will NOT send if any Node is in Learn Mode or if there are any outstanding requests from the Node.
-
setEvVarByIndex
Used in CBUS_NEVAL response from Node. Set the value of an event variable by event Index and event Variable Index- Parameters:
eventIndex- Event IndexeventVarIndex- Event Variable IndexnewVal- New Value
-
setNextEmptyNodeEvent
Used to process a CBUS_ENRSP response from node If existing index known, use that slot in the event array, else if event array has empty slot for that index, use that slot.- Parameters:
nn- Node Numberen- Event Numberindex- Index Number
-
isEventIndexValid
Get if the Node event index is valid.- Returns:
- true if event index is valid, else false if invalid or no events on node.
-
setEvIndexValid
Set the Node event index flag as valid or invalid.Resets all Node Event Indexes to -1 if invalid.
- Parameters:
newval- true if Event Index Valid, else false
-
sendNewEvSToNode
Send and teach updated Events to this node- Parameters:
evArray- array of CbusNodeEvents to be taught
-
deleteEvOnNode
Send a message to delete an event stored on this node- Parameters:
nn- event node numberen- event event number
-
teachNewEvLoop
Loop for event teaching, triggered from various places -
resetNodeEvents
Resets Node Events with null array. For when a CbusNode is reset to unknown events. -
resetNodeEventsToZero
Resets Node Events with zero length array. For when a CbusNode is reset to 0 events -
getNextFreeIndex
the next event index for a CbusDummyNode NODE to allocate, NOT a software tool.- Returns:
- next available event index
-
toString
-