Example #1
0
 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);
 }
Example #2
0
        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);
        }
Example #3
0
 protected virtual void S1F1ReceiveAreYouThere(object sender, SECSEventArgs e)
 {
     try
     {
         S1F1 s1f1 = ((S1F1)e.secsHandler.Parse <S1F1>(e));
         SCUtility.secsActionRecordMsg(scApp, true, s1f1);
         SCUtility.actionRecordMsg(scApp, s1f1.StreamFunction, line.Real_ID,
                                   "Receive Are You There From MES.", "");
         if (!isProcess(s1f1))
         {
             return;
         }
         S1F2 s1f2 = new S1F2()
         {
             SECSAgentName = scApp.EAPSecsAgentName,
             SystemByte    = s1f1.SystemByte,
             MDLN          = bcfApp.BC_ID,
             SOFTREV       = SCApplication.getMessageString("SYSTEM_VERSION")
         };
         SCUtility.secsActionRecordMsg(scApp, false, s1f2);
         TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s1f2);
         SCUtility.actionRecordMsg(scApp, s1f1.StreamFunction, line.Real_ID,
                                   "Reply Are You There To MES.", rtnCode.ToString());
         if (rtnCode != TrxSECS.ReturnCode.Normal)
         {
             logger.Warn("Reply EAP S1F2 Error:{0}", rtnCode);
         }
     }
     catch (Exception ex)
     {
         logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}",
                      line.LINE_ID, "S1F1_Receive_AreYouThere", ex.ToString());
     }
 }
Example #4
0
        protected virtual void S2F15ReceiveNewEquiptment(object sender, SECSEventArgs e)
        {
            try
            {
                S2F15 s2f15 = ((S2F15)e.secsHandler.Parse <S2F15>(e));
                SCUtility.secsActionRecordMsg(scApp, true, s2f15);
                SCUtility.actionRecordMsg(scApp, s2f15.StreamFunction, line.Real_ID,
                                          "Receive New EQPT Constant Data From MES.", "");
                if (!isProcess(s2f15))
                {
                    return;
                }

                S2F16 s2f16 = new S2F16();
                s2f16.SECSAgentName = scApp.EAPSecsAgentName;
                s2f16.SystemByte    = s2f15.SystemByte;
                s2f16.EAC           = "0";

                SCUtility.secsActionRecordMsg(scApp, false, s2f16);
                TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s2f16);
                SCUtility.actionRecordMsg(scApp, s2f16.StreamFunction, line.Real_ID,
                                          "Reply OK To MES.", rtnCode.ToString());
            }
            catch (Exception ex)
            {
                logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}",
                             line.LINE_ID, "S2F15_Receive_New_EQConstants", ex.ToString());
            }
        }
        protected virtual void S1F13ReceiveEstablishCommunicationRequest(object sender, SECSEventArgs e)
        {
            try
            {
                S1F13_Empty s1f13 = ((S1F13_Empty)e.secsHandler.Parse<S1F13_Empty>(e));
                SCUtility.secsActionRecordMsg(scApp, true, s1f13);
                SCUtility.actionRecordMsg(scApp, s1f13.StreamFunction, line.Real_ID,
                        "Receive Establish Communication From MES.", "");
                //if (!isProcessEAP(s1f13)) { return; }
                S1F14 s1f14 = new S1F14();
                s1f14.SECSAgentName = scApp.EAPSecsAgentName;
                s1f14.SystemByte = s1f13.SystemByte;
                s1f14.COMMACK = "0";
                s1f14.VERSION_INFO = new string[2]
                { "OHS",
                  SCAppConstants.getMainFormVersion("") };

                SCUtility.secsActionRecordMsg(scApp, false, s1f14);
                TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s1f14);
                SCUtility.actionRecordMsg(scApp, s1f13.StreamFunction, line.Real_ID,
                        "Reply Establish Communication To MES.", rtnCode.ToString());
                if (rtnCode != TrxSECS.ReturnCode.Normal)
                {
                    logger.Warn("Reply EAP S1F14 Error:{0}", rtnCode);
                }
                logger.Debug("s1f13Receive ok!");
                line.EstablishComm = true;
            }
            catch (Exception ex)
            {
                logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}",
                    line.LINE_ID, "s1f13_Receive_EstablishCommunication", ex.ToString());
            }
        }
Example #6
0
 protected virtual void S1F15OffLineRequest(object sender, SECSEventArgs e)
 {
     try
     {
         S1F15 s1f15 = ((S1F15)e.secsHandler.Parse <S1F15>(e));
         SCUtility.secsActionRecordMsg(scApp, true, s1f15);
         SCUtility.actionRecordMsg(scApp, s1f15.StreamFunction, line.Real_ID,
                                   "Receive Establish Communication From MES.", "");
         //if (!isProcessEAP(s1f13)) { return; }
         S1F16 s1f16 = new S1F16();
         s1f16.SECSAgentName = scApp.EAPSecsAgentName;
         s1f16.SystemByte    = s1f15.SystemByte;
         s1f16.OFLACK        = "0";
         SCUtility.secsActionRecordMsg(scApp, false, s1f16);
         TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s1f16);
         SCUtility.actionRecordMsg(scApp, s1f15.StreamFunction, line.Real_ID,
                                   "Reply Establish Communication To MES.", rtnCode.ToString());
         if (rtnCode != TrxSECS.ReturnCode.Normal)
         {
             logger.Warn("Reply EAP S1F16 Error:{0}", rtnCode);
         }
     }
     catch (Exception ex)
     {
         logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}",
                      line.LINE_ID, nameof(S1F15OffLineRequest), ex.ToString());
     }
 }
Example #7
0
        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);
        }
Example #8
0
        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());
            }
        }
Example #9
0
        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);
        }
Example #10
0
 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);
     }
 }