Пример #1
0
            StateMaschinePage[] CreateStateMaschine()
            {
                timeoutTimer = parent.GridTerminalSystem.GetBlockWithName("Timeout Trigger") as IMyTimerBlock;

                int lengthStateTable = Enum.GetNames(typeof(State)).Length - 2;

                StateMaschinePage[] stateMaschine = new StateMaschinePage[lengthStateTable];
                for (int i = 0; i < lengthStateTable; i++)
                {
                    stateMaschine[i] = new StateMaschinePage();
                }
                FillStateTable(stateMaschine);

                //Check if logic part is missing------------------------------------------
                if (timeoutTimer == null)
                {
                    lcdHandler.logMessage("Timer not found, should be named 'Timeout Trigger'", Tags.STM, Labels.cERR);
                    currentState = State.Error;
                    return(null);
                }
                else
                {
                    lcdHandler.logMessage("State Maschine operational", Tags.STM, Labels.BOOT);
                    currentState = State.Idle;
                    return(stateMaschine);
                }
                //---------------------------------------------------------------------------
            }
Пример #2
0
 void FillStateTableEntry(StateMaschinePage entry, State current, State next, bool wait)
 {
     entry.currentState   = current;
     entry.nextState      = next;
     entry.waitForTrigger = wait;
 }