Example #1
0
 /// <summary>
 /// Handle periodic sensor readings from the brick
 /// </summary>
 /// <param name="update"></param>
 private void NotificationHandler(brick.LegoSensorUpdate update)
 {
     nxtcmd.I2CResponseSonarSensor inputValues = new nxtcmd.I2CResponseSonarSensor(update.Body.CommandData);
     if (inputValues.Success)
     {
         bool firstTime = (_state.TimeStamp == DateTime.MinValue);
         _state.TimeStamp = inputValues.TimeStamp;
         if (_state.Distance != inputValues.UltraSonicVariable || firstTime)
         {
             _state.Distance = inputValues.UltraSonicVariable;
             SendNotification <SonarSensorUpdate>(_subMgrPort, _state);
             SendNotification <pxanalogsensor.Replace>(_genericSubMgrPort, SyncGenericState());
         }
     }
 }
 /// <summary>
 /// Handle periodic sensor readings from the brick
 /// </summary>
 /// <param name="update"></param>
 private void NotificationHandler(brick.LegoSensorUpdate update)
 {
     nxtcmd.I2CResponseSonarSensor inputValues = new nxtcmd.I2CResponseSonarSensor(update.Body.CommandData);
     if (inputValues.Success)
     {
         bool firstTime = (_state.TimeStamp == DateTime.MinValue);
         _state.TimeStamp = inputValues.TimeStamp;
         if (_state.Distance != inputValues.UltraSonicVariable || firstTime)
         {
             _state.Distance = inputValues.UltraSonicVariable;
             SendNotification<SonarSensorUpdate>(_subMgrPort, _state);
             SendNotification<pxanalogsensor.Replace>(_genericSubMgrPort, SyncGenericState());
         }
     }
 }