private void onWhiskerRight(object sender, MeasuredValuesEventArgs ev) { LogInfo("TrackRoamerBrickPowerService : WhiskerRight : " + ev.value1); if (ev.value1 > 0 && (!_state.Whiskers.FrontWhiskerRight.HasValue || !_state.Whiskers.FrontWhiskerRight.Value)) { // if this is a "whisker pressed" event, do emergency stop. stopMotorsNow(); // Note: UpdateMotorSpeedHandler() will not set positive speed if whiskers are pressed. } _state.Whiskers.Timestamp = new DateTime(ev.timestamp); _state.Whiskers.FrontWhiskerRight = ev.value1 > 0; _state.TimeStamp = DateTime.Now; UpdateWhiskers uw = new UpdateWhiskers(); uw.Body.Timestamp = _state.Whiskers.Timestamp; uw.Body.FrontWhiskerRight = ev.value1 > 0; base.SendNotification <UpdateWhiskers>(_subMgrPort, uw); }
private void onWhiskerRight(object sender, MeasuredValuesEventArgs ev) { LogInfo("TrackRoamerBrickPowerService : WhiskerRight : " + ev.value1); if (ev.value1 > 0 && (!_state.Whiskers.FrontWhiskerRight.HasValue || !_state.Whiskers.FrontWhiskerRight.Value)) { // if this is a "whisker pressed" event, do emergency stop. stopMotorsNow(); // Note: UpdateMotorSpeedHandler() will not set positive speed if whiskers are pressed. } _state.Whiskers.Timestamp = new DateTime(ev.timestamp); _state.Whiskers.FrontWhiskerRight = ev.value1 > 0; _state.TimeStamp = DateTime.Now; UpdateWhiskers uw = new UpdateWhiskers(); uw.Body.Timestamp = _state.Whiskers.Timestamp; uw.Body.FrontWhiskerRight = ev.value1 > 0; base.SendNotification<UpdateWhiskers>(_subMgrPort, uw); }