Пример #1
0
        private void ManualOperate()
        {
            if (package.Head == 10004)
            {
                MainWindow.whUIHandle.WH_OPER_STATE = "已收到出库指令";
                ExecuteOrder.SendWHCmdEnable        = false;
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已收到出库指令", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表通信状态为【已收到】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHComState(con, package.SerialNumber);
            }

            if (package.Head == 20004)
            {
                if (package.InlibMatchingID == 1)  // 与预期的托盘号一致,匹配成功
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "已收到入库指令";
                    ExecuteOrder.SendWHCmdEnable        = false;
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("已收到入库指令", LogInfoHelp.LOG_TYPE.LOG_INFO);
                    //更新立库表通信状态为【已收到】
                    DataBaseHandle db  = new DataBaseHandle();
                    SqlConnection  con = new SqlConnection();
                    db.UpdateWHComState(con, package.SerialNumber);
                }
                else
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "入库托盘匹配不成功";
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("入库托盘匹配不成功", LogInfoHelp.LOG_TYPE.LOG_ERROR);
                    MessageBox.Show("入库托盘匹配不成功,请选择正确的托盘类型,或者检查托盘RFID码是否正确,否则RFID读写器可能出现异常");
                    ExecuteOrder.HandAndDownFlag = false;
                    DataBaseHandle db1  = new DataBaseHandle();
                    SqlConnection  con1 = new SqlConnection();
                    db1.DeleteAGVCmdTable(con1);
                    db1.DeleteWHCmdTable(con1);
                }
                return;
            }
            if (package.Head == 10005)
            {
                if (package.OutlibMatchingID == 2)
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "出库托盘匹配不成功";
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("出库托盘匹配不成功", LogInfoHelp.LOG_TYPE.LOG_ERROR);
                    MessageBox.Show("出库托盘匹配不成功,请检查MES系统的托盘位置和立库实际的托盘位置是否一致,否则RFID读写器可能出现异常");
                    ExecuteOrder.HandAndDownFlag = false;
                    DataBaseHandle db1  = new DataBaseHandle();
                    SqlConnection  con1 = new SqlConnection();
                    db1.DeleteAGVCmdTable(con1);
                    db1.DeleteWHCmdTable(con1);
                    return;
                }
                MainWindow.whUIHandle.WH_OPER_STATE = "已出库";
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已出库", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表工作状态为【完成】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHWorkState(con, package.SerialNumber);
                ExecuteOrder.SendWHCmdEnable = true;
                //更新库位表(根据流水号得到出库的货位ID,然后将此ID号对应的货位类型置为0,选中状态置为未选中)
                db.UpdateCargoInfo(con, package.SerialNumber);

                //通知AGV来取货物,并送往立库下料区
                //(根据当前出库的托盘类型和订单类型和各个工作区的PLC状态来判断应该将货物送往哪里,然后向AGV指令表中插入数据)

                //防止由于连续接收到相同信息,从而导致连续插入相同的指令以及防止线程重复创建
                if (InformAGVThread1State == false)
                {
                    InformAGVThread1 = new Thread(new ParameterizedThreadStart(CheckAndInformAGV1));
                    InformAGVThread1.IsBackground = true;
                    InformAGVThread1State         = true;
                    InformAGVThread1.Start(package);
                }
                return;
            }
            if (package.Head == 20005)
            {
                MainWindow.whUIHandle.WH_OPER_STATE = "已入库";
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已入库", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表工作状态为【完成】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHWorkState(con, package.SerialNumber);
                ExecuteOrder.SendWHCmdEnable = true;
                //更新库位表(根据流水号得出入库的货位ID,然后根据得到的托盘类型,将货位类型置为相应的类型。选中状态置为未选中)
                db.UpdateCargoInfo(con, package.SerialNumber, package.TrayStyle);

                //当前上料订单完成事件,恢复上下料的按钮功能。
                UDDelegate();
            }
        }
Пример #2
0
        //执行订单(自动操作)AGV时收到消息的处理方法
        private void AutoOperate()
        {
            if (package.Head == 30000)
            {
                MainWindow.whUIHandle.WH_OPER_STATE = "写码完成";
                LogInfoHelp.GetInstance().WriteInfoToLogFile("写码完成", LogInfoHelp.LOG_TYPE.LOG_INFO);
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.InsertAGVCmd(con, ConfigClass.WHOutlibArea2, ConfigClass.WHInlibArea);
                return;
            }
            if (package.Head == 10004)
            {
                MainWindow.whUIHandle.WH_OPER_STATE = "已收到出库指令";
                ExecuteOrder.SendWHCmdEnable        = false;
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已收到出库指令", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表通信状态为【已收到】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHComState(con, package.SerialNumber);
                return;
            }

            if (package.Head == 20004)
            {
                if (package.InlibMatchingID == 1)  // 与预期的托盘号一致,匹配成功
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "已收到入库指令";
                    ExecuteOrder.SendWHCmdEnable        = false;
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("已收到入库指令", LogInfoHelp.LOG_TYPE.LOG_INFO);
                    //更新立库表通信状态为【已收到】
                    DataBaseHandle db  = new DataBaseHandle();
                    SqlConnection  con = new SqlConnection();
                    db.UpdateWHComState(con, package.SerialNumber);
                }
                else
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "入库托盘匹配不成功";
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("入库托盘匹配不成功", LogInfoHelp.LOG_TYPE.LOG_ERROR);
                    MessageBox.Show("入库托盘匹配不成功,RFID读写器可能出现异常或者出现一些不可预见因素");
                    ExecuteOrder.ExecuteFlag = false;
                    DataBaseHandle db  = new DataBaseHandle();
                    SqlConnection  con = new SqlConnection();
                    db.DeleteAGVCmdTable(con);
                    db.DeleteWHCmdTable(con);
                }
                return;
            }
            if (package.Head == 30004)
            {
                MainWindow.whUIHandle.WH_OPER_STATE = "已收到侧边出库命令";
                ExecuteOrder.SendWHCmdEnable        = false;
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已收到侧边出库命令", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表通信状态为【已收到】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHComState(con, package.SerialNumber);
                return;
            }
            if (package.Head == 10005)
            {
                if (package.OutlibMatchingID == 2)
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "出库托盘匹配不成功";
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("出库托盘匹配不成功", LogInfoHelp.LOG_TYPE.LOG_ERROR);
                    MessageBox.Show("出库托盘匹配不成功,请检查MES系统的托盘位置和立库实际的托盘位置是否一致,否则RFID读写器可能出现异常");
                    ExecuteOrder.ExecuteFlag = false;
                    DataBaseHandle db1  = new DataBaseHandle();
                    SqlConnection  con1 = new SqlConnection();
                    db1.DeleteAGVCmdTable(con1);
                    db1.DeleteWHCmdTable(con1);
                    return;
                }
                MainWindow.whUIHandle.WH_OPER_STATE = "已出库";
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已出库", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表工作状态为【完成】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHWorkState(con, package.SerialNumber);
                ExecuteOrder.SendWHCmdEnable = true;
                //更新库位表(根据流水号得到出库的货位ID,然后将此ID号对应的货位类型置为0,选中状态置为未选中)
                db.UpdateCargoInfo(con, package.SerialNumber);

                //通知AGV来取货物,并送往指定位置
                //(根据当前出库的托盘类型和订单类型和各个工作区的PLC状态来判断应该将货物送往哪里,然后向AGV指令表中插入数据)

                //防止由于连续接收到相同信息,从而导致连续插入相同的指令以及防止线程重复创建
                if (InformAGVThreadState == false)
                {
                    InformAGVThread = new Thread(new ParameterizedThreadStart(CheckAndInformAGV));
                    InformAGVThread.IsBackground = true;
                    InformAGVThread1State        = true;
                    InformAGVThread.Start(package);
                    InformAGVThread.Priority = ThreadPriority.AboveNormal;
                }
                return;
            }
            if (package.Head == 20005)
            {
                MainWindow.whUIHandle.WH_OPER_STATE = "已入库";
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已入库", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表工作状态为【完成】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHWorkState(con, package.SerialNumber);
                ExecuteOrder.SendWHCmdEnable = true;
                //更新库位表(根据流水号得出入库的货位ID,然后根据得到的托盘类型,将货位类型置为相应的类型。选中状态置为未选中)
                db.UpdateCargoInfo(con, package.SerialNumber, package.TrayStyle);

                //如果订单类型是入库订单的话,我们就根据其托盘类型更新订单表 ,然后判断立库中订单表的数量,
                //如果为0停止响应的机器工作
                //不为0的话则通知出库。
                if (UpdateOrderThreadState == false)
                {
                    UpdateOrderThread = new Thread(new ParameterizedThreadStart(UpdateOrderTable));
                    UpdateOrderThread.IsBackground = true;
                    UpdateOrderThreadState         = true;
                    UpdateOrderThread.Start(package.SerialNumber);
                    UpdateOrderThread.Priority = ThreadPriority.AboveNormal;
                }
            }

            if (package.Head == 30005)
            {
                if (package.OutlibMatchingID == 2)
                {
                    MainWindow.whUIHandle.WH_OPER_STATE = "托盘匹配不成功";
                    LogInfoHelp.GetInstance().WriteInfoToLogFile("侧边托盘匹配不成功", LogInfoHelp.LOG_TYPE.LOG_ERROR);
                    MessageBox.Show("侧边出库托盘匹配不成功,请检查MES系统的托盘位置和立库实际的托盘位置是否一致,否则RFID读写器可能出现异常");
                    ExecuteOrder.ExecuteFlag = false;
                    DataBaseHandle db1  = new DataBaseHandle();
                    SqlConnection  con1 = new SqlConnection();
                    db1.DeleteAGVCmdTable(con1);
                    db1.DeleteWHCmdTable(con1);
                    return;
                }
                MainWindow.whUIHandle.WH_OPER_STATE = "已侧边出库";
                LogInfoHelp.GetInstance().WriteInfoToLogFile("已侧边出库", LogInfoHelp.LOG_TYPE.LOG_INFO);
                //更新立库表工作状态为【完成】
                DataBaseHandle db  = new DataBaseHandle();
                SqlConnection  con = new SqlConnection();
                db.UpdateWHWorkState(con, package.SerialNumber);
                ExecuteOrder.SendWHCmdEnable = true;
                //更新库位表(根据流水号得到出库的货位ID,然后将此ID号对应的货位类型置为0,选中状态置为未选中)
                db.UpdateCargoInfo(con, package.SerialNumber);

                //通知加工区机器人来取货物
                DTUSendPackage.Raw_Tray_Out = 1;

                return;
            }
        }