void RangerDistanceChangedEvent(object sender, RangerSensorEventArgs e) { //Debug.WriteLine("Ranger: " + e.Name + " RangeMeters=" + e.RangeMeters); lock (currentSensorsDataLock) { SensorsData sensorsData = new SensorsData(this.currentSensorsData); switch (e.Name) { case "IrLeft": sensorsData.IrLeftMeters = e.RangeMeters[0]; sensorsData.IrLeftMetersTimestamp = e.TimeTicks; break; case "IrRight": sensorsData.IrRightMeters = e.RangeMeters[0]; sensorsData.IrRightMetersTimestamp = e.TimeTicks; break; case "IrFront": sensorsData.IrFrontMeters = e.RangeMeters[0]; sensorsData.IrFrontMetersTimestamp = e.TimeTicks; break; case "IrRear": sensorsData.IrRearMeters = e.RangeMeters[0]; sensorsData.IrRearMetersTimestamp = e.TimeTicks; break; case "SonarLeft": sensorsData.RangerFrontLeftMeters = e.RangeMeters[0]; sensorsData.RangerFrontLeftMetersTimestamp = e.TimeTicks; break; case "SonarRight": sensorsData.RangerFrontRightMeters = e.RangeMeters[0]; sensorsData.RangerFrontRightMetersTimestamp = e.TimeTicks; break; } //Debug.WriteLine(sensorsData.ToString()); this.currentSensorsData = sensorsData; } }
private void RangerDistanceChangedEvent(object sender, RangerSensorEventArgs e) { //Debug.WriteLine("Ranger: " + e.Name + " RangeMeters=" + e.RangeMeters); lock (currentSensorsDataLock) { SensorsData sensorsData = new SensorsData(this.currentSensorsData); switch (e.Name) { case "ParkingSonar": sensorsData.RangerFrontRightMeters = e.RangeMeters[0]; sensorsData.RangerFrontLeftMeters = e.RangeMeters[1]; sensorsData.RangerRearRightMeters = e.RangeMeters[2]; sensorsData.RangerRearLeftMeters = e.RangeMeters[3]; sensorsData.RangerFrontRightMetersTimestamp = sensorsData.RangerFrontLeftMetersTimestamp = sensorsData.RangerRearRightMetersTimestamp = sensorsData.RangerRearLeftMetersTimestamp = e.TimeTicks; break; default: throw new NotImplementedException("Error: RangerDistanceChangedEvent: unknown name " + e.Name); } //Debug.WriteLine(sensorsData.ToString()); this.currentSensorsData = sensorsData; } }