Exemplo n.º 1
0
        public (bool isSuccess, string reason) RecoverCVEnable(string segmentID)
        {
            bool   is_success = true;
            string reason     = "";

            try
            {
                ASEGMENT seg_vo = SegmentBLL.cache.GetSegment(segmentID);
                List <sc.Data.VO.OHCV> ohcvs = app.EquipmentBLL.cache.loadOHCVDevicesBySegmentLocation(segmentID);
                if (ohcvs == null || ohcvs.Count == 0)
                {
                    reason     = $"Segment ID:{segmentID} not is cv of segemnt.";
                    is_success = false;;
                    return(is_success, reason);
                }
                if (!seg_vo.DISABLE_FLAG_SAFETY)
                {
                    reason     = $"Segment ID:{segmentID} of safty flag already off.";
                    is_success = false;;
                    return(is_success, reason);
                }
                foreach (sc.Data.VO.OHCV ohcv in ohcvs)
                {
                    if (!ohcv.DoorClosed)
                    {
                        reason     = $"ohcv ID:{ohcv.EQPT_ID} of door closed:{ohcv.DoorClosed} ,can't enable segment.";
                        is_success = false;
                        return(is_success, reason);
                    }
                    if (!ohcv.Is_Eq_Alive)
                    {
                        reason     = $"ohcv ID:{ohcv.EQPT_ID} of alive:{ohcv.Is_Eq_Alive} ,can't enable segment.";
                        is_success = false;
                        return(is_success, reason);
                    }
                }
                //取得CV所在的Node,By Segment ID
                string seg_id = SCUtility.Trim(segmentID, true);
                ANODE  node   = NodeBLL.OperateCatch.getNodeBySegment(seg_id);
                doEnableDisableSegment(seg_id,
                                       E_PORT_STATUS.InService, ASEGMENT.DisableType.Safety,
                                       sc.Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI);

                foreach (var ohcv in node.getSubEqptList())
                {
                    LineService.ProcessAlarmReport(
                        ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "",
                        SCAppConstants.SystemAlarmCode.OHCV_Issue.CVALLAlarmReset,
                        ProtocolFormat.OHTMessage.ErrorStatus.ErrReset);
                }
                return(is_success, reason);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
                reason     = $"{ex}-Exception";
                is_success = false;
                return(is_success, reason);
            }
        }
        public bool RecoverCVEnable(string segmentID)
        {
            try
            {
                //取得CV所在的Node,By Segment ID
                string seg_id = SCUtility.Trim(segmentID, true);
                ANODE  node   = NodeBLL.OperateCatch.getNodeBySegment(seg_id);
                doEnableDisableSegment(seg_id,
                                       E_PORT_STATUS.InService, ASEGMENT.DisableType.Safety,
                                       sc.Data.SECS.CSOT.SECSConst.LANECUTTYPE_LaneCutOnHMI);

                foreach (var ohcv in node.getSubEqptList())
                {
                    LineService.ProcessAlarmReport(
                        ohcv.NODE_ID, ohcv.EQPT_ID, ohcv.Real_ID, "",
                        SCAppConstants.SystemAlarmCode.OHCV_Issue.CVALLAlarmReset,
                        ProtocolFormat.OHTMessage.ErrorStatus.ErrReset);
                }
                return(true);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
                return(false);
            }
        }
        private void Charger_CouplerHPSafetyChaged(object sender, SCAppConstants.CouplerHPSafety e)
        {
            try
            {
                if (DebugParameter.isPassCouplerHPSafetySignal)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"pass coupler hp safey signal,flag:{DebugParameter.isPassCouplerHPSafetySignal}");
                    return;
                }
                AUNIT charger = sender as AUNIT;
                if (charger == null)
                {
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"charger is null");
                    return;
                }
                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                              Data: $"Coupler hp safyte has changed,charger id:{charger.UNIT_ID} hp safety:{e}");
                var couplers = addressesBLL.cache.LoadCouplerAddresses(charger.UNIT_ID);
                var vhs      = vehicleBLL.cache.loadAllVh();
                switch (e)
                {
                case SCAppConstants.CouplerHPSafety.NonSafety:
                    lineService.ProcessAlarmReport(charger.UNIT_ID, AlarmBLL.AGVC_CHARGER_HP_NOT_SAFETY, ErrorStatus.ErrSet, $"Coupler position not safety.");
                    break;

                case SCAppConstants.CouplerHPSafety.Safyte:
                    lineService.ProcessAlarmReport(charger.UNIT_ID, AlarmBLL.AGVC_CHARGER_HP_NOT_SAFETY, ErrorStatus.ErrReset, $"Coupler position not safety.");
                    break;
                }
                foreach (var coupler in couplers)
                {
                    string coupler_adr_id = coupler.ADR_ID;
                    LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                  Data: $"Coupler hp safyte has changed,coupler adr id:{coupler_adr_id}, start check has vh can pass...");
                    foreach (var vh in vhs)
                    {
                        if (vh.isTcpIpConnect &&
                            (vh.MODE_STATUS == VHModeStatus.AutoRemote ||
                             vh.MODE_STATUS == VHModeStatus.AutoCharging ||
                             vh.MODE_STATUS == VHModeStatus.AutoCharging)
                            )
                        {
                            string vh_cur_adr_id = vh.CUR_ADR_ID;
                            bool   is_walkable   = guideBLL.IsRoadWalkable(coupler_adr_id, vh_cur_adr_id);
                            if (is_walkable)
                            {
                                LogHelper.Log(logger: logger, LogLevel: LogLevel.Info, Class: nameof(VehicleChargerModule), Device: DEVICE_NAME,
                                              Data: $"Coupler hp safyte has changed,coupler adr id:{coupler_adr_id} vh current adr:{vh_cur_adr_id}, is walkable start pause/continue action");
                                string     vh_id      = vh.VEHICLE_ID;
                                PauseType  pauseType  = PauseType.Normal;
                                PauseEvent pauseEvent = PauseEvent.Pause;
                                if (e == SCAppConstants.CouplerHPSafety.Safyte)
                                {
                                    pauseEvent = PauseEvent.Continue;
                                }
                                else
                                {
                                    pauseEvent = PauseEvent.Pause;
                                }
                                //Task.Run(() =>
                                //{
                                //    try
                                //    {
                                //        vehicleService.Send.Pause(vh_id, pauseEvent, pauseType);
                                //    }
                                //    catch (Exception ex)
                                //    {
                                //        logger.Error(ex, "Exception:");
                                //    }
                                //});
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception:");
            }
        }