コード例 #1
0
        public void StackerReset(int devID)
        {
            if (devID == 1001)
            {
                Array.Clear(Stacker1001.DB2, 0, Stacker1001.DB2.Count());

                Stacker1001.DevStatusCommit();
            }
            else if (devID == 1002)
            {
                Array.Clear(Stacker1002.DB2, 0, Stacker1001.DB2.Count());

                Stacker1002.DevStatusCommit();
            }
        }
コード例 #2
0
        private void ExeStacker1002Business()
        {
            if (TransPort2006.DB1[0] == 1)
            {
                TransPort2006.DB2[0] = 0;
            }
            if (TransPort2008.DB1[0] == 1)
            {
                TransPort2008.DB2[0] = 0;
            }
            //if (TransPort2007.DB1[0] == 1)
            //{
            //    TransPort2007.DB2[0] = 0;
            //}
            if (TransPort2009.DB1[0] == 1)
            {
                TransPort2009.DB2[0] = 0;
            }
            switch (currentTaskPhaseB1)
            {
            case 0:
            {
                exeTaskCounterB1 = 0;
                if (Stacker1002.DB1[1] == 1)
                {
                    //信号置位:允许接收

                    Stacker1002.DB2[2] = 1;
                    if (Stacker1002.DevStatusCommit())
                    {
                        currentTaskPhaseB1++;
                    }
                }
                break;
            }

            case 1:
            {
                if (Stacker1002.DB1[2] == 1)
                {
                    //信号复位:允许接收
                    Stacker1002.DB2[2] = 0;

                    if (Stacker1002.DevStatusCommit())
                    {
                        currentTaskPhaseB1++;
                    }
                }
                break;
            }

            case 2:
            {
                //开始取数据,取完后信号置位:取数据完成
                currentTaskB1          = new HouseInOutTask();
                currentTaskB1.TaskType = Stacker1002.DB1[4];
                currentTaskB1.TaskCode = (Int16)(Stacker1002.DB1[5] + (Stacker1002.DB1[6] << 8));
                currentTaskB1.CellX    = Stacker1001.DB1[7];
                currentTaskB1.CellY    = Stacker1001.DB1[8];
                currentTaskB1.CellZ    = Stacker1001.DB1[9];
                AddLog("成功接收任务,参数已保存,任务开始启动");
                Stacker1002.DB2[3] = 1;
                Stacker1002.DB2[1] = 2;         //设备处于工作状态
                if (Stacker1002.DevStatusCommit())
                {
                    currentTaskPhaseB1++;
                }


                break;
            }

            case 3:
            {
                if (Stacker1002.DB1[2] == 0)
                {
                    //信号复位:取数据完成信号
                    Stacker1002.DB2[2] = 0;
                    if (Stacker1002.DevStatusCommit())
                    {
                        currentTaskPhaseB1++;
                    }
                }
                exeTaskCounterB1++;
                AddLog("任务类型号" + currentTaskB1.TaskType.ToString() + ",任务执行中,执行到第 " + exeTaskCounterB1 + " 步");

                break;
            }

            case 4:
            {
                if (exeTaskCounterB1 > 5)
                {
                    exeTaskCounterB1 = 0;
                    currentTaskPhaseB1++;
                }
                else
                {
                    exeTaskCounterB1++;
                    AddLog("任务类型号" + currentTaskB1.TaskType.ToString() + ",任务执行中,执行到第 " + exeTaskCounterB1 + " 步");
                }
                break;
            }

            case 5:
            {
                Stacker1002.DB2[5] = (byte)(currentTaskB1.TaskCode & 0xff);
                Stacker1002.DB2[6] = (byte)(currentTaskB1.TaskCode >> 8);

                if (Stacker1002.DevStatusCommit())
                {
                    currentTaskPhaseB1++;
                    AddLog("任务完成,返回任务号:" + currentTaskB1.TaskCode);
                }
                break;
            }

            case 6:
            {
                Stacker1002.DB2[4] = 1;
                if (Stacker1002.DevStatusCommit())
                {
                    currentTaskPhaseB1++;
                }
                break;
            }

            case 7:
            {
                if (Stacker1002.DB1[3] == 1)
                {
                    Array.Clear(Stacker1002.DB2, 0, Stacker1001.DB2.Count());
                    Stacker1002.DB2[1] = 1;         //空闲
                    if (Stacker1002.DevStatusCommit())
                    {
                        currentTaskPhaseB1++;
                    }
                }
                break;
            }

            case 8:
            {
                AddLog("任务" + currentTaskB1.TaskCode + "通信结束");
                currentTaskB1      = null;
                currentTaskPhaseB1 = 0;
                break;
            }

            default:
                break;
            }
        }