Esempio n. 1
0
        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();
        }
Esempio n. 3
0
        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);
 }
Esempio n. 7
0
        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
     // ...
 }
Esempio n. 12
0
 private bool isReady(NSFStateMachineContext context)
 {
     return(resetStrategy.ReadyState.isActive());
 }
Esempio n. 13
0
 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;
 }
Esempio n. 16
0
 private bool canRetry(NSFStateMachineContext context)
 {
     return(retries < maxRetries);
 }
 private void state2ReactionToEvent1Actions(NSFStateMachineContext context)
 {
     queueEvent(event2);
 }
Esempio n. 18
0
 private void handleStateExited(NSFStateMachineContext context)
 {
     NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Exiting " + context.ExitingState.Name);
 }
Esempio n. 19
0
 private void initializeBEntryActions(NSFStateMachineContext context)
 {
     bReadyEvent.schedule(InitializeBDelayTime, 0);
 }
Esempio n. 20
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);
 }
Esempio n. 23
0
 private bool isHardwareReset(NSFStateMachineContext context)
 {
     return(hardwareReset);
 }
Esempio n. 24
0
 private void cycleBEntryActions(NSFStateMachineContext context)
 {
     bCompleteEvent.schedule(CompleteBDelayTime, 0);
 }
 private void test13ReactionToEvent2Actions(NSFStateMachineContext context)
 {
     queueEvent(event1);
 }
Esempio n. 26
0
 private bool isCommReady(NSFStateMachineContext context)
 {
     return(commReady);
 }
Esempio n. 27
0
 private void waitForResponseEntryActions(NSFStateMachineContext context)
 {
     retries = 0;
 }
 private bool hasCommand(NSFStateMachineContext context)
 {
     return(commandQueue.Count != 0);
 }
Esempio n. 29
0
 private void state2EntryActions(NSFStateMachineContext context)
 {
     throw new Exception("Intentional exception");
 }
Esempio n. 30
0
 protected virtual bool isEnemyInRange(NSFStateMachineContext context)
 {
     return(DistanceToEnemy < InRangeDistance);
 }