Example #1
0
        async void Scan(object sender, PLCEventArgs e)
        {
            logger.Info("启动扫描二维码");
            await Task.Delay(2 * 1000);

            My.PLC.Set(e.Index, 12);//扫码器扫码完成
            logger.Info("B{0}.12:扫码器扫码完成", e.Index);
        }
Example #2
0
        async void PrintQRCode(object sender, PLCEventArgs e)
        {
            logger.Info("启动打印二维码");
            Print();
            await Task.Delay(60 * 1000);

            My.PLC.Set(e.Index, 12);//打印二维码完成
            logger.Info("B{0}.12:打印二维码完成", e.Index);
        }
Example #3
0
        void AssembleRead(object sender, PLCEventArgs e)
        {
            var data = My.RFIDs[e.Site].Read();

            if (data == null)
            {
                logger.Warn("{0}:RFID读取失败(装配台请求读)", Enum.GetName(typeof(EnumPSite), e.Site));
                return;
            }
            My.PLC.Set(e.Index, 1);//读取成功
            logger.Info("B{0}.1:RFID读取成功(装配台请求读)", e.Index);
            for (int i = 4; i < 9; i++)
            {
                My.PLC.Clear(e.Index, i);
            }
            My.PLC.Set(e.Index, Work_PLC.WpBitDict[data.Workpiece]);//工件类型
            logger.Info("B{0}.{1}:设置工件类型(装配台请求读),物料类型{2}", e.Index, Work_PLC.WpBitDict[data.Workpiece], Enum.GetName(typeof(EnumWorkpiece), data.Workpiece));
            if (data.IsRough || data.IsFake)
            {
                My.PLC.Set(e.Index, 3);//工件不符合当前工位
                logger.Info("B{0}.3:工件不符合当前工位(装配台请求读)", e.Index);
                SimulationZD(data, e.Site);
            }
            else if (data.Assemble == EnumAssemble.Wanted && data.Clean == EnumClean.Wanted)
            {
                My.PLC.Set(10, 0);      //装配
                My.PLC.Set(10, 1);      //清洗
                My.PLC.Set(e.Index, 2); //工件符合当前工位
                logger.Info("B{0}.2:装配、清洗,工件符合当前工位(装配台请求读)", e.Index);
                SimulationDS(data, e.Site);
            }
            else if (data.Assemble == EnumAssemble.Unwanted && data.Clean == EnumClean.Wanted)
            {
                My.PLC.Clear(10, 0);    //不装配
                My.PLC.Set(10, 1);      //清洗
                My.PLC.Set(e.Index, 2); //工件符合当前工位
                logger.Info("B{0}.2:不装配、清洗,工件符合当前工位(装配台请求读)", e.Index);
                SimulationDS(data, e.Site);
            }
            else if (data.Assemble == EnumAssemble.Wanted && data.Clean == EnumClean.Unwanted)
            {
                My.PLC.Set(10, 0);      //装配
                My.PLC.Clear(10, 1);    //不清洗
                My.PLC.Set(e.Index, 2); //工件符合当前工位
                logger.Info("B{0}.2:装配、不清洗,工件符合当前工位(装配台请求读)", e.Index);
                SimulationDS(data, e.Site);
            }
            else
            {
                My.PLC.Clear(10, 0);    //不装配
                My.PLC.Clear(10, 1);    //不清洗
                My.PLC.Set(e.Index, 3); //工件不符合当前工位
                logger.Info("B{0}.3:不装配、不清洗,工件不符合当前工位(装配台请求读)", e.Index);
                SimulationZD(data, e.Site);
            }
        }
Example #4
0
 void RequestIn(object sender, PLCEventArgs e)
 {
     logger.Info("通知WMS请求入库");
     if (UpWait().IsOK)
     {
         logger.Info("WMS接收入库通知成功");
     }
     else
     {
         logger.Warn("WMS接收入库通知失败,重新发起 请求入库B11.2");
     }
 }
Example #5
0
 void PermitOut(object sender, PLCEventArgs e)
 {
     logger.Info("调用出库皮带线");
     if (SpinOut().IsOK)
     {
         RFID.RFIDData data = null;
         My.Work_Vision.DataQueue.TryPeek(out data);
         My.Work_Simulation.Send(new CKX(data, CKX.EnumActionType.出库检测位转移物料至定位台1));
         logger.Info("调用出库皮带线成功");
     }
     else
     {
         logger.Warn("出库皮带线调用失败,重新发起 请求出库B11.0");
     }
 }
Example #6
0
        void ProcessWriteFailure(object sender, PLCEventArgs e)
        {
            var data = My.RFIDs[e.Site].Read();

            if (data == null)
            {
                logger.Warn("{0}:RFID读取失败(加工请求写入失败)", Enum.GetName(typeof(EnumPSite), e.Site));
                return;
            }
            data.SetProcessResult(EnumPResult.Failed);
            My.RFIDs[e.Site].Write(data);
            My.PLC.Set(e.Index, 12);//RFID写入完成
            logger.Info("B{0}.12:RFID写入完成(加工请求写入失败)", e.Index);
            SimulationZD(data, e.Site);
        }
Example #7
0
        void AssembleWriteFailure(object sender, PLCEventArgs e)
        {
            var data = My.RFIDs[e.Site].Read();

            if (data == null)
            {
                logger.Warn("{0}:RFID读取失败(装配台请求写入装配、清洗失败)", Enum.GetName(typeof(EnumPSite), e.Site));
                return;
            }
            if (data.Assemble == EnumAssemble.Wanted)
            {
                data.Assemble = EnumAssemble.Failed;
            }
            if (data.Clean == EnumClean.Wanted)
            {
                data.Clean = EnumClean.Failed;
            }
            My.RFIDs[e.Site].Write(data);
            My.PLC.Set(e.Index, 12);//写入完成
            logger.Info("B{0}.12:RFID写入完成(装配台请求写入装配、清洗失败)", e.Index);
            SimulationZD(data, e.Site);
        }
Example #8
0
        void AlignmentRead(object sender, PLCEventArgs e)
        {
            var data = My.RFIDs[e.Site].Read();

            if (data == null)
            {
                logger.Warn("{0}:RFID读取失败(定位台请求读)", Enum.GetName(typeof(EnumPSite), e.Site));
                return;
            }
            My.PLC.Set(e.Index, 1);//读取成功
            logger.Info("B{0}.1:RFID读取成功(定位台请求读)", e.Index);
            if (data.Assemble == EnumAssemble.Wanted || data.IsRough || data.IsFake)
            {
                My.PLC.Set(e.Index, 4);//非入库料盘
                logger.Info("B{0}.4:非入库料盘(定位台请求读)", e.Index);
                SimulationZD(data, e.Site);
            }
            else
            {
                My.PLC.Set(e.Index, data.Workpiece == EnumWorkpiece.E ? 3 : 2);//入库料盘
                logger.Info("B{0}.{1}:入库料盘(定位台请求读),物料类型{2}", e.Index, data.Workpiece == EnumWorkpiece.E ? 3 : 2, Enum.GetName(typeof(EnumWorkpiece), data.Workpiece));
                SimulationDS(data, e.Site);
            }
        }
Example #9
0
        public void Photograph(object sender, PLCEventArgs e)
        {
            try
            {
                if (!tcpClient.Connected)
                {
                    My.Work_PLC.Photograph -= Photograph;
                    ClientConnectAsync();
                    throw new Exception("出库视觉相机连接失败,正在尝试重连");
                }
                if (DataQueue.Count < 1)
                {
                    logger.Error("出库口无RFID信息记录,无法进行比对");
                    logger.Error("请手动将料盘放回出库口RFID读写位,并使用故障恢复里的<获取RFID信息>与<请求出库>的功能");
                    return;
                }
                byte[] buffer = new byte[16];
                tcpClient.Client.Send(Encoding.UTF8.GetBytes("1"));
                tcpClient.ReceiveTimeout = 10 * 1000;
                tcpClient.Client.Receive(buffer);
                var text = Encoding.UTF8.GetString(buffer);
                My.PLC.Set(e.Index, 1);//拍照完成
                logger.Info("B{0}.1:拍照完成", e.Index);
                logger.Info("Vision数据:{0}|{1}", VisionDict.ContainsKey(text) ? VisionDict[text] : string.Empty, text);
                RFIDData data;
                if (!DataQueue.TryDequeue(out data))
                {
                    throw new Exception("获取RFID数据失败");
                }
                logger.Info(data);
                #region PLC
                switch (data.Workpiece)
                {
                case EnumWorkpiece.A:
                    if (data.IsRough && text == AR)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else if (!data.IsRough && text == AS)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else
                    {
                        My.PLC.Set(e.Index, 3);    //工件不匹配
                        logger.Info("B{0}.3:工件不匹配", e.Index);
                    }
                    break;

                case EnumWorkpiece.B:
                    if (data.IsRough && text == BR)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else if (!data.IsRough && text == BS)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else
                    {
                        My.PLC.Set(e.Index, 3);    //工件不匹配
                        logger.Info("B{0}.3:工件不匹配", e.Index);
                    }
                    break;

                case EnumWorkpiece.C:
                    if (data.IsRough && text == CR)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else if (!data.IsRough && text == CS)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else
                    {
                        My.PLC.Set(e.Index, 3);    //工件不匹配
                        logger.Info("B{0}.3:工件不匹配", e.Index);
                    }
                    break;

                case EnumWorkpiece.D:
                    if (data.IsRough && text == DR)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else if (!data.IsRough && text == DS)
                    {
                        My.PLC.Set(e.Index, 2);    //工件匹配
                        logger.Info("B{0}.2:工件匹配", e.Index);
                    }
                    else
                    {
                        My.PLC.Set(e.Index, 3);    //工件不匹配
                        logger.Info("B{0}.3:工件不匹配", e.Index);
                    }
                    break;

                case EnumWorkpiece.E:
                    My.PLC.Set(e.Index, 2);    //工件匹配
                    logger.Info("B{0}.2:工件匹配", e.Index);
                    break;

                default:
                    My.PLC.Set(e.Index, 3);    //工件不匹配
                    logger.Info("B{0}.3:工件不匹配", e.Index);
                    break;
                }
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error("出库相机拍照失败");
                logger.Error(ex.Message);
            }
        }
Example #10
0
        void ProcessRead(object sender, PLCEventArgs e)
        {
            var data = My.RFIDs[e.Site].Read();

            if (data == null)
            {
                logger.Warn("{0}:RFID读取失败(加工请求读)", Enum.GetName(typeof(EnumPSite), e.Site));
                return;
            }
            My.PLC.Set(e.Index, 1);//读取成功
            logger.Info("B{0}.1:RFID读取成功(加工请求读)", e.Index);
            for (int i = 4; i < 9; i++)
            {
                My.PLC.Clear(e.Index, i);
            }
            if (data.Workpiece == EnumWorkpiece.D && data.IsFake)
            {
                My.PLC.Set(e.Index, 9);//D1设置为B5.9——D半成品
                logger.Info("B{0}.{1}:设置工件类型(加工请求读),物料类型{2}", e.Index, 9, "D半成品");
            }
            else
            {
                My.PLC.Set(e.Index, Work_PLC.WpBitDict[data.Workpiece]);//工件类型
                logger.Info("B{0}.{1}:设置工件类型(加工请求读),物料类型{2}", e.Index, Work_PLC.WpBitDict[data.Workpiece], Enum.GetName(typeof(EnumWorkpiece), data.Workpiece));
            }
            if (data.GetProcessSite() == e.Site)
            {
                #region GCode
                if (false)//关闭G代码下发
                {
                    var dict = GCodeFile.Dict[e.Site];
                    var mt   = My.MachineTools[e.Site];
                    var file = GCodeFile.EnumFile.联调试验程序;
                    if (!data.IsFake)
                    {
                        switch (data.Workpiece)
                        {
                        case EnumWorkpiece.A:
                            file = GCodeFile.EnumFile.加工A料程序;
                            break;

                        case EnumWorkpiece.B:
                            file = GCodeFile.EnumFile.加工B料程序;
                            break;

                        case EnumWorkpiece.C:
                            file = GCodeFile.EnumFile.加工C料程序;
                            break;

                        default:
                            break;
                        }
                    }
                    if (!mt.HNC_NetFileSend(dict[file], "O999"))
                    {
                        throw new ArgumentException("G代码下发失败,请检查后重试!");
                    }
                }
                #endregion
                My.PLC.Set(e.Index, 2);//工件符合当前工位
                logger.Info("B{0}.2:工件符合当前工位(加工请求读)", e.Index);
                SimulationDS(data, e.Site);
            }
            else
            {
                My.PLC.Set(e.Index, 3);//工件不符合当前工位
                logger.Info("B{0}.3:工件不符合当前工位(加工请求读)", e.Index);
                SimulationZD(data, e.Site);
            }
        }