MazdaApiLib/MazdaApiVehicleStatus.cs
/// <summary>
/// Get the simplified vehicle status information from the API asynchronously.
/// </summary>
/// <param name="internalVin">The internal vehicle identity number for the vehicle which can be found with calls to methods that return vehicles</param>
/// <returns>A VehicleStatus</returns>
Get the simplified vehicle status information from the API asynchronously.
Get the simplified vehicle status information from the API asynchronously .
public async Task<VehicleStatus> GetVehicleStatusAsync(string internalVin)
        {
            MazdaApiRawVehicleStatus rawStatus = await GetRawVehicleStatusAsync(internalVin);
            AlertInfo alertInfo = rawStatus.AlertInfos[0];
            RemoteInfo remoteInfo = rawStatus.RemoteInfos[0];
            VehicleStatus retval = new VehicleStatus
            {
                LastUpdatedTimestamp = alertInfo.OccurrenceDate,
                Latitude = remoteInfo.PositionInfo.Latitude * (remoteInfo.PositionInfo.LatitudeFlag ? -1 : 1),
                Longitude = remoteInfo.PositionInfo.Longitude * (remoteInfo.PositionInfo.LongitudeFlag ? 1 : -1),
                PositionTimestamp = remoteInfo.PositionInfo.AcquisitionDatetime,
                FuelRemainingPercent = remoteInfo.ResidualFuel.FuelSegementDActl,
                FuelDistanceRemainingKm = remoteInfo.ResidualFuel.RemDrvDistDActlKm,
                OdometerKm = remoteInfo.DriveInformation.OdoDispValue,
                Doors = new Doors
                {
                    DriverDoorOpen = alertInfo.Door.DrStatDrv == 1,
                    PassengerDoorOpen = alertInfo.Door.DrStatPsngr == 1,
                    RearLeftDoorOpen = alertInfo.Door.DrStatRl == 1,
                    RearRightDoorOpen = alertInfo.Door.DrStatRr == 1,
                    TrunkOpen = alertInfo.Door.DrStatTrnkLg == 1,
                    HoodOpen = alertInfo.Door.DrStatHood == 1,
                    FuelLidOpen = alertInfo.Door.FuelLidOpenStatus == 1
                },
                DoorLocks = new DoorLocks
                {
                    DriverDoorUnlocked = alertInfo.Door.LockLinkSwDrv == 1,
                    PassengerDoorUnlocked = alertInfo.Door.LockLinkSwPsngr == 1,
                    RearLeftDoorUnlocked = alertInfo.Door.LockLinkSwRl == 1,
                    RearRightDoorUnlocked = alertInfo.Door.LockLinkSwRr == 1
                },
                Windows = new Windows
                {
                    DriverWindowOpen = alertInfo.Pw.PwPosDrv == 1,
                    PassengerWindowOpen = alertInfo.Pw.PwPosPsngr == 1,
                    RearLeftWindowOpen = alertInfo.Pw.PwPosRl == 1,
                    RearRightWindowOpen = alertInfo.Pw.PwPosRr == 1
                },
                HazardLightsOn = alertInfo.HazardLamp.HazardSw == 1,
                TirePressure = new TirePressure
                {
                    FrontLeftTirePressurePsi = remoteInfo.TpmsInformation.FltPrsDispPsi,
                    FrontRightTirePressurePsi = remoteInfo.TpmsInformation.FrtPrsDispPsi,
                    RearLeftTirePressurePsi = remoteInfo.TpmsInformation.RltPrsDispPsi,
                    RearRightTirePressurePsi = remoteInfo.TpmsInformation.RrtPrsDispPsi
                }
            };
            CachedLockState lockState = GetCachedLockState(internalVin);
            lockState.ApiLockTimestamp = retval.LastUpdatedTimestamp;
            lockState.ApiLockState = !(retval.DoorLocks.DriverDoorUnlocked || retval.DoorLocks.PassengerDoorUnlocked || retval.DoorLocks.RearLeftDoorUnlocked || retval.DoorLocks.RearRightDoorUnlocked);
            return retval;
        }
public async Task < VehicleStatus > GetVehicleStatusAsync ( string internalVin ) { MazdaApiRawVehicleStatus rawStatus = await GetRawVehicleStatusAsync ( internalVin ) ; AlertInfo alertInfo = rawStatus . AlertInfos [ 0 ] ; RemoteInfo remoteInfo = rawStatus . RemoteInfos [ 0 ] ; VehicleStatus retval = new VehicleStatus { LastUpdatedTimestamp = alertInfo . OccurrenceDate , Latitude = remoteInfo . PositionInfo . Latitude * ( remoteInfo . PositionInfo . LatitudeFlag ? - 1 : 1 ) , Longitude = remoteInfo . PositionInfo . Longitude * ( remoteInfo . PositionInfo . LongitudeFlag ? 1 : - 1 ) , PositionTimestamp = remoteInfo . PositionInfo . AcquisitionDatetime , FuelRemainingPercent = remoteInfo . ResidualFuel . FuelSegementDActl , FuelDistanceRemainingKm = remoteInfo . ResidualFuel . RemDrvDistDActlKm , OdometerKm = remoteInfo . DriveInformation . OdoDispValue , Doors = new Doors { DriverDoorOpen = alertInfo . Door . DrStatDrv == 1 , PassengerDoorOpen = alertInfo . Door . DrStatPsngr == 1 , RearLeftDoorOpen = alertInfo . Door . DrStatRl == 1 , RearRightDoorOpen = alertInfo . Door . DrStatRr == 1 , TrunkOpen = alertInfo . Door . DrStatTrnkLg == 1 , HoodOpen = alertInfo . Door . DrStatHood == 1 , FuelLidOpen = alertInfo . Door . FuelLidOpenStatus == 1 } , DoorLocks = new DoorLocks { DriverDoorUnlocked = alertInfo . Door . LockLinkSwDrv == 1 , PassengerDoorUnlocked = alertInfo . Door . LockLinkSwPsngr == 1 , RearLeftDoorUnlocked = alertInfo . Door . LockLinkSwRl == 1 , RearRightDoorUnlocked = alertInfo . Door . LockLinkSwRr == 1 } , Windows = new Windows { DriverWindowOpen = alertInfo . Pw . PwPosDrv == 1 , PassengerWindowOpen = alertInfo . Pw . PwPosPsngr == 1 , RearLeftWindowOpen = alertInfo . Pw . PwPosRl == 1 , RearRightWindowOpen = alertInfo . Pw . PwPosRr == 1 } , HazardLightsOn = alertInfo . HazardLamp . HazardSw == 1 , TirePressure = new TirePressure { FrontLeftTirePressurePsi = remoteInfo . TpmsInformation . FltPrsDispPsi , FrontRightTirePressurePsi = remoteInfo . TpmsInformation . FrtPrsDispPsi , RearLeftTirePressurePsi = remoteInfo . TpmsInformation . RltPrsDispPsi , RearRightTirePressurePsi = remoteInfo . TpmsInformation . RrtPrsDispPsi } } ; CachedLockState lockState = GetCachedLockState ( internalVin ) ; lockState . ApiLockTimestamp = retval . LastUpdatedTimestamp ; lockState . ApiLockState = ! ( retval . DoorLocks . DriverDoorUnlocked || retval . DoorLocks . PassengerDoorUnlocked || retval . DoorLocks . RearLeftDoorUnlocked || retval . DoorLocks . RearRightDoorUnlocked ) ; return retval ; }
Get the simplified vehicle status information from the API asynchronously.
Get the simplified vehicle status information from the API asynchronously .
None
internalVin
string
The internal vehicle identity number for the vehicle which can be found with calls to methods that return vehicles
The internal vehicle identity number for the vehicle which can be found with calls to methods that return vehicles