Пример #1
0
 private async Task PostTemp(SensorTemperatureValues item)
 {
     try
     {
         await WolaClient.PostItemToController <SensorTemperatureValues>("SensorTempValue", item);
     }
     catch (Exception ex)
     {
         Log.e(ex);
     }
 }
        async Task ManageSensorValues(SerialMessage message)
        {
            ISenssor val = new SensorDs8b20();

            switch (message.SensorType)
            {
            case SensorTypeEnum.test:
                break;

            case SensorTypeEnum.Ds18B20:
                val = JsonConvert.DeserializeObject <SensorDs8b20>(message.Message);
                await WolaClient.PostItemToController <SensorDs8b20>("SensorDs18b20", (SensorDs8b20)val);

                //     WolaClient.PostItemToController<SensorTemperatureValues>("SensorTempValue", item);
                break;

            case SensorTypeEnum.Dht11:
                val = JsonConvert.DeserializeObject <SensorDht>(message.Message);
                await WolaClient.PostItemToController <SensorDht>("SensorDht22", (SensorDht)val);

                break;

            case SensorTypeEnum.Dht22:
                val = JsonConvert.DeserializeObject <SensorDht>(message.Message);
                await WolaClient.PostItemToController <SensorDht>("SensorDht22", (SensorDht)val);

                break;

            case SensorTypeEnum.BMP180:
                val = JsonConvert.DeserializeObject <SensorBmp180>(message.Message);
                await WolaClient.PostItemToController <SensorBmp180>("SensorBMP180", (SensorBmp180)val);

                break;

            case SensorTypeEnum.ACS712:

                val = JsonConvert.DeserializeObject <SensorAcs712>(message.Message);
                await WolaClient.PostItemToController <SensorAcs712>("SensorAcs712", (SensorAcs712)val);

                break;

            case SensorTypeEnum.OnOff:

                break;

            default:
                break;
            }
            Debug.WriteLine(val.ToString());
        }