ToJson() public method

ToJson function is used to convert sensor data into a JSON string to be sent to Azure Event Hub
public ToJson ( ) : string
return string
        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());
        }
Example #2
0
 public void SendSensorData(ConnectTheDotsSensor sensor)
 {
     sensor.timecreated = DateTime.UtcNow.ToString("o");
     sendMessage(sensor.ToJson());
 }
Example #3
0
 public void SendSensorData(ConnectTheDotsSensor sensor)
 {
     sensor.timecreated = DateTime.UtcNow.ToString("o");
     sendMessage(sensor.ToJson());
 }