Class to manage sensor data and attributes
예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ConnectTheDotsSensor sensor = ctdHelper.sensors.Find(item => item.measurename == "Temperature");

            sensor.value = counter++;
            ctdHelper.SendSensorData(sensor);
        }
예제 #2
0
        private void TelemetryTimer_Tick(object sender, object e)
        {
            // Light Sensor
            ConnectTheDotsSensor lSensor = ctdHelper.sensors.Find(item => item.UOM1 == "Kg");

            lSensor.RemainingWeight = this.hat.GetLightLevel();  //Using Light as weight
            lSensor.Temperature     = this.hat.GetTemperature(); //Temperature reading

            this.ctdHelper.SendSensorData(lSensor);

            this.LightTextBox.Text   = lSensor.RemainingWeight.ToString("P2", CultureInfo.InvariantCulture);
            this.LightProgress.Value = lSensor.RemainingWeight;

            this.TempTextBox.Text = lSensor.Temperature.ToString("N2", CultureInfo.InvariantCulture);

            System.Diagnostics.Debug.WriteLine("Temperature: {0} °C, Light {1}", lSensor.Temperature.ToString("N2", CultureInfo.InvariantCulture), lSensor.RemainingWeight.ToString("P2", CultureInfo.InvariantCulture));
        }
        public void SendSensorData(ConnectTheDotsSensor sensor)
        {
            sensor.TimeFlag = DateTime.UtcNow.ToString("o");

            if (i == 0)
            {
                sensor.DeviceId = "RaspberryScale1";
                sensor.MenuItem = "Bread";
                i++;
            }
            else if (i == 1)
            {
                sensor.DeviceId = "RaspberryScale2";
                sensor.MenuItem = "Pasta";
                i++;
            }
            else if (i == 2)
            {
                sensor.DeviceId = "RaspberryScale3";
                sensor.MenuItem = "Lasagna";
                i++;
            }
            else if (i == 3)
            {
                sensor.DeviceId = "RaspberryScale4";
                sensor.MenuItem = "Burger";
                i++;
            }
            else if (i == 4)
            {
                sensor.DeviceId = "RaspberryScale5";
                sensor.MenuItem = "Sandwich";
                i++;
            }

            if (i == 5)
            {
                i = 0;
            }


            sendMessage(sensor.ToJson());
        }
예제 #4
0
        private void Timer_Tick(object sender, object e)
        {
            // Light Sensor
            ConnectTheDotsSensor lSensor = ctdHelper.sensors.Find(item => item.measurename == "Light");

            lSensor.value = this.hat.GetLightLevel();

            this.ctdHelper.SendSensorData(lSensor);
            this.LightTextBox.Text   = lSensor.value.ToString("P2", CultureInfo.InvariantCulture);
            this.LightProgress.Value = lSensor.value;

            // Temperature Sensor
            var tSensor = ctdHelper.sensors.Find(item => item.measurename == "Temperature");

            tSensor.value = this.hat.GetTemperature();
            this.ctdHelper.SendSensorData(tSensor);

            this.TempTextBox.Text = tSensor.value.ToString("N2", CultureInfo.InvariantCulture);

            System.Diagnostics.Debug.WriteLine("Temperature: {0} °C, Light {1}", tSensor.value.ToString("N2", CultureInfo.InvariantCulture), lSensor.value.ToString("P2", CultureInfo.InvariantCulture));
        }
        private void TelemetryTimer_Tick(object sender, object e)
        {
            // Light Sensor
            ConnectTheDotsSensor lSensor = ctdHelper.sensors.Find(item => item.measurename == "Light");

            lSensor.value = this.hat.GetLightLevel();

            this.ctdHelper.SendSensorData(lSensor);
            this.LightTextBox.Text = lSensor.value.ToString("P2", CultureInfo.InvariantCulture);

            this.LightProgress.Value = lSensor.value;


            if (this.LightProgress.Value * 100 < 60)
            {
                hat.D2.Color = new FEZHAT.Color(255, 255, 255);
                hat.D3.Color = new FEZHAT.Color(255, 255, 255);
            }
            else
            {
                hat.D2.TurnOff();
                hat.D3.TurnOff();
            }

            // Temperature Sensor
            var tSensor = ctdHelper.sensors.Find(item => item.measurename == "Temperature");

            tSensor.value = this.hat.GetTemperature();
            this.ctdHelper.SendSensorData(tSensor);

            this.TempTextBox.Text = tSensor.value.ToString("N2", CultureInfo.InvariantCulture) + " °C";


            System.Diagnostics.Debug.WriteLine("Temperature: {0} °C, Light {1} ",
                                               tSensor.value.ToString("N2", CultureInfo.InvariantCulture),
                                               lSensor.value.ToString("P2", CultureInfo.InvariantCulture)
                                               );
        }
예제 #6
0
 public void SendSensorData(ConnectTheDotsSensor sensor)
 {
     sensor.timecreated = DateTime.UtcNow.ToString("o");
     sendMessage(sensor.ToJson());
 }
예제 #7
0
 public void SendSensorData(ConnectTheDotsSensor sensor)
 {
     sensor.timecreated = DateTime.UtcNow.ToString("o");
     sendMessage(sensor.ToJson());
 }