예제 #1
0
 public GraphDatum GetGraphDatum()
 {
     return(new GraphDatum
     {
         TripId = -1,
         Date = new DateTimeOffset(DateTime.Now),
         LostEnergy = (float)LostEnergyList.Sum(),
         ConvertLoss = (float)ConvertLossList.Sum(),
         AirResistance = (float)AirResistanceList.Sum(),
         RollingResistance = (float)RollingResistanceList.Sum(),
         RegeneLoss = (float)RegeneLossList.Sum(),
         TransitTime = (int)(PositionCollection.Last().Timestamp -
                             PositionCollection.First().Timestamp).TotalSeconds,
     });
 }
예제 #2
0
        private void CalcEcolog(int count)
        {
            if (count == 2)
            {
                _altitudeBefore = AltitudeCalculator.CalcAltitude(PositionCollection[count - 1].Latitude, PositionCollection[count - 1].Longitude);
                //Debug.WriteLine("AltitudeBefore: " + _altitudeBefore.Altitude);
            }
            else if (PositionCollection.Count > 2)
            {
                var positionBefore  = PositionCollection[count - 3];
                var positionCurrent = PositionCollection[count - 2];
                var positionAfter   = PositionCollection[count - 1];

                var distanceDiff = DistanceCalculator.CalcDistance(positionBefore.Latitude,
                                                                   positionBefore.Longitude,
                                                                   positionCurrent.Latitude,
                                                                   positionCurrent.Longitude);
                //Debug.WriteLine("DistanceDiff: " + distanceDiff);

                // meter per sec
                var speed = SpeedCalculator.CalcSpeed(positionBefore.Latitude,
                                                      positionBefore.Longitude,
                                                      positionBefore.Timestamp.DateTime,
                                                      positionAfter.Latitude,
                                                      positionAfter.Longitude,
                                                      positionAfter.Timestamp.DateTime,
                                                      positionCurrent.Latitude,
                                                      positionCurrent.Longitude) / 3.6;
                //Debug.WriteLine("Speed: " + speed * 3.6);

                if (count == 3)
                {
                    _speedBefore = speed;
                }

                var altitude = AltitudeCalculator.CalcAltitude(positionCurrent.Latitude, positionCurrent.Longitude);
                //var altitude = new AltitudeDatum { Altitude = 40 };
                double altitudeDiff = 0;
                if (altitude != null && _altitudeBefore != null)
                {
                    altitudeDiff = altitude.Altitude - _altitudeBefore.Altitude;
                }
                _altitudeBefore = altitude;
                //Debug.WriteLine("AltitudeDiff: " + altitudeDiff);

                double airResistancePower = 0;
                if (speed > 1.0 / 3.6 && distanceDiff > 0)
                {
                    airResistancePower = AirResistanceCalculator.CalcPower(
                        Constants.Rho, Car.GetLeaf().CdValue, Car.GetLeaf().FrontalProjectedArea, speed, speed);
                }
                //Debug.WriteLine("AirResistace: " + airResistancePower);

                double rollingResistancePower = 0;
                if (speed > 1.0 / 3.6 && distanceDiff > 0)
                {
                    rollingResistancePower = RollingResistanceCalculator.CalcPower(
                        Constants.Myu, Car.GetLeaf().Weight, Math.Atan(altitudeDiff / distanceDiff), speed);
                }
                //Debug.WriteLine("rollingResistancePower: " + rollingResistancePower);

                double climbingResistancePower = 0;
                if (speed > 1.0 / 3.6 && distanceDiff > 0)
                {
                    climbingResistancePower = ClimbingResistanceCalculator.CalcPowerPreVer(
                        Car.GetLeaf().Weight, altitudeDiff);
                }
                //Debug.WriteLine("climbingResistancePower: " + climbingResistancePower);

                double accResistancePower = 0;
                if (speed > 1.0 / 3.6 && distanceDiff > 0)
                {
                    accResistancePower = AccResistanceCalculator.CalcPower(
                        _speedBefore,
                        positionBefore.Timestamp.DateTime,
                        speed,
                        positionCurrent.Timestamp.DateTime,
                        Car.GetLeaf().Weight);
                }
                //Debug.WriteLine("accResistancePower: " + accResistancePower);

                double drivingResistancePower =
                    airResistancePower + rollingResistancePower + climbingResistancePower + accResistancePower;

                double torque = 0;
                if (drivingResistancePower > 0 && speed > 0)
                {
                    torque = drivingResistancePower * 1000 * 3600 / speed * Car.GetLeaf().TireRadius /
                             Car.GetLeaf().ReductionRatio;
                }
                //Debug.WriteLine("torque: " + torque);

                var efficiency = EfficiencyCalculator.CalcEfficiency(Car.GetLeaf(), speed, torque).Efficiency;
                //var efficiency = 90;
                //Debug.WriteLine("efficiency: " + efficiency);

                double convertLoss = ConvertLossCalculator.CalcEnergyPreVer(
                    drivingResistancePower, speed, efficiency);
                //Debug.WriteLine("convertLoss: " + convertLoss);

                double regeneEnergy = RegeneEnergyCalculator.CalcEnergy(drivingResistancePower,
                                                                        speed, Car.GetLeaf(), efficiency);
                //Debug.WriteLine("regeneEnergy: " + regeneEnergy);

                double regeneLoss = RegeneLossCalculator.CalcEnergyPreVer(drivingResistancePower, speed, efficiency);
                //Debug.WriteLine($"{positionCurrent.Timestamp.DateTime}: {regeneLoss}, {efficiency}");

                double lostEnergy = LostEnergyCalculator.CalcEnergy(convertLoss, regeneLoss, airResistancePower,
                                                                    rollingResistancePower);
                //Debug.WriteLine("LostEnergy: " + lostEnergy);

                _speedBefore = speed;

                //var consumedEnergy = ConsumedEnergyCaluculator.CalcEnergy(drivingResistancePower, Car.GetLeaf(), speed, efficiency);

                //Debug.WriteLine($"Efficiency: {efficiency}, CalcEfficiency: {(consumedEnergy / convertLoss) * 100}");

                LostEnergyList.Add(lostEnergy);
                AirResistanceList.Add(airResistancePower);
                RollingResistanceList.Add(rollingResistancePower);
                ConvertLossList.Add(Math.Abs(convertLoss));
                RegeneLossList.Add(Math.Abs(regeneLoss));
            }
        }