Esempio n. 1
0
        protected override void ExecuteCore(CarSignalInfo signalInfo)
        {
            ///停车不检测角度
            if (signalInfo.CarState == CarState.Stop)
            {
                return;
            }
            //过滤10m
            if (!isOverPrepareDistance)
            {
                if (signalInfo.Distance - StartChangeLanesDistance < Settings.ChangeLanesPrepareDistance)
                {
                    return;
                }
                else
                {
                    isOverPrepareDistance = true;
                    StartChangeLanesAngle = signalInfo.BearingAngle;
                    return;
                }
            }
            //变更车道超时
            if (IsTimeOut())
            {
                if (!IsSuccess)
                {
                    BreakRule(DeductionRuleCodes.RC40503);
                }

                StopCore();
                return;
            }

            //变更车道超距
            if (IsOverDistance(signalInfo))
            {
                if (!IsSuccess)
                {
                    BreakRule(DeductionRuleCodes.RC40503);
                }
                StopCore();
                return;
            }

            if (IsLightChecked == false && IsSuccess == false)
            {
                if (signalInfo.Sensor.RightIndicatorLight)
                {
                    IsLightChecked = true;
                    CheckRule(true, DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503);
                }
            }

            Logger.InfoFormat("变道流程状态: {0}", StepState.ToString());

            if (Settings.ChangeLanesAngle > 0)
            {
                if (StepState == ChangeLanesStep.None)
                {
                    //判断车辆是否在进行变道
                    if (signalInfo.BearingAngle.IsValidAngle() &&
                        StartChangeLanesAngle.IsValidAngle() &&
                        !GeoHelper.IsBetweenDiffAngle(signalInfo.BearingAngle, StartChangeLanesAngle, Settings.ChangeLanesAngle))
                    {
                        StepState            = ChangeLanesStep.StartChangeLanes;
                        ChangeLanesStartTime = DateTime.Now;
                    }
                }
                else if (StepState == ChangeLanesStep.StartChangeLanes)
                {
                    StepState = ChangeLanesStep.EndChangeLanes;
                    if (Settings.ChangeLanesLightCheck && IsLightChecked == false)
                    {
                        IsLightChecked = true;
                        //是否打转向灯
                        var hasTurnLight = CarSignalSet.Query(StartChangeLanesTime).Any(d => d.Sensor.LeftIndicatorLight);

                        if (!hasTurnLight)
                        {
                            CheckRule(true, DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503);
                        }
                        else
                        {
                            //转向灯是否超过3秒
                            var hasIndicatorLight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime);
                            if (hasIndicatorLight)
                            {
                                return;
                            }

                            BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020603);
                        }
                    }
                }
                else
                {
                    IsSuccess = true;
                    //完成变道,结束该项目
                    return;
                    //StopCore();
                }
            }
            else if (Settings.ChangeLanesAngle == 0)
            {
                IsSuccess = true;
            }

            base.ExecuteCore(signalInfo);
        }
Esempio n. 2
0
        protected override void ExecuteCore(CarSignalInfo signalInfo)
        {
            if (Constants.ChangeLaneDistance == 0)
            {
                Constants.ChangeLaneDistance = signalInfo.Distance;
            }
            if (stopDelayDistance.HasValue)
            {
                if ((signalInfo.Distance - stopDelayDistance.Value) > 10)
                {
                    StopCore();
                }
            }
            if (signalInfo.CarState == CarState.Stop)
            {
                return;
            }
            //播报第2次语音
            if (IsSecondVoice == false && !string.IsNullOrEmpty(Settings.ChangeLanesSecondVoice) && Settings.ChangeLanesPrepareDistance > 1)
            {
                IsSecondVoice = true;
                Speaker.PlayAudioAsync(Settings.ChangeLanesSecondVoice, SpeechPriority.Normal);
            }
            //过滤10m
            if (!isOverPrepareDistance)
            {
                if (signalInfo.Distance - StartChangeLanesDistance < Settings.ChangeLanesPrepareDistance)
                {
                    return;
                }
                else
                {
                    isOverPrepareDistance = true;
                    StartChangeLanesAngle = signalInfo.BearingAngle;
                    return;
                }
            }
            //不要超时避免误判
            //不要吵
            //if (IsTimeOut())
            //{
            //    if (!IsSuccess)
            //    {
            //        BreakRule(DeductionRuleCodes.RC40503);
            //    }

            //    StopCore();
            //    return;
            //}

            //变更车道超距
            if (IsOverDistance(signalInfo))
            {
                if (!IsSuccess)
                {
                    BreakRule(DeductionRuleCodes.RC40503);
                }
                StopCore();
                return;
            }
            Logger.InfoFormat("变道流程状态: {0}", StepState.ToString());
            //Logger.Error("变道流程状态"+StepState.ToString()+"ChangeLanes" + signalInfo.BearingAngle.ToString()+ "StartChangeLanesAngle:"+ StartChangeLanesAngle.ToString()+ "Settings.ChangeLanesAngle:" + Settings.ChangeLanesAngle.ToString());
            if (Settings.ChangeLanesAngle > 0)
            {
                if (StepState == ChangeLanesStep.None)
                {
                    //变道摆正10米后才进行下面的检测(转向灯评判太快,车还没摆正)
                    if (ChangeStartDistance.HasValue)
                    {
                        if (signalInfo.Distance - ChangeStartDistance.Value > Settings.ChangeLanesPrepareDistance)
                        {
                            StepState = ChangeLanesStep.StartChangeLanes;
                        }
                    }
                    //判断车辆是否在进行变道
                    if (signalInfo.BearingAngle.IsValidAngle() &&
                        StartChangeLanesAngle.IsValidAngle() &&
                        !GeoHelper.IsBetweenDiffAngle(signalInfo.BearingAngle, StartChangeLanesAngle, Settings.ChangeLanesAngle))
                    {
                        StepState            = ChangeLanesStep.StartChangeLanes;
                        ChangeStartDistance  = signalInfo.Distance;
                        ChangeLanesStartTime = DateTime.Now;
                    }
                }
                else if (StepState == ChangeLanesStep.StartChangeLanes)
                {
                    StepState = ChangeLanesStep.EndChangeLanes;
                    if (Settings.ChangeLanesLightCheck)
                    {
                        //只能左转
                        if (Settings.ChangelineDirect.Equals(1))
                        {
                            //是否打转向灯
                            var hasTurnLight  = CarSignalSet.Query(StartChangeLanesTime).Any(d => d.Sensor.LeftIndicatorLight);
                            var hasErrorLight = CarSignalSet.Query(StartChangeLanesTime).Any(d => d.Sensor.RightIndicatorLight);
                            if (!hasTurnLight || hasErrorLight)
                            {
                                BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503);
                            }
                            else
                            {
                                //转向灯是否超过3秒
                                var hasIndicatorLight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime);
                                if (hasIndicatorLight)
                                {
                                    return;
                                }
                                BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020603);
                            }
                        }//只能右转
                        else if (Settings.ChangelineDirect.Equals(2))
                        {
                            //是否打转向灯
                            var hasTurnLight  = CarSignalSet.Query(StartChangeLanesTime).Any(d => d.Sensor.RightIndicatorLight);
                            var hasErrorLight = CarSignalSet.Query(StartChangeLanesTime).Any(d => d.Sensor.LeftIndicatorLight);
                            if (!hasTurnLight || hasErrorLight)
                            {
                                BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503);
                            }
                            else
                            {
                                //转向灯是否超过3秒
                                var hasIndicatorLight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime);
                                if (hasIndicatorLight)
                                {
                                    return;
                                }
                                BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020603);
                            }
                        }
                        else
                        {
                            //是否打转向灯
                            var hasTurnLight = CarSignalSet.Query(StartChangeLanesTime).Any(d => d.Sensor.LeftIndicatorLight || d.Sensor.RightIndicatorLight);
                            if (!hasTurnLight)
                            {
                                BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503);
                            }
                            else
                            {
                                //转向灯是否超过3秒
                                var hasIndicatorLight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight || x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime);
                                if (hasIndicatorLight)
                                {
                                    return;
                                }
                                BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020603);
                            }
                        }
                    }
                }
                else
                {
                    IsSuccess = true;
                    //完成变道,结束该项目
                    if (Settings.ChkChangeLanesEndFlag && !stopDelayDistance.HasValue)
                    {
                        stopDelayDistance = signalInfo.Distance;
                    }
                    return;
                }
            }
            else if (Settings.ChangeLanesAngle == 0)
            {
                IsSuccess = true;
            }

            base.ExecuteCore(signalInfo);
        }