private void createStateMachine() { // State Machine Components // Define and initialize in the order: // 1) Events // 2) Regions and states, from outer to inner // 3) Transitions, ordered internal, local, external // 4) Group states and transitions within a region together. // Events commReadyEvent = new NSFEvent("CommReady", this); hardwareResetEvent = new NSFEvent("HardwareReset", this); // Regions and states, from outer to inner // Initial state construtors take the form (name, parent) initialResetStrategyState = new NSFInitialState("InitialResetStrategy", this); // Composite state construtors take the form (name, parent, entry action, exit action) resetHardwareState = new NSFCompositeState("ResetHardware", this, resetHardwareEntryActions, null); reestablishCommunicationsState = new NSFCompositeState("ReestablishCommunications", this, reestablishCommunicationsEntryActions, null); readyState = new NSFCompositeState("ThreadReady", this, null, null); // Transitions, ordered internal, local, external // External transition construtors take the form (name, source, target, trigger, guard, action) initialResetStrategyToResetHardwareTransition = new NSFExternalTransition("InitialToResetHardware", initialResetStrategyState, resetHardwareState, null, null, resetVariables); resetHardwareToReestablishCommunicationsTransition = new NSFExternalTransition("ResetHardwareToReestablishCommunications", resetHardwareState, reestablishCommunicationsState, null, isHardwareReset, null); reestablishCommunicationsStateToReadyTransition = new NSFExternalTransition("ReestablishCommunicationsStateToReady", reestablishCommunicationsState, readyState, null, isCommReady, null); // Actions resetHardwareAction = new NSFScheduledAction("ReadHardware", resetHardware, EventThread); readyCommAction = new NSFScheduledAction("ResetComm", resetComm, EventThread); }