/// <summary> /// 上工序校验 /// </summary> /// <param name="session"></param> /// <param name="data"></param> /// <returns></returns> public static bool CheckRoute(TransmitData data, string deviceID, bool first, string Result) { try { //上工序校验 DM_SFCInterface DM_SFC = new DM_SFCInterface(); DataTable dt = DM_SFC.SFC_DM_CheckRoute(data.SN, string.IsNullOrWhiteSpace(deviceID) ? data.EquipmentID : deviceID, first ? data.WO : "", Result);//FAIL string CheckStatus = dt.Rows[0][0].ToString().ToString(); string ReturnMsg = dt.Rows[0][1].ToString().ToString(); if (CheckStatus == "1") // 成功 { data.CheckResult = CheckResult.OK.ToString(); return(true); } else { data.CheckResult = CheckResult.ERROR.ToString(); data.Description = ReturnMsg; return(false); } } catch (Exception e) { data.CheckResult = CheckResult.ERROR.ToString(); data.Description = e.Message; return(false); } }
private void btnFail_Click(object sender, EventArgs e) { DialogResult dr = DlgBox.Show("确定检验结果为FAIL吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (dr == DialogResult.Cancel) { return; } else { SetBtnEnable(false); try { if (lblHandle.Text == PFCheck) { SetPlcStatus(GlobalData.MonitorTagAdd, 6); log.Info("Fail" + PFCheckFAIL + Msg); } else if (lblHandle.Text == VICheck) { SetPlcStatus(GlobalData.MonitorTagAdd, 8); log.Info("Fail" + VICheckFAIL + Msg); } DataTable dt = SFCInterface.SFC_DM_CheckRoute(plcSN, GlobalData.EquipmentNO, "", "FAIL");//FAIL CheckStatus = dt.Rows[0][0].ToString().ToString(); ReturnMsg = dt.Rows[0][1].ToString().ToString(); Msg = CheckStatus + ":" + ReturnMsg; if (CheckStatus == "1") //成功 { SetPlcStatus(GlobalData.MonitorTagAdd, 10); SendMsgToPlc(int.Parse(GlobalData.MsgDB), int.Parse(GlobalData.MsgStart), "Pass" + STATIONFAIL + Msg); log.Info("Pass" + STATIONPASS + Msg); } else { SendMsgToPlc(int.Parse(GlobalData.MsgDB), int.Parse(GlobalData.MsgStart), "Fail " + STATIONFAIL + Msg); log.Info("Fail" + STATIONFAIL + Msg); } } catch (Exception ex) { log.Info("Func error " + STATIONFAIL + ex.Message); } } }
/// <summary> /// 上瓶机位业务逻辑处理:3-称重校验;4-是否继续上瓶判断 /// </summary> /// <param name="sN"></param> private void SpDeviceProcess(MesSession _session, TransmitData _transData) { //3-称重校验 bool weightIsOK = CheckWeight(_transData.SN, _transData.Items["aWeight"]); if (weightIsOK) { _transData.CheckResult = CheckResult.OK.ToString(); //4-是否继续上瓶判断 bool isContinue = IsContinue(_transData.WO); _transData.Items.Add("continue", isContinue.ToString()); //5-处理完成,过站 DM_SFCInterface DM_SFC = new DM_SFCInterface(); DataTable dt = DM_SFC.SFC_DM_CheckRoute(_transData.SN, _transData.EquipmentID, _transData.WO, "PASS");//FAIL string CheckStatus = dt.Rows[0][0].ToString().ToString(); string ReturnMsg = dt.Rows[0][1].ToString().ToString(); if (CheckStatus == "1") //过站成功,开始扣料 { DM_Bucklematerial bucklematerial = new DM_Bucklematerial(); bucklematerial.BuckleMaterialIn(_transData.SN, "ASM", _transData.EquipmentID + "-01"); } else { _transData.CheckResult = "ERROR"; _transData.Description = ReturnMsg; } } else { _transData.CheckResult = "NG"; _transData.Description = "error---query fail,please check SN."; } string sendTransData = JsonHelper.SerializeObject(_transData); _session.Send(sendTransData); _session.Logger.Info(_transData.CheckResult + "---" + _transData.Description); }
private void Plc_DataChange(object sender, DataChangeEventArgs e) { lock (sync) { string ht = e._stateType; ushort hv = e._stateValue; if (ht == "HandleType") { #region OP010-1 switch (hv) { case 0: OnDisplayMesSn("", 0, 0); OnDisplayMesSn("", 0, 1); OnDisplayMesSn("", 0, 2); OnDisplayLog(""); ResetWarningChart(0, true); log.Info(hv + INITADDRESS); break; case 1: log.Info(hv + CLEARSUCCESS); ResetWarningChart(1, true); // 清洗完毕 ResetWarningChart(2, true); // 读取信号完毕 mesSN = printSNBarcode(); OnDisplayMesSn(mesSN, 1, 1); //清洗完毕,告诉plc消息已收到 SetPlcStatus(GlobalData.MonitorTagAdd, 2); break; case 2: log.Info(hv + READSUCCESS); SendMsgToPlc(int.Parse(GlobalData.MsgDB), 0, hv + READSUCCESS); break; case 3: ResetWarningChart(5, true); log.Info(hv + PRINTSUCCESS + "SN<" + mesSN + ">"); //扫码完成,MES读取条码 byte[] bytes = plc.ReadBytes(DataType.DataBlock, int.Parse(GlobalData.MsgDB), 0, 256); plcSN = Utility.ConvertToString(bytes); ResetWarningChart(6, true); //扫码完成,告诉plc消息已收到 SetPlcStatus(GlobalData.MonitorTagAdd, 4); break; case 4: log.Info(hv + READSUCCESS + "SN<" + plcSN + ">."); if (mesSN == plcSN) { OnDisplayMesSn(plcSN, 1, 2); OnDisplayMesSn("", 1, 0); OnDisplayLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm") + " 条码校验正确 "); SetPlcStatus(GlobalData.MonitorTagAdd, 5); //校验成功 SendMsgToPlc(int.Parse(GlobalData.MsgDB), 0, hv + SNCHECKSUCCESS); } else { OnDisplayMesSn(plcSN, 2, 2); OnDisplayMesSn("", 2, 0); OnDisplayLog(DateTime.Now.ToString("yyyy/MM/dd HH:mm") + " 条码校验错误:MES推送条码与现场PLC扫描条码不一致 "); ResetWarningChart(7, false); SetPlcStatus(GlobalData.MonitorTagAdd, 6); SendMsgToPlc(int.Parse(GlobalData.MsgDB), 0, hv + SNCHECKFAIL); } break; case 5: log.Info(hv + SNCHECKSUCCESS); ResetWarningChart(7, true); try { DataTable dt = SFCInterface.SFC_DM_CheckRoute(plcSN, GlobalData.EquipmentNO, GlobalData.WorkOrder, "PASS"); //FAIL CheckStatus = dt.Rows[0][0].ToString().ToString(); ReturnMsg = dt.Rows[0][1].ToString().ToString(); Msg = CheckStatus + ":" + ReturnMsg; if (CheckStatus == "1") //成功 { SetPlcStatus(GlobalData.MonitorTagAdd, 7); SendMsgToPlc(int.Parse(GlobalData.MsgDB), 0, hv + STATIONPASS + Msg); log.Info(hv + STATIONPASS + Msg); } else { SetPlcStatus(GlobalData.MonitorTagAdd, 8); SendMsgToPlc(int.Parse(GlobalData.MsgDB), 0, hv + STATIONFAIL + Msg); log.Info(hv + STATIONFAIL + Msg); } // 扣料 BuckleMaterialIn(hv, plcSN, GlobalData.EquipmentNO, GlobalData.PalCode, ""); } catch (Exception ex) { log.Info(hv + SNCHECKFAIL + ex.Message); } break; case 6: log.Info(hv + SNCHECKFAIL); ResetWarningChart(7, false); break; case 7: log.Info(hv + STATIONPASS); ResetWarningChart(8, true); break; case 8: log.Info(hv + STATIONFAIL); ResetWarningChart(8, false); break; default: log.Info(hv + UNKNOWNVALEU); break; } #endregion } } }