static void Main(String[] args) { NSFExceptionHandler.ExceptionActions += globalExceptionAction; NSFTraceLog.PrimaryTraceLog.Enabled = true; CommandProcessorWithResetStateMachine commandProcessor = new CommandProcessorWithResetStateMachine("CommandProcessor"); #pragma warning disable 0219 CommandProcessorObserver commandProcessorObserver = new CommandProcessorObserver(commandProcessor); #pragma warning restore 0219 commandProcessor.startStateMachine(); // Simple example of polling for state int i = 0; while (true) { Thread.Sleep(500); if (commandProcessor.isInState(commandProcessor.WaitForCommandState)) { NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Press Enter key to inject a command"); Console.ReadKey(); commandProcessor.addCommand("TestCommand"); } else if (commandProcessor.isInState(commandProcessor.WaitForResponseState)) { // Only send two responses if (++i <= 2) { commandProcessor.addResponse("TestResponse"); } } else if (commandProcessor.isInState(commandProcessor.ErrorState)) { break; } } NSFTraceLog.PrimaryTraceLog.saveLog("CommandProcessorWithResetStateMachineExampleTrace.xml"); NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Press Enter key to continue"); Console.ReadKey(); NSFEnvironment.terminate(); }
static void Main(String[] args) { NSFTraceLog.PrimaryTraceLog.Enabled = true; CommandProcessorWithResetStateMachine commandProcessor = new CommandProcessorWithResetStateMachine("CommandProcessor"); #pragma warning disable 0219 CommandProcessorObserver commandProcessorObserver = new CommandProcessorObserver(commandProcessor); #pragma warning restore 0219 commandProcessor.startStateMachine(); // Simple example of polling for state int i = 0; while (true) { Thread.Sleep(500); if (commandProcessor.isInState(commandProcessor.WaitForCommandState)) { NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Press Enter key to inject a command"); Console.ReadKey(); commandProcessor.addCommand("TestCommand"); } else if (commandProcessor.isInState(commandProcessor.WaitForResponseState)) { // Only send two responses if (++i <= 2) { commandProcessor.addResponse("TestResponse"); } } else if (commandProcessor.isInState(commandProcessor.ErrorState)) { break; } } NSFTraceLog.PrimaryTraceLog.saveLog("CommandProcessorWithResetStateMachineExampleTrace.xml"); NSFDebugUtility.PrimaryDebugUtility.writeLineToConsole("Press Enter key to continue"); Console.ReadKey(); NSFEnvironment.terminate(); }