public TireReading(VehicleTireReading Reading, IVehicleTire Tire)
 {
     _parentReading = Reading;
     _currentTire = Tire;
     TireId = _currentTire.Id;
     CurrentPressure = _currentTire.GetCurrentPressure();
     Position = _currentTire.PositionNumber;
     CurrentSpeed = _currentTire.GetCurrentSpeed();
     CurrrentDistanceTraveled = _currentTire.DistanceTraveledInMiles;
     IsFlat = _currentTire.IsFlat();
     IsOverInflated = _currentTire.IsOverInflated();
     IsUnderInflated = _currentTire.IsUnderInflated();
     RelativeTireAge = _currentTire.CalcRelativeTireAge().TotalDays.ToString();
 }
Exemple #2
0
 public TireReading(VehicleTireReading Reading, IVehicleTire Tire)
 {
     _parentReading           = Reading;
     _currentTire             = Tire;
     TireId                   = _currentTire.Id;
     CurrentPressure          = _currentTire.GetCurrentPressure();
     Position                 = _currentTire.PositionNumber;
     CurrentSpeed             = _currentTire.GetCurrentSpeed();
     CurrrentDistanceTraveled = _currentTire.DistanceTraveledInMiles;
     IsFlat                   = _currentTire.IsFlat();
     IsOverInflated           = _currentTire.IsOverInflated();
     IsUnderInflated          = _currentTire.IsUnderInflated();
     RelativeTireAge          = _currentTire.CalcRelativeTireAge().TotalDays.ToString();
 }
Exemple #3
0
 private static void writeToConsole(VehicleTireReading currentReading, Car currentCar)
 {
     Console.WriteLine("ReadingId={0};Factory={1};VehicleType={2};Speed={3};Miles={4}", currentReading.ReadingId, currentCar.FactoryName, currentCar.TypeOfCar, currentReading.CurrentSpeed, currentReading.CurrrentDistanceTraveled);
 }
Exemple #4
0
        // Create a message and send it to IoT Hub.
        static async Task SendEvent(DeviceClient deviceClient, Car CurrentCar, VehicleTireReading TireData)
        {
            try
            {
                string jsonData = JsonConvert.SerializeObject(TireData);
                Microsoft.Azure.Devices.Client.Message eventMessage = new Microsoft.Azure.Devices.Client.Message(Encoding.UTF8.GetBytes(jsonData));
                eventMessage.Properties.Add("messagetype", "TLM");
                await deviceClient.SendEventAsync(eventMessage);

                Console.WriteLine("Sent Data for Vehicle={0};ReadingId={1}", CurrentCar.Id, TireData.ReadingId);
            }
            catch (Exception ex)
            {
                Console.WriteLine("An error occured writing to event hub" + ex.ToString());
            }
        }
Exemple #5
0
 public TireReading Read(VehicleTireReading ParentReading)
 {
     TireReading currentReading = new TireReading(ParentReading, this);
     return currentReading;
 }
Exemple #6
0
        public VehicleTireReading ReadTires()
        {
            VehicleTireReading currentReading = new VehicleTireReading(this);

            return(currentReading);
        }
Exemple #7
0
        public TireReading Read(VehicleTireReading ParentReading)
        {
            TireReading currentReading = new TireReading(ParentReading, this);

            return(currentReading);
        }
Exemple #8
0
 static void sendCarDataToEventHub(Car CurrentCar, VehicleTireReading TireData)
 {
     try
     {
         string jsonData = JsonConvert.SerializeObject(TireData);
         EventData ehData = new EventData(Encoding.UTF8.GetBytes(jsonData));
         ehData.Properties.Add("VehicleType", TireData.TypeOfCar);
         ehData.Properties.Add("VehicleId", TireData.VehicleId.ToString());
         ehData.Properties.Add("ReadingId", TireData.ReadingId);
         ehClient.Send(ehData);
         Console.WriteLine("Sent Data for Vehicle={0};ReadingId={1}", CurrentCar.Id, TireData.ReadingId);
     }
     catch (Exception ex)
     {
         Console.WriteLine("An error occured writing to event hub" + ex.ToString());
     }
 }
Exemple #9
0
 public VehicleTireReading ReadTires()
 {
     VehicleTireReading currentReading = new VehicleTireReading(this);
     return currentReading;
 }