Example #1
0
 /// <summary>
 /// Handle sensor notifications from the brick
 /// </summary>
 /// <param name="update"></param>
 private void NotificationHandler(brick.LegoSensorUpdate update)
 {
     nxtcmd.LegoResponseGetInputValues inputValues = new nxtcmd.LegoResponseGetInputValues(update.Body.CommandData);
     if (inputValues != null && inputValues.Success)
     {
         bool firstNotification = (_state.TimeStamp == DateTime.MinValue);
         _state.TimeStamp = inputValues.TimeStamp;
         if (_state.Intensity != inputValues.ScaledValue || firstNotification)
         {
             _state.Intensity = inputValues.ScaledValue;
             SendNotification <SoundSensorUpdate>(_subMgrPort, _state);
             SendNotification <pxanalogsensor.Replace>(_genericSubMgrPort, SyncGenericState());
         }
     }
 }
 private void NotificationHandler(brick.LegoSensorUpdate update)
 {
     nxtcmd.LegoResponseGetInputValues inputValues = new nxtcmd.LegoResponseGetInputValues(update.Body.CommandData);
     if (inputValues != null && inputValues.Success)
     {
         bool touch = (inputValues.ScaledValue == 1);
         if (_state.TouchSensorOn != touch || _state.TimeStamp == DateTime.MinValue)
         {
             _state.TouchSensorOn = touch;
             _state.TimeStamp     = inputValues.TimeStamp;
             // Send Touch Sensor notification
             SendNotification <TouchSensorUpdate>(_subMgrPort, _state);
             // Send contact sensor notification
             SyncGenericContactState();
             SendNotification <contactsensor.Update>(_genericSubMgrPort, _genericSensor);
         }
     }
 }
 /// <summary>
 /// Handle sensor notifications from the brick
 /// </summary>
 /// <param name="update"></param>
 private void NotificationHandler(brick.LegoSensorUpdate update)
 {
     nxtcmd.LegoResponseGetInputValues inputValues = new nxtcmd.LegoResponseGetInputValues(update.Body.CommandData);
     if (inputValues != null && inputValues.Success)
     {
         bool firstNotification = (_state.TimeStamp == DateTime.MinValue);
         _state.TimeStamp = inputValues.TimeStamp;
         if (_state.Intensity != inputValues.ScaledValue || firstNotification)
         {
             _state.Intensity = inputValues.ScaledValue;
             SendNotification<SoundSensorUpdate>(_subMgrPort, _state);
             SendNotification<pxanalogsensor.Replace>(_genericSubMgrPort, SyncGenericState());
         }
     }
 }
 private void NotificationHandler(brick.LegoSensorUpdate update)
 {
     nxtcmd.LegoResponseGetInputValues inputValues =  new nxtcmd.LegoResponseGetInputValues(update.Body.CommandData);
     if (inputValues != null && inputValues.Success)
     {
         bool touch = (inputValues.ScaledValue == 1);
         if (_state.TouchSensorOn != touch || _state.TimeStamp == DateTime.MinValue)
         {
             _state.TouchSensorOn = touch;
             _state.TimeStamp = inputValues.TimeStamp;
             // Send Touch Sensor notification
             SendNotification<TouchSensorUpdate>(_subMgrPort, _state);
             // Send contact sensor notification
             SyncGenericContactState();
             SendNotification<contactsensor.Update>(_genericSubMgrPort, _genericSensor);
         }
     }
 }