Ejemplo n.º 1
0
        public async Task <AlignedTripData> GetTripDataAligned(Guid deviceId, PrimitiveDataPoints dataPoints, DateTimeOffset?start = null, DateTimeOffset?end = null, string interval = "1m", CancellationToken cancellationToken = default(CancellationToken))
        {
            var data = await GetTripData(deviceId, dataPoints, start, end, interval, cancellationToken);

            var aligned = new AlignedTripData()
            {
                DeviceId            = deviceId,
                Start               = start.Value,
                End                 = end.Value,
                PrimitiveDataPoints = dataPoints,
                AlignedDataPoints   = new List <TripDataPoint>()
            };

            if (dataPoints.HasFlag(PrimitiveDataPoints.Voltage))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.Voltage, PrimitiveDataPoints.Voltage);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.CoolantTemp))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.CoolantTemp, PrimitiveDataPoints.CoolantTemp);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.EngineLoad))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.EngineLoad, PrimitiveDataPoints.EngineLoad);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.FuelLevel))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.FuelLevel, PrimitiveDataPoints.FuelLevel);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.FuelRate))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.FuelRate, PrimitiveDataPoints.FuelRate);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.IntakeTemp))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.IntakeTemp, PrimitiveDataPoints.IntakeTemp);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.Position))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.Position, PrimitiveDataPoints.Position);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.RpiTemperature))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.RpiTemperature, PrimitiveDataPoints.RpiTemperature);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.Speed))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.Speed, PrimitiveDataPoints.Speed);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.AccelerometerX))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.AccelerometerX, PrimitiveDataPoints.AccelerometerX);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.AccelerometerY))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.AccelerometerY, PrimitiveDataPoints.AccelerometerY);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.AccelerometerZ))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.AccelerometerZ, PrimitiveDataPoints.AccelerometerZ);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.Altitude))
            {
                aligned.AlignedDataPoints = AlignData(aligned.AlignedDataPoints, data.Altitude, PrimitiveDataPoints.Altitude);
            }
            return(aligned);
        }
Ejemplo n.º 2
0
        public async Task <TripData> GetTripData(Guid deviceId, PrimitiveDataPoints dataPoints, DateTimeOffset?start = null, DateTimeOffset?end = null, string interval = "1m", CancellationToken cancellationToken = default(CancellationToken))
        {
            if (start == null || start >= DateTimeOffset.UtcNow)
            {
                start = DateTimeOffset.UtcNow.AddDays(-1);
            }
            if (end == null || end >= DateTimeOffset.UtcNow)
            {
                end = DateTimeOffset.UtcNow;
            }
            var data = new TripData()
            {
                Start               = start.Value,
                End                 = end.Value,
                DeviceId            = deviceId,
                PrimitiveDataPoints = dataPoints
            };

            if (dataPoints.HasFlag(PrimitiveDataPoints.Position))
            {
                data.Position = await GetPositionData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.CoolantTemp))
            {
                data.CoolantTemp = await GetEngineCoolantTemperatureData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.EngineLoad))
            {
                data.EngineLoad = await GetEngineLoadLevelsData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.FuelLevel))
            {
                data.FuelLevel = await GetFuelLevelData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.FuelRate))
            {
                data.FuelRate = await GetFuelRateData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.IntakeTemp))
            {
                data.IntakeTemp = await GetIntakeTempData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.RpiTemperature))
            {
                data.RpiTemperature = await GetRpiTemperatureData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.Speed))
            {
                data.Speed = await GetSpeedData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.Voltage))
            {
                data.Voltage = await GetVoltageData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.AccelerometerX))
            {
                data.AccelerometerX = await GetAccelerometerXData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.AccelerometerY))
            {
                data.AccelerometerY = await GetAccelerometerYData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.AccelerometerZ))
            {
                data.AccelerometerZ = await GetAccelerometerZData(deviceId, start, end, interval, cancellationToken);
            }
            if (dataPoints.HasFlag(PrimitiveDataPoints.Altitude))
            {
                data.Altitude = await GetAltitudeData(deviceId, start, end, interval, cancellationToken);
            }

            return(data);
        }