private void reestablishCommunicationsEntryActions(NSFStateMachineContext context) { commReady = false; // Simulate behavior using an action readyCommAction.schedule(commReadyDelayTime); }
private void waitForResponseExitActions(NSFStateMachineContext context) { // Unschedule the timeout event responseTimeoutEvent.unschedule(); commandQueue.Dequeue(); }
private void resetHardwareEntryActions(NSFStateMachineContext context) { hardwareReset = false; // Simulate behavior using an action resetHardwareAction.schedule(hardwareResetDelayTime); }
private bool isResponse(NSFStateMachineContext context) { // Code to verify that the resposne is correct for the command goes here. // ... return(true); }
private bool isReady(NSFStateMachineContext context) { // Code to check if hardware is reset properly goes here // ... return(true); }
private void queueCommand(NSFStateMachineContext context) { // Add data to command queue. // If the state machine is in the waitForCommandState, then the // run to completion step will result in transitioning to the // waitForResponse state, sending the command during the transtion. commandQueue.Enqueue(((NSFDataEvent <String>)(context.Trigger)).Data); }
private void retrySend(NSFStateMachineContext context) { NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Retry send ..."); ++retries; // Code to re-send the command goes here // ... // Schedule timeout event, in case no response received responseTimeoutEvent.schedule(responseTimeout, 0); }
private void handleResponse(NSFStateMachineContext context) { // Code to handle the response goes here // ... // Log trace of response received // Trace Format: // <MessageReceived> // <Source>name</Source> // <Message>message</Message> // </MessageReceived> NSFTraceLog.PrimaryTraceLog.addTrace(NSFTraceTags.MessageReceivedTag, NSFTraceTags.SourceTag, Name, NSFTraceTags.MessageTag, ((NSFDataEvent <String>)(context.Trigger)).Data); }
private void sendCommand(NSFStateMachineContext context) { String commandString = commandQueue.Peek(); // Code to send the command goes here // ... // Log trace of command sent // Trace Format: // <MessageSent> // <Source>name</Source> // <Message>message</Message> // </MessageSent> NSFTraceLog.PrimaryTraceLog.addTrace(NSFTraceTags.MessageSentTag, NSFTraceTags.SourceTag, Name, NSFTraceTags.MessageTag, commandString); }
private void state1_1EntryAction(NSFStateMachineContext context) { ++currentEventCount; if ((currentEventCount % numberOfRepeatedEvents) == 0) { NSFDebugUtility.PrimaryDebugUtility.writeToConsole("."); event1.queueEvent(); event3.queueEvent(); event4.copy().queueEvent(); event2.schedule(50, 0); } else { event1.queueEvent(); event5.queueEvent(); event6.copy().queueEvent(); event2.schedule(50, 0); } }
private void errorEntryActions(NSFStateMachineContext context) { // Code to handle the error goes here // ... }
private bool isReady(NSFStateMachineContext context) { return(resetStrategy.ReadyState.isActive()); }
private void handleTransition(NSFStateMachineContext context) { NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Transitioning from " + context.Transition.Source.Name + " to " + context.Transition.Target.Name); }
private void waitForResponseEntryActions(NSFStateMachineContext context) { // Schedule timeout event, in case no response received responseTimeoutEvent.schedule(responseTimeout, 0); }
private void state1ExitAction(NSFStateMachineContext context) { state1_1.EntryActions -= state1_1EntryAction; }
private bool canRetry(NSFStateMachineContext context) { return(retries < maxRetries); }
private void state2ReactionToEvent1Actions(NSFStateMachineContext context) { queueEvent(event2); }
private void handleStateExited(NSFStateMachineContext context) { NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Exiting " + context.ExitingState.Name); }
private void initializeBEntryActions(NSFStateMachineContext context) { bReadyEvent.schedule(InitializeBDelayTime, 0); }
private void resetVariables(NSFStateMachineContext context) { hardwareReset = false; commReady = false; }
private void resetEntryActions(NSFStateMachineContext context) { // Code to reset hardware goes here // ... }
private void state3_1ExitActions(NSFStateMachineContext context) { queueEvent(event3); }
private bool isHardwareReset(NSFStateMachineContext context) { return(hardwareReset); }
private void cycleBEntryActions(NSFStateMachineContext context) { bCompleteEvent.schedule(CompleteBDelayTime, 0); }
private void test13ReactionToEvent2Actions(NSFStateMachineContext context) { queueEvent(event1); }
private bool isCommReady(NSFStateMachineContext context) { return(commReady); }
private void waitForResponseEntryActions(NSFStateMachineContext context) { retries = 0; }
private bool hasCommand(NSFStateMachineContext context) { return(commandQueue.Count != 0); }
private void state2EntryActions(NSFStateMachineContext context) { throw new Exception("Intentional exception"); }
protected virtual bool isEnemyInRange(NSFStateMachineContext context) { return(DistanceToEnemy < InRangeDistance); }