public MeadowApp() { _bluetooth = new Hc06(Device, Device.SerialPortNames.Com4); CycleCount = 0; DispatchTime = 0; TelemetrySendTime = 0; _layout = new Layout("control", this); //Components _sensorReader = new SensorReader(Device, _layout); _telemetrySender = new TelemetrySender(new DeviceStream(_bluetooth), TelemetryConfig.Meadow, _layout); _lookup = _layout.GetLookup(); }
public KDevice FindDevice(string path) { int colonPos = path.IndexOf(':'); if (colonPos >= 0) { path = path.Substring(0, colonPos); } KDevice device; if (DeviceLookup.TryGetValue(path, out device) == true) { return(device); } else { Debug.Assert(false, string.Format("Unable to find a device matching the alias '{0}'", path)); return(null); } }
public void Dispatch(DeviceLookup lookup) { //Update values DateTime now = DateTime.Now; for (int i = 0; i < _config.Count; i++) { int messageIndex = i / TelemetryMessage.EntryLength; int entryIndex = i % TelemetryMessage.EntryLength; DeviceValue entry = _messages[messageIndex].Devices[entryIndex]; object value = lookup[entry.Hash].Get(); if (lookup[entry.Hash].Property.PropertyType == typeof(Int32)) { _messages[messageIndex].Devices[entryIndex].IValue = (Int32)value; } else if (lookup[entry.Hash].Property.PropertyType == typeof(float)) { _messages[messageIndex].Devices[entryIndex].DValue = (float)value; } else { Console.WriteLine("Unknown Type: {0}", lookup[entry.Hash].Property.PropertyType); } } //Send packets foreach (TelemetryMessage message in _messages) { //var m = message; //m.Header.DateTime = now; //Send telemetry byte[] buffer = StructSerializer.Serialize(message); _stream.Write(buffer); } }
public void Dispatch(DeviceLookup lookup = null) { //Console.WriteLine("Dispatch - {0}", DateTime.Now); _sensorReader.Dispatch(); }
public async void Dispatch(DeviceLookup lookup = null) { AtmosphericConditions temp = await _temperature.Read(); Temperature = temp.Temperature.HasValue ? temp.Temperature.Value : 0; }