//------------------------------------------------------------------------------------------------------------------------ #endregion #region Constructor //------------------------------------------------------------------------------------------------------------------------ public SensorWatcher(GrovePiSensor sensor, int period_msec, Transport sharppy) { this.sensor = sensor; this.sharppyiface = sharppy; this.sharppyiface.OnRxMsgcb += OnRxPythonMsg; WatcherId = Interlocked.Increment(ref idGen); SamplingPeriod = period_msec; }
static void OnGetContinuousDatacb(GrovePiSensor sensor, object data) { var thing = Lookup.FirstOrDefault(i => i.Value == sensor).Key; if (thing == null) { return; } foreach (var port in thing.Ports) { if (port.ioDirection == ioPortDirection.Output || port.ioDirection == ioPortDirection.InputOutput) { Helper.node.SetState(thing, port, data as string); break; //optimization cheat } } }