Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="target">has to be in range[0, 100][%]</param>
        public void SetTarget(double target)
        {
            if (Limiter.LimitAndReturnTrueIfLimitted(ref target, 0, 100))
            {
                Logger.Log(this, "target brake is not in range [0, 100]", 1);
            }

            double calculatedSteering;

            if (alertBrakeActive)
            {
                calculatedSteering = regulator.SetTargetValue(ALERT_BRAKE_BRAKE_SETTING);
            }
            else if (stopModeOn)
            {
                calculatedSteering = regulator.SetTargetValue(100);
            }
            else
            {
                calculatedSteering = regulator.SetTargetValue(target);
            }

            //this will also invoke evNewBrakeSettingCalculated event
            BrakeSteering = calculatedSteering;
        }
        void car_evTargetSteeringWheelAngleChanged(object sender, TargetSteeringWheelAngleChangedEventArgs args)
        {
            double calculatedSteering = regulator.SetTargetValue(args.GetTargetWheelAngle());

            NewSteeringWheelSettingCalculatedEventHandler newWheelSteeringCalculatedEvent = evNewSteeringWheelSettingCalculated;

            if (newWheelSteeringCalculatedEvent != null)
            {
                newWheelSteeringCalculatedEvent(this, new NewSteeringWheelSettingCalculateddEventArgs(calculatedSteering));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// depending on what is target speed it can have different meanings
        /// speed >> 0 ---> going forward
        /// speed ~= 0 ---> stand still mode
        /// speed << 0 ---> going backward
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void Car_evTargetSpeedChanged(object sender, TargetSpeedChangedEventArgs args)
        {
            targetSpeedLocalCopy = args.GetTargetSpeed();
            Logger.Log(this, String.Format("target speed changed to: {0}", args.GetTargetSpeed()));

            if (targetSpeedLocalCopy <= MAX_STAND_STILL_SPEED_IN_MPS && targetSpeedLocalCopy >= MIN_STAND_STILL_SPEED_IN_MPS)
            {
                Mode = RideMode.standStill;
            }
            else if (targetSpeedLocalCopy > MAX_STAND_STILL_SPEED_IN_MPS)
            {
                Mode = RideMode.forward;
            }
            else //if targetSpeedLocalCopy < MIN_STAND_STILL_SPEED_IN_MPS
            {
                Mode = RideMode.backward;
            }

            //this setter also sends event "evNewSpeedSettingCalculated"
            SpeedSteering = regulator.SetTargetValue(targetSpeedLocalCopy);
        }