public override void HandleMessage(ADMMessage message) { base.HandleMessage(message); if (ADMMessage.IsCommandType(message.CommandID, (byte)ArduinoCommand.CommandType.READ)) { Mode mode = (Mode)ADMMessage.GetCommandIndex(message.CommandID); switch (mode) { case Mode.COUNT: Count = message.ArgumentAsLong(0); Interval = message.ArgumentAsLong(1); Mgr.Sampler.ProvideSample(this, (double)Count, Interval); message.AddValue(PARAM_COUNT, Count); message.AddValue(PARAM_INTERVAL, Interval); break; case Mode.RATE: Rate = message.ArgumentAsFloat(0); Mgr.Sampler.ProvideSample(this, (double)Rate); message.AddValue(PARAM_RATE, Rate); break; } } }
protected override void OnConnect(ADMMessage message) { base.OnConnect(message); message.AddValue("SensorIndex", message.ArgumentAsInt(0)); message.AddValue("SensorCount", message.ArgumentAsInt(1)); }
private void HandleSilenceTimer(Object sender, System.Timers.ElapsedEventArgs ea) { //turn off timer and set buzzer pin to whatever the buzzer state really is Unsilence(); ADMMessage message = new ADMMessage(); message.Type = Messaging.MessageType.NOTIFICATION; message.AddValue("Silenced", _silenced); message.Value = "Silenced timer ended"; Broadcast(message); }
public override void HandleMessage(ADMMessage message) { base.HandleMessage(message); if (message.Type == MessageType.DATA) { double duration = message.ArgumentAsLong(0); //this is in microseconds if (duration > 0) { double speedInMicros = Measurement.ConvertUnit(SpeedOfSound, Measurement.Unit.MICROSECOND, Measurement.Unit.SECOND); Distance = 0.5 * Measurement.ConvertUnit(speedInMicros * duration, Measurement.Unit.METER, MeasurementUnit); } else { Distance = 0; } Sampler?.ProvideSample(this, Distance); message.AddValue(PARAM_DISTANCE, Distance); message.AddValue(PARAM_UNITS, MeasurementUnit); } } //end HandleMessage
virtual protected void OnStateChange(bool newState) { if (newState) { LastOn = DateTime.Now; } else { LastOff = DateTime.Now; } ADMMessage message = new ADMMessage(); message.Type = BroadcastStateChangeAs; message.AddValue("State", newState); Broadcast(message); }