Example #1
0
        public string onMainAlarm(string mAlarmCode, params object[] args)
        {
            MainAlarm mainAlarm = mainAlarmDao.getMainAlarmByCode(mAlarmCode);
            bool      isAlarm   = false;
            string    msg       = string.Empty;

            try
            {
                if (mainAlarm != null)
                {
                    isAlarm = mainAlarm.CODE.StartsWith("A");
                    msg     = string.Format(mainAlarm.DESCRIPTION, args);
                    if (isAlarm)
                    {
                        msg = string.Format("[{0}]{2}", mainAlarm.CODE, Environment.NewLine, msg);
                        BCFApplication.onErrorMsg(msg);
                    }
                    else
                    {
                        msg = string.Format("[{0}]{2}", mainAlarm.CODE, Environment.NewLine, msg);
                        BCFApplication.onWarningMsg(msg);
                    }
                }
                else
                {
                    logger.Warn(string.Format("LFC alarm/warm happen, but no defin remark code:[{0}] !!!", mAlarmCode));
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
            }
            return(msg);
        }
 public void doorClosedChange(object sender, PropertyChangedEventArgs e)
 {
     try
     {
         ANODE node = sender as ANODE;
         if (sender == null)
         {
             return;
         }
         if (!node.DoorClosed)
         {
             if (!node.SafetyCheckComplete)
             {
                 BCFApplication.onWarningMsg($"OHCV:[{node.NODE_ID}] door has been open without authorization.");
                 //對CV所在路段的OHT下pause Todo by Kevin
                 scApp.RoadControlService.ProcessOHCVAbnormallyScenario(node);
                 //上報Alarm給MCS Todo by Kevin
                 foreach (var ohcv in node.getSubEqptList())
                 {
                     if (!ohcv.DoorClosed)
                     {
                         scApp.LineService.ProcessAlarmReport(
                             ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "",
                             SCAppConstants.SystemAlarmCode.OHCV_Issue.CVDoorAbnormallyOpen,
                             ProtocolFormat.OHTMessage.ErrorStatus.ErrSet);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception:");
     }
 }
Example #3
0
        public ValueWrite getValueWriteHandshake(BCFApplication bcfApp, string eqObjIDCate, string eq_id)
        {
            ValueWrite vw = null;

            vw = bcfApp.getWriteValueEvent(eqObjIDCate, eq_id, HandshakePropName);
            return(vw);
        }
Example #4
0
        public virtual void Read(BCFApplication bcfApp, string eqObjIDCate, string eq_id)
        {
            List <ValueRead> listVR = new List <ValueRead>();

            foreach (FieldInfo info in fieldInfos)
            {
                ValueRead  vr      = null;
                PLCElement element = getPLCElementAttr(info);
                if (bcfApp.tryGetReadValueEventstring(eqObjIDCate, EQ_ID, element.ValueName, out vr))
                {
                    if (info.FieldType == typeof(Int32))
                    {
                        info.SetValue(this, Convert.ToInt32(vr.getText()));
                    }
                    else
                    {
                        info.SetValue(this, vr.getText());
                    }
                    listVR.Add(vr);
                }
                else
                {
                }
            }
            if (listVR.Count > 0)
            {
                BCFUtility.writeEquipmentLog(eq_id, listVR);
            }
        }
Example #5
0
 public SubChargerValueDefMapAction()
     : base()
 {
     scApp  = SCApplication.getInstance();
     bcfApp = scApp.getBCFApplication();
     line   = scApp.getEQObjCacheManager().getLine();
 }
        private void cancelSafetyCheckRequest()
        {
            if (scApp.getEQObjCacheManager().getLine().ServiceMode != SCAppConstants.AppServiceMode.Active)
            {
                return;
            }

            if (!node.DoorClosed)//檢查安全門是不是關閉的
            {
                BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request cancel to OHTC,but door is open now.");
                return;
            }
            if (!node.Is_Alive)//檢查Alive有沒有變化
            {
                BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request cancel to OHTC,but OHCV alive is not changing.");
                return;
            }
            if (node.SafetyCheckComplete)//確定是否有通知過其它門,現在是可以開啟的
            {
                return;
            }
            //enable 該CV所在路段 Todo by Kevin
            scApp.RoadControlService.doEnableDisableSegment
                (eqpt.SegmentLocation, E_PORT_STATUS.InService, ASEGMENT.DisableType.Safety, Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI);
        }
Example #7
0
        private void Write(BCFApplication bcfApp, string eqObjIDCate, string eq_id, out ValueWrite vw_handshake)
        {
            vw_handshake = null;
            EQ_ID        = eq_id;
            List <ValueWrite> listVW = new List <ValueWrite>();

            foreach (FieldInfo info in fieldInfos)
            {
                PLCElement element = getPLCElementAttr(info);

                string   value       = string.Empty;
                UInt16[] ivalueArray = null;
                object   valueObj    = info.GetValue(this);
                if (valueObj is Enum)
                {
                    value = ((int)valueObj).ToString();
                }
                else if (valueObj is bool)
                {
                    value = ((bool)valueObj) ? "1" : "0";
                }
                else if (valueObj is UInt16[])
                {
                    ivalueArray = valueObj as UInt16[];
                }
                else
                {
                    object obj = info.GetValue(this);
                    if (obj != null)
                    {
                        value = info.GetValue(this).ToString();
                    }
                }

                ValueWrite vw = null;
                vw = bcfApp.getWriteValueEvent(eqObjIDCate, eq_id, element.ValueName);
                if (valueObj is UInt16[])
                {
                    vw.setWriteValue(ivalueArray);
                }
                else
                {
                    vw.setWriteValue(value);
                }
                if (element.IsHandshakeProp ||
                    element.IsIndexProp)
                {
                    vw_handshake = vw;
                }
                else
                {
                    ISMControl.writeDeviceBlock(bcfApp, vw);
                }
                listVW.Add(vw);
            }
            if (listVW.Count > 0)
            {
                BCFUtility.writeEquipmentLog(eq_id, listVW);
            }
        }
 public void aliveChange(object sender, PropertyChangedEventArgs e)
 {
     try
     {
         ANODE node = sender as ANODE;
         if (sender == null)
         {
             return;
         }
         if (!node.Is_Alive)
         {
             BCFApplication.onWarningMsg($"OHCV:[{node.NODE_ID}] alive is not changing.");
             //對CV所在路段的OHT下pause Todo by Kevin
             scApp.RoadControlService.ProcessOHCVAbnormallyScenario(node);
             //上報Alarm給MCS Todo by Kevin
             foreach (var ohcv in node.getSubEqptList())
             {
                 if (!ohcv.Is_Eq_Alive)
                 {
                     scApp.LineService.ProcessAlarmReport(
                         ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "",
                         SCAppConstants.SystemAlarmCode.OHCV_Issue.CVOfAliveSignalAbnormal,
                         ProtocolFormat.OHTMessage.ErrorStatus.ErrSet);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception:");
     }
 }
 public void doWork(string workKey, BackgroundWorkItem item)
 {
     try
     {
         using (TransactionScope tx = SCUtility.getTransactionScope())
         {
             bool          can_block_pass = true;
             bool          can_hid_pass   = true;
             bool          isSuccess      = false;
             SCApplication scApp          = SCApplication.getInstance();
             //BCFApplication bcfApp, AVEHICLE eqpt, EventType eventType, int seqNum, string req_block_id, string req_hid_secid
             //Node node = item.Param[0] as Node;
             BCFApplication bcfApp        = item.Param[0] as BCFApplication;
             AVEHICLE       eqpt          = item.Param[1] as AVEHICLE;
             EventType      eventType     = (EventType)item.Param[2];
             int            seqNum        = (int)item.Param[3];
             string         req_block_id  = item.Param[4] as string;
             string         req_hid_secid = item.Param[5] as string;
             can_block_pass = scApp.VehicleService.ProcessBlockReqNewNew(bcfApp, eqpt, req_block_id);
             isSuccess      = scApp.VehicleService.replyTranEventReport(bcfApp, eventType, eqpt, seqNum, canBlockPass: can_block_pass, canHIDPass: can_hid_pass);
             if (isSuccess)
             {
                 tx.Complete();
             }
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
 }
Example #10
0
 internal string getIPAddress(BCFApplication bcfApp)
 {
     if (SCUtility.isEmpty(TcpIpAgentName))
     {
         return(string.Empty);
     }
     return(ITcpIpControl.getRemoteIPAddress(bcfApp, TcpIpAgentName));
 }
Example #11
0
 internal System.Net.IPEndPoint getIPEndPoint(BCFApplication bcfApp)
 {
     if (SCUtility.isEmpty(TcpIpAgentName))
     {
         return(null);
     }
     return(ITcpIpControl.RemoteEndPoint(bcfApp, TcpIpAgentName));
 }
Example #12
0
        public bool IsCommunication(BCFApplication bcfApp)
        {
            bool      is_communication = false;
            Stopwatch fromLastCommTime = ITcpIpControl.StopWatch_FromTheLastCommTime(bcfApp, TcpIpAgentName);

            is_communication = fromLastCommTime.IsRunning ?
                               fromLastCommTime.ElapsedMilliseconds < CommunicationInterval_ms : false;
            return(is_communication);
        }
Example #13
0
        public bool resetHandshake(BCFApplication bcfApp, string eqObjIDCate, string eq_id)
        {
            ValueWrite        handshake_vw = getValueWriteHandshake(bcfApp, eqObjIDCate, eq_id);
            List <ValueWrite> vws          = new List <ValueWrite>(); //A0.01

            handshake_vw.initWriteValue();
            vws.Add(handshake_vw);                         //A0.01
            BCFUtility.writeEquipmentLog(eq_id, vws);      //A0.01
            return(ISMControl.writeDeviceBlock(bcfApp, handshake_vw));
        }
Example #14
0
        public virtual void Write(BCFApplication bcfApp, string eqObjIDCate, string eq_id)
        {
            ValueWrite ve_handshake = null;

            Write(bcfApp, eqObjIDCate, eq_id, out ve_handshake);
            if (ve_handshake != null)
            {
                SpinWait.SpinUntil(() => false, 500);
                ISMControl.writeDeviceBlock(bcfApp, ve_handshake);
            }
        }
Example #15
0
 private void connectionCheck(AVEHICLE vh)
 {
     if (!vh.isTcpIpConnect)
     {
         vh.isTcpIpConnect = true;
         BCFApplication.onWarningMsg($"vh:{vh.VEHICLE_ID} Force change connection status to connection !");
         LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(EQTcpIpMapAction), Device: "AGVC",
                       Data: "Force change connection status to connection !",
                       VehicleID: vh.VEHICLE_ID,
                       CarrierID: vh.CST_ID);
     }
 }
 public new void Read(BCFApplication bcfApp, string eqObjIDCate, string eq_id, int item_count)
 {
     for (int i = 1; i <= item_count; i++)
     {
         CSTInterfaceDetail interfaceDetail = new CSTInterfaceDetail();
         interfaceDetail.LogIndex = $"Recode{nameof(VehicleCSTInterface)}";
         interfaceDetail.EQ_ID    = this.EQ_ID;
         interfaceDetail.Read(bcfApp, eqObjIDCate, eq_id, i);
         Details.Add(interfaceDetail);
     }
     base.Read(bcfApp, eqObjIDCate, eq_id);
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BCMainForm"/> class.
 /// </summary>
 /// <param name="bcid">The bcid.</param>
 public BCMainForm(string bcid, string server_name)
 {
     InitializeComponent();
     Adapter.Initialize();
     BC_ID      = bcid;
     ServerName = server_name;
     Pic_Lock   = global::com.mirle.ibg3k0.bc.winform.Properties.Resources.lock1;
     Pic_Unlock = global::com.mirle.ibg3k0.bc.winform.Properties.Resources.unlock;
     logger.Error("Error Test");
     //Application
     BCFApplication.addErrorMsgHandler(errorLogHandler);
     BCFApplication.addWarningMsgHandler(warnLogHandler);
     BCFApplication.addInfoMsgHandler(infoLogHandler);
 }
Example #18
0
        public TrxMPLC.ReturnCode SendRecv(BCFApplication bcfApp, string eqObjIDCate, string eq_id, ValueRead replyMsg)
        {
            ValueWrite ve_handshake = null;

            Write(bcfApp, eqObjIDCate, eq_id, out ve_handshake);
            if (ve_handshake == null)
            {
                throw new NullReferenceException();
                //TODO Log
            }
            SpinWait.SpinUntil(() => false, 1000);
            return(ISMControl.sendRecv(bcfApp, ve_handshake, replyMsg, 20));
            //return TrxMPLC.ReturnCode.Normal;
        }
Example #19
0
 public new void Read(BCFApplication bcfApp, string eqObjIDCate, string eq_id, int item_count)
 {
     Details.Clear();
     RawDetails.Clear();
     for (int i = 1; i <= item_count; i++)
     {
         ChargerInterfaceDetail interfaceDetail = new ChargerInterfaceDetail();
         interfaceDetail.Index = $"Recode{nameof(ChargerInterface)}";
         interfaceDetail.EQ_ID = this.EQ_ID;
         interfaceDetail.Read(bcfApp, eqObjIDCate, eq_id, i);
         RawDetails.Add(interfaceDetail);
     }
     base.Read(bcfApp, eqObjIDCate, eq_id);
 }
Example #20
0
        public bool IsTcpIpListening(BCFApplication bcfApp)
        {
            bool IsListening = false;
            int  local_port  = ITcpIpControl.getLocalPortNum(bcfApp, TcpIpAgentName);

            if (local_port != 0)
            {
                iibg3k0.ttc.Common.TCPIP.TcpIpServer tcpip_server = bcfApp.getTcpIpServerByPortNum(local_port);
                if (tcpip_server != null)
                {
                    IsListening = tcpip_server.IsListening;
                }
            }
            return(IsListening);
        }
Example #21
0
        //private void checkSegmentStatus()
        //{
        //    if (Interlocked.Exchange(ref checkSyncPoint, 1) == 0)
        //    {
        //        try
        //        {
        //            bool hasPrepare = false;
        //            bcApp.SCApplication.LineBLL.BegingOrEndSegmentPreDisableExcute(true);
        //            do
        //            {

        //                foreach (ASEGMENT seg in segment_List)
        //                {
        //                    if (seg.PRE_DISABLE_FLAG)
        //                    {
        //                        bool canDisable = false;
        //                        if (IsRealTime)
        //                        {
        //                            List<string> will_be_pass_cmd_ids = null;
        //                            bool HasCmdWillPass = bcApp.SCApplication.CMDBLL.HasCmdWillPassSegment(seg.SEG_NUM, out will_be_pass_cmd_ids);
        //                            if (HasCmdWillPass)
        //                            {
        //                                foreach (string cmd_id in will_be_pass_cmd_ids)
        //                                {
        //                                    ACMD_OHTC will_pass_cmd = bcApp.SCApplication.CMDBLL.getExcuteCMD_OHTCByCmdID(cmd_id);
        //                                    if (will_pass_cmd == null)
        //                                        continue;
        //                                    AVEHICLE excute_vh = bcApp.SCApplication.getEQObjCacheManager().getVehicletByVHID(will_pass_cmd.VH_ID);
        //                                    sc.ProtocolFormat.OHTMessage.CMDCancelType cMDCancelType = default(sc.ProtocolFormat.OHTMessage.CMDCancelType);
        //                                    E_CMD_STATUS e_CMD_STATUS = default(E_CMD_STATUS);

        //                                    ASECTION crtSection = bcApp.SCApplication.MapBLL.getSectiontByID(excute_vh.CUR_SEC_ID);

        //                                    if (SCUtility.isMatche(crtSection.SEG_NUM, seg.SEG_NUM))
        //                                    {
        //                                        continue;
        //                                    }

        //                                    if (excute_vh.HAS_CST == 0)
        //                                    {
        //                                        e_CMD_STATUS = E_CMD_STATUS.Canceling;
        //                                        cMDCancelType = sc.ProtocolFormat.OHTMessage.CMDCancelType.CmdCancel;
        //                                    }
        //                                    else
        //                                    {
        //                                        e_CMD_STATUS = E_CMD_STATUS.Aborting;
        //                                        cMDCancelType = sc.ProtocolFormat.OHTMessage.CMDCancelType.CmdAbout;
        //                                    }
        //                                    if (excute_vh.sned_Str37(will_pass_cmd.CMD_ID, cMDCancelType))
        //                                    {
        //                                        bcApp.SCApplication.CMDBLL.updateCommand_OHTC_StatusByCmdID(will_pass_cmd.CMD_ID, e_CMD_STATUS);
        //                                    }

        //                                }
        //                            }
        //                            canDisable = !HasCmdWillPass;
        //                            if (canDisable)
        //                            {
        //                                List<ACMD_MCS> lstACMD_MCS = bcApp.SCApplication.CMDBLL.loadCMD_MCS_IsExcute(seg.PRE_DISABLE_TIME.Value);
        //                                if (lstACMD_MCS != null && lstACMD_MCS.Count > 0)
        //                                {
        //                                    List<string> adrs_SourceAndDestination = new List<string>();
        //                                    foreach (ACMD_MCS cmd in lstACMD_MCS)
        //                                    {
        //                                        string fromAdr = string.Empty;
        //                                        string toAdr = string.Empty;
        //                                        if (bcApp.SCApplication.MapBLL.getAddressID(cmd.HOSTSOURCE, out fromAdr))
        //                                            adrs_SourceAndDestination.Add(fromAdr);
        //                                        if (bcApp.SCApplication.MapBLL.getAddressID(cmd.HOSTDESTINATION, out toAdr))
        //                                            adrs_SourceAndDestination.Add(toAdr);
        //                                    }
        //                                    List<ASECTION> sections_SourceAndDestination =
        //                                          bcApp.SCApplication.MapBLL.loadSectionByToAdrs(adrs_SourceAndDestination);
        //                                    List<string> segments_SourceAndDestination = sections_SourceAndDestination.Select(sec => sec.SEG_NUM.Trim()).ToList();
        //                                    canDisable = !segments_SourceAndDestination.Contains(seg.SEG_NUM.Trim());
        //                                }
        //                            }
        //                        }
        //                        else
        //                        {
        //                            //1.確認是否有在Disable前的命令還沒執行完
        //                            canDisable = bcApp.SCApplication.CMDBLL.getCMD_MCSIsRunningCount(seg.PRE_DISABLE_TIME.Value) == 0;
        //                            //2.確認是否還有命令還會通過這裡
        //                            if (canDisable)
        //                            {

        //                                List<string> will_be_pass_cmd_ids = null;
        //                                canDisable = !bcApp.SCApplication.CMDBLL.HasCmdWillPassSegment(seg.SEG_NUM, out will_be_pass_cmd_ids);
        //                            }
        //                            //3.確認是否還有VH在管制道路上
        //                            if (canDisable)
        //                            {
        //                                List<AVEHICLE> listVH = bcApp.SCApplication.getEQObjCacheManager().getAllVehicle();
        //                                foreach (AVEHICLE vh in listVH)
        //                                {
        //                                    ASECTION vh_current_sec = bcApp.SCApplication.MapBLL.getSectiontByID(vh.CUR_SEC_ID);
        //                                    if (SCUtility.isMatche(vh_current_sec.SEG_NUM, seg.SEG_NUM))
        //                                    {
        //                                        canDisable = false;
        //                                        break;
        //                                    }
        //                                }
        //                            }
        //                        }
        //                        if (canDisable)
        //                        {
        //                            int index = segment_List.IndexOf(seg);
        //                            string seg_num = seg.SEG_NUM;
        //                            var newSeg = bcApp.SCApplication.RouteGuide.CloseSegment(seg_num.Trim());
        //                            var orderSeg = segment_List[index];
        //                            BCFUtility.setValueToPropety(ref newSeg, ref orderSeg);
        //                            Adapter.Invoke((obj) =>
        //                            {
        //                                dgv_segment.Refresh();
        //                            }, null);
        //                            hasPrepare = false;
        //                        }
        //                        else
        //                        {
        //                            hasPrepare = true;
        //                        }
        //                    }
        //                }
        //                SpinWait.SpinUntil(() => false, 1000);
        //            }
        //            while (hasPrepare);
        //        }
        //        catch (Exception ex)
        //        {
        //            logger.Error(ex, "Exection:");
        //        }
        //        finally
        //        {
        //            Interlocked.Exchange(ref checkSyncPoint, 0);
        //            bcApp.SCApplication.LineBLL.BegingOrEndSegmentPreDisableExcute(false);
        //        }
        //    }
        //}
        #endregion 保留



        private void RoadControlForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (bcApp.SCApplication.getEQObjCacheManager().getLine().SegmentPreDisableExcuting)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Segment is changing state to disable. please wait or cancel.")
                .AppendLine("segment num:");
                foreach (ASEGMENT seg in segment_List)
                {
                    if (seg.PRE_DISABLE_FLAG)
                    {
                        sb.Append(seg.SEG_NUM.Trim()).Append(',');
                    }
                }
                BCFApplication.onWarningMsg(sb.ToString());
                e.Cancel = true;
            }
        }
Example #22
0
        public ValueRead getValueReadHandshake(BCFApplication bcfApp, string eqObjIDCate, string eq_id)
        {
            ValueRead vr = null;

            if (!SCUtility.isEmpty(HandshakePropName))
            {
                if (!bcfApp.tryGetReadValueEventstring(eqObjIDCate, eq_id, HandshakePropName, out vr))
                {
                }
            }
            else if (!SCUtility.isEmpty(IndexPropName))
            {
                if (!bcfApp.tryGetReadValueEventstring(eqObjIDCate, eq_id, IndexPropName, out vr))
                {
                }
            }

            return(vr);
        }
Example #23
0
        public void getAgentInfo(BCFApplication bcfApp,
                                 out bool IsListening, out bool IsCommunication, out bool IsConnections,
                                 out DateTime connTime, out TimeSpan accConnTime,
                                 out DateTime disConnTime, out TimeSpan accDisConnTime,
                                 out int disconnTimes, out int lostPackets)
        {
            Stopwatch fromLastCommTime = ITcpIpControl.StopWatch_FromTheLastCommTime(bcfApp, TcpIpAgentName);

            IsCommunication = fromLastCommTime.IsRunning ?
                              fromLastCommTime.ElapsedMilliseconds < CommunicationInterval_ms : false;
            IsConnections  = ITcpIpControl.IsConnection(bcfApp, TcpIpAgentName);
            connTime       = ITcpIpControl.ConnectionTime(bcfApp, TcpIpAgentName);
            accConnTime    = ITcpIpControl.StopWatch_ConnectionTime(bcfApp, TcpIpAgentName).Elapsed;
            disConnTime    = ITcpIpControl.DisconnectionTime(bcfApp, TcpIpAgentName);
            accDisConnTime = ITcpIpControl.StopWatch_DisconnectionTime(bcfApp, TcpIpAgentName).Elapsed;
            disconnTimes   = ITcpIpControl.DisconnectionTimes(bcfApp, TcpIpAgentName);
            lostPackets    = ITcpIpControl.NumberOfPacketsLost(bcfApp, TcpIpAgentName);
            //取得目前VH 使用的TCPIPAgent所對應的TCPIPServer是否有在進行聆聽中
            IsListening = IsTcpIpListening(bcfApp);
        }
Example #24
0
        public virtual void Read(BCFApplication bcfApp, string eqObjIDCate, string eq_id, int index)
        {
            List <ValueRead> listVR = new List <ValueRead>();

            foreach (FieldInfo info in fieldInfos)
            {
                ValueRead  vr         = null;
                PLCElement element    = getPLCElementAttr(info);
                string     value_name = $"{element.ValueName}{index}";
                if (bcfApp.tryGetReadValueEventstring(eqObjIDCate, EQ_ID, value_name, out vr))
                {
                    info.SetValue(this, vr.getText());
                    listVR.Add(vr);
                }
                else
                {
                }
            }
            if (listVR.Count > 0)
            {
                BCFUtility.writeEquipmentLog(eq_id, listVR);
            }
        }
Example #25
0
 /// <summary>
 /// MPLCs the handshake timeout.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="ErrorEventArgs"/> instance containing the event data.</param>
 private void mplcHandshakeTimeout(object sender, ErrorEventArgs e)
 {
     BCFApplication.onErrorMsg(String.Format("MPLC Handshake Timeout: {0}", e.ErrorMsg));
 }
 public FireDoorInfoDefaultValueDefMapAction()
     : base()
 {
     scApp  = SCApplication.getInstance();
     bcfApp = scApp.getBCFApplication();
 }
Example #27
0
        public virtual void SafetyCheckRequestChange(object sender, ValueChangedEventArgs args)
        {
            try
            {
                string   pre_control_segment_id = eqpt.SegmentLocation;
                ASEGMENT pre_control_segment    = scApp.SegmentBLL.cache.GetSegment(pre_control_segment_id);

                var recevie_function = scApp.getFunBaseObj <OHCVToOHxC_SafetyCheckRequest>(eqpt.EQPT_ID) as OHCVToOHxC_SafetyCheckRequest;
                recevie_function.Read(bcfApp, eqpt.EqptObjectCate, eqpt.EQPT_ID);
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV,
                              Data: recevie_function.ToString(),
                              VehicleID: eqpt.EQPT_ID);
                eqpt.SafetyCheckRequest = recevie_function.SafetyCheckRequest;
                if (recevie_function.SafetyCheckRequest)
                {
                    //if (!node.DoorClosed)//檢查安全門是不是關閉的
                    if (!eqpt.DoorClosed)//檢查安全門是不是關閉的
                    {
                        BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request to OHTC,but door is open now.");
                        return;
                    }
                    //if (!node.Is_Alive)//檢查Alive有沒有變化
                    if (!eqpt.Is_Eq_Alive)//檢查Alive有沒有變化
                    {
                        BCFApplication.onWarningMsg($"OHCV:[{eqpt.EQPT_ID}] send safety check request to OHTC,but OHCV alive is not changing.");
                        return;
                    }

                    bool initNotifyResult = sendRoadControlInitialNotify();

                    if (initNotifyResult)
                    {
                        if (eqpt.SafetyCheckRequest)//沒有被取消
                        {
                            //如果現在這組CV的狀態是DISABLE而且是由SAFETY_DISABLE而且有通知這組CV已經可以開啟,
                            //就可以直接回覆Complete
                            if (pre_control_segment.DISABLE_FLAG_SAFETY &&
                                pre_control_segment.STATUS == E_SEG_STATUS.Closed &&
                                node.SafetyCheckComplete)
                            {
                                Pre_control_segment_ControlComplete(pre_control_segment, null);
                            }
                            else
                            {
                                //註冊該segment control complete的事件
                                pre_control_segment.ControlComplete += Pre_control_segment_ControlComplete;

                                //開始處理CV的OP in request時,要處理的事項
                                //1.predisable 該CV所在路段 Todo by Kevin
                                //2.確認無車輛會再過該CV路段 Todo by Kevin
                                //3.disable 該CV所在路段 Todo by Kevin
                                //4.當上述條件成功時,會觸發"ControlComplete"的事件
                                scApp.RoadControlService.ProcessCVOpInRequest(eqpt);
                            }
                            //bool completeNotifyResult = sendRoadControlCompleteNotify(); //disable路段後發出Complete Notify
                            //if (completeNotifyResult)
                            //{
                            //    //do nothing
                            //}
                            //else
                            //{
                            //    BCFApplication.onWarningMsg($"OHTC send road control complete notify to OHCV:[{eqpt.EQPT_ID}] with error happend.");
                            //    return;
                            //}
                        }
                        else//被中途取消了
                        {
                            //do nothing
                        }
                    }
                    else
                    {
                        BCFApplication.onWarningMsg($"OHTC send road control initial notify to OHCV:[{eqpt.EQPT_ID}] with error happend.");
                        return;
                    }
                }
                else//SafetyCheckRequest訊號OFF
                {
                    //當SafetyCheckRequest關閉後,就再次取消註冊的Control complete事件,確保已經不會再收到控制完成的通知。
                    pre_control_segment.ControlComplete -= Pre_control_segment_ControlComplete;

                    if (eqpt.SafetyCheckComplete)
                    {
                        //donothing
                    }
                    else
                    {
                        cancelSafetyCheckRequest();
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
        }
Example #28
0
 public EquipmentValueDefMapAction()
     : base()
 {
     scApp  = SCApplication.getInstance();
     bcfApp = scApp.getBCFApplication();
 }
Example #29
0
 public GEMDriver()
 {
     scApp    = SCApplication.getInstance();
     eventBLL = scApp.EventBLL;
     bcfApp   = scApp.getBCFApplication();
 }
Example #30
0
        private void Pre_control_segment_ControlComplete(object sender, EventArgs e)
        {
            ASEGMENT control_complete_segment = sender as ASEGMENT;

            try
            {
                //再次確認是否Safety check=true、door closed=true、alive=true
                if (!eqpt.SafetyCheckRequest)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV,
                                  Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," +
                                  $"but cv:{eqpt.EQPT_ID} of {nameof(eqpt.SafetyCheckRequest)} is {eqpt.SafetyCheckRequest}",
                                  VehicleID: eqpt.EQPT_ID);
                    return;
                }

                if (!eqpt.DoorClosed)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV,
                                  Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," +
                                  $"but cv:{eqpt.EQPT_ID} of {nameof(eqpt.DoorClosed)} is {eqpt.DoorClosed}",
                                  VehicleID: eqpt.EQPT_ID);
                    return;
                }
                if (!eqpt.Is_Eq_Alive)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV,
                                  Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," +
                                  $"but cv:{eqpt.EQPT_ID} of {nameof(eqpt.Is_Eq_Alive)} is {eqpt.Is_Eq_Alive}",
                                  VehicleID: eqpt.EQPT_ID);
                    return;
                }


                //foreach (var cv in node.getSubEqptList())
                //{
                //    if (!cv.DoorClosed)
                //    {
                //        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV,
                //                 Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," +
                //                       $"but cv:{cv.EQPT_ID} of {nameof(cv.DoorClosed)} is {cv.DoorClosed}",
                //                 VehicleID: eqpt.EQPT_ID);
                //        return;
                //    }
                //    if (!cv.Is_Eq_Alive)
                //    {
                //        LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(OHCVValueDefMapAction), Device: DEVICE_NAME_OHCV,
                //                 Data: $"want to notify cv:{eqpt.EQPT_ID} segment id:{control_complete_segment.SEG_NUM} is control complete," +
                //                       $"but cv:{cv.EQPT_ID} of {nameof(cv.Is_Eq_Alive)} is {cv.Is_Eq_Alive}",
                //                 VehicleID: eqpt.EQPT_ID);
                //        return;
                //    }
                //}


                bool completeNotifyResult = sendRoadControlCompleteNotify(); //disable路段後發出Complete Notify
                if (completeNotifyResult)
                {
                    //do nothing
                }
                else
                {
                    BCFApplication.onWarningMsg($"OHTC send road control complete notify to OHCV:[{eqpt.EQPT_ID}] with error happend.");
                    //return;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exection:");
            }
            finally
            {
                control_complete_segment.ControlComplete -= Pre_control_segment_ControlComplete;
            }
        }