public override void DoWork(PLCMsg msg) { return; CurrMsg = msg; if (CurrMsg.STATUS == 1)//判断挡停放行 { //判断挡停后边专机空闲 var nxtDevice = DeviceBase.GetDevice("E0100201"); if (nxtDevice.CurrMsg?.STATUS == 0) { ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//放行挡停 } } else { } }
public override void DoWork(PLCMsg msg) { CurrMsg = msg; AskPallet_Fujiao(); //判断专机满表启动插针 if (CurrMsg.PALLET_COUNT == 8 && !(CurrMsg.STATUS == 1 || CurrMsg.STATUS == 2 || CurrMsg.STATUS == 3)) { ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = 3, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg)); //启动专机 } if (CurrMsg.STATUS == 1) //判断插针就绪 { //判断其他专机非放行状态 var d2 = DeviceBase.GetDevice("E02202"); if (d2.CurrMsg?.STATUS == 2) { return; } var d3 = DeviceBase.GetDevice("E02203"); if (d3.CurrMsg?.STATUS == 2) { return; } var d4 = DeviceBase.GetDevice("E02204"); if (d4.CurrMsg?.STATUS == 2) { return; } //放行后等10秒再次放行 if (LAST_PASS_TIME.HasValue && (DateTime.Now - LAST_PASS_TIME.Value).Seconds < 10) { return; } LAST_PASS_TIME = DateTime.Now; ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; Task.Run(() => { //System.Threading.Thread.Sleep(5000);//5s后放行 GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//放行专机 }); } else { } }
private static int LastNo = 1;//专机号1,2 = no%2+1 public override void DoWork(PLCMsg msg) { CurrMsg = msg; return; if (CurrMsg.STATUS == 1)//判断挡停放行 { bool canpass = true; if (count == 8) { //判断托盘到位 string strLastNo = "E0210" + LastNo; var lastDevice = DeviceBase.GetDevice(strLastNo); if (lastDevice.CurrMsg?.PALLET_COUNT == 8)//8个托盘到位了 { //发送3 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = "E021", NO = strLastNo, COMMAND_ID = 3, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg)); //启动专机 canpass = true; LastNo++; //换下一个专机 LastNo = LastNo % 2 + 1; count = 0; } else { canpass = false; } } if (canpass) { count++; var ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = (LastNo + 1),//放行命令23 = no + 1 MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//放行挡停 } } else { } }
public override void DoWork(PLCMsg msg) { CurrMsg = msg; if (CurrMsg.STATUS == 1)//TODO:判断专机启用 { //放行后等5秒再次放行 //if (LAST_PASS_TIME.HasValue && (DateTime.Now - LAST_PASS_TIME.Value).Seconds < 3) //{ // return; //} //LAST_PASS_TIME = DateTime.Now; ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = 3, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg)); //启动专机 } else if (CurrMsg.STATUS == 4) //完成,判断后续空闲 { if (LAST_PASS_TIME.HasValue && (DateTime.Now - LAST_PASS_TIME.Value).Seconds < 3) { return; } LAST_PASS_TIME = DateTime.Now; var nxtDevice = DeviceBase.GetDevice("E0100103"); if (nxtDevice.CurrMsg != null && nxtDevice.CurrMsg.STATUS == 0) { ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//放行专机 } } else { } }
protected void AskPallet_Fujiao() { var c1 = DeviceBase.GetDevice("E02201"); var c2 = DeviceBase.GetDevice("E02202"); var c3 = DeviceBase.GetDevice("E02203"); var c4 = DeviceBase.GetDevice("E02204"); var stop = DeviceBase.GetDevice("E00215"); if (CurrFujiaoNo == 1) //当前放行至复校1 { if (FujiaoCount < 8) //尚未放满8个 { if (stop.CurrMsg?.STATUS == 1) //有待放行的表 { if ((DateTime.Now - LastFujiaoPassTime).Seconds < 5) { return; } LastFujiaoPassTime = DateTime.Now; //放行至复校1 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = stop.DEVICE_TYPE, NO = stop.NO, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 FujiaoCount++; Console.WriteLine("放行至复校1 -- " + FujiaoCount); } } else { if (c1.CurrMsg?.PALLET_COUNT == 8)//复校1的8个到位后可切换至复校2 { FujiaoCount = 0; CurrFujiaoNo = 2; } } } if (CurrFujiaoNo == 2) //当前放行至复校2 { if (FujiaoCount < 8) //尚未放满8个 { if (stop.CurrMsg?.STATUS == 1) //有待放行的表 { if ((DateTime.Now - LastFujiaoPassTime).Seconds < 5) { return; } LastFujiaoPassTime = DateTime.Now; //放行至复校2 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = stop.DEVICE_TYPE, NO = stop.NO, COMMAND_ID = 3, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 FujiaoCount++; Console.WriteLine("放行至复校2 -- " + FujiaoCount); } } else { if (c2.CurrMsg?.PALLET_COUNT == 8)//初调2的8个到位后可切换至复校3 { FujiaoCount = 0; CurrFujiaoNo = 3; } } } if (CurrFujiaoNo == 3) //当前放行至复校3 { if (FujiaoCount < 8) //尚未放满8个 { if (stop.CurrMsg?.STATUS == 1) //有待放行的表 { if ((DateTime.Now - LastFujiaoPassTime).Seconds < 5) { return; } LastFujiaoPassTime = DateTime.Now; //放行至复校3 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = stop.DEVICE_TYPE, NO = stop.NO, COMMAND_ID = 4, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 FujiaoCount++; Console.WriteLine("放行至复校3 -- " + FujiaoCount); } } else { if (c3.CurrMsg?.PALLET_COUNT == 8)//初调3的8个到位后可切换至复校4 { FujiaoCount = 0; CurrFujiaoNo = 4; } } } if (CurrFujiaoNo == 4) //当前放行至复校4 { if (FujiaoCount < 8) //尚未放满8个 { if (stop.CurrMsg?.STATUS == 1) //有待放行的表 { if ((DateTime.Now - LastFujiaoPassTime).Seconds < 5) { return; } LastFujiaoPassTime = DateTime.Now; //放行至复校4 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = stop.DEVICE_TYPE, NO = stop.NO, COMMAND_ID = 5, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 FujiaoCount++; Console.WriteLine("放行至复校4 -- " + FujiaoCount); } } else { if (c4.CurrMsg?.PALLET_COUNT == 8)//初调4的8个到位后可切换至复校1 { FujiaoCount = 0; CurrFujiaoNo = 1; } } } }
protected void AskPallet_Chutiao() { //判断专机空闲,且托盘不满8个(包括在途) var c1 = DeviceBase.GetDevice("E02101"); var c2 = DeviceBase.GetDevice("E02102"); var stop = DeviceBase.GetDevice("E00214"); if (CurrChutiaoNo == 1) //当前放行至初调1 { if (ChuTiaoCount < 8) //尚未放满8个 { if (stop.CurrMsg?.STATUS == 1) //有待放行的表 { if ((DateTime.Now - LastChutiaoPassTime).Seconds < 5) { return; } LastChutiaoPassTime = DateTime.Now; //放行至初调1 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = stop.DEVICE_TYPE, NO = stop.NO, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 ChuTiaoCount++; Console.WriteLine("放行至初调1 -- " + ChuTiaoCount); } } else { if (c1.CurrMsg?.PALLET_COUNT == 8)//初调1的8个到位后可切换至初调2 { ChuTiaoCount = 0; CurrChutiaoNo = 2; } } } if (CurrChutiaoNo == 2) //当前放行至初调2 { if (ChuTiaoCount < 8) //尚未放满8个 { if (stop.CurrMsg?.STATUS == 1) //有待放行的表 { if ((DateTime.Now - LastChutiaoPassTime).Seconds < 5) { return; } LastChutiaoPassTime = DateTime.Now; //放行至初调2 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = stop.DEVICE_TYPE, NO = stop.NO, COMMAND_ID = 3, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 ChuTiaoCount++; Console.WriteLine("放行至初调2 -- " + ChuTiaoCount); } } else { if (c2.CurrMsg?.PALLET_COUNT == 8)//初调2的8个到位后可切换至初调1 { ChuTiaoCount = 0; CurrChutiaoNo = 1; } } } }
public override void DoWork(PLCMsg msg) { CurrMsg = msg; if (CurrMsg.STATUS == 4 || CurrMsg.STATUS == 0) //机器人抓完后 { if ((DateTime.Now - LastStatus4).Seconds < 10) //两次状态4之间超过10秒认为机器人抓完 { return; } LastStatus4 = DateTime.Now; var stopBefore = DeviceBase.GetDevice("E00216"); var stopAfter = DeviceBase.GetDevice("E00217"); //判断前面托盘到位 && 判断后边托盘到位 if (stopBefore.CurrMsg?.STATUS == 1 && stopAfter.CurrMsg?.STATUS == 1) { #region 启动机器人 ControlMsg pickMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = flags[i % flags.Count], MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; i++; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(pickMsg)); #endregion #region 放行机器人后挡停 Task.Run(() => { System.Threading.Thread.Sleep(6000);//等5秒机器人放完 ControlMsg ctl_af_Msg = new ControlMsg() { NO = stopAfter.NO, DEVICE_TYPE = stopAfter.DEVICE_TYPE, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctl_af_Msg)); }); #endregion #region 放行机器人前挡停 if (i > 0 && i % flags.Count == 0)//判断抓完6个 { Task.Run(() => { System.Threading.Thread.Sleep(2000);//等2秒机器人抓走 ControlMsg ctl_br_Msg = new ControlMsg() { NO = stopBefore.NO, DEVICE_TYPE = stopBefore.DEVICE_TYPE, COMMAND_ID = 2, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctl_br_Msg)); }); } #endregion } } }
private static int LastNo = 1;//专机号1,2,3,4 = (no % 4) + 1 public override void DoWork(PLCMsg msg) { CurrMsg = msg; return; if (CurrMsg.STATUS == 1)//判断挡停放行 { bool canpass = true; if (count == 8) { //判断托盘到位 string strLastNo = "E0220" + LastNo; var lastDevice = DeviceBase.GetDevice(strLastNo); if (lastDevice.CurrMsg?.PALLET_COUNT == 8)//8个托盘到位了 { //发送3 ControlMsg ctlMsg = new ControlMsg() { DEVICE_TYPE = "E022", NO = strLastNo, COMMAND_ID = 3, MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//启动专机 canpass = true; LastNo++;//换下一个专机 LastNo = LastNo % 4 + 1; count = 0; } else { canpass = false; } } if (canpass) { count++; var ctlMsg = new ControlMsg() { DEVICE_TYPE = msg.DEVICE_TYPE, NO = msg.NO, COMMAND_ID = (LastNo + 1),//放行命令2345 = no + 1 MESSAGE_TYPE = "control", time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//放行挡停 } //int cmdid = 0; ////判断挡停后边专机空闲 //var nxtDevice1 = DeviceBase.GetDevice("E02201"); //var nxtDevice2 = DeviceBase.GetDevice("E02202"); //var nxtDevice3 = DeviceBase.GetDevice("E02203"); //var nxtDevice4 = DeviceBase.GetDevice("E02204"); //if (nxtDevice1.CurrMsg?.PALLET_COUNT < 8) //{ // cmdid = 2; //} //else if (nxtDevice2.CurrMsg?.STATUS < 8) //{ // cmdid = 3; //} //else if (nxtDevice3.CurrMsg?.STATUS < 8) //{ // cmdid = 4; //} //else if (nxtDevice4.CurrMsg?.STATUS < 8) //{ // cmdid = 5; //} //else //{ //} //if (cmdid != 0 && (DateTime.Now - LastCount8).Seconds > 20)//每放8个等20秒 //{ // count++; // if (count % 8 == 0) // LastCount8 = DateTime.Now; // var ctlMsg = new ControlMsg() // { // DEVICE_TYPE = msg.DEVICE_TYPE, // NO = msg.NO, // COMMAND_ID = cmdid, // MESSAGE_TYPE = "control", // time_stamp = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") // }; // GlobalData.MQ.SentMessage(JsonConvert.SerializeObject(ctlMsg));//放行挡停 //} } else { } }