Esempio n. 1
0
File: Main.cs Progetto: 0000duck/XN
 private void tmUpErpWorker(object sender, System.Timers.ElapsedEventArgs e)
 {
     lock (this)
     {
         try
         {
             tmUpErpWorkTimer.Stop();
             App.Dispatching.Process.Report report = new Dispatching.Process.Report();
             DataParameter[] para = new DataParameter[] { new DataParameter("{0}", string.Format("WCS_TASK.State in (7,9) and WCS_TASK.FinishReturnCode!='000' and WCS_TASK.WarehouseCode='{0}'", Program.WarehouseCode)) };
             DataTable       dt   = bll.FillDataTable("WCS.SelectTask", para);
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 string TaskNo = dt.Rows[i]["TaskNo"].ToString();
                 int    Flag   = 3;
                 if (dt.Rows[i]["State"].ToString() == "9")
                 {
                     Flag = 5;
                 }
                 report.Send2MJWcs(context, Flag, TaskNo);
                 Logger.Info("WCS重新上传任务完成标志,任务号:" + TaskNo);
             }
         }
         catch (Exception ex)
         {
             Logger.Error(ex.Message);
         }
         finally
         {
             tmUpErpWorkTimer.Start();
         }
     }
 }
Esempio n. 2
0
File: Main.cs Progetto: 0000duck/XN
        private void ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string ItemName = ((ToolStripMenuItem)sender).Name;
            string State    = ItemName.Substring(ItemName.Length - 1, 1);

            if (this.dgvMain.CurrentCell != null)
            {
                BLL.BLLBase bll       = new BLL.BLLBase();
                string      TaskNo    = this.dgvMain.Rows[this.dgvMain.CurrentCell.RowIndex].Cells[0].Value.ToString();
                string      TaskState = this.dgvMain.Rows[this.dgvMain.CurrentCell.RowIndex].Cells[2].Value.ToString();
                if (TaskState == "等待" && State == "7")
                {
                    frmChangefalse frm = new frmChangefalse();
                    frm.ShowDialog();
                    return;
                }

                DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", TaskNo), new DataParameter("@State", State) };
                bll.ExecNonQueryTran("WCS.Sp_UpdateTaskState", param);

                BindData();
                Logger.Info("任务:" + TaskNo + " 手动切换状态为:" + State);
                try
                {
                    App.Dispatching.Process.Report report = new Dispatching.Process.Report();
                    if (State == "7")
                    {
                        report.Send2MJWcs(context, 3, TaskNo);
                    }
                    else if (State == "9")
                    {
                        report.Send2MJWcs(context, 5, TaskNo);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("切换状态,上报MJ-WCS时发生错误:" + ex.Message);
                }
            }
        }
Esempio n. 3
0
File: Main.cs Progetto: 0000duck/XN
 private void ToolStripMenuItemCellCode_Click(object sender, EventArgs e)
 {
     if (this.dgvMain.CurrentCell != null)
     {
         BLL.BLLBase bll       = new BLL.BLLBase();
         string      TaskNo    = this.dgvMain.Rows[this.dgvMain.CurrentCell.RowIndex].Cells[0].Value.ToString();
         string      TaskType  = this.dgvMain.Rows[this.dgvMain.CurrentCell.RowIndex].Cells["colTaskType"].Value.ToString();
         string      AlarmCode = this.dgvMain.Rows[this.dgvMain.CurrentCell.RowIndex].Cells["colAlarmCode"].ToString();
         if (AlarmCode == "503" || AlarmCode == "504")
         {
             App.Dispatching.Process.Report report = new Dispatching.Process.Report();
             report.Send2MJWcs(context, 4, TaskNo);
         }
         else
         {
             Logger.Info("非重入或入库货位阻塞不可重新申请货位");
         }
     }
 }
Esempio n. 4
0
        protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher)
        {
            try
            {
                lock (this)
                {
                    switch (stateItem.ItemName)
                    {
                    case "CarAlarm01":
                    case "CarAlarm02":

                        object obj = ObjectUtil.GetObject(stateItem.State);
                        if (obj == null)
                        {
                            return;
                        }

                        string carNo     = stateItem.ItemName.Substring(8, 2);
                        string DeviceNo  = stateItem.Name.Substring(5, 2) + carNo;
                        string AlarmCode = obj.ToString();
                        string AlarmDesc = "";
                        //更新故障表
                        DataTable dtDevice      = bll.FillDataTable("CMD.SelectDevice", new DataParameter("{0}", string.Format("DeviceNo2='{0}' and WarehouseCode='{1}'", DeviceNo, Program.WarehouseCode)));
                        string    WarehouseCode = dtDevice.Rows[0]["WarehouseCode"].ToString();
                        string    AreaCode      = dtDevice.Rows[0]["AreaCode"].ToString();
                        if (AlarmCode != "0")
                        {
                            bll.ExecNonQuery("WCS.InsertDeviceAlarmRecord", new DataParameter[] { new DataParameter("@WareHouseCode", WarehouseCode), new
                                                                                                  DataParameter("@AreaCode", AreaCode), new DataParameter("@DeviceNo", DeviceNo), new DataParameter("@AlarmCode", AlarmCode) });

                            DataRow[] drs = dtDeviceAlarm.Select(string.Format("AlarmCode={0}", AlarmCode));
                            if (drs.Length > 0)
                            {
                                AlarmDesc = drs[0]["AlarmDesc"].ToString();
                            }
                            else
                            {
                                AlarmDesc = "穿梭车未知错误!";
                            }
                            //更新任务报警
                            string TaskNo = Util.ConvertStringChar.BytesToString(ObjectUtil.GetObjects(WriteToService(stateItem.Name, "CarTask" + carNo)));
                            if (TaskNo.Length > 0)
                            {
                                DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", TaskNo), new DataParameter("@AlarmCode", obj), new DataParameter("@AlarmDesc", AlarmDesc) };
                                bll.ExecNonQueryTran("WCS.UpdateTaskDeviceAlarm", param);

                                report.Send2MJWcs(base.Context, 2, TaskNo);
                                //Send2MJWcs(2, TaskNo);
                            }

                            Logger.Error("设备编号" + DeviceNo + "发生报警,代号:" + obj.ToString() + ";描述:" + AlarmDesc);
                        }
                        else
                        {
                            bll.ExecNonQuery("WCS.UpdateDeviceAlarmRecord", new DataParameter[] { new DataParameter("@AreaCode", AreaCode), new DataParameter("@WarehouseCode", WarehouseCode), new
                                                                                                  DataParameter("@DeviceNo", DeviceNo) });
                        }
                        DataParameter[] paramb = new DataParameter[] { new DataParameter("@AlarmCode", obj), new DataParameter("@DeviceNo", DeviceNo) };
                        bll.ExecNonQueryTran("WCS.UpdateDeviceAlarm", paramb);
                        //上报设备状态
                        report.SendDeviceStatus2(base.Context, stateItem.Name, carNo, AlarmDesc);
                        //SendDeviceStatus(stateItem.Name, AlarmDesc);
                        break;

                    case "ElevatorAlarm":
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Error("ElevatorAlarmProcess StateChanged方法出错,原因:" + ex.Message);
            }
        }
Esempio n. 5
0
        protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher)
        {
            switch (stateItem.ItemName)
            {
            case "TaskFinished01":
            case "TaskFinished02":


                try
                {
                    object[] obj = ObjectUtil.GetObjects(stateItem.State);

                    Logger.Debug("收到完成信号,PLC编号:" + stateItem.Name + "小车号:" + stateItem.ItemName + "任务号:" + ConvertStringChar.BytesToString(obj));
                    if (obj == null)
                    {
                        return;
                    }
                    string TaskNo = ConvertStringChar.BytesToString(obj);

                    //存储过程处理
                    if (TaskNo.Length > 0)
                    {
                        byte[] b = new byte[30];
                        ConvertStringChar.stringToByte("", 30).CopyTo(b, 0);
                        WriteToService(stateItem.Name, stateItem.ItemName, b);

                        Logger.Info(stateItem.ItemName + "完成标志,任务号:" + TaskNo);
                        DataParameter[] param = new DataParameter[] { new DataParameter("@TaskNo", TaskNo) };
                        bll.ExecNonQueryTran("WCS.Sp_TaskProcess", param);

                        DataParameter[] para = new DataParameter[] { new DataParameter("{0}", string.Format("WCS_Task.TaskNo='{0}'", TaskNo)) };
                        DataTable       dt   = bll.FillDataTable("WCS.SelectTask", para);

                        if (dt.Rows.Count > 0)
                        {
                            string TaskType = dt.Rows[0]["TaskType"].ToString();
                            if (TaskType == "12")
                            {
                                string Barcode = dt.Rows[0]["PalletBarcode"].ToString();
                                byte[] barcode = new byte[20];
                                ConvertStringChar.stringToByte(Barcode, 20).CopyTo(barcode, 0);
                                WriteToService(stateItem.Name, "OutLocation01", barcode);
                            }
                        }

                        report.Send2MJWcs(base.Context, 3, TaskNo);
                    }
                }
                catch (Exception ex)
                {
                    Logger.Error("小车完成过程中出错" + ex.ToString());
                }
                //上报总控WCS,下架完成

                break;

            case "Run":
                blRun = (int)stateItem.State == 1;
                if (blRun)
                {
                    tmWorkTimer.Start();
                    Logger.Info("提升机联机");
                }
                else
                {
                    tmWorkTimer.Stop();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    Logger.Info("提升机脱机");
                }
                break;

            default:
                break;
            }
        }
Esempio n. 6
0
        protected override void StateChanged(StateItem stateItem, IProcessDispatcher dispatcher)
        {
            try
            {
                string TaskNo        = "";
                string PalletBarcode = "";
                switch (stateItem.ItemName)
                {
                case "TaskFinish":
                    object obj = ObjectUtil.GetObject(stateItem.State);
                    if (obj == null)
                    {
                        return;
                    }
                    string TaskFinish = obj.ToString();
                    if (TaskFinish.Equals("True") || TaskFinish.Equals("1"))
                    {
                        //TaskNo = Util.ConvertStringChar.BytesToString(ObjectUtil.GetObjects(WriteToService(stateItem.Name, "ReadTaskNo")));
                        //DataParameter[] para = new DataParameter[] { new DataParameter("{0}", string.Format("WCS_Task.TaskNo='{0}'", TaskNo)) };
                        PalletBarcode = Util.ConvertStringChar.BytesToString(ObjectUtil.GetObjects(WriteToService(stateItem.Name, "ReadTaskNo")));
                        DataParameter[] para = new DataParameter[] { new DataParameter("{0}", string.Format("WCS_Task.PalletBarcode='{0}' and WCS_TASK.State!=0 and WCS_TASK.State<7", PalletBarcode)) };
                        DataTable       dt   = bll.FillDataTable("WCS.SelectTask", para);
                        TaskNo = dt.Rows[0]["TaskNo"].ToString();
                        string TaskType = "";
                        if (dt.Rows.Count > 0)
                        {
                            TaskType = dt.Rows[0]["TaskType"].ToString();
                        }

                        //存储过程处理
                        if (TaskNo != "")
                        {
                            Logger.Info(stateItem.ItemName + "完成标志,任务号:" + TaskNo);
                            //更新任务状态

                            List <string>          comds = new List <string>();
                            List <DataParameter[]> paras = new List <DataParameter[]>();

                            comds.Add("WCS.Sp_TaskProcess");

                            para = new DataParameter[] { new DataParameter("@TaskNo", TaskNo) };
                            paras.Add(para);

                            bll.ExecTran(comds.ToArray(), paras);

                            //清除堆垛机任务号
                            sbyte[] taskNo = new sbyte[20];
                            for (int i = 0; i < 20; i++)
                            {
                                taskNo[i] = 32;
                            }
                            //Util.ConvertStringChar.stringToBytes("", 20).CopyTo(taskNo, 0);
                            WriteToService(stateItem.Name, "TaskNo", taskNo);
                            //Thread th = new Thread(new ThreadStart(ThreadMethod)); //也可简写为new Thread(ThreadMethod);
                            //th.Start(); //启动线程

                            report.Send2MJWcs(base.Context, 3, TaskNo);
                        }
                    }
                    break;

                case "ACK":
                    obj = ObjectUtil.GetObject(stateItem.State);
                    if (obj == null)
                    {
                        return;
                    }
                    string ack = obj.ToString();

                    Logger.Info(stateItem.Name + " Receive ACK:" + ack);
                    if (ack.Equals("True") || ack.Equals("1"))
                    {
                        WriteToService(stateItem.Name, "STB", 0);
                        Logger.Info(stateItem.Name + " Receive ACK 1");
                    }
                    break;

                case "Run":
                    blRun = (int)stateItem.State == 1;
                    if (blRun)
                    {
                        tmWorkTimer.Start();
                        Logger.Info("堆垛机联机");
                    }
                    else
                    {
                        tmWorkTimer.Stop();
                        Logger.Info("堆垛机脱机");
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                Logger.Error("CraneProcess StateChanged方法出错,原因:" + ex.Message);
            }
        }