示例#1
0
        // Implements the required start method for the TSubject class
        public override void Start()
        {
            while (!IsExitting)
            {
                // Dequeus the next state
                QSMStateData CurrentState = QSM.GetNextState();
                switch (CurrentState.State)
                {
                case "Module Initialize":
                    // Assign any initial values to things here
                    break;

                case "Event Check":
                    // If there's any events that have been added to the mailbox, then attend to them
                    Console.WriteLine("Hello World, this is the sample module!");
                    Exit();
                    break;

                default:
                    // Occurs when there's a state in the Queue that doesn't match any of the cases
                    Console.WriteLine("Unrecognized state: {0}", CurrentState.State);
                    break;
                }
            }
        }
示例#2
0
        //Override method for the messageRx event
        protected override void OnMessageRx(CommQueueDefaultData e)
        {
            // Adds any received messages as states to the QSM
            base.OnMessageRx(e);
            QSMStateData temp = new QSMStateData(e.Command, e.Data);

            QSM.AddStates(temp);
        }
        // Implements the required start method for the TSubject class
        public override void Start()
        {
            while (!isExitting)
            {
                // Dequeus the next state
                QSMStateData CurrentState = QSM.GetNextState();
                switch (CurrentState.State)
                {
                case "Module Initialize":
                    // Assign any initial values to things here
                    timerCount = 0;
                    timers     = new List <TimerData>();
                    break;

                case "Event Check":
                    // If there's any events that have been added to the mailbox, then attend to them
                    break;

                case "Add Timer":
                    // Adds a timer to the list
                    AddTimer((TimerData)CurrentState.Data);
                    timerCount++;
                    break;

                case "Remove Timer":
                    // Removes a timer from the list
                    RemoveTimer((int)CurrentState.Data);
                    timerCount--;
                    break;

                case "Exit":
                    // Causes the module to exit
                    Exit();
                    break;

                case "MsgTimerPing":
                    // Sends a message to the network stating that a timer has been fired
                    OnMessageTx(new MessageEventArgs <CommQueueDefaultData>(
                                    new CommQueueData <CommQueueDefaultData>(
                                        new CommQueueDefaultData("Timer Ping!", CurrentState.Data))));
                    break;

                default:
                    // Occurs when there's a state in the Queue that doesn't match any of the cases
                    Console.WriteLine("Unrecognized state: {0}", CurrentState.State);
                    break;
                }
            }
        }