Exemplo n.º 1
0
 private void _fillFictiveTrackData(TrackInfo track) {
    track.BatteryCapacity = 22;
    var dist = track.OdometerEnd - track.OdometerStart;
    if (dist.IsPositive()) {
       track.EstimatedDistance = (1.05 - _rand.NextDouble() * 0.1) * dist;
    }
    var ticks = (track.ActualEndTime - track.ActualStartTime).Ticks;
    if (ticks > 0) {
       track.EstimatedEndTime = track.ActualEndTime + TimeSpan.FromTicks((long)((0.05 - _rand.NextDouble() * 0.1) * ticks));
    }
 }
Exemplo n.º 2
0
 private TrackInfo _initializeTrackInfo(DbRecord record) {
    var newTrackInfo = new TrackInfo();
    newTrackInfo.ActivityId = record.GetString("ActivityId");
    newTrackInfo.VehicleKey = record.GetString("VehicleKey");
    newTrackInfo.DriverId = record.GetString("DriverId");
    newTrackInfo.BatteryKey = record.GetString("BatteryKey");
    newTrackInfo.OdometerStart = record.GetDouble("Odometer");
    newTrackInfo.ActualStartEnergy = record.GetDouble("Bat_Energy");
    newTrackInfo.ActualStartTime = record.GetDateTime("TimeStamp");
    var estimations = record.GetString("EndEstimations");
    _extractEstimations(newTrackInfo, estimations);
    return newTrackInfo;
 }
Exemplo n.º 3
0
 private void _extractEstimations(TrackInfo trackInfo, string estimations) {
    trackInfo.EstimatedEndTime = DateTimeOffset.MinValue;
    if (estimations.IsEmpty()) return;
    var Est = estimations.Split(";");
    try {
       trackInfo.EstimatedEndTime = DateTimeOffset.Parse(Est[0]);
    } catch { }
    try {
       trackInfo.EstimatedEndEnergy = Double.Parse(Est[1]);
    } catch { }
    try {
       trackInfo.EstimatedDistance = Double.Parse(Est[2]);
    } catch { }
 }
Exemplo n.º 4
0
 private void _finalizeTrackInfo(TrackInfo trackInfo, DbRecord record, int SegmentCount) {
    trackInfo.OdometerEnd = record.GetDouble("Odometer");
    trackInfo.ActualEndEnergy = record.GetDouble("Bat_Energy");
    trackInfo.EstimatedEndEnergy = record.GetDouble("DrvEst_Eea");
    trackInfo.ActualEndTime = record.GetDateTime("TimeStamp");
    trackInfo.SegmentCount = SegmentCount;
 }
Exemplo n.º 5
0
 private void _aggregateTrackInfo(TrackInfo trackInfo, DbRecord record) {
    var length = record.GetDouble("Seg_Length");
    trackInfo.TrackDistance += length;
    if (!(record.IsNull("Seg_Slope"))) {
       var slope = record.GetDouble("Seg_Slope");
       var index = (int)(Math.Round(Math.Atan(slope).ToDegrees().Limit(-10, 10) / 1.0)) + 10;
       trackInfo.Elevations[index] += length;
    }
 }
Exemplo n.º 6
0
 public static TrackInfo Parse(string input, PropertyInfo[] fields) {
    var track = new TrackInfo();
    var tokens = input.Split("\t");
    if (fields == null) fields = _fields;
    for (var i = 0; i < fields.Length; i++) {
       var field = fields[i];
       var dtype = field.PropertyType;
       var token = tokens[i];
       if (token.IsEmpty()) continue;
       object value = null;
       if (dtype.IsA<string>()) {
          value = token;
       } else if (dtype.IsA<bool>()) {
          value = Boolean.Parse(token);
       } else if (dtype.IsA<int>()) {
          value = Int32.Parse(token);
       } else if (dtype.IsA<double>()) {
          value = Double.Parse(token);
       } else if (dtype.IsA<double[]>()) {
          value = _parseDoubles(token);
       } else if (dtype.IsA<DateTimeOffset>()) {
          value = DateTimeOffset.Parse(token);
       }
       if (value != null) {
          field.SetValue(track, value, null);
       }
    }
    return track;
 }