Esempio n. 1
0
        void Run()
        {
            while (true)
            {
                CheckError();
                GetCurrentPos();
                try
                {
                    sw.Restart();
                    switch (m_SeqState)
                    {
                    case SeqState.none:
                        break;

                    case SeqState.initialize:
                        break;

                    case SeqState.wait:
                        break;

                    case SeqState.start:
                        foreach (string strAxis in ListOfAxis)
                        {
                            MovePosition(strAxis, 0);
                        }
                        if (false == IsMoving())
                        {
                            m_SeqState = SeqState.Action;
                            ntick      = 0;
                        }
                        break;

                    case SeqState.Action:
                        //if (false == IsMoving())
                        //{
                        //    double dbPosition_U = 2 * Math.Sin(Math.PI * 0.2 * ntick);
                        //    double dbPosition_V = 2 * Math.Cos(Math.PI * 0.2 * ntick);
                        //    RotateAction(dbPosition_U, dbPosition_V);
                        //}
                        double dbPosition_U = 5 * Math.Sin(Math.PI * 0.1 * ntick);
                        double dbPosition_V = 5 * Math.Cos(Math.PI * 0.1 * ntick);
                        RotateAction(dbPosition_U, dbPosition_V);
                        break;

                    case SeqState.stop:
                        ntick         = 0;
                        m_ActionState = ActionState.first;
                        m_SeqState    = SeqState.wait;
                        break;
                    }
                    Thread.Sleep(50);
                    sw.Stop();
                    Console.WriteLine("Time :" + sw.ElapsedMilliseconds.ToString() + "msec");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
Esempio n. 2
0
 public void Connect()
 {
     m_ID = PI.GCS2.InterfaceSetupDlg("");
     if (m_ID > -1)
     {
         CompleteConnectionProcess();
         m_SeqState = SeqState.wait;
     }
 }
Esempio n. 3
0
 public void Reset(bool regenSeqList)
 {
     if (regenSeqList)
     {
         SeqList = this.BuildSeqList(this._sinc);
     }
     SeqStep = -1;
     _state  = SeqState.SeqDone;
     this.SecuenciaReinicia();
 }
Esempio n. 4
0
            public IAutomaton Next(int i)
            {
                var s1 = State1.Next(i);

                if (State1.Empty)
                {
                    var s2 = State2.Next(i);
                    return(OrState.Create(s2, SeqState.Create(s1, State2)));
                }
                else
                {
                    return(SeqState.Create(s1, State2));
                }
            }
Esempio n. 5
0
 private StarState(IAutomaton a)
 {
     Child    = a;
     unpacked = SeqState.Create(a, this);
 }
Esempio n. 6
0
        public void Ejecutar()
        {
            bool suspend = false;

            if (_state == SeqState.SeqDone)
            {
                _state = SeqState.SeqInProgress;
                this.SecuenciaComienza();
            }
            for (int i = SeqStep + 1; i < SeqList.Count; i++)
            {
                if (SeqList[i].GetType() == typeof(Operacion))
                {
                    ActiveOperation = (Operacion)SeqList[i];
                    suspend         = this.Exec((Operacion)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(PreSincro))
                {
                    ActiveTask = (PreSincro)SeqList[i];
                    suspend    = this.Exec((PreSincro)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(Sincro))
                {
                    ActiveTask = (Sincro)SeqList[i];
                    suspend    = this.Exec((Sincro)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(PostSincro))
                {
                    ActiveTask = (PostSincro)SeqList[i];
                    suspend    = this.Exec((PostSincro)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(Complemento))
                {
                    ActiveTask = (Complemento)SeqList[i];
                    suspend    = this.Exec((Complemento)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(CmdSeleccionar))
                {
                    suspend = this.Exec((CmdSeleccionar)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(CmdComparar))
                {
                    suspend = this.Exec((CmdComparar)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(CmdAvisar))
                {
                    suspend = this.Exec((CmdAvisar)SeqList[i]);
                }
                if (SeqList[i].GetType() == typeof(CmdSincronizar))
                {
                    CmdSincronizar c = (CmdSincronizar)SeqList[i];
                    //Fase de configuración de excepciones
                    suspend = this.Exec(c, SyncroStep.ExceptionsCfg);
                    //Fase de simulación
                    suspend = this.Exec(c, SyncroStep.Simulation);
                    //Fase de sincronización
                    if (!suspend)
                    {
                        suspend = this.Exec(c, SyncroStep.Transaction);
                    }
                }
                if (SeqList[i].GetType() == typeof(CmdEditar))
                {
                    suspend = this.Exec((CmdEditar)SeqList[i]);
                }
                SeqStep = i;
                if (suspend)
                {
                    break;
                }
            }
            if (SeqStep == SeqList.Count - 1)
            {
                _state  = SeqState.SeqDone;
                SeqStep = -1;
                this.SecuenciaTermina();
            }
        }