private void WiimoteChanged(object sender, WiimoteChangedEventArgs e) { WiiBoardData singleDataPoint = dataMapper.MapFromWiiFormat(e.WiimoteState, this.acquisitionStartedAt); LOG.DebugFormat("Current value: topLeftKg={0}, topRightKg={1}, bottomLeftKg={2}, bottomRightKg={3}, weightKg={4}, gravity.X={5}, gravity.Y={6}, Horodate={7}, TIMESTAMP={8}", singleDataPoint.topLeftKg, singleDataPoint.topRightKg, singleDataPoint.bottomLeftKg, singleDataPoint.bottomRightKg, singleDataPoint.weightKg, singleDataPoint.gravity.X, singleDataPoint.gravity.Y, singleDataPoint.Horodate, singleDataPoint.TIMESTAMP); if (IsValidData(singleDataPoint)) { WiiBoardDatas.Add(singleDataPoint); #if DEBUG LOG.DebugFormat("Wiimote callback from ID={0}: data was collected.", ((Wiimote)sender).ID); #endif } else { LOG.DebugFormat("Wiimote callback from ID={0}: no valid data.", ((Wiimote)sender).ID); } }
/// <summary> /// Filtrer les NaN sinon plantage à la sérialisation. /// Filter les valeurs à 0 car inutiles. /// </summary> /// <param name="singleDataPoint"></param> /// <returns></returns> private static bool IsValidData(WiiBoardData singleDataPoint) { return(!float.IsNaN(singleDataPoint.gravity.X) & singleDataPoint.bottomLeftKg != singleDataPoint.bottomRightKg & singleDataPoint.topLeftKg != singleDataPoint.topRightKg); }