public void OnMesg(object sender, MesgEventArgs e) { // Notify any subscribers of either our general mesg event or specific profile mesg event if (MesgEvent != null) { MesgEvent(sender, e); } switch (e.mesg.Num) { case (ushort)MesgNum.FileId: if (FileIdMesgEvent != null) { FileIdMesg fileIdMesg = new FileIdMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileIdMesg; FileIdMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FileCreator: if (FileCreatorMesgEvent != null) { FileCreatorMesg fileCreatorMesg = new FileCreatorMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileCreatorMesg; FileCreatorMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.TimestampCorrelation: if (TimestampCorrelationMesgEvent != null) { TimestampCorrelationMesg timestampCorrelationMesg = new TimestampCorrelationMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = timestampCorrelationMesg; TimestampCorrelationMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Software: if (SoftwareMesgEvent != null) { SoftwareMesg softwareMesg = new SoftwareMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = softwareMesg; SoftwareMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SlaveDevice: if (SlaveDeviceMesgEvent != null) { SlaveDeviceMesg slaveDeviceMesg = new SlaveDeviceMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = slaveDeviceMesg; SlaveDeviceMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Capabilities: if (CapabilitiesMesgEvent != null) { CapabilitiesMesg capabilitiesMesg = new CapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = capabilitiesMesg; CapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FileCapabilities: if (FileCapabilitiesMesgEvent != null) { FileCapabilitiesMesg fileCapabilitiesMesg = new FileCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileCapabilitiesMesg; FileCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MesgCapabilities: if (MesgCapabilitiesMesgEvent != null) { MesgCapabilitiesMesg mesgCapabilitiesMesg = new MesgCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = mesgCapabilitiesMesg; MesgCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FieldCapabilities: if (FieldCapabilitiesMesgEvent != null) { FieldCapabilitiesMesg fieldCapabilitiesMesg = new FieldCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fieldCapabilitiesMesg; FieldCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeviceSettings: if (DeviceSettingsMesgEvent != null) { DeviceSettingsMesg deviceSettingsMesg = new DeviceSettingsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = deviceSettingsMesg; DeviceSettingsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.UserProfile: if (UserProfileMesgEvent != null) { UserProfileMesg userProfileMesg = new UserProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = userProfileMesg; UserProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.HrmProfile: if (HrmProfileMesgEvent != null) { HrmProfileMesg hrmProfileMesg = new HrmProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrmProfileMesg; HrmProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SdmProfile: if (SdmProfileMesgEvent != null) { SdmProfileMesg sdmProfileMesg = new SdmProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sdmProfileMesg; SdmProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BikeProfile: if (BikeProfileMesgEvent != null) { BikeProfileMesg bikeProfileMesg = new BikeProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = bikeProfileMesg; BikeProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Connectivity: if (ConnectivityMesgEvent != null) { ConnectivityMesg connectivityMesg = new ConnectivityMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = connectivityMesg; ConnectivityMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WatchfaceSettings: if (WatchfaceSettingsMesgEvent != null) { WatchfaceSettingsMesg watchfaceSettingsMesg = new WatchfaceSettingsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = watchfaceSettingsMesg; WatchfaceSettingsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.OhrSettings: if (OhrSettingsMesgEvent != null) { OhrSettingsMesg ohrSettingsMesg = new OhrSettingsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = ohrSettingsMesg; OhrSettingsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ZonesTarget: if (ZonesTargetMesgEvent != null) { ZonesTargetMesg zonesTargetMesg = new ZonesTargetMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = zonesTargetMesg; ZonesTargetMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Sport: if (SportMesgEvent != null) { SportMesg sportMesg = new SportMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sportMesg; SportMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.HrZone: if (HrZoneMesgEvent != null) { HrZoneMesg hrZoneMesg = new HrZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrZoneMesg; HrZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SpeedZone: if (SpeedZoneMesgEvent != null) { SpeedZoneMesg speedZoneMesg = new SpeedZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = speedZoneMesg; SpeedZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CadenceZone: if (CadenceZoneMesgEvent != null) { CadenceZoneMesg cadenceZoneMesg = new CadenceZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = cadenceZoneMesg; CadenceZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.PowerZone: if (PowerZoneMesgEvent != null) { PowerZoneMesg powerZoneMesg = new PowerZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = powerZoneMesg; PowerZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MetZone: if (MetZoneMesgEvent != null) { MetZoneMesg metZoneMesg = new MetZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = metZoneMesg; MetZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DiveSettings: if (DiveSettingsMesgEvent != null) { DiveSettingsMesg diveSettingsMesg = new DiveSettingsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = diveSettingsMesg; DiveSettingsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DiveAlarm: if (DiveAlarmMesgEvent != null) { DiveAlarmMesg diveAlarmMesg = new DiveAlarmMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = diveAlarmMesg; DiveAlarmMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DiveGas: if (DiveGasMesgEvent != null) { DiveGasMesg diveGasMesg = new DiveGasMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = diveGasMesg; DiveGasMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Goal: if (GoalMesgEvent != null) { GoalMesg goalMesg = new GoalMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = goalMesg; GoalMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Activity: if (ActivityMesgEvent != null) { ActivityMesg activityMesg = new ActivityMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = activityMesg; ActivityMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Session: if (SessionMesgEvent != null) { SessionMesg sessionMesg = new SessionMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sessionMesg; SessionMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Lap: if (LapMesgEvent != null) { LapMesg lapMesg = new LapMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = lapMesg; LapMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Length: if (LengthMesgEvent != null) { LengthMesg lengthMesg = new LengthMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = lengthMesg; LengthMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Record: if (RecordMesgEvent != null) { RecordMesg recordMesg = new RecordMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = recordMesg; RecordMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Event: if (EventMesgEvent != null) { EventMesg eventMesg = new EventMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = eventMesg; EventMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeviceInfo: if (DeviceInfoMesgEvent != null) { DeviceInfoMesg deviceInfoMesg = new DeviceInfoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = deviceInfoMesg; DeviceInfoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.TrainingFile: if (TrainingFileMesgEvent != null) { TrainingFileMesg trainingFileMesg = new TrainingFileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = trainingFileMesg; TrainingFileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Hrv: if (HrvMesgEvent != null) { HrvMesg hrvMesg = new HrvMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrvMesg; HrvMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WeatherConditions: if (WeatherConditionsMesgEvent != null) { WeatherConditionsMesg weatherConditionsMesg = new WeatherConditionsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = weatherConditionsMesg; WeatherConditionsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WeatherAlert: if (WeatherAlertMesgEvent != null) { WeatherAlertMesg weatherAlertMesg = new WeatherAlertMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = weatherAlertMesg; WeatherAlertMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.GpsMetadata: if (GpsMetadataMesgEvent != null) { GpsMetadataMesg gpsMetadataMesg = new GpsMetadataMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = gpsMetadataMesg; GpsMetadataMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CameraEvent: if (CameraEventMesgEvent != null) { CameraEventMesg cameraEventMesg = new CameraEventMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = cameraEventMesg; CameraEventMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.GyroscopeData: if (GyroscopeDataMesgEvent != null) { GyroscopeDataMesg gyroscopeDataMesg = new GyroscopeDataMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = gyroscopeDataMesg; GyroscopeDataMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.AccelerometerData: if (AccelerometerDataMesgEvent != null) { AccelerometerDataMesg accelerometerDataMesg = new AccelerometerDataMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = accelerometerDataMesg; AccelerometerDataMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MagnetometerData: if (MagnetometerDataMesgEvent != null) { MagnetometerDataMesg magnetometerDataMesg = new MagnetometerDataMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = magnetometerDataMesg; MagnetometerDataMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BarometerData: if (BarometerDataMesgEvent != null) { BarometerDataMesg barometerDataMesg = new BarometerDataMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = barometerDataMesg; BarometerDataMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ThreeDSensorCalibration: if (ThreeDSensorCalibrationMesgEvent != null) { ThreeDSensorCalibrationMesg threeDSensorCalibrationMesg = new ThreeDSensorCalibrationMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = threeDSensorCalibrationMesg; ThreeDSensorCalibrationMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.OneDSensorCalibration: if (OneDSensorCalibrationMesgEvent != null) { OneDSensorCalibrationMesg oneDSensorCalibrationMesg = new OneDSensorCalibrationMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = oneDSensorCalibrationMesg; OneDSensorCalibrationMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.VideoFrame: if (VideoFrameMesgEvent != null) { VideoFrameMesg videoFrameMesg = new VideoFrameMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = videoFrameMesg; VideoFrameMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ObdiiData: if (ObdiiDataMesgEvent != null) { ObdiiDataMesg obdiiDataMesg = new ObdiiDataMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = obdiiDataMesg; ObdiiDataMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.NmeaSentence: if (NmeaSentenceMesgEvent != null) { NmeaSentenceMesg nmeaSentenceMesg = new NmeaSentenceMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = nmeaSentenceMesg; NmeaSentenceMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.AviationAttitude: if (AviationAttitudeMesgEvent != null) { AviationAttitudeMesg aviationAttitudeMesg = new AviationAttitudeMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = aviationAttitudeMesg; AviationAttitudeMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Video: if (VideoMesgEvent != null) { VideoMesg videoMesg = new VideoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = videoMesg; VideoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.VideoTitle: if (VideoTitleMesgEvent != null) { VideoTitleMesg videoTitleMesg = new VideoTitleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = videoTitleMesg; VideoTitleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.VideoDescription: if (VideoDescriptionMesgEvent != null) { VideoDescriptionMesg videoDescriptionMesg = new VideoDescriptionMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = videoDescriptionMesg; VideoDescriptionMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.VideoClip: if (VideoClipMesgEvent != null) { VideoClipMesg videoClipMesg = new VideoClipMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = videoClipMesg; VideoClipMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Set: if (SetMesgEvent != null) { SetMesg setMesg = new SetMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = setMesg; SetMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Jump: if (JumpMesgEvent != null) { JumpMesg jumpMesg = new JumpMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = jumpMesg; JumpMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Course: if (CourseMesgEvent != null) { CourseMesg courseMesg = new CourseMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = courseMesg; CourseMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CoursePoint: if (CoursePointMesgEvent != null) { CoursePointMesg coursePointMesg = new CoursePointMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = coursePointMesg; CoursePointMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SegmentId: if (SegmentIdMesgEvent != null) { SegmentIdMesg segmentIdMesg = new SegmentIdMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = segmentIdMesg; SegmentIdMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SegmentLeaderboardEntry: if (SegmentLeaderboardEntryMesgEvent != null) { SegmentLeaderboardEntryMesg segmentLeaderboardEntryMesg = new SegmentLeaderboardEntryMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = segmentLeaderboardEntryMesg; SegmentLeaderboardEntryMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SegmentPoint: if (SegmentPointMesgEvent != null) { SegmentPointMesg segmentPointMesg = new SegmentPointMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = segmentPointMesg; SegmentPointMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SegmentLap: if (SegmentLapMesgEvent != null) { SegmentLapMesg segmentLapMesg = new SegmentLapMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = segmentLapMesg; SegmentLapMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SegmentFile: if (SegmentFileMesgEvent != null) { SegmentFileMesg segmentFileMesg = new SegmentFileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = segmentFileMesg; SegmentFileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Workout: if (WorkoutMesgEvent != null) { WorkoutMesg workoutMesg = new WorkoutMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutMesg; WorkoutMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WorkoutSession: if (WorkoutSessionMesgEvent != null) { WorkoutSessionMesg workoutSessionMesg = new WorkoutSessionMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutSessionMesg; WorkoutSessionMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WorkoutStep: if (WorkoutStepMesgEvent != null) { WorkoutStepMesg workoutStepMesg = new WorkoutStepMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutStepMesg; WorkoutStepMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ExerciseTitle: if (ExerciseTitleMesgEvent != null) { ExerciseTitleMesg exerciseTitleMesg = new ExerciseTitleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = exerciseTitleMesg; ExerciseTitleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Schedule: if (ScheduleMesgEvent != null) { ScheduleMesg scheduleMesg = new ScheduleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = scheduleMesg; ScheduleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Totals: if (TotalsMesgEvent != null) { TotalsMesg totalsMesg = new TotalsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = totalsMesg; TotalsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WeightScale: if (WeightScaleMesgEvent != null) { WeightScaleMesg weightScaleMesg = new WeightScaleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = weightScaleMesg; WeightScaleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BloodPressure: if (BloodPressureMesgEvent != null) { BloodPressureMesg bloodPressureMesg = new BloodPressureMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = bloodPressureMesg; BloodPressureMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MonitoringInfo: if (MonitoringInfoMesgEvent != null) { MonitoringInfoMesg monitoringInfoMesg = new MonitoringInfoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = monitoringInfoMesg; MonitoringInfoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Monitoring: if (MonitoringMesgEvent != null) { MonitoringMesg monitoringMesg = new MonitoringMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = monitoringMesg; MonitoringMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Hr: if (HrMesgEvent != null) { HrMesg hrMesg = new HrMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrMesg; HrMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.StressLevel: if (StressLevelMesgEvent != null) { StressLevelMesg stressLevelMesg = new StressLevelMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = stressLevelMesg; StressLevelMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MemoGlob: if (MemoGlobMesgEvent != null) { MemoGlobMesg memoGlobMesg = new MemoGlobMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = memoGlobMesg; MemoGlobMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.AntChannelId: if (AntChannelIdMesgEvent != null) { AntChannelIdMesg antChannelIdMesg = new AntChannelIdMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = antChannelIdMesg; AntChannelIdMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.AntRx: if (AntRxMesgEvent != null) { AntRxMesg antRxMesg = new AntRxMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = antRxMesg; AntRxMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.AntTx: if (AntTxMesgEvent != null) { AntTxMesg antTxMesg = new AntTxMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = antTxMesg; AntTxMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ExdScreenConfiguration: if (ExdScreenConfigurationMesgEvent != null) { ExdScreenConfigurationMesg exdScreenConfigurationMesg = new ExdScreenConfigurationMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = exdScreenConfigurationMesg; ExdScreenConfigurationMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ExdDataFieldConfiguration: if (ExdDataFieldConfigurationMesgEvent != null) { ExdDataFieldConfigurationMesg exdDataFieldConfigurationMesg = new ExdDataFieldConfigurationMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = exdDataFieldConfigurationMesg; ExdDataFieldConfigurationMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ExdDataConceptConfiguration: if (ExdDataConceptConfigurationMesgEvent != null) { ExdDataConceptConfigurationMesg exdDataConceptConfigurationMesg = new ExdDataConceptConfigurationMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = exdDataConceptConfigurationMesg; ExdDataConceptConfigurationMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FieldDescription: if (FieldDescriptionMesgEvent != null) { FieldDescriptionMesg fieldDescriptionMesg = new FieldDescriptionMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fieldDescriptionMesg; FieldDescriptionMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeveloperDataId: if (DeveloperDataIdMesgEvent != null) { DeveloperDataIdMesg developerDataIdMesg = new DeveloperDataIdMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = developerDataIdMesg; DeveloperDataIdMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DiveSummary: if (DiveSummaryMesgEvent != null) { DiveSummaryMesg diveSummaryMesg = new DiveSummaryMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = diveSummaryMesg; DiveSummaryMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ClimbPro: if (ClimbProMesgEvent != null) { ClimbProMesg climbProMesg = new ClimbProMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = climbProMesg; ClimbProMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Pad: if (PadMesgEvent != null) { PadMesg padMesg = new PadMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = padMesg; PadMesgEvent(sender, mesgEventArgs); } break; } }
public void OnBroadcast(object sender, MesgBroadcastEventArgs e) { List <Mesg> mesgs = e.mesgs; if (isActivityFile && (hr_start_index != HrToRecordMesgBroadcastPlugin.INVALID_INDEX)) { float? hr_anchor_event_timestamp = 0.0f; DateTime hr_anchor_timestamp = new DateTime(0); bool hr_anchor_set = false; byte? last_valid_hr = 0; DateTime last_valid_hr_time = new DateTime(0); for (int mesgCounter = 0; mesgCounter < mesgs.Count; mesgCounter++) { Mesg mesg = mesgs[mesgCounter]; if (mesg.Num == MesgNum.Record) { long hrSum = 0; long hrSumCount = 0; // Cast message to record message RecordMesg recordMesg = new RecordMesg(mesg); // Obtain the time for which the record message is valid DateTime record_range_end_time = new DateTime(recordMesg.GetTimestamp()); // Need to determine timestamp range which applies to this record bool findingInRangeHrMesgs = true; // Start searching HR mesgs where we left off int hr_mesg_counter = hr_start_index; int hr_sub_mesg_counter = hr_start_sub_index; while (findingInRangeHrMesgs && (hr_mesg_counter < mesgs.Count)) { // Skip over any non HR messages if (mesgs[hr_mesg_counter].Num == MesgNum.Hr) { HrMesg hrMesg = new HrMesg(mesgs[hr_mesg_counter]); // Update HR timestamp anchor, if present if (hrMesg.GetTimestamp() != null && hrMesg.GetTimestamp().GetTimeStamp() != 0) { hr_anchor_timestamp = new DateTime(hrMesg.GetTimestamp()); hr_anchor_set = true; if (hrMesg.GetFractionalTimestamp() != null) { hr_anchor_timestamp.Add((double)hrMesg.GetFractionalTimestamp()); } if (hrMesg.GetNumEventTimestamp() == 1) { hr_anchor_event_timestamp = hrMesg.GetEventTimestamp(0); } else { throw new FitException("FIT HrToRecordMesgBroadcastPlugin Error: Anchor HR mesg must have 1 event_timestamp"); } } if (hr_anchor_set == false) { // We cannot process any HR messages if we have not received a timestamp anchor throw new FitException("FIT HrToRecordMesgBroadcastPlugin Error: No anchor timestamp received in a HR mesg before diff HR mesgs"); } else if (hrMesg.GetNumEventTimestamp() != hrMesg.GetNumFilteredBpm()) { throw new FitException("FIT HrToRecordMesgBroadcastPlugin Error: HR mesg with mismatching event timestamp and filtered bpm"); } for (int j = hr_sub_mesg_counter; j < hrMesg.GetNumEventTimestamp(); j++) { // Build up timestamp for each message using the anchor and event_timestamp DateTime hrMesgTime = new DateTime(hr_anchor_timestamp); float? event_timestamp = hrMesg.GetEventTimestamp(j); // Deal with roll over case if (event_timestamp < hr_anchor_event_timestamp) { if ((hr_anchor_event_timestamp - event_timestamp) > (1 << 21)) { event_timestamp += (1 << 22); } else { throw new FitException("FIT HrToRecordMesgBroadcastPlugin Error: Anchor event_timestamp is greater than subsequent event_timestamp. This does not allow for correct delta calculation."); } } hrMesgTime.Add((double)(event_timestamp - hr_anchor_event_timestamp)); // Check if hrMesgTime is gt record start time // and if hrMesgTime is lte to record end time if ((hrMesgTime.CompareTo(record_range_start_time) > 0) && (hrMesgTime.CompareTo(record_range_end_time) <= 0)) { hrSum += (long)hrMesg.GetFilteredBpm(j); hrSumCount++; last_valid_hr_time = new DateTime(hrMesgTime); } // check if hrMesgTime exceeds the record time else if (hrMesgTime.CompareTo(record_range_end_time) > 0) { // Remember where we left off hr_start_index = hr_mesg_counter; hr_start_sub_index = j; findingInRangeHrMesgs = false; if (hrSumCount > 0) { // Update record heart rate last_valid_hr = (byte?)System.Math.Round((((float)hrSum) / hrSumCount), MidpointRounding.AwayFromZero); recordMesg.SetHeartRate(last_valid_hr); mesgs[mesgCounter] = (Mesg)recordMesg; } // If no stored HR is available, fill in record messages with the // last valid filtered hr for a maximum of 5 seconds else if ((record_range_start_time.CompareTo(last_valid_hr_time) > 0) && ((record_range_start_time.GetTimeStamp() - last_valid_hr_time.GetTimeStamp()) < 5)) { recordMesg.SetHeartRate(last_valid_hr); mesgs[mesgCounter] = (Mesg)recordMesg; } // Reset HR average hrSum = 0; hrSumCount = 0; record_range_start_time = new DateTime(record_range_end_time); // Breaks out of looping within the event_timestamp array break; } } } hr_mesg_counter++; hr_sub_mesg_counter = 0; } } } } }
public void OnMesg(object sender, MesgEventArgs e) { // Notify any subscribers of either our general mesg event or specific profile mesg event if (MesgEvent != null) { MesgEvent(sender, e); } switch (e.mesg.Num) { case (ushort)MesgNum.FileId: if (FileIdMesgEvent != null) { FileIdMesg fileIdMesg = new FileIdMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileIdMesg; FileIdMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FileCreator: if (FileCreatorMesgEvent != null) { FileCreatorMesg fileCreatorMesg = new FileCreatorMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileCreatorMesg; FileCreatorMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Software: if (SoftwareMesgEvent != null) { SoftwareMesg softwareMesg = new SoftwareMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = softwareMesg; SoftwareMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SlaveDevice: if (SlaveDeviceMesgEvent != null) { SlaveDeviceMesg slaveDeviceMesg = new SlaveDeviceMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = slaveDeviceMesg; SlaveDeviceMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Capabilities: if (CapabilitiesMesgEvent != null) { CapabilitiesMesg capabilitiesMesg = new CapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = capabilitiesMesg; CapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FileCapabilities: if (FileCapabilitiesMesgEvent != null) { FileCapabilitiesMesg fileCapabilitiesMesg = new FileCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileCapabilitiesMesg; FileCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MesgCapabilities: if (MesgCapabilitiesMesgEvent != null) { MesgCapabilitiesMesg mesgCapabilitiesMesg = new MesgCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = mesgCapabilitiesMesg; MesgCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FieldCapabilities: if (FieldCapabilitiesMesgEvent != null) { FieldCapabilitiesMesg fieldCapabilitiesMesg = new FieldCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fieldCapabilitiesMesg; FieldCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeviceSettings: if (DeviceSettingsMesgEvent != null) { DeviceSettingsMesg deviceSettingsMesg = new DeviceSettingsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = deviceSettingsMesg; DeviceSettingsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.UserProfile: if (UserProfileMesgEvent != null) { UserProfileMesg userProfileMesg = new UserProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = userProfileMesg; UserProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.HrmProfile: if (HrmProfileMesgEvent != null) { HrmProfileMesg hrmProfileMesg = new HrmProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrmProfileMesg; HrmProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SdmProfile: if (SdmProfileMesgEvent != null) { SdmProfileMesg sdmProfileMesg = new SdmProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sdmProfileMesg; SdmProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BikeProfile: if (BikeProfileMesgEvent != null) { BikeProfileMesg bikeProfileMesg = new BikeProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = bikeProfileMesg; BikeProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ZonesTarget: if (ZonesTargetMesgEvent != null) { ZonesTargetMesg zonesTargetMesg = new ZonesTargetMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = zonesTargetMesg; ZonesTargetMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Sport: if (SportMesgEvent != null) { SportMesg sportMesg = new SportMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sportMesg; SportMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.HrZone: if (HrZoneMesgEvent != null) { HrZoneMesg hrZoneMesg = new HrZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrZoneMesg; HrZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SpeedZone: if (SpeedZoneMesgEvent != null) { SpeedZoneMesg speedZoneMesg = new SpeedZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = speedZoneMesg; SpeedZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CadenceZone: if (CadenceZoneMesgEvent != null) { CadenceZoneMesg cadenceZoneMesg = new CadenceZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = cadenceZoneMesg; CadenceZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.PowerZone: if (PowerZoneMesgEvent != null) { PowerZoneMesg powerZoneMesg = new PowerZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = powerZoneMesg; PowerZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MetZone: if (MetZoneMesgEvent != null) { MetZoneMesg metZoneMesg = new MetZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = metZoneMesg; MetZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Goal: if (GoalMesgEvent != null) { GoalMesg goalMesg = new GoalMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = goalMesg; GoalMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Activity: if (ActivityMesgEvent != null) { ActivityMesg activityMesg = new ActivityMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = activityMesg; ActivityMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Session: if (SessionMesgEvent != null) { SessionMesg sessionMesg = new SessionMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sessionMesg; SessionMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Lap: if (LapMesgEvent != null) { LapMesg lapMesg = new LapMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = lapMesg; LapMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Length: if (LengthMesgEvent != null) { LengthMesg lengthMesg = new LengthMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = lengthMesg; LengthMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Record: if (RecordMesgEvent != null) { RecordMesg recordMesg = new RecordMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = recordMesg; RecordMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Event: if (EventMesgEvent != null) { EventMesg eventMesg = new EventMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = eventMesg; EventMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeviceInfo: if (DeviceInfoMesgEvent != null) { DeviceInfoMesg deviceInfoMesg = new DeviceInfoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = deviceInfoMesg; DeviceInfoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Hrv: if (HrvMesgEvent != null) { HrvMesg hrvMesg = new HrvMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrvMesg; HrvMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Course: if (CourseMesgEvent != null) { CourseMesg courseMesg = new CourseMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = courseMesg; CourseMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CoursePoint: if (CoursePointMesgEvent != null) { CoursePointMesg coursePointMesg = new CoursePointMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = coursePointMesg; CoursePointMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Workout: if (WorkoutMesgEvent != null) { WorkoutMesg workoutMesg = new WorkoutMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutMesg; WorkoutMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WorkoutStep: if (WorkoutStepMesgEvent != null) { WorkoutStepMesg workoutStepMesg = new WorkoutStepMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutStepMesg; WorkoutStepMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Schedule: if (ScheduleMesgEvent != null) { ScheduleMesg scheduleMesg = new ScheduleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = scheduleMesg; ScheduleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Totals: if (TotalsMesgEvent != null) { TotalsMesg totalsMesg = new TotalsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = totalsMesg; TotalsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WeightScale: if (WeightScaleMesgEvent != null) { WeightScaleMesg weightScaleMesg = new WeightScaleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = weightScaleMesg; WeightScaleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BloodPressure: if (BloodPressureMesgEvent != null) { BloodPressureMesg bloodPressureMesg = new BloodPressureMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = bloodPressureMesg; BloodPressureMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MonitoringInfo: if (MonitoringInfoMesgEvent != null) { MonitoringInfoMesg monitoringInfoMesg = new MonitoringInfoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = monitoringInfoMesg; MonitoringInfoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Monitoring: if (MonitoringMesgEvent != null) { MonitoringMesg monitoringMesg = new MonitoringMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = monitoringMesg; MonitoringMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MemoGlob: if (MemoGlobMesgEvent != null) { MemoGlobMesg memoGlobMesg = new MemoGlobMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = memoGlobMesg; MemoGlobMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Pad: if (PadMesgEvent != null) { PadMesg padMesg = new PadMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = padMesg; PadMesgEvent(sender, mesgEventArgs); } break; } }
public void OnMesg(object sender, MesgEventArgs e) { // Notify any subscribers of either our general mesg event or specific profile mesg event if (MesgEvent != null) { MesgEvent(sender, e); } switch (e.mesg.Num) { case (ushort)MesgNum.FileId: if (FileIdMesgEvent != null) { FileIdMesg fileIdMesg = new FileIdMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileIdMesg; FileIdMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FileCreator: if (FileCreatorMesgEvent != null) { FileCreatorMesg fileCreatorMesg = new FileCreatorMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileCreatorMesg; FileCreatorMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Software: if (SoftwareMesgEvent != null) { SoftwareMesg softwareMesg = new SoftwareMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = softwareMesg; SoftwareMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SlaveDevice: if (SlaveDeviceMesgEvent != null) { SlaveDeviceMesg slaveDeviceMesg = new SlaveDeviceMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = slaveDeviceMesg; SlaveDeviceMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Capabilities: if (CapabilitiesMesgEvent != null) { CapabilitiesMesg capabilitiesMesg = new CapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = capabilitiesMesg; CapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FileCapabilities: if (FileCapabilitiesMesgEvent != null) { FileCapabilitiesMesg fileCapabilitiesMesg = new FileCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fileCapabilitiesMesg; FileCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MesgCapabilities: if (MesgCapabilitiesMesgEvent != null) { MesgCapabilitiesMesg mesgCapabilitiesMesg = new MesgCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = mesgCapabilitiesMesg; MesgCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.FieldCapabilities: if (FieldCapabilitiesMesgEvent != null) { FieldCapabilitiesMesg fieldCapabilitiesMesg = new FieldCapabilitiesMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = fieldCapabilitiesMesg; FieldCapabilitiesMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeviceSettings: if (DeviceSettingsMesgEvent != null) { DeviceSettingsMesg deviceSettingsMesg = new DeviceSettingsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = deviceSettingsMesg; DeviceSettingsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.UserProfile: if (UserProfileMesgEvent != null) { UserProfileMesg userProfileMesg = new UserProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = userProfileMesg; UserProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.HrmProfile: if (HrmProfileMesgEvent != null) { HrmProfileMesg hrmProfileMesg = new HrmProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrmProfileMesg; HrmProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SdmProfile: if (SdmProfileMesgEvent != null) { SdmProfileMesg sdmProfileMesg = new SdmProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sdmProfileMesg; SdmProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BikeProfile: if (BikeProfileMesgEvent != null) { BikeProfileMesg bikeProfileMesg = new BikeProfileMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = bikeProfileMesg; BikeProfileMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.ZonesTarget: if (ZonesTargetMesgEvent != null) { ZonesTargetMesg zonesTargetMesg = new ZonesTargetMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = zonesTargetMesg; ZonesTargetMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Sport: if (SportMesgEvent != null) { SportMesg sportMesg = new SportMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sportMesg; SportMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.HrZone: if (HrZoneMesgEvent != null) { HrZoneMesg hrZoneMesg = new HrZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrZoneMesg; HrZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.SpeedZone: if (SpeedZoneMesgEvent != null) { SpeedZoneMesg speedZoneMesg = new SpeedZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = speedZoneMesg; SpeedZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CadenceZone: if (CadenceZoneMesgEvent != null) { CadenceZoneMesg cadenceZoneMesg = new CadenceZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = cadenceZoneMesg; CadenceZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.PowerZone: if (PowerZoneMesgEvent != null) { PowerZoneMesg powerZoneMesg = new PowerZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = powerZoneMesg; PowerZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MetZone: if (MetZoneMesgEvent != null) { MetZoneMesg metZoneMesg = new MetZoneMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = metZoneMesg; MetZoneMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Goal: if (GoalMesgEvent != null) { GoalMesg goalMesg = new GoalMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = goalMesg; GoalMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Activity: if (ActivityMesgEvent != null) { ActivityMesg activityMesg = new ActivityMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = activityMesg; ActivityMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Session: if (SessionMesgEvent != null) { SessionMesg sessionMesg = new SessionMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = sessionMesg; SessionMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Lap: if (LapMesgEvent != null) { LapMesg lapMesg = new LapMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = lapMesg; LapMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Length: if (LengthMesgEvent != null) { LengthMesg lengthMesg = new LengthMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = lengthMesg; LengthMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Record: if (RecordMesgEvent != null) { RecordMesg recordMesg = new RecordMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = recordMesg; RecordMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Event: if (EventMesgEvent != null) { EventMesg eventMesg = new EventMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = eventMesg; EventMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.DeviceInfo: if (DeviceInfoMesgEvent != null) { DeviceInfoMesg deviceInfoMesg = new DeviceInfoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = deviceInfoMesg; DeviceInfoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Hrv: if (HrvMesgEvent != null) { HrvMesg hrvMesg = new HrvMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = hrvMesg; HrvMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Course: if (CourseMesgEvent != null) { CourseMesg courseMesg = new CourseMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = courseMesg; CourseMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.CoursePoint: if (CoursePointMesgEvent != null) { CoursePointMesg coursePointMesg = new CoursePointMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = coursePointMesg; CoursePointMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Workout: if (WorkoutMesgEvent != null) { WorkoutMesg workoutMesg = new WorkoutMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutMesg; WorkoutMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WorkoutStep: if (WorkoutStepMesgEvent != null) { WorkoutStepMesg workoutStepMesg = new WorkoutStepMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = workoutStepMesg; WorkoutStepMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Schedule: if (ScheduleMesgEvent != null) { ScheduleMesg scheduleMesg = new ScheduleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = scheduleMesg; ScheduleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Totals: if (TotalsMesgEvent != null) { TotalsMesg totalsMesg = new TotalsMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = totalsMesg; TotalsMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.WeightScale: if (WeightScaleMesgEvent != null) { WeightScaleMesg weightScaleMesg = new WeightScaleMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = weightScaleMesg; WeightScaleMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.BloodPressure: if (BloodPressureMesgEvent != null) { BloodPressureMesg bloodPressureMesg = new BloodPressureMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = bloodPressureMesg; BloodPressureMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.MonitoringInfo: if (MonitoringInfoMesgEvent != null) { MonitoringInfoMesg monitoringInfoMesg = new MonitoringInfoMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = monitoringInfoMesg; MonitoringInfoMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Monitoring: if (MonitoringMesgEvent != null) { MonitoringMesg monitoringMesg = new MonitoringMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = monitoringMesg; MonitoringMesgEvent(sender, mesgEventArgs); } break; case (ushort)MesgNum.Pad: if (PadMesgEvent != null) { PadMesg padMesg = new PadMesg(e.mesg); MesgEventArgs mesgEventArgs = new MesgEventArgs(); mesgEventArgs.mesg = padMesg; PadMesgEvent(sender, mesgEventArgs); } break; } }