Ejemplo n.º 1
0
        private QState AO_StateSearch_InState_SigFound(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;

                if (newTransition == null)
                {
                    newTransition = new Transition(tempWord.Substring(0, tempWord.Length - 1), null);
                }
                else
                {
                    newTransition.transitionName += string.Format(",{0}", tempWord.Substring(0, tempWord.Length - 1));
                }

                actionBlockScopeLevel = scopeLevel;
                transition(AO_StateSearch_InState_InAction);
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 2
0
        private QState AO_Search_TypeDefFound(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

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

                if (tempWord.Contains("struct"))
                {
                    transition(AO_Search_StructFound);
                    return(handled);
                }
                else
                {
                    return(handled);
                }
            }
            }
            return(AO_Search);
        }
Ejemplo n.º 3
0
        public void PublishSignal(QEvent qEvent)
        {
            if (HSTMachine.Workcell.HSTSettings.Install.EnableDebugLog)
            {
                Log.Info(this, "PublishSignal, ProcessName:{0}, SignalName:{1}", _processName, qEvent.QSignal.ToString());
            }

            if (HSTMachine.Workcell != null)
            {
                if (HSTMachine.Workcell.getPanelOperation() != null)
                {
                    if (HSTMachine.Workcell.getPanelOperation().getOperationStatusPanel() != null)
                    {
                        UIUtility.Invoke(HSTMachine.Workcell.getPanelOperation().getOperationStatusPanel(), () =>
                        {
                            HSTMachine.Workcell.getPanelOperation().getOperationMainPanel().labelOriginatorSignalTimestamp.Text = DateTime.Now.ToString();
                            HSTMachine.Workcell.getPanelOperation().getOperationMainPanel().labelOriginatorSignalName.Text      = qEvent.QSignal.ToString();
                            HSTMachine.Workcell.getPanelOperation().getOperationMainPanel().labelOriginatorSignalSource.Text    = _processName;
                        });
                    }
                }
            }

            QF.Instance.Publish(qEvent);
        }
Ejemplo n.º 4
0
        private QState AO_StateSearch_InState_InAction(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;
                if (tempWord.Contains("return"))
                {
                    transition(AO_StateSearch_InState_ReturnFound);
                }
                else if (tempWord.Equals("case") && actionBlockScopeLevel == scopeLevel)
                {
                    transition(AO_StateSearch_InState_SigFound);
                }
                else if (tempWord.Equals("if"))
                {
                    newGuardedTransition = new GuardedTransition(newTransition.transitionName);
                    transition(AO_StateSearch_InState_IfBlock);
                }
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 5
0
        private QState AO_StateSearch_InState_WaitingSuper(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;

                tempWord = pruneAmpersand(tempWord);

                foreach (State s in currentAOParsing.states)
                {
                    if (s.stateName.Equals(tempWord))
                    {
                        currentStateParsing.superState = s;
                        s.subStates.Add(currentStateParsing);
                        transition(AO_StateSearch_InState);
                    }
                }
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 6
0
        private QState AO_StateSearch_InState_IfBlock_Else(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

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

                if (tempWord.Equals("if"))
                {
                    transition(AO_StateSearch_InState_IfBlock);
                }
                else if (tempWord.Contains("return") && ifBlockScopeLevel == scopeLevel)
                {
                    ifTransition = new Transition(ifBlockCondition, null);
                    transition(AO_StateSearchs_InState_GuardedTransitionReturnFound);
                }
                else
                {
                    transition(AO_StateSearch_InState_IfBlock_WaitReturn);
                }
                return(handled);
            }
            }
            return(AO_StateSearch_InState_IfBlock);
        }
Ejemplo n.º 7
0
        private QState AO_StateSearchs_InState_GuardedTransitionReturnFound(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

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

                if (tempWord.Contains("Q_TRAN"))
                {
                    transition(AO_StateSearch_InState_GuardedTransitionWaitingTarget);
                }
                else if (tempWord.Contains("Q_HANDLED"))
                {
                    newGuardedTransition.transitions.Add(ifTransition);
                    ifTransition = null;
                    currentStateParsing.guardedTransitions.Add(newGuardedTransition);
                    transition(AO_StateSearch_InState);
                }
                else /* This is a transition into history... */
                {
                    transition(AO_StateSearch_InState_GuardedTransitionWaitingTarget);
                }
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 8
0
        private QState top(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

            case (int)HSMSignals.INIT_SIG:
            {
                initial_transition(AO_Search);
                return(handled);
            }

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

            case (int)Signals.DECREMENT_SCOP_LEVEL_SIG:
            {
                this.scopeLevel--;
                return(handled);
            }
            }
            return(handled);
        }
Ejemplo n.º 9
0
        private QState AO_StateSearch(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;

                if (tempWord.Contains("typedef"))
                {
                    transition(AO_Search_TypeDefFound);
                }
                else if (tempWord.Contains("QState") && !tempWord.Contains("QStateHandler"))
                {
                    transition(AO_StateSearch_QStateFound);
                }
            }
                return(handled);
            }
            return(top);
        }
Ejemplo n.º 10
0
        private QState AO_StateSearch_InState_GuardedTransitionWaitingTarget(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            {
                ifTransition = null;
                return(handled);
            }

            case (int)HSMSignals.ENTRY_SIG:
            case (int)Signals.START_PARENTHESIS_SIG:
            case (int)Signals.END_PARENTHESIS_SIG:
            {
                return(handled);
            }

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

                tempWord = pruneAmpersand(tempWord);

                foreach (State s in currentAOParsing.states)
                {
                    if (s.stateName.Equals(tempWord))
                    {
                        ifTransition.targetState = s;
                        newGuardedTransition.transitions.Add(ifTransition);
                        targetFound = true;
                    }
                }

                if (!targetFound)
                {
                    State history = new State();
                    history.stateName = "Transition To History";
                    newGuardedTransition.transitions.Add(new Transition(tempWord, history));
                }

                ifBlockCondition = "";
                if (lastState == AO_StateSearch_InState)
                {
                    currentStateParsing.guardedTransitions.Add(newGuardedTransition);
                    newGuardedTransition = null;
                    newTransition        = null;
                }
                transition(lastState);
            }
                return(handled);
            }
            return(AO_StateSearch_InState_IfBlock);
        }
Ejemplo n.º 11
0
        private QState AO_StateSearch_InState_ReturnFound(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            {
                return(handled);
            }

            case (int)HSMSignals.EXIT_SIG:

            {
                return(handled);
            }

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

                if (tempWord.Contains("Q_TRAN"))
                {
                    if (newTransition == null)
                    {
                        newTransition = new Transition("", null);
                    }
                    transition(AO_StateSearch_InState_WaitingTarget);
                }
                else if (tempWord.Contains("Q_HANDLED"))
                {
                    if (newTransition == null)
                    {
                        newTransition = new Transition("", null);
                    }
                    currentStateParsing.transitions.Add(newTransition);
                    newTransition = null;
                    transition(AO_StateSearch_InState);
                }
                else if (tempWord.Contains("Q_SUPER"))
                {
                    transition(AO_StateSearch_InState_WaitingSuper);
                }
                else /* This is a transition into history... */
                {
                    transition(AO_StateSearch_InState_WaitingTarget);
                }
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 12
0
 public new bool EventFilter(QObject obj, QEvent evnt)
 {
     if (evnt.type() == QEvent.TypeOf.KeyPress)
     {
         if (KeyEvent != null)
         {
             if (KeyEvent((QKeyEvent)evnt))
             {
                 return(true);
             }
         }
     }
     return(obj.EventFilter(obj, evnt));
 }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        private QState AO_StateSearch_InState_WaitingTarget(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            {
                newTransition = null;
                return(handled);
            }

            case (int)HSMSignals.ENTRY_SIG:
            {
                return(handled);
            }

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

                tempWord = pruneAmpersand(tempWord);

                foreach (State s in currentAOParsing.states)
                {
                    if (s.stateName.Equals(tempWord))
                    {
                        newTransition.targetState = s;
                        currentStateParsing.transitions.Add(newTransition);
                        targetFound = true;
                    }
                }

                if (!targetFound)
                {
                    State history = new State();
                    history.stateName = "Transition To History";
                    currentStateParsing.transitions.Add(new Transition(tempWord, history));
                }

                newTransition = null;
                transition(AO_StateSearch_InState);
            }
                return(handled);
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 15
0
        private QState AO_StateSearch_InState_IfBlock_ConditionGather(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            {
                parenthesisLevel = 1;
                return(handled);
            }

            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

            case (int)Signals.START_PARENTHESIS_SIG:
            {
                ifBlockCondition += "(";
                parenthesisLevel++;
                return(handled);
            }

            case (int)Signals.END_PARENTHESIS_SIG:
            {
                ifBlockCondition += ")";
                parenthesisLevel--;

                if (parenthesisLevel == 0)
                {
                    ifBlockScopeLevel = scopeLevel + 1;
                    transition(AO_StateSearch_InState_IfBlock_WaitReturn);
                }
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;
                ifBlockCondition += tempWord + " ";
                return(handled);
            }
            }
            return(AO_StateSearch_InState_IfBlock);
        }
Ejemplo n.º 16
0
        private QState AO_StateSearch_InState_IfBlock(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            {
                return(handled);
            }

            case (int)Signals.START_PARENTHESIS_SIG:
            {
                lastState         = AO_StateSearch_InState_IfBlock;
                ifBlockCondition += "if (";
                transition(AO_StateSearch_InState_IfBlock_ConditionGather);
                return(handled);
            }

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

                if (tempWord.Equals("else"))
                {
                    ifBlockCondition += "else ";
                    transition(AO_StateSearch_InState_IfBlock_Else);
                }
                else if (tempWord.Equals("break"))
                {
                    if (newGuardedTransition != null)
                    {
                        currentStateParsing.guardedTransitions.Add(newGuardedTransition);
                        newGuardedTransition = null;
                    }
                    newTransition = null;
                    transition(AO_StateSearch_InState);
                }
                return(handled);
            }
            }
            return(AO_StateSearch_InState);
        }
Ejemplo n.º 17
0
        private QState AO_StateSearch_InState_IfBlock_WaitReturn(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.ENTRY_SIG:
            case (int)HSMSignals.EXIT_SIG:
            case (int)Signals.START_PARENTHESIS_SIG:
            case (int)Signals.END_PARENTHESIS_SIG:
            {
                return(handled);
            }

            case (int)Signals.DECREMENT_SCOP_LEVEL_SIG:
            {
                this.scopeLevel--;
                if ((ifBlockScopeLevel - 1) == scopeLevel)
                {
                    ifBlockCondition     = "";
                    newGuardedTransition = null;
                    transition(AO_StateSearch_InState);
                }
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;
                if (tempWord.Contains("return") && ifBlockScopeLevel == scopeLevel)
                {
                    ifTransition = new Transition(ifBlockCondition, null);
                    transition(AO_StateSearchs_InState_GuardedTransitionReturnFound);
                }
                return(handled);
            }
            }
            return(AO_StateSearch_InState_IfBlock);
        }
Ejemplo n.º 18
0
        public new bool EventFilter(QObject obj, QEvent evnt)
        {
            var type = evnt.type();

            if (type == QEvent.TypeOf.MouseButtonPress)
            {
                var mouseEvent = (QMouseEvent)evnt;
                if (mouseEvent.Button() == Qt.MouseButton.LeftButton)
                {
                    m_Moving = true;
                    m_OrigX  = mouseEvent.X();
                    m_OrigY  = mouseEvent.Y();
                    m_ParentWidget.Cursor = new QCursor(Qt.CursorShape.SizeAllCursor);
                }
            }
            else if (type == QEvent.TypeOf.MouseMove)
            {
                var mouseEvent = (QMouseEvent)evnt;
                if (m_Moving)
                {
                    var pos = mouseEvent.GlobalPos();
                    m_ParentWidget.Move(pos.X() - m_OrigX, pos.Y() - m_OrigY);
                }
            }
            else if (type == QEvent.TypeOf.MouseButtonRelease)
            {
                var mouseEvent = (QMouseEvent)evnt;
                if (m_Moving && mouseEvent.Button() == Qt.MouseButton.LeftButton)
                {
                    m_Moving = false;
                    m_ParentWidget.Cursor = new QCursor(Qt.CursorShape.ArrowCursor);
                }
            }

            return(obj.EventFilter(obj, evnt));
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
        protected override QState StatePaused(IQEvent qEvent)
        {
            LogMessage("Paused", qEvent);

            if (qEvent.IsSignal(SigStop))
            {
                TransitionTo(stateStopping);
                return(null);
            }
            if (qEvent.IsSignal(SigAbort))
            {
                TransitionTo(stateAborting);
                return(null);
            }
            if (qEvent.IsSignal(SigResume))
            {
                this.targetState = stateHistory;
                base.TransitionToWithoutJob(targetState);
                QEvent event2 = new QEvent(base.SigStateJob);
                base.PostFIFO(event2);
                return(null);
            }
            return(stateActive);
        }
Ejemplo n.º 21
0
        protected override QState StateError(IQEvent qEvent)
        {
            LogStateInfo(_processName, System.Reflection.MethodBase.GetCurrentMethod().Name, qEvent);

            if (qEvent.IsSignal(QSignals.Entry))
            {
                _isErrorstate = true;
                string str = this.ToString();
                str = str.Substring(str.LastIndexOf(".") + 1);
                str = str.Remove(str.LastIndexOf("-"));
                str = str + ": " + this.currentException.Source;
                _workcell.DisplayTitleMessage("Error Occurred (" + str + ")");
            }
            if (qEvent.IsSignal(QSignals.Exit))
            {
                _isErrorstate = false;
                string str = this.ToString();
                str = str.Substring(str.LastIndexOf(".") + 1);
                str = str.Remove(str.LastIndexOf("-"));
                str = str + ": " + this.currentException.Source;
                _workcell.DisplayTitleMessage("Error Cleared (" + str + ")");

                // Log alarm cleared.
                string errMsg = this.GetErrorLogFormatString();
                Log.Error(this, "{0} Message:{1}", LoggerCategory.AlarmCleared, errMsg);
            }
            if (qEvent.IsSignal(base.SigStateJob))
            {
                // Format to CLU error format.
                this.errorMessageHST.Format();

                this.DefaultErrorHandler();

                // Change state UDT.
                _workcell.ARAMSState.ChangeState(ARAMSStateHST.ARAMSSubstateCodes.UDT_UnscheduledDownTime);

                // Log alarm occured
                string errMsg = this.GetErrorLogFormatString();
                Log.Error(this, "{0} Message:{1}", LoggerCategory.AlarmOccured, errMsg);

                string [] maintenance_msg = this.GetMaintenanceLogFormatString();
                Log.Maintenance(this, "{0}, {1}", maintenance_msg[0], maintenance_msg[1]);
                return(null);
            }
            if (!qEvent.IsSignal(Active.SigResume))
            {
                return(this.statePaused);
            }
            System.Threading.Thread.Sleep(500);
            _workcell.OffAlarm = false;
            switch (base.errorMessage.ButtonSelected)
            {
            case ErrorButton.Abort:
                this._workcell.MainProcess.Abort();
                break;

            case ErrorButton.Retry:
            {
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event2 = new QEvent(base.SigStateJob);
                event2.EventObject = base.errorMessage.ButtonSelected;
                this.errorMessage  = null;
                base.PostFIFO(event2);
                break;
            }

            case ErrorButton.Stop:
                this._workcell.MainProcess.Stop();

                for (int i = 0; i < ServiceManager.ErrorHandler.ErrorList.Count; i++)
                {
                    IErrorMessage currentMessage = ServiceManager.ErrorHandler.ErrorList[i] as IErrorMessage;
                    ServiceManager.ErrorHandler.UnRegisterMessage(currentMessage);
                }
                break;

            case ErrorButton.NoButton:
                //TY: Treat NoButton as Retry
                Console.Beep();
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event4 = new QEvent(base.SigStateJob);
                event4.EventObject = base.errorMessage.ButtonSelected;
                this.errorMessage  = null;
                base.PostFIFO(event4);
                break;

            default:
            {
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event3 = new QEvent(base.SigRecover);
                event3.EventObject = base.errorMessage.ButtonSelected;
                base.PostFIFO(event3);
                break;
            }
            }
            return(null);
        }
Ejemplo n.º 22
0
        private QState AO_StateSearch_InState(QEvent e)
        {
            switch (e.sig)
            {
            case (int)HSMSignals.EXIT_SIG:
            case (int)HSMSignals.ENTRY_SIG:
            {
                return(handled);
            }

            case (int)Signals.DECREMENT_SCOP_LEVEL_SIG:
            {
                this.scopeLevel--;
                if (scopeLevel == 0)
                {
                    transition(AO_StateSearch);

                    /* This is an initial transition check, which should only
                     * have return 1 Q_TRAN.*/
                    if (currentStateParsing.guardedTransitions.Count == 0 &&
                        currentStateParsing.superState == null &&
                        currentStateParsing.transitions.Count == 1)
                    {
                        int aoCount = currentAOParsing.states.Count;
                        foreach (State s in currentAOParsing.states)
                        {
                            if (s.stateName == currentStateParsing.transitions[0].targetState.stateName)
                            {
                                currentAOParsing.states[0].transitions.Add(new Transition("Q_INIT_SIG", s));

                                for (int i = 0; i < currentAOParsing.states.Count; i++)
                                {
                                    if (currentAOParsing.states[i] == currentStateParsing)
                                    {
                                        currentAOParsing.states.RemoveAt(i);
                                        break;
                                    }
                                }
                            }

                            if (aoCount > currentAOParsing.states.Count)
                            {
                                break;
                            }
                        }
                    }
                }
                return(handled);
            }

            case (int)Signals.NEW_WORD_SIG:
            {
                string tempWord = ((WordFeeder)e).Word;
                if (tempWord.Contains("return"))
                {
                    transition(AO_StateSearch_InState_ReturnFound);
                }
                else if (tempWord.Contains("case"))
                {
                    transition(AO_StateSearch_InState_SigFound);
                }
            }
                return(handled);
            }
            return(AO_StateSearch);
        }
Ejemplo n.º 23
0
 public override bool Event(QEvent e)
 {
     return((bool)interceptor.Invoke("event#", "event(QEvent*)", typeof(bool), typeof(QEvent), e));
 }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
0
 protected override bool Event(QEvent arg1)
 {
     return((bool)interceptor.Invoke("event#", "event(QEvent*)", typeof(bool), typeof(QEvent), arg1));
 }
Ejemplo n.º 26
0
        /* @brief Scans the file and generates an event list (tokens) for
         *        the parser to consume.
         **/
        private void GenerateEventList(string File)
        {
            bool         inComment  = false;
            StreamReader fileReader = new StreamReader(new FileStream(File, FileMode.Open, FileAccess.Read));

            while (!fileReader.EndOfStream)
            {
                string tempLine = fileReader.ReadLine();
                string tempWord = "";

                while (tempLine.Length > 0)
                {
                    if (tempLine[0] == '{')
                    {
                        QEvent scopePlus = new QEvent();
                        scopePlus.sig = (int)Signals.INCREMENT_SCOPE_LEVEL_SIG;
                        eventList.Add(scopePlus);
                    }
                    else if (tempLine[0] == '}')
                    {
                        QEvent scopeMinus = new QEvent();
                        scopeMinus.sig = (int)Signals.DECREMENT_SCOP_LEVEL_SIG;
                        eventList.Add(scopeMinus);
                    }
                    else if (!char.IsWhiteSpace(tempLine[0]) && !inComment)
                    {
                        if (tempLine[0] == '(')
                        {
                            if (tempWord != "")
                            {
                                WordFeeder newWord = new WordFeeder(tempWord, (int)Signals.NEW_WORD_SIG);
                                eventList.Add((QEvent)newWord);
                                tempWord = "";
                            }
                            eventList.Add(new QEvent((int)Signals.START_PARENTHESIS_SIG));
                        }
                        else if (tempLine[0] == ')')
                        {
                            if (tempWord != "")
                            {
                                WordFeeder newWord = new WordFeeder(tempWord, (int)Signals.NEW_WORD_SIG);
                                eventList.Add((QEvent)newWord);
                                tempWord = "";
                            }
                            eventList.Add(new QEvent((int)Signals.END_PARENTHESIS_SIG));
                        }
                        else if (tempLine[0] != ';')
                        {
                            tempWord += tempLine[0];
                        }
                        else if (tempWord != "")
                        {
                            WordFeeder endLine = new WordFeeder(tempWord, (int)Signals.END_LINE_SIG);
                            eventList.Add(endLine);
                            tempWord = "";
                        }
                    }
                    else if (!char.IsWhiteSpace(tempLine[0]) && inComment)
                    {
                        tempWord += tempLine[0];
                    }
                    else if (tempWord != "")
                    {
                        if (tempWord.Contains("/*"))
                        {
                            inComment = true;
                        }
                        else if (tempWord.Contains("*/"))
                        {
                            inComment = false;
                        }
                        else if (!inComment)
                        {
                            WordFeeder newWord = new WordFeeder(tempWord, (int)Signals.NEW_WORD_SIG);
                            eventList.Add((QEvent)newWord);
                        }
                        tempWord = "";
                    }

                    tempLine = tempLine.Substring(1);
                }

                if (tempWord != "")
                {
                    if (tempWord.Contains("/*"))
                    {
                        inComment = true;
                    }
                    else if (tempWord.Contains("*/"))
                    {
                        inComment = false;
                    }
                    else if (!inComment)
                    {
                        WordFeeder newWord = new WordFeeder(tempWord, (int)Signals.NEW_WORD_SIG);
                        eventList.Add((QEvent)newWord);
                    }
                    tempWord = "";
                }
            }

            fileReader.Close();
            fileReader.Dispose();
        }
Ejemplo n.º 27
0
		/// <summary>
		/// If USE_DOTNET_EVENTS is defined, this method is intended to be used only for self-posting.
		/// Otherwise, it allows any object to add events to the Hsm's queue.
		/// </summary>
		/// <param name="qEvent">New message posted (to self) during processing</param>
		#if USE_DOTNET_EVENTS
		protected void Enqueue(QEvent qEvent)