예제 #1
0
 public ICollection <AvailableTemperatureInputProtocol> Provide(Building model)
 {
     return(_temperatureInputProvider.GetAvailableProtocolNames()
            .Select(x =>
     {
         return new AvailableTemperatureInputProtocol
         {
             ProtocolName = x,
             ConfigurationOptions = _temperatureInputProvider.Provide(x).ConfigurationOptions
         };
     })
            .ToList());
 }
        private void ProcessReads(ControllerState controllerState)
        {
            Parallel.ForEach(controllerState.TemperatureSensorIdToState,
                             sensor =>
            {
                var sensorRead = _temperatureInputProvider.Provide(sensor.Value.TemperatureSensor.ProtocolName)
                                 .GetValue(sensor.Value.TemperatureSensor.InputDescriptor);

                sensorRead.Wait();

                if (sensorRead.Result.CrcOk)
                {
                    var temperatureSensorState = sensor.Value;

                    ProcessCurrentRead(temperatureSensorState, sensorRead);
                    ProcessHistory(temperatureSensorState);
                }
                else
                {
                    Logger.Warning(Localization.NotificationMessage.SensorCrcError.FormatWith(sensor.Value.TemperatureSensor.Name));
                }
            });
        }