protected virtual void ProcessIsValid(CarSignalInfo signalInfo) { if (signalInfo.Gps == null) { signalInfo.IsGpsValid = false; Logger.Error("ProcessIsValid:" + string.Join(",", signalInfo.commands)); return; } //有卫星数量 signalInfo.IsGpsValid = signalInfo.Gps.FixedSatelliteCount > 0 && signalInfo.Gps.LatitudeDegrees > 0 && signalInfo.Gps.LongitudeDegrees > 0; //对于异常速度进行处理 if (signalInfo.Sensor.SpeedInKmh >= 0 && signalInfo.Sensor.SpeedInKmh <= Constants.InvalidSpeedLimit) { signalInfo.IsSensorValid = true; return; } //对于异常转速比进行处理 //对最近2秒钟的信号进行判断分析,如果持续无效信息则返回 var queryTime = DateTime.Now.AddSeconds(-2); var allInvalid = CarSignalSet.TakeWhile(x => x.RecordTime > queryTime).All(x => x.Sensor.SpeedInKmh <0 && x.Sensor.SpeedInKmh> Constants.InvalidSpeedLimit); signalInfo.IsSensorValid = !allInvalid; }
protected override void StopCore() { if (CarSignalSet.Query(StartTime).Count(d => d.Sensor.RightIndicatorLight) >= Constants.ErrorSignalCount) { //打错转向灯 BreakRule(DeductionRuleCodes.RC30205); } else { //检测转向灯 if (CarSignalSet.Query(StartTime).Count(d => d.Sensor.LeftIndicatorLight) < Constants.ErrorSignalCount) { //是否打转向灯 BreakRule(DeductionRuleCodes.RC30205); } else { var isOk = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!isOk) { BreakRule(DeductionRuleCodes.RC30206); } } } base.StopCore(); }
protected override void StopCore() { var isOk = CheckSpeedLimit(); if (!isOk) { CheckRule(true, DeductionRuleCodes.RC41001); } //喇叭检测 if ((CheckLoudSpeakerInDay && Context.ExamTimeMode == ExamTimeMode.Day) || (CheckLoudSpeakerInNight && Context.ExamTimeMode == ExamTimeMode.Night)) { var hasLoudSpeaker = CarSignalSet.Query(StartTime).Any(x => x.Sensor.Loudspeaker); if (!hasLoudSpeaker) { CheckRule(true, DeductionRuleCodes.RC30212); } } //夜间远近光交替 if (CheckLowAndHighBeam && Context.ExamTimeMode == ExamTimeMode.Night) { var hasLowAndHighBeam = AdvancedSignal.CheckHighBeam(StartTime); if (!hasLowAndHighBeam) { CheckRule(true, DeductionRuleCodes.RC41603); } } base.StopCore(); }
protected void CheckRight() { indicatorChecked = true; // if (hasLeftIndicator && CarSignalSet.Query(StartTime).Count(d => d.Sensor.LeftIndicatorLight) >= Constants.ErrorSignalCount) { BreakRule(DeductionRuleCodes.RC30205); } else { if (!hasRightIndicator && CarSignalSet.Query(StartTime).Count(d => d.Sensor.RightIndicatorLight) < Constants.ErrorSignalCount) { //是否打转向灯 // BreakRule(DeductionRuleCodes.RC30205); //是否 } else { //检测时间 var isOk = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!isOk) { BreakRule(DeductionRuleCodes.RC30206); } } } }
protected override void StopCore() { //左转和右转进行了灯光检测 var isCheckedLeftIndicatorLight = CarSignalSet.Query(StartTime).Any(d => d.Sensor.LeftIndicatorLight); var isCheckedRightIndicatorLight = CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight); var isCheckedLeftIndicatorLightEnough = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); var isCheckedRightIndicatorLightEnough = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!(isCheckedLeftIndicatorLight || isCheckedRightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503); } else { if (!(isCheckedLeftIndicatorLightEnough || isCheckedRightIndicatorLightEnough)) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020603); } } //夜考双闪 if (Settings.ChangeLanesLowAndHighBeamCheck && Context.ExamTimeMode == ExamTimeMode.Night) { if (!AdvancedSignal.CheckHighBeam(StartTime)) { BreakRule(DeductionRuleCodes.RC41603); } } base.StopCore(); }
protected override void StopCore() { //最后判断是否有打转向灯 if (Settings.ChangeLanesAngle == 0) { //如果没打左转 if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.LeftIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } else { if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020604); } } // } //夜考双闪 if (Settings.ChangeLanesLowAndHighBeamCheck && Context.ExamTimeMode == ExamTimeMode.Night) { if (!AdvancedSignal.CheckHighBeam(StartChangeLanesTime)) { BreakRule(DeductionRuleCodes.RC41603); } } Logger.InfoFormat("变道结束 当前流程状态;{0} 设定角度:{1} 开始角度:{2} 结束角度:{3}", StepState.ToString(), Settings.ChangeLanesAngle, StartChangeLanesAngle, CarSignalSet.Current.BearingAngle); base.StopCore(); }
/// <summary> /// 检测右转(动方向或者车停时检测) /// </summary> protected void CheckRightIndicatorLight() { if (IsRightIndicatorLightChecked) { return; } //如果扣分了 //IsRightIndicatorLightChecked = true; if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight)) { IsRightIndicatorLightChecked = true; BreakRule(DeductionRuleCodes.RC40610); } else { var advancedSignal = Singleton.GetAdvancedCarSignal; var rightIndicator = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!rightIndicator) { IsRightIndicatorLightChecked = true; BreakRule(DeductionRuleCodes.RC40611); } } }
protected bool CheckMaxSpeedLimit() { if (Settings.StraightDrivingSpeedMaxLimit > 0 && StraightDrivingStartTime.HasValue) { return(CarSignalSet.Query(StraightDrivingStartTime.Value).All(x => x.SpeedInKmh <= Settings.StraightDrivingSpeedMaxLimit)); } return(true); }
protected override void StopCore() { //全程没有达到最低速度 if (!IsArrivedLowSpeed) { CheckRule(true, DeductionRuleCodes.RC30116); } if (IsDefaultRule) { if (!IsSuccess) { //BreakRule(DeductionRuleCodes.RC30103); } } else { //如果不是默认规则就只需要检查转向灯 if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.LeftIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); Logger.InfoFormat("OverTakeTest Not LeftIndicatorLight"); } else { if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020604); Logger.InfoFormat("OverTakeTest LeftIndicatorLight Time:{0}", Settings.TurnLightAheadOfTime); } } } //检查喇叭 if (!IsLoudSpeakerCheck) { if (Settings.OvertakeLoudSpeakerNightCheck && Context.ExamTimeMode == ExamTimeMode.Night) { BreakRule(DeductionRuleCodes.RC30212); } if (Settings.OvertakeLoudSpeakerDayCheck && Context.ExamTimeMode == ExamTimeMode.Day) { BreakRule(DeductionRuleCodes.RC30212); } } //夜考双闪 if (Settings.OvertakeLowAndHighBeamCheck && Context.ExamTimeMode == ExamTimeMode.Night) { if (!AdvancedSignal.CheckHighBeam(StartTime)) { BreakRule(DeductionRuleCodes.RC41603); } } Logger.InfoFormat("超车结束 当前流程状态:{0} 设定角度:{1} 开始角度:{2} 结束角度:{3}", OvertakeStepState.ToString(), Settings.OvertakeChangeLanesAngle, StartChangeLanesAngle, CarSignalSet.Current.BearingAngle); //Speaker.PlayAudioAsync(EndVoiceFile, Infrastructure.Speech.SpeechPriority.Highest); base.StopCore(); }
protected override void StopCore() { //只有第一个出口检测转向灯 if (Settings.RoundaboutLightCheck) { if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC40212); } } base.StopCore(); }
protected override void StopCore() { if (Settings.SharpTurnLeftLightCheck && !Settings.SharpTurnRightLightCheck) { if (CarSignalSet.Query(StartTime).Count(d => d.Sensor.LeftIndicatorLight) < Constants.ErrorSignalCount) { //是否打转向灯 BreakRule(DeductionRuleCodes.RC30205); } else { var isOk = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!isOk) { BreakRule(DeductionRuleCodes.RC30206); } } } //检测转向灯 if (Settings.SharpTurnRightLightCheck && !Settings.SharpTurnLeftLightCheck) { if (CarSignalSet.Query(StartTime).Count(d => d.Sensor.RightIndicatorLight) < Constants.ErrorSignalCount) { //是否打转向灯 BreakRule(DeductionRuleCodes.RC30205); //是否 } else { //检测时间 var isOk = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!isOk) { BreakRule(DeductionRuleCodes.RC30206); } } } //这样左转和右转只要随便开了一个就可以 if (Settings.SharpTurnLeftLightCheck && Settings.SharpTurnRightLightCheck) { var isOkRight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); var isOkLeft = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!isOkLeft && !isOkRight) { BreakRule(DeductionRuleCodes.RC30206); } } base.StopCore(); }
protected void GetSpeedFiltering(CarSignalInfo signalInfo) { //开始100个信号不会处理,避免信号不稳定情况! if (CarSignalSet.Count < 100) { signalInfo.SpeedInKmh = signalInfo.SpeedInKmh; return; } var SignalInfo = CarSignalSet.Skip(CarSignalSet.Count - 10).Take(10).Select(s => s.SpeedInKmh).ToArray(); //var SignalInfo = CarSignalSet.Select(s => s.SpeedInKmh).Take(10).ToArray(); signalInfo.SpeedInKmh = GetFilterVale(SignalInfo); }
protected override void StopCore() { //禁止鸣笛 if (Settings.SchoolAreaForbidLoudSpeakerCheck) { var hasLoudspeaker = CarSignalSet.Query(StartTime).Any(x => x.Sensor.Loudspeaker); if (hasLoudspeaker) { BreakRule(DeductionRuleCodes.RC30214); } } base.StopCore(); }
/// <summary> /// 转向灯超时,停着不计算时间 /// </summary> /// <param name="signalInfo"></param> /// <returns></returns> protected bool CheckIndicatorTimeout(CarSignalInfo signalInfo) { // Logger.Error(Settings.IndicatorLightTimeout.ToString()); if (Settings.IndicatorLightTimeout <= 0 || !ExamItemEndTime.HasValue) { return(true); } //项目结束到现在超过设置时间才有效 if ((DateTime.Now - ExamItemEndTime.Value).TotalSeconds < Settings.IndicatorLightTimeout) { return(true); } //刚开始的时候数据未超过超时时间 if (CarSignalSet.Count == 0 || (DateTime.Now - CarSignalSet.Last().RecordTime).TotalSeconds < Settings.IndicatorLightTimeout) { return(true); } //查询15秒以前的数据 var sensors = CarSignalSet.QueryCachedSeconds(Settings.IndicatorLightTimeout).Where(x => x.IsValid); //需要处理一下重新计算时间 var carSignalInfos = sensors.ToArray(); if (signalInfo.Sensor.LeftIndicatorLight) { if (carSignalInfos.All(x => x.Sensor.LeftIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30215, null); return(false); } } if (signalInfo.Sensor.RightIndicatorLight) { if (carSignalInfos.All(x => x.Sensor.RightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30215, null); return(false); } } return(true); }
protected override bool CheckSpeedLimit() { //进入项目后没得松开刹车动作再踩,则不算踩刹车 if (Settings.CheckBrakeMustInitem) { if (!_hasLoosenBrake) { return(false); } } //判断下如果是泸州 //必踩刹车 if (CheckBrakeRequired) { var hasBrake = CarSignalSet.Query(StartTime).Any(x => x.Sensor.Brake); Logger.InfoFormat("{0}-{1}-{2}-必踩刹车-{3}", Name, StartDistance, StartTime, hasBrake); if (!hasBrake && !braked) { return(false); } } // 速度限制 if (SlowSpeedLimit > 0) { var isOverspeed = CarSignalSet.Current.SpeedInKmh > SlowSpeedLimit; Logger.InfoFormat("{0}-{1}-{2}-速度限制-{3}:{4}", Name, StartDistance, StartTime, isOverspeed, SlowSpeedLimit); if (isOverspeed) { return(false); } } // 该速度以上必踩刹车 if (OverSpeedMustBrake > 0) { var isOverspeed = CarSignalSet.Current.SpeedInKmh > OverSpeedMustBrake; Logger.InfoFormat("{0}-{1}-{2}-该速度以上必踩刹车-{3}:{4}", Name, StartDistance, StartTime, isOverspeed, OverSpeedMustBrake); if (isOverspeed) { var hasBrake = CarSignalSet.Query(StartTime).Any(x => x.Sensor.Brake); if (!hasBrake && !braked) { return(false); } } } return(true); }
protected override void StopCore() { //检测喇叭 if ((Settings.VehicleStartingLoudSpeakerDayCheck && Context.ExamTimeMode == ExamTimeMode.Day) || (Settings.VehicleStartingLoudSpeakerNightCheck && Context.ExamTimeMode == ExamTimeMode.Night)) { if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.Loudspeaker)) { BreakRule(DeductionRuleCodes.RC40208); } } //Speaker.PlayAudioAsync("sanya/itemEnd40200.wav", SpeechPriority.Highest); Logger.InfoFormat("起步结束"); base.StopCore(); }
protected void GetEngineRpmFiltering(CarSignalInfo signalInfo) { //开始100个信号不会处理,避免信号不稳定情况! if (CarSignalSet.Count < 100) { signalInfo.SpeedInKmh = signalInfo.SpeedInKmh; return; } Logger.Error("GetEngineRpmFiltering Count>100"); var SignalInfo = CarSignalSet.Skip(CarSignalSet.Count - 10).Take(10).Select(s => s.EngineRpm).ToArray(); Logger.Error("SignalInfoSensor", string.Join(",", SignalInfo)); //var SignalInfo = CarSignalSet.Select(s => s.SpeedInKmh).Take(10).ToArray(); signalInfo.EngineRpm = GetFilterVale(SignalInfo); }
protected override void ExecuteCore(CarSignalInfo signalInfo) { //乱打灯不扣分,20160323,李 ////乱打转向灯扣10分 if (!isSpeakIndicator && (CarSignalSet.Query(StartTime).Count(d => d.Sensor.LeftIndicatorLight) >= Constants.ErrorSignalCount || CarSignalSet.Query(StartTime).Count(d => d.Sensor.RightIndicatorLight) >= Constants.ErrorSignalCount)) { isSpeakIndicator = true; BreakRule(DeductionRuleCodes.RC40212); } //在准备距离不检测 if (signalInfo.Distance - StraightDrivingStartDistance < Settings.StraightDrivingPrepareDistance) { return; } //直线行驶开始时间,开始的时候记录时间 if (!StraightDrivingStartTime.HasValue) { if (signalInfo.BearingAngle.IsValidAngle()) { StraightDrivingStartOffsetAngle = signalInfo.BearingAngle; StraightDrivingStartTime = DateTime.Now; } } //如果角度无效返回不检测 if (!signalInfo.BearingAngle.IsValidAngle() || !StraightDrivingStartOffsetAngle.IsValidAngle()) { return; } if (!IsBroken_RC40301 && Settings.StraightDrivingMaxOffsetAngle > 0 && !GeoHelper.IsBetweenDiffAngle(signalInfo.BearingAngle, StraightDrivingStartOffsetAngle, Settings.StraightDrivingMaxOffsetAngle)) { IsBroken_RC40301 = true; //当偏移角度过大时触发规则 BreakRule(DeductionRuleCodes.RC40301); return; } base.ExecuteCore(signalInfo); }
/// <summary> /// 处理发动机 外接发动机线的情况 /// </summary> /// <param name="signalInfo"></param> protected virtual void ProcessEngineLine(CarSignalInfo signalInfo) { if (signalInfo.Sensor == null || !signalInfo.IsSensorValid) { if (signalInfo.Sensor == null) { Logger.WarnFormat("ProcessEngine函数,处理发动机状态时sensor==null"); } var lastSignal = CarSignalSet.FirstOrDefault(d => d.IsSensorValid && d.Sensor != null); if (lastSignal != null) { Logger.WarnFormat("ProcessEngine函数,处理发动机状态时使用上一次数据:{0}-{1},当前发动机转速:{2}-{3}", lastSignal.Sensor.Engine, lastSignal.EngineRpm, signalInfo.Sensor.Engine, signalInfo.EngineRpm); signalInfo.Sensor.Engine = lastSignal.Sensor.Engine; } else { //signalInfo.Sensor.Engine = true; } return; } //发动机信号线为高电平或者转速大于10,都认为发动机处理正常状态;否则,发动机视为熄火状态;发动机信号线延迟0.5秒,转速线延迟0.5秒 recordEngineInfo.Enqueue(signalInfo.Sensor.Engine); if (recordEngineInfo.Count > 10) { recordEngineInfo.Dequeue(); } signalInfo.Sensor.Engine = recordEngineInfo.Any(x => x == true) || signalInfo.EngineRpm > Constants.EngineRpmLimit || CarSignalSet.Take(5).Where(x => x.IsSensorValid).Any(x => x.EngineRpm > Constants.EngineRpmLimit) || signalInfo.Sensor.SpecialEngine; //signalInfo.Sensor.Engine = signalInfo.Sensor.Engine || // signalInfo.EngineRpm > Constants.EngineRpmLimit || // CarSignalSet.Take(5).Where(x => x.IsSensorValid).Any(x => x.EngineRpm > Constants.EngineRpmLimit); if (!signalInfo.Sensor.Engine) { Logger.DebugFormat("发动机熄火,当前转速:{0}", signalInfo.EngineRpm); } }
protected virtual void ProcessCarState(CarSignalInfo signalInfo) { if (signalInfo.SpeedInKmh >= Settings.ParkingValueKmh) { signalInfo.CarState = CarState.Moving; return; } var carSignal = CarSignalSet.FirstOrDefault(); if (carSignal == null) { signalInfo.CarState = CarState.Stop; return; } //跳过速度小于ParkingValue并且记录时间大于延迟停车时间 var hasMovingCarSignal = CarSignalSet.QueryCachedSeconds(Settings.ParkingDelaySeconds).Any(x => x.SpeedInKmh > Settings.ParkingValueKmh); signalInfo.CarState = hasMovingCarSignal ? CarState.Moving : CarState.Stop; }
protected override void ExecuteCore(CarSignalInfo signalInfo) { if (signalInfo.Sensor == null) { return; } //检测刹车保持时间 if (Settings.BrakeKeepTime > 0 && !isBrakeRuleSpeaked) { if (signalInfo.Sensor.Brake) { if (!startBrakeTime.HasValue) { startBrakeTime = DateTime.Now; } } else { if (!startBrakeTime.HasValue) { return; } isBrakeRuleSpeaked = true; if ((DateTime.Now - startBrakeTime.Value).TotalSeconds < Settings.BrakeKeepTime) { BreakRule(DeductionRuleCodes.RC30221); } } } //乱打转向灯扣10分 if (!isSpeakIndicator && (CarSignalSet.Query(StartTime).Count(d => d.Sensor.LeftIndicatorLight) >= Constants.ErrorSignalCount || CarSignalSet.Query(StartTime).Count(d => d.Sensor.RightIndicatorLight) >= Constants.ErrorSignalCount)) { isSpeakIndicator = true; BreakRule(DeductionRuleCodes.RC40212); } }
/// <summary> /// 处理使用的时间 /// </summary> /// <param name="signalInfo"></param> protected virtual void ProcessUsedTime(CarSignalInfo signalInfo) { if (ExamContext == null) { return; } if (ExamContext.IsExaming) { signalInfo.UsedTime = DateTime.Now - ExamContext.StartExamTime; } else { var lastSignal = CarSignalSet.FirstOrDefault(); if (lastSignal != null) { signalInfo.UsedTime = lastSignal.UsedTime; } } ExamContext.UsedTime = signalInfo.UsedTime; }
protected override void StopCore() { //喇叭检测 var hasLoudSpeaker = CarSignalSet.Query(StartTime).Any(x => x.Sensor.Loudspeaker); if (!hasLoudSpeaker) { BreakRule(DeductionRuleCodes.RC30212); } //夜间远近光交替 if (Context.ExamTimeMode == ExamTimeMode.Night) { var hasLowAndHighBeam = AdvancedSignal.CheckHighBeam(StartTime); if (!hasLowAndHighBeam) { BreakRule(DeductionRuleCodes.RC41603); } } base.StopCore(); }
protected override void ExecuteCore(CarSignalInfo signalInfo) { if (Settings.StartEngineRpm > 0 && signalInfo.EngineRpm > Settings.StartEngineRpm && !isBrokenStartEngineRpmRule) { isBrokenStartEngineRpmRule = true; BreakRule(DeductionRuleCodes.RC40210); } if (signalInfo.CarState != CarState.Moving) { return; } //检测起步警报灯延时两秒 if (startMovingCarTime != null && (DateTime.Now - startMovingCarTime.Value).TotalSeconds > 2 && Settings.IsCheckStartLightOnNight && Context.ExamTimeMode == ExamTimeMode.Night && !IsCautionLightSpeaked && CarSignalSet.Query(StartMovingTime).Any(d => d.Sensor.CautionLight)) { IsCautionLightSpeaked = true; BreakRule(DeductionRuleCodes.RC41601, DeductionRuleCodes.SRC4160105); } if (IsFirstCarMoving) { if (!startMovingCarTime.HasValue) { StartMovingTime = DateTime.Now; startMovingCarTime = DateTime.Now; return; } //座椅起步开始前验证三模 if (!CarSignalSet.Query(Context.ExamContext.StartExamTime).Any(d => d.Sensor.Seats)) { BreakRule(DeductionRuleCodes.RC40211, DeductionRuleCodes.SRC4021101); } if (!CarSignalSet.Query(Context.ExamContext.StartExamTime).Any(d => d.Sensor.ExteriorMirror)) { BreakRule(DeductionRuleCodes.RC40211, DeductionRuleCodes.SRC4021102); } if (!CarSignalSet.Query(Context.ExamContext.StartExamTime).Any(d => d.Sensor.InnerMirror)) { BreakRule(DeductionRuleCodes.RC40211, DeductionRuleCodes.SRC4021103); } IsFirstCarMoving = false; //起步左转向灯检查 if (Settings.IsCheckStartLight) { //白天只对左转向灯进行检测 //if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.LeftIndicatorLight)) //打了右转向灯进行评判 if (CarSignalSet.Query(StartTime).Count(d => d.Sensor.LeftIndicatorLight) < Constants.ErrorSignalCount || CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020501); } else { //是否提前3秒打转向灯进行检测 var isTurnLight = AdvancedCarSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!isTurnLight) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020601); } } } //夜间灯光检查 if (Settings.IsCheckStartLightOnNight && Context.ExamTimeMode == ExamTimeMode.Night && !IsCautionLightSpeaked) { //夜间起步灯光检测,打近光,关危险警报灯光 if (CarSignalSet.Query(StartTime).Count(d => d.Sensor.LowBeam) < Constants.ErrorSignalCount || CarSignalSet.Query(StartMovingTime).Any(d => d.Sensor.HighBeam)) { IsCautionLightSpeaked = true; BreakRule(DeductionRuleCodes.RC41601, DeductionRuleCodes.SRC4160105); } } //夜间远近光交替 if (Settings.StartLowAndHighBeamInNight && Context.ExamTimeMode == ExamTimeMode.Night) { if (!AdvancedCarSignal.CheckHighBeam(StartTime, 1)) { BreakRule(DeductionRuleCodes.RC41603); } } //检测是否车门未关闭起步 if (signalInfo.Sensor.Door) { BreakRule(DeductionRuleCodes.RC40202); } } //检测手刹 CheckHandbrake(signalInfo); //Logger.InfoFormat("StartEngineRpm:{0}", signalInfo.Sensor.EngineRpm); //Logger.InfoFormat("Settings:StartEngineRpm:{0}", Settings.StartEngineRpm); //检测发动机转速 //当车辆停止的时候且向前运行一段距离后,停止检测 if (signalInfo.CarState == CarState.Stop && (signalInfo.Distance - StartDistance) > 0) { StopCore(); } }
protected override void StopCore() { //达到一次速度判断 if (Settings.OvertakeSpeedOnce > 10 && IsCheckOverSpeed == false) { IsCheckOverSpeed = true; if (_reachSpeedSet.Count < 12) { CheckRule(true, DeductionRuleCodes.RC30116); } ; } //判断车辆是否返回原车道 if (Settings.OvertakeChangeLanesAngle > 0) { if (OvertakeStepState == OvertakeStep.EndChangeLanesToLeft) { BreakRule(DeductionRuleCodes.RC41408); } if (!IsSuccess) { CheckRule(true, DeductionRuleCodes.RC30103, DeductionRuleCodes.SRC3010302); } } //如果角度设置为0 只需要检测转向灯 if (Settings.OvertakeChangeLanesAngle == 0) { //TODO:海南海口版本特殊要求 其他地方不适合 //检测左转 if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.LeftIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } else { if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020604); } } //判断是否返回原车到 //检测右转 if (Settings.OvertakeBackToOriginalLane) { if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } else { if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020604); } } } } //检查喇叭 if (!IsLoudSpeakerCheck) { if (Settings.OvertakeLoudSpeakerNightCheck && Context.ExamTimeMode == ExamTimeMode.Night) { BreakRule(DeductionRuleCodes.RC30212); } if (Settings.OvertakeLoudSpeakerDayCheck && Context.ExamTimeMode == ExamTimeMode.Day) { BreakRule(DeductionRuleCodes.RC30212); } } //夜考双闪 if (Settings.OvertakeLowAndHighBeamCheck && Context.ExamTimeMode == ExamTimeMode.Night) { if (!AdvancedSignal.CheckHighBeam(StartTime)) { BreakRule(DeductionRuleCodes.RC41603); } } base.StopCore(); }
protected override void ExecuteCore(CarSignalInfo signalInfo) { if (!IsLoudSpeakerCheck && signalInfo.Sensor.Loudspeaker) { IsLoudSpeakerCheck = true; } //过滤10m //准备距离0 处理 if (!isOverPrepareDistance && Settings.OvertakePrepareDistance > 0) { //超车10米后才评判 if (signalInfo.Distance - StartDistance < Settings.OvertakePrepareDistance) { return; } if (signalInfo.BearingAngle.IsValidAngle()) { isOverPrepareDistance = true; StartAngle = signalInfo.BearingAngle; } return; } //检测是否超速 //检测打错灯,一进入就打右转 if (OvertakeStepState == OvertakeStep.None && !checkErrorLight) { //超车,第一次打的是右转右灯判错 if (signalInfo.Sensor.RightIndicatorLight || signalInfo.Sensor.LeftIndicatorLight) { checkErrorLight = true; if (signalInfo.Sensor.RightIndicatorLight) { CheckRule(true, DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } } } //TODO:以前有部分客户反馈是会2扣分得。原因不明。不知道是不是信号不稳定影响得。有时间可以打开在多次测试 2018.04.22 鲍君 if (IsCheckOverSpeed == false && ((Settings.OvertakeSpeedLimit > 0 && signalInfo.SpeedInKmh > Settings.OvertakeSpeedLimit) || (Settings.OvertakeLowestSpeed > 0 && signalInfo.SpeedInKmh < Settings.OvertakeLowestSpeed))) { IsCheckOverSpeed = true; CheckRule(true, DeductionRuleCodes.RC30116); } //达到一次速度 if (Settings.OvertakeSpeedOnce > 10) { if (signalInfo.SpeedInKmh > Settings.OvertakeSpeedOnce) { _reachSpeedSet.Enqueue(signalInfo.SpeedInKmh); } if (_reachSpeedSet.Count > 30) { _reachSpeedSet.Dequeue(); } } //检测是否低于规定速度 //Logger.InfoFormat("OverTakeTest {0}", OvertakeStepState.ToString()); //检测开始超车转向角度 //如果角度大于0 if (Settings.OvertakeChangeLanesAngle > 0) { if (OvertakeStepState == OvertakeStep.None) { if (signalInfo.BearingAngle.IsValidAngle() && !GeoHelper.IsBetweenDiffAngle(signalInfo.BearingAngle, StartAngle, Settings.OvertakeChangeLanesAngle)) { //设置开始变道时的距离(由于评判转向灯太快,所以延后大概1秒) if (!StartChangingLanesDistance.HasValue) { StartChangingLanesDistance = signalInfo.Distance; } //变道摆正10米后才开始评判 if (signalInfo.Distance - StartChangingLanesDistance.Value < 10) { return; } //设置开始变道时的距离 OvertakeStepState = OvertakeStep.StartChangeLanesToLeft; if (Settings.OvertakeLightCheck && !IsCheckedOvertakeLeftLight) { IsCheckedOvertakeLeftLight = true; //超车,左转向灯,或者右灯判错 if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.LeftIndicatorLight)) { CheckRule(true, DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } else { if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020604); } } } //判断一下是否有点客户不需要返回原车道 } } else if (OvertakeStepState == OvertakeStep.StartChangeLanesToLeft) { //当开始变道后向前行驶15米则认为变道成功 if (signalInfo.Distance - StartChangingLanesDistance >= OvertakeChangingLanesSuccessOrBackToOriginalLanceDistance && signalInfo.BearingAngle.IsValidAngle()) { //路径 // OvertakeStepState = OvertakeStep.EndChangeLanesToLeft; StartChangeLanesAngle = signalInfo.BearingAngle; //如果设置了不需要返回原车道 if (!Settings.OvertakeBackToOriginalLane) { OvertakeStepState = OvertakeStep.EndChangeLanesToRight; } else { Speaker.PlayAudioAsync(Settings.OvertakeBackToOriginalLaneVocie); } } } else if (OvertakeStepState == OvertakeStep.EndChangeLanesToLeft) { if (signalInfo.BearingAngle.IsValidAngle() && !GeoHelper.IsBetweenDiffAngle(signalInfo.BearingAngle, StartChangeLanesAngle, Settings.OvertakeChangeLanesAngle)) { OvertakeStepState = OvertakeStep.EndChangeLanesToRight; if (Settings.OvertakeLightCheck && !IsCheckedOvertakeRightLight) { IsCheckedOvertakeRightLight = true; if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } else { if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020506); } } } } } else if (OvertakeStepState == OvertakeStep.EndChangeLanesToRight) { //结束考试项目 //StopCore(); IsSuccess = true; return; } } else { //表示客户其实只关心打灯问题 //简单的处理 如果打右转灯之前没有打过左转灯则扣分 if (signalInfo.Sensor.RightIndicatorLight && !IsCheckedOvertakeLeftLight) { //如果没有打左转灯就扣分 if (!AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, StartTime, Settings.TurnLightAheadOfTime)) { //CheckRule(true, DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); //只有泸州版本才这样 //todo:之所以不分出来 是觉得其实全国所有的版本都可以这样做 if (DataBase.VersionNumber.Contains("泸州")) { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020506); } else { BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); } // BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020504); IsCheckedOvertakeLeftLight = true; } } // if (signalInfo.Sensor.RightIndicatorLight) // { // IsCheckedOvertakeLeftLight = true; // CheckRule(tru IsSuccess = true; } base.ExecuteCore(signalInfo); }
public override RuleExecutionResult Check(CarSignalInfo signalInfo) { if (signalInfo == null) { return(RuleExecutionResult.Continue); } var oldSignal = CarSignalSet.Skip(1).FirstOrDefault(); if (oldSignal == null) { return(RuleExecutionResult.Continue); } //等待播放语音 if (WaitingForPlayingVoice()) { return(RuleExecutionResult.Continue); } //评定是否超时 if (!StartDateTime.HasValue) { StartDateTime = DateTime.Now; return(RuleExecutionResult.Continue); } else if (IsTimeout()) { string str = string.Format("{0}-灯光超时:{1},起始时间:{2:yyyy-MM-dd HH-mm-ss}", Name, LightTimeout, StartDateTime); Logger.Info(str); if (!TimeoutRuleCheck(signalInfo.Sensor)) { BreakRule(); } return(RuleExecutionResult.Break); } //如果灯光有错误 if (_hasLightError) { //等待一段时间后,返回错误; if (WaitLightInterval()) { return(RuleExecutionResult.Continue); } else { return(RuleExecutionResult.Break); } } var oldSensor = oldSignal.Sensor; var newSensor = signalInfo.Sensor; var changedProperties = GetLightChangedProperties(oldSensor, newSensor); Logger.Info("changedProperties:", changedProperties.ToJson().ToString()); if (changedProperties.Count > 0) { var hasErrorLights = HasErrorLights(changedProperties, newSensor); Logger.Info("HasErrorLights:", hasErrorLights.ToString()); if (hasErrorLights) { BreakRule(); _hasLightError = true; Logger.InfoFormat("{0}-灯光错误:当前灯光,上一个灯光:{1}", Name, string.Join(", ", changedProperties, newSensor.ToJson(), oldSensor.ToJson())); return(RuleExecutionResult.Break); } else { var result = CheckLights(changedProperties, newSensor); //等待一定的间隔 Logger.Info("NoErrorLightsResult" + result.ToString()); if (result && !WaitLightInterval()) { Logger.Info(Name + "判定灯光成功"); //判定成功之后还需要判断是否关闭所有的灯光 return(RuleExecutionResult.Finish); } } } else { var result = CheckLights(changedProperties, newSensor); //等待一定的间隔 Logger.Info("Result" + result.ToString()); if (result && !WaitLightInterval()) { Logger.Info(Name + "判定灯光成功"); //判定成功之后还需要判断是否关闭所有的灯光 return(RuleExecutionResult.Finish); } } return(RuleExecutionResult.Continue); }
protected void ChangeLineAngleCheck(CarSignalInfo signalInfo) { //由于停车和起步的时候会报触发规则,所以过滤 //全程变道最低速度 if (signalInfo.SpeedInKmh < 10) { return; } //过滤掉变更车道和会车,超车,掉头,左转,右转,起步,靠边停车 if (tempExamitemSkip) { return; } //因为掉头,变道,角度达到就结束了,太快,所以延迟15s if (tempExamItem && finishTime.HasValue) { if ((DateTime.Now - finishTime.Value).TotalSeconds > 15) { finishTime = null; tempExamItem = false; StartChangeLanesAngle = signalInfo.BearingAngle; } else { return; } } //播报后进行延时 if (IsChangeLineSpeak) { if ((DateTime.Now - delayDateTime).TotalSeconds > 12) { IsChangeLineSpeak = false; //重置角度 RecordSignalCount = 0; RecordSignalTime = DateTime.Now; StartChangeLanesAngle = signalInfo.BearingAngle; } else { //重置角度 RecordSignalCount = 0; RecordSignalTime = DateTime.Now; StartChangeLanesAngle = signalInfo.BearingAngle; return; } } RecordSignalCount++; if (!RecordSignalTime.HasValue) { RecordSignalTime = DateTime.Now; } //过滤掉大于30度的跳动 if (GeoHelper.GetDiffAngle(StartChangeLanesAngle, signalInfo.BearingAngle) > 30) { StartChangeLanesAngle = signalInfo.BearingAngle; return; } //判断车辆是否在进行变道 if ((DateTime.Now - RecordSignalTime.Value).TotalSeconds >= Settings.CommonExamItemsChangeLanesTimeOut && IsChangeLineSpeak == false && signalInfo.BearingAngle.IsValidAngle() && StartChangeLanesAngle.IsValidAngle() && !GeoHelper.IsBetweenDiffAngle(signalInfo.BearingAngle, StartChangeLanesAngle, Settings.CommonExamItemsChangeLanesAngle)) { //if (!signalInfo.Sensor.LeftIndicatorLight || !signalInfo.Sensor.RightIndicatorLight) if (!CarSignalSet.Query(DateTime.Now - TimeSpan.FromSeconds(12)).Any(d => d.Sensor.LeftIndicatorLight || d.Sensor.RightIndicatorLight)) { delayDateTime = DateTime.Now; IsChangeLineSpeak = true; RecordSignalCount = 0; RecordSignalTime = null; StartChangeLanesAngle = signalInfo.BearingAngle; BreakRule(DeductionRuleCodes.RC30205, DeductionRuleCodes.SRC3020503); } else { delayDateTime = DateTime.Now; IsChangeLineSpeak = true; //转向灯是否超过3秒,检测12秒前 var leftLight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.LeftIndicatorLight, DateTime.Now - TimeSpan.FromSeconds(12), Settings.TurnLightAheadOfTime);; if (leftLight) { return; } var rightLight = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, DateTime.Now - TimeSpan.FromSeconds(12), Settings.TurnLightAheadOfTime);; if (rightLight) { return; } BreakRule(DeductionRuleCodes.RC30206, DeductionRuleCodes.SRC3020603); } } if (RecordSignalTime != null && (DateTime.Now - RecordSignalTime.Value).TotalSeconds > Settings.CommonExamItemsChangeLanesTimeOut) { //重置角度 RecordSignalTime = null; StartChangeLanesAngle = signalInfo.BearingAngle; } }
//TODO:关闭所有灯光的规则修改 只有超时才会判 public override RuleExecutionResult Check(CarSignalInfo signalInfo) { if (signalInfo == null) { return(RuleExecutionResult.Continue); } var oldSignal = CarSignalSet.Skip(1).FirstOrDefault(); if (oldSignal == null) { return(RuleExecutionResult.Continue); } //等待播放语音 if (WaitingForPlayingVoice()) { return(RuleExecutionResult.Continue); } //评定是否超时 //估计是超时 if (!StartDateTime.HasValue) { StartDateTime = DateTime.Now; return(RuleExecutionResult.Continue); } else if (IsTimeout()) { string str = string.Format("{0}-灯光超时:{1},起始时间:{2:yyyy-MM-dd HH-mm-ss}", Name, LightTimeout, StartDateTime); // Logger.Info(str); if (!TimeoutRuleCheck(signalInfo.Sensor)) { BreakRule(); } return(RuleExecutionResult.FinishExamItem); } //如果灯光有错误 if (_hasLightError) { //等待一段时间后,返回错误; if (WaitLightInterval()) { return(RuleExecutionResult.Continue); } else { return(RuleExecutionResult.FinishExamItem); } } var oldSensor = oldSignal.Sensor; var newSensor = signalInfo.Sensor; var changedProperties = GetLightChangedProperties(oldSensor, newSensor); // Logger.InfoFormat(changedProperties.ToString()); var result = CheckLights(changedProperties, newSensor); //等待一定的间隔 Logger.Info("Result" + result.ToString()); if (result) { Logger.Info(Name + "判定灯光成功"); //判定成功之后还需要判断是否关闭所有的灯光 return(RuleExecutionResult.FinishExamItem); } return(RuleExecutionResult.Continue); }
protected override void ExecuteCore(CarSignalInfo signalInfo) { if ((int)PullOverStepState >= (int)PullOverStep.StopCar) { if (!isSpeakHandBrake && signalInfo.Sensor.Handbrake) { isSpeakHandBrake = true; //请操作完成后下车 Speaker.PlayAudioAsync("请操作完成后下车", SpeechPriority.Normal); } } if (PullOverStepState == PullOverStep.None) { ///拉手刹结束启动靠边停车检测 if (signalInfo.Sensor.Handbrake) { PullOverStepState = PullOverStep.StopCar; StopCarTime = DateTime.Now; Messenger.Send(new EngineRuleMessage(false)); Logger.DebugFormat("{0}-关闭发动机熄火评判规则", Name); } } else if (PullOverStepState == PullOverStep.StopCar) { //停车转向灯检查 PullOverStepState = PullOverStep.OpenPullOverLight; if (!CarSignalSet.Query(StartTime).Any(d => d.Sensor.RightIndicatorLight)) { BreakRule(DeductionRuleCodes.RC40610); } else { var rightIndicator = AdvancedSignal.CheckOperationAheadSeconds(x => x.Sensor.RightIndicatorLight, StartTime, Settings.TurnLightAheadOfTime); if (!rightIndicator) { BreakRule(DeductionRuleCodes.RC40611); } } } else if (PullOverStepState == PullOverStep.OpenPullOverLight) { CheckHandbrake(signalInfo); } else if (PullOverStepState == PullOverStep.PullHandbrake) { //判断靠边停车是否结束 CheckEndMark(signalInfo); } else if (PullOverStepState == PullOverStep.CheckStop) { if (!_isCheckedPulloverStop) { _isCheckedPulloverStop = true; CheckPullOverStop(signalInfo); } if (!(Settings.PullOverEndMark == PullOverEndMark.None || Settings.PullOverEndMark == PullOverEndMark.OpenCloseDoorCheck)) { StopCore(); return; } if (!OpenDoorTime.HasValue) { OpenDoorTime = DateTime.Now; } if (!signalInfo.Sensor.Door) { PullOverStepState = PullOverStep.CloseDoor; Messenger.Send(new DoorChangedMessage(signalInfo.Sensor.Door)); StopCore(); return; } //在规定的时间内没有关闭车门 if (CloseDoorTimeOut()) { BreakRule(DeductionRuleCodes.RC40605); StopCore(); } } }