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 void S2F31ReceiveDateTimeSetReq(object sender, SECSEventArgs e) { try { S2F31 s2f31 = ((S2F31)e.secsHandler.Parse <S2F31>(e)); SCUtility.secsActionRecordMsg(scApp, true, s2f31); SCUtility.actionRecordMsg(scApp, s2f31.StreamFunction, line.Real_ID, "Receive Date Time Set Request From MES.", ""); if (!isProcess(s2f31)) { return; } S2F32 s2f32 = new S2F32(); s2f32.SECSAgentName = scApp.EAPSecsAgentName; s2f32.SystemByte = s2f31.SystemByte; s2f32.TIACK = SECSConst.TIACK_Accepted; string timeStr = s2f31.TIME; DateTime mesDateTime = DateTime.Now; try { mesDateTime = DateTime.ParseExact(timeStr.Trim(), SCAppConstants.TimestampFormat_16, CultureInfo.CurrentCulture); } catch (Exception dtEx) { s2f32.TIACK = SECSConst.TIACK_Error_not_done; } SCUtility.secsActionRecordMsg(scApp, false, s2f32); ISECSControl.replySECS(bcfApp, s2f32); if (!DebugParameter.DisableSyncTime) { SCUtility.updateSystemTime(mesDateTime); } //TODO 與設備同步 } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S2F31_Receive_Date_Time_Set_Req", ex.ToString()); } }