public virtual bool S1F13SendEstablishCommunicationRequest() { try { S1F13 s1f13 = new S1F13(); s1f13.SECSAgentName = scApp.EAPSecsAgentName; s1f13.MDLN = scApp.getEQObjCacheManager().getLine().LINE_ID.Trim(); s1f13.SOFTREV = SCApplication.getMessageString("SYSTEM_VERSION"); S1F14 s1f14 = null; string rtnMsg = string.Empty; SXFY abortSecs = null; SCUtility.secsActionRecordMsg(scApp, false, s1f13); TrxSECS.ReturnCode rtnCode = ISECSControl.sendRecv <S1F14>(bcfApp, s1f13, out s1f14, out abortSecs, out rtnMsg, null); SCUtility.actionRecordMsg(scApp, s1f13.StreamFunction, line.Real_ID, "Establish Communication.", rtnCode.ToString()); if (rtnCode == TrxSECS.ReturnCode.Normal) { SCUtility.secsActionRecordMsg(scApp, true, s1f14); line.EstablishComm = true; return(true); } else { line.EstablishComm = false; logger.Warn("Send Establish Communication[S1F13] Error!"); } } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, " sendS1F13_Establish_Comm", ex.ToString()); } return(false); }
protected virtual Boolean isSend(SXFY sxfy) { Boolean result = false; try { if (sxfy is S6F11) { S6F11 s6f11 = (sxfy as S6F11); if (s6f11.CEID == SECSConst.CEID_Equipment_OFF_LINE || s6f11.CEID == SECSConst.CEID_Control_Status_Local || s6f11.CEID == SECSConst.CEID_Control_Status_Remote) { return(true); } } result = scApp.getEQObjCacheManager().getLine().Host_Control_State == SCAppConstants.LineHostControlState.HostControlState.On_Line_Local || scApp.getEQObjCacheManager().getLine().Host_Control_State == SCAppConstants.LineHostControlState.HostControlState.On_Line_Remote; //if (bcf.Common.BCFUtility.isMatche(sxfy.StreamFunction, "S6F11")) //{ // S6F11 s6f11 = null; // string ceid = (string)sxfy.getField(bcf.Common.BCFUtility.getPropertyName(() => s6f11.CEID)); // if (!eventBLL.isEnableReport(ceid)) // { // return false; // } //} } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "isSendEAP", ex.ToString()); } return(result); }
public virtual bool S1F1SendAreYouThere() { try { S1F1 s1f1 = new S1F1() { SECSAgentName = scApp.EAPSecsAgentName }; S1F2 s1f2 = null; string rtnMsg = string.Empty; SXFY abortSecs = null; //SCUtility.secsActionRecordMsg(scApp, false, s1f1); TrxSECS.ReturnCode rtnCode = ISECSControl.sendRecv <S1F2>(bcfApp, s1f1, out s1f2, out abortSecs, out rtnMsg, null); SCUtility.actionRecordMsg(scApp, s1f1.StreamFunction, line.Real_ID, "Send Are You There To MES.", rtnCode.ToString()); if (rtnCode == TrxSECS.ReturnCode.Normal) { //SCUtility.secsActionRecordMsg(scApp, false, s1f2); return(true); } else if (rtnCode == TrxSECS.ReturnCode.Abort) { SCUtility.secsActionRecordMsg(scApp, false, abortSecs); } } catch (Exception ex) { logger.Error(ex, "Exection:"); } return(false); }
public static void Log(Logger logger, NLog.LogLevel LogLevel, string Class, string Device, SXFY Data, string VehicleID = null, string CST_ID_L = null, string CST_ID_R = null, string LogID = null, string Level = null, string ThreadID = null, string Lot = null, string XID = null, string Transaction = null, [CallerMemberName] string Method = "") { return; //如果被F'Y',Y可以被2整除的話代表是收到的 bool isReceive = Data.getF() % 2 == 0; LogConstants.Type type = isReceive ? LogConstants.Type.Receive : LogConstants.Type.Send; Log(logger, LogLevel, Class, Device, Data: $"[{Data.SystemByte}]{Data.StreamFunction}-{Data.StreamFunctionName}", VehicleID: VehicleID, CST_ID_L: CST_ID_L, CST_ID_R: CST_ID_R, Type: type, LogID: LogID, Level: Level, ThreadID: ThreadID, Lot: Lot, XID: XID, Details: Data.toSECSString(), Method: Method ); }
public virtual bool S2F17SendDateAndTimeRequest() { try { S2F17 s2f17 = new S2F17(); s2f17.SECSAgentName = scApp.EAPSecsAgentName; S2F18 s2f18 = null; string rtnMsg = string.Empty; SXFY abortSecs = null; SCUtility.secsActionRecordMsg(scApp, false, s2f17); TrxSECS.ReturnCode rtnCode = ISECSControl.sendRecv <S2F18>(bcfApp, s2f17, out s2f18, out abortSecs, out rtnMsg, null); SCUtility.actionRecordMsg(scApp, s2f17.StreamFunction, line.Real_ID, "Date Time Request.", rtnCode.ToString()); if (rtnCode == TrxSECS.ReturnCode.Normal) { SCUtility.secsActionRecordMsg(scApp, true, s2f18); string timeStr = s2f18.TIME; DateTime mesDateTime = DateTime.Now; try { mesDateTime = DateTime.ParseExact(timeStr.Trim(), SCAppConstants.TimestampFormat_16, CultureInfo.CurrentCulture); } catch (Exception dtEx) { logger.Error(dtEx, String.Format("Receive Date Time Set Request From MES. Format Error![Date Time:{0}]", timeStr)); } if (!DebugParameter.DisableSyncTime) { SCUtility.updateSystemTime(mesDateTime); } //todo 跟其他設備同步 return(true); } else { logger.Warn("Send Date Time Request[S2F17] Error!"); } } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "sendS2F17_DateTimeReq", ex.ToString()); } return(false); }
protected virtual Boolean isProcess(SXFY sxfy) { Boolean isProcess = false; string streamFunction = sxfy.StreamFunction; if (line.Host_Control_State == SCAppConstants.LineHostControlState.HostControlState.EQ_Off_line) { if (sxfy is S1F17) { isProcess = true; } else if (sxfy is S2F41) { string rcmd = (sxfy as S2F41).RCMD; } else { isProcess = false; } } else { isProcess = true; } if (!isProcess) { S1F0 sxf0 = new S1F0() { SECSAgentName = scApp.EAPSecsAgentName, StreamFunction = sxfy.getAbortFunctionName(), SystemByte = sxfy.SystemByte }; SCUtility.secsActionRecordMsg(scApp, false, sxf0); TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, sxf0); SCUtility.actionRecordMsg(scApp, sxf0.StreamFunction, line.Real_ID, "Reply Abort To MES.", rtnCode.ToString()); } return(isProcess); }
public virtual bool S5F1SendAlarmReport(string alcd, string alid, string altx) { try { S5F1 s5f1 = new S5F1() { SECSAgentName = scApp.EAPSecsAgentName, ALCD = alcd, ALID = alid, ALTX = altx }; S5F2 s5f2 = null; SXFY abortSecs = null; String rtnMsg = string.Empty; if (isSend()) { TrxSECS.ReturnCode rtnCode = ISECSControl.sendRecv <S5F2>(bcfApp, s5f1, out s5f2, out abortSecs, out rtnMsg, null); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(GEMDriver), Device: DEVICE_NAME_MCS, Data: s5f1); LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(GEMDriver), Device: DEVICE_NAME_MCS, Data: s5f2); SCUtility.actionRecordMsg(scApp, s5f1.StreamFunction, line.Real_ID, "Send Alarm Report.", rtnCode.ToString()); if (rtnCode != TrxSECS.ReturnCode.Normal) { logger.Warn("Send Alarm Report[S5F1] Error![rtnCode={0}]", rtnCode); return(false); } } return(true); } catch (Exception ex) { logger.Error(ex, "Exception:"); return(false); } }