/// <summary> /// Initializes a new instance of the <see cref="SensorSource"/> class. /// </summary> public SensorSource() { List<ConnectTheDotsSensor> sensors = new List<ConnectTheDotsSensor> { new ConnectTheDotsSensor("2298f348-13a2-4258-ed52-82a4353531ab", "temperature", "C"), new ConnectTheDotsSensor("3213a232-e2f9-4438-ab23-63a7676542fe", "light", "lumen"), new ConnectTheDotsSensor("6458a325-63a7-7694-ce23-74a5326453ab", "motion", "binary") }; //this is the connection to eventhub ctdHelper = new ConnectTheDotsHelper(serviceBusNamespace: "cspi1-ns", eventHubName: "ehdevices", keyName: "raspiberrypisender", key: "", displayName: "RaspberryPi2Win10", organization: "Microsoft Singapore DX Team", location: "SG MIC 2", sensorList: sensors); motionsensor = ctdHelper.sensors.Find(item => item.measurename == "motion"); tempsensor = ctdHelper.sensors.Find(item => item.measurename == "temperature"); lightsensor = ctdHelper.sensors.Find(item => item.measurename == "light"); // Hard coding guid for sensors. Not an issue for this particular application which is meant for testing and demos Init(); }
public void SendSensorData(ConnectTheDotsSensor sensor) { sensor.timecreated = DateTime.UtcNow.ToString("o"); sendMessage(sensor.ToJson()); }