/// <summary> /// 检验opc连接 /// </summary> /// <returns></returns> public bool CheckConnection() { //包装机异型烟链板机(合包)plc连接状态 int flag1 = SpyBiaozhiGroup.ReadD(0).CastTo <int>(-1);//读取标志 if (flag1 == -1) { return(false); } else { return(true); } }
public void checkConnection() { int flag = SpyBiaozhiGroup.ReadD(0).CastTo <int>(-1); if (flag != -1) { updateListBox("连接服务器成功......"); writeLog.Write(" 连接服务器成功......"); updateControlEnable(false, button10); strat = true; isInit = true; AutoFinishTask(); } else { updateListBox("连接服务器失败,请检查网络."); writeLog.Write(" 连接服务器失败,请检查网络."); } }
/// <summary> ///特异形烟1线 /// </summary> void sendSSTask1() { try { issendone = true; int flag = SpyBiaozhiGroup.ReadD(1).CastTo <int>(-1);//发送数据前读标志位 writeLog.Write("1线特异形烟发送数据前读标志位:" + flag); if (flag == 0) { string OutStr = ""; object[] datas = UnPokeService.GetSpecialSmokeData(10, "1", out listSS1B, out OutStr);//获取可发送任务 if (int.Parse(datas[0].ToString()) == 0) { updateListBox("1线特异形烟分拣数据发送完毕"); return; } writeLog.Write("1线特异形烟分拣线:" + OutStr); updateListBox("1线特异形烟分拣线:" + OutStr); SpecialSmokeGroup1.SyncWrite(datas); } else { writeLog.Write("1线特异形烟标志位读取到异常:" + flag); updateListBox("1线特异形烟标志位读取到异常:" + flag); } } catch (Exception ex) { writeLog.Write(ex.Message); updateListBox(ex.Message); Thread.Sleep(10000); if (ex.InnerException != null && ex.InnerException.Message != null) { writeLog.Write(ex.InnerException.Message); updateListBox(ex.InnerException.Message); } sendSSTask1();//异常后重新发送 } }
/// <summary> /// 写入异型烟链板机(合包)任务发送区DB块的内容 /// </summary> /// <returns></returns> public StringBuilder SendOnlyTask(object[] datas, StringBuilder OutStr) { StringBuilder sb = new StringBuilder(); IsSendOn = true; int flag = SpyBiaozhiGroup.ReadD(0).CastTo <int>(-1); WriteLog.GetLog().Write("烟仓烟柜发送数据前读标志位:" + flag + flag); if (flag == 0) { if (int.Parse(datas[0].ToString()) == 0) { sb.AppendLine("烟仓烟柜分拣数据发送完毕"); return(sb); } //WriteLog.GetLog().Write("烟仓烟柜分拣线:" + OutStr); sb.AppendLine("烟仓烟柜分拣线:" + OutStr); OnlyTaskGroup.SyncWrite(datas); } IsSendOn = false; return(sb); }
public void checkConnection() { int flag = SpyBiaozhiGroup.ReadD(0).CastTo <int>(-1); if (flag == -1) { updateListBox("连接服务器失败,请检查网络."); writeLog.Write(" 连接服务器失败,请检查网络."); } else { updateListBox("连接服务器成功......"); writeLog.Write(" 连接服务器成功......"); SpyBiaozhiGroup.Write(2, 0); SpyBiaozhiGroup.Write(0, 0); SpyBiaozhiGroup.Write(2, 1); SpyBiaozhiGroup.Write(0, 1); SpyBiaozhiGroup.Write(2, 2); SpyBiaozhiGroup.Write(0, 2); updateControlEnable(false, button10); isInit = true; } }
/// <summary> /// 一组交互 /// </summary> void sendOnlyTask() { try { issendone = true; int flag = SpyBiaozhiGroup.ReadD(0).CastTo <int>(-1); writeLog.Write("烟仓烟柜发送数据前读标志位:" + flag); if (flag == 0) { #region //int pcgm = 4; //while (!UnPokeService.CheckExistPreSendTask("1", 1, 12) && UnPokeService.CheckExistCanSendPackeMachine("1", 1)) //{ // decimal sortnum, xyqty; // for (int i = 1; i <= 8; i++) // { // try // { // sortnum = 0; // xyqty = 0; // } // catch // { // sortnum = 0; // xyqty = 0; // } // if (!UnPokeService.CheckExistTaskNo(sortnum)) // { // xyqty = 0; // } // sortNumList.Add(sortnum); // zqNumList.Add(xyqty); // } // decimal DISPATCHESIZE = 0; // pcgm = UnPokeService.GetSendPackageMachineYC(1, sortNumList, zqNumList, out DISPATCHESIZE);//获取包装机 // if (packagemachine > 0) // { // UnPokeService.UpdateSendtasknumByPM(pcgm, (int)DISPATCHESIZE);//计算可发送任务 // } // if (pcgm - 1 > 0) // { // pcgm -= 1; // } // else // { // pcgm = 4; // } // Thread.Sleep(100); //} #endregion string OutStr = ""; object[] datas = UnPokeService.getAllLineTask(10, out listOnly, out OutStr);//获取可发送任务 if (int.Parse(datas[0].ToString()) == 0) { updateListBox("烟仓烟柜分拣数据发送完毕"); return; } writeLog.Write("烟仓烟柜分拣线:" + OutStr); updateListBox("烟仓烟柜分拣线:" + OutStr); OnlyTaskGorup.SyncWrite(datas); } } catch (Exception ex) { writeLog.Write(ex.Message); updateListBox(ex.Message); Thread.Sleep(10000); if (ex.InnerException != null && ex.InnerException.Message != null) { writeLog.Write(ex.InnerException.Message); updateListBox(ex.InnerException.Message); } sendOnlyTask();//异常后重新发送 } }
/// <summary> /// 任务交互 /// </summary> void sendOnlyTask1() { try { issendone = true; List <decimal> sortNumList = new List <decimal>(); //当前任务号集合 List <decimal> xyNumList = new List <decimal>(); //当前吸烟数量集合 int flag = SpyBiaozhiGroup.ReadD(0).CastTo <int>(-1); writeLog.Write(ListLineNum[0] + "线烟仓发送数据前读标志位:" + flag); if (flag == 0) { while (!UnPokeService.CheckExistCanSendTask(12, ListLineNum[0]) && UnPokeService.CheckExistCanSendTask(10, ListLineNum[0])) { sortNumList.Clear(); xyNumList.Clear(); decimal sortNum, xyNum; decimal packagemachine = 0; if (SendWay == 2) { for (int i = ListPackge[0]; i <= ListPackge[1]; i++) { try { if (UnPokeService.checkExist(i, ListLineNum[0])) { sortNum = listPM[i - 1].ReadD(2).CastTo <decimal>(-1); //包装机读取出来的任务号 xyNum = listPM[i - 1].ReadD(3).CastTo <decimal>(-1); //包装机读取出来的数量 } else { sortNum = 0; xyNum = 0; } } catch { sortNum = 0; //读取出错的情况下 默认为0 xyNum = 0; } writeLog.Write(ListLineNum[0] + "线plc地址:S7:[PackageMachine" + i + "]DB1,D506" + " ,包装机:" + i + "号, 包装机读取任务号:" + sortNum + " ,包装机读取抓取数量:" + xyNum); updateListBox(ListLineNum[0] + "线plc地址:S7:[PackageMachine" + i + "]DB1,D506" + " ,包装机:" + i + " 号,包装机读取任务号:" + sortNum + ", 包装机读取抓取数量:" + xyNum); sortNumList.Add(sortNum); xyNumList.Add(xyNum); } } else { for (int i = 0; i < 2; i++) { sortNumList.Add(0); xyNumList.Add(0); } } // decimal DISPATCHESIZE = 0; packagemachine = UnPokeService.GetSendPackageMachine_New(sortNumList, xyNumList, SendWay, ListLineNum[0]); if (packagemachine > 0) { UnPokeService.UpdateTaskByPackMachine(packagemachine); } Thread.Sleep(100); } string OutStr = ""; object[] datas = UnPokeService.getOneDateBaseTask(12, ListLineNum[0], out OutStr);//获取可发送任务 if (int.Parse(datas[0].ToString()) == 0) { updateListBox(ListLineNum[0] + "线烟仓烟柜分拣数据发送完毕"); return; } writeLog.Write(ListLineNum[0] + "线烟仓烟柜分拣线:" + OutStr); updateListBox(ListLineNum[0] + "线烟仓烟柜分拣线:" + OutStr); OnlyTaskGorup1.SyncWrite(datas); } } catch (Exception ex) { writeLog.Write(ex.Message); updateListBox(ex.Message); Thread.Sleep(10000); if (ex.InnerException != null && ex.InnerException.Message != null) { writeLog.Write(ex.InnerException.Message); updateListBox(ex.InnerException.Message); } sendOnlyTask1();//异常后重新发送 } issendone = false; }