示例#1
0
        public Mapper(ActiveObject SourceAO)
        {
            StateBox hsmTop = new StateBox();

            hsmTop.startX = -8;
            hsmTop.startY = -8;
            aoToMap       = SourceAO;
            stateDiagrams = new List <StateBox>();

            DrawAoStates(aoToMap.states[0], hsmTop, 0, 0);
        }
示例#2
0
        private QState AO_StateSearch_QStateFound(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            case (int)HSMSignals.ENTRY_SIG:
            {
                return(handled);
            }

            /* Check if this is already a state we found from a forward declaration.
             * If it is, then it's a definition. If not, it's a declaration so we
             * add it.*/
            case (int)Signals.NEW_WORD_SIG:
            {
                bool   isDecleared = false;
                string tempWord    = ((WordFeeder)e).Word;

                foreach (ActiveObject ao in parsedAOs)
                {
                    foreach (State s in ao.states)
                    {
                        if (s.stateName.Equals(tempWord))
                        {
                            isDecleared         = true;
                            currentAOParsing    = ao;
                            currentStateParsing = s;
                        }
                    }
                }

                if (!isDecleared)
                {
                    State newState = new State();
                    newState.stateName = tempWord;
                    newState.subStates = new List <State>();
                    currentAOParsing.states.Add(newState);
                    transition(AO_StateSearch);
                }
                else
                {
                    transition(AO_StateSearch_InState);
                }
            }
                return(handled);
            }
            return(AO_StateSearch);
        }
示例#3
0
        private QState AO_Search_StructFound(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

            case (int)Signals.INCREMENT_SCOPE_LEVEL_SIG:
            {
                this.scopeLevel++;

                /* Should probably start populating attributes.*/
                currentAOParsing = new ActiveObject("");
                parsedAOs.Add(currentAOParsing);
                variable = new List <string>();
                transition(AO_Search_InPossibleAO);
                return(handled);
            }
            }
            return(AO_Search);
        }
示例#4
0
        private QState AO_Search_InPossibleAO(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            case (int)HSMSignals.ENTRY_SIG:
            {
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;

                variable.Add(tempWord);
            }
                return(handled);

            case (int)Signals.END_LINE_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;

                if (scopeLevel > 0)
                {
                    string dataType = "";

                    foreach (string s in variable)
                    {
                        dataType += s + " ";
                    }

                    dataType = dataType.Substring(0, dataType.Length - 1);

                    currentAOParsing.attributes.Add(tempWord, dataType);
                    variable = new List <string>();
                }
                else
                {
                    bool isReallyAO = false;
                    foreach (KeyValuePair <string, string> pair in currentAOParsing.attributes)
                    {
                        if (pair.Value.Contains("QActive"))
                        {
                            currentAOParsing.smType = StateMachineType.AO;
                            currentAOParsing.attributes.Remove("super");
                            isReallyAO = true;
                            break;
                        }
                        else if (pair.Value.Contains("QHsm"))
                        {
                            currentAOParsing.smType = StateMachineType.HSM;
                            currentAOParsing.attributes.Remove("super");
                            isReallyAO = true;
                            break;
                        }
                    }

                    if (isReallyAO)
                    {
                        State QHsm_top = new State();
                        QHsm_top.stateName  = "QHsm_top";
                        QHsm_top.superState = null;
                        QHsm_top.subStates  = new List <State>();

                        currentAOParsing.aoName = tempWord;
                        currentAOParsing.states.Add(QHsm_top);
                        transition(AO_StateSearch);
                    }
                    else
                    {
                        currentAOParsing = null;
                    }
                }
            }
                return(handled);
            }
            return(AO_Search);
        }
示例#5
0
 public Translator(ActiveObject AO)
 {
     aoToTranslate = AO;
 }