コード例 #1
0
ファイル: ElevatorProcess.cs プロジェクト: baoyigang/ZKSA
        private void SendAGVTask()
        {
            DataTable dt = bll.FillDataTable("WCS.SelectAGVTask", new DataParameter[] { new DataParameter("{0}", string.Format("TaskType='11' and State=0 and not exists(select 1 from WCS_TASK where TaskType='11' and State in (2,3,4) ")), new DataParameter("{1}", "TaskNo,RowIndex"), new DataParameter("{2}", 4) });

            if (dt.Rows.Count > 0)
            {
                ushort FromStation = ushort.Parse(dt.Rows[0]["FromStation"].ToString());
                //获取入库巷道
                ushort ToStation = ushort.Parse(dt.Rows[0]["ToStation"].ToString());
                //获取AGV操作码
                ushort AGVActionID = SendAGVMessage.GetAGVActionID();
                //获取AGV任务号
                ushort AGVTaskID = SendAGVMessage.GetAGVTaskID();
                //更新WCS_Task AGVTaskID
                string TaskNo = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    TaskNo += "'" + dt.Rows[0]["TaskNo"].ToString() + "',";
                }
                bll.ExecNonQuery("WCS.UpdateTaskState", new DataParameter[] { new DataParameter("{0}", string.Format("AGVTaskID={0},State=1,AGVStation={1}", AGVTaskID, ToStation)), new DataParameter("{1}", string.Format("TaskNo in ({0})", TaskNo.TrimEnd(','))) });
                //获取发送信息
                byte[] sendByte = SendAGVMessage.GetSendTask1(AGVTaskID, FromStation, ToStation, AGVActionID);
                WriteToService("AGVService", "ACK", sendByte);
            }
        }
コード例 #2
0
        private void tmWorker(object sender, ElapsedEventArgs e)
        {
            lock (this)
            {
                try
                {
                    tmWorkTimer.Stop();
                    if (!blRun)
                    {
                        return;
                    }

                    //判断是否存在入库任务,且不存在未完成的
                    DataTable dt = bll.FillDataTable("WCS.SelectAGVTask", new DataParameter[] { new DataParameter("{0}", "TaskType='11' and State=0 and not exists(select 1 from WCS_TASK where TaskType='11' and State in (1,2,3,4) )"), new DataParameter("{1}", "TaskNo,RowIndex"), new DataParameter("{2}", 4) });
                    if (dt.Rows.Count > 0)
                    {
                        ushort FromStation = ushort.Parse(dt.Rows[0]["FromStation"].ToString());
                        //获取入库巷道
                        ushort ToStation = ushort.Parse(dt.Rows[0]["ToStation"].ToString());
                        //获取AGV操作码
                        ushort AGVActionID = SendAGVMessage.GetAGVActionID();
                        //获取AGV任务号
                        ushort AGVTaskID = SendAGVMessage.GetAGVTaskID();
                        //更新WCS_Task AGVTaskID
                        string TaskNo = "";
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            TaskNo += "'" + dt.Rows[i]["TaskNo"].ToString() + "',";
                        }
                        bll.ExecNonQuery("WCS.UpdateTaskState", new DataParameter[] { new DataParameter("{0}", string.Format("AGVTaskID={0},State=1,AGVStation={1}", AGVTaskID, ToStation)), new DataParameter("{1}", string.Format("TaskNo in ({0})", TaskNo.TrimEnd(','))) });
                        //获取发送信息
                        byte[] sendByte = SendAGVMessage.GetSendTask1(AGVTaskID, FromStation, ToStation, AGVActionID);
                        WriteToService("AGVService", "ACK", sendByte);
                        Logger.Info("下发小车入库任务,小车任务号:" + AGVTaskID);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("AGVProcess中下发任务出错:" + ex.Message);
                }
                finally
                {
                    tmWorkTimer.Start();
                }
            }
        }