Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ZipatoSensors"/> class.
        /// The list of UUIDs from the SettingsData is used to create the device instances.
        /// </summary>
        /// <param name="zipato"></param>
        public ZipatoSensors(IZipato zipato)
        {
            _zipato = zipato;

            foreach (var uuid in zipato.SensorsInfo.VirtualMeters)
            {
                VirtualMeters.Add(new VirtualMeter(zipato, uuid));
            }

            foreach (var uuid in zipato.SensorsInfo.ConsumptionMeters)
            {
                ConsumptionMeters.Add(new ConsumptionMeter(zipato, uuid));
            }

            foreach (var uuid in zipato.SensorsInfo.TemperatureSensors)
            {
                TemperatureSensors.Add(new TemperatureSensor(zipato, uuid));
            }

            foreach (var uuid in zipato.SensorsInfo.HumiditySensors)
            {
                HumiditySensors.Add(new HumiditySensor(zipato, uuid));
            }

            foreach (var uuid in zipato.SensorsInfo.LuminanceSensors)
            {
                LuminanceSensors.Add(new LuminanceSensor(zipato, uuid));
            }

            Status = _zipato?.Data?.Status ?? Uncertain;
        }
Exemplo n.º 2
0
 public override bool AddPhidget(IPhidgetViewModel viewModel)
 {
     if (viewModel is TemperatureSensorViewModel || viewModel is ThermocoupleInputViewModel)
     {
         if (viewModel.Channel >= phidget.GetDeviceChannelCount(ChannelClass.TemperatureSensor))
         {
             throw new ArgumentException($"Can't find a channel to add '{viewModel.DeviceName}' to");
         }
         TemperatureSensors.Add(viewModel);
         TemperatureSensors.Sort((a, b) => { return(a.Channel.CompareTo(b.Channel)); });
         return(true);
     }
     else if (viewModel is HumiditySensorViewModel)
     {
         if (viewModel.Channel >= phidget.GetDeviceChannelCount(ChannelClass.HumiditySensor))
         {
             throw new ArgumentException($"Can't find a channel to add '{viewModel.DeviceName}' to");
         }
         HumiditySensors.Add(viewModel);
         HumiditySensors.Sort((a, b) => a.Channel.CompareTo(b.Channel));
         return(true);
     }
     return(true);
 }