Exemplo n.º 1
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     StopAllSemiStateMachine();
     _activeSM = _smReset;
     _activeSM.Go();
     RunAndWaitForSMReset();
 }
Exemplo n.º 2
0
 protected virtual void PreRun()
 {
     try
     {
         if (!_isAlreadyPreRun)
         {
             if (stateMachine == null)
             {
                 stateMachine = StateMachine;
             }
             _timeoutHandle.Reset();
             waitHandle         = stateMachine.WaitHandle;
             decisionWaitHandle = stateMachine.DecisionWaitHandle;
             decisionLoopList   = stateMachine.DecisionLoopList;
             pathOut            = null;
             flowItemForPathOut = null;
             _decisionTimeout   = -1;
             ExitFlowItem();
             FindStart();
             EnterFlowItem();
             _isAlreadyPreRun = true;
         }
     }
     catch
     {
         _isAlreadyPreRun = false;
     }
 }
        public void AddSemiStateMachinePage(SMStateMachine sm)
        {
            AppFloatableSMFlowChart floatSMFlowChart = new AppFloatableSMFlowChart();

            floatSMFlowChart.Dock = DockStyle.Fill;
            floatSMFlowChart.Bind = sm;
            KryptonPage smSemiPage = new KryptonPage();

            smSemiPage.Text = sm.Name;
            smSemiPage.StateCommon.Tab.Back.Color1 = Color.White;
            smSemiPage.StateCommon.Tab.Back.Color2 = Color.LightBlue;
            smSemiPage.Controls.Add(floatSMFlowChart);
            kNavigatorSemiStateMachine.Pages.Add(smSemiPage);
        }
Exemplo n.º 4
0
        private void AsyncWaitSM()
        {
            //Ensure Correct GUI
            this.BeginInvoke((MethodInvoker) delegate { _mainPanel.AnySMRunningOnChange(true); });
            do
            {
                System.Threading.Thread.Sleep(100);
            } while (IsSMRunning);
            _activeSM = null;
            UpdateControlButtons();
            _waithSMTask = null;

            //Ensure Correct GUI
            this.BeginInvoke((MethodInvoker) delegate { _mainPanel.AnySMRunningOnChange(false); });
        }
Exemplo n.º 5
0
        private void GetSMSemiAutoInstanceWithBindControl()
        {
            _smSemiAutoReset = U.GetComponent(AppConstStaticName.SM_SEMI_RESET) as SMStateMachine;
            _smSemiAutoMain  = U.GetComponent(AppConstStaticName.SM_SEMI_MAIN) as SMStateMachine;
            CompBase allSemiAutoState = U.GetComponent(AppConstStaticName.ALL_SEMI_AUTO_STATE_MACHINE);

            foreach (CompBase childState in allSemiAutoState.ChildArray)
            {
                SMStateMachine sm = childState as SMStateMachine;
                if (sm != null)
                {
                    _allSemiStateMachine.Add(sm);
                    _mainPanel.AddSemiStateMachinePage(sm);
                }
            }
        }
Exemplo n.º 6
0
        private void btnStartRun_Click(object sender, EventArgs e)
        {
            StopAllSemiStateMachine();

            mcbStopWhenFinished.Enabled = true;
            _activeSM = _smMain;

            List <Task> smStartTask = new List <Task>();

            foreach (SMStateMachine smState in _allStateMachine)
            {
                if (smState.Name != AppConstStaticName.SM_RESET)
                {
                    smStartTask.Add(new Task(() => smState.Go()));
                }
            }
            Parallel.ForEach <Task>(smStartTask, (sm) => sm.Start());

            RunAndWaitForSM();
        }
Exemplo n.º 7
0
        private void InitialSemiAutoOperationGUI()
        {
            CompBase _allSemiStateMachine = U.GetComponent(AppConstStaticName.ALL_SEMI_AUTO_STATE_MACHINE) as CompBase;
            CompBase _allStation          = U.GetComponent(AppConstStaticName.ALL_STATIONS) as CompBase;


            foreach (CompBase childState in _allSemiStateMachine.ChildArray)
            {
                SMStateMachine sm = childState as SMStateMachine;
                if (sm != null)
                {
                    System.Windows.Forms.Panel smStorePanel = new System.Windows.Forms.Panel();;
                    smStorePanel.Size = new System.Drawing.Size(1100, 30);
                    AppFloatableSMOperate floatSMFlowChart = new AppFloatableSMOperate();
                    floatSMFlowChart.Bind = sm;
                    switch (sm.Name)
                    {
                    case AppConstStaticName.SM_SEMI_MAIN:
                    {
                        StringCtl plugInCtrlParam = new StringCtl();
                        plugInCtrlParam.BindTwoWay(() => AppMachine.Comp.AppMachine.This.SemiAutoMainParam);
                        floatSMFlowChart.PluginControlParameter(plugInCtrlParam, "Param");
                        floatSMFlowChart.BackColor = Color.Green;
                    }
                    break;

                    case AppConstStaticName.SM_SEMI_RESET:
                    {
                        StringCtl plugInCtrlParam = new StringCtl();
                        plugInCtrlParam.BindTwoWay(() => AppMachine.Comp.AppMachine.This.SemiAutoResetParam);
                        floatSMFlowChart.PluginControlParameter(plugInCtrlParam, "Param");
                        floatSMFlowChart.BackColor = Color.MediumPurple;
                    }
                    break;
                    }

                    smStorePanel.Controls.Add(floatSMFlowChart);
                    flpSemiAutoOpr.Controls.Add(smStorePanel);
                }
            }
        }
Exemplo n.º 8
0
        private void btnAbort_Click(object sender, EventArgs e)
        {
            StopAllSemiStateMachine();

            AppMachine.Comp.AppMachine.This.StopWhenFinished = true;
            do
            {
                foreach (SMStateMachine smState in _allStateMachine)
                {
                    if (smState.IsRunning && smState.Mode == SMStateMachine.eMode.Pause)
                    {
                        smState.Mode = SMStateMachine.eMode.Run;
                    }
                    smState.Stop();
                }
                Application.DoEvents();
            } while (IsSMRunning);

            _activeSM = null;
            AppMachine.Comp.AppMachine.This.StopWhenFinished = false;
            UpdateControlButtons();
        }