-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsession_gen.go
executable file
·4707 lines (4356 loc) · 164 KB
/
session_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by internal/cmd/fitgen/main.go. DO NOT EDIT.
// Copyright 2023 The FIT SDK for Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mesgdef
import (
"github.com/muktihari/fit/factory"
"github.com/muktihari/fit/internal/sliceutil"
"github.com/muktihari/fit/kit/datetime"
"github.com/muktihari/fit/kit/semicircles"
"github.com/muktihari/fit/profile/basetype"
"github.com/muktihari/fit/profile/typedef"
"github.com/muktihari/fit/proto"
"math"
"time"
)
// Session is a Session message.
//
// Note: The order of the fields is optimized using a memory alignment algorithm.
// Do not rely on field indices, such as when using reflection.
type Session struct {
Timestamp time.Time // Units: s; Sesson end time.
StartTime time.Time
TimeInHrZone []uint32 // Array: [N]; Scale: 1000; Units: s
TimeInSpeedZone []uint32 // Array: [N]; Scale: 1000; Units: s
TimeInCadenceZone []uint32 // Array: [N]; Scale: 1000; Units: s
TimeInPowerZone []uint32 // Array: [N]; Scale: 1000; Units: s
OpponentName string
StrokeCount []uint16 // Array: [N]; Units: counts; stroke_type enum used as the index
ZoneCount []uint16 // Array: [N]; Units: counts; zone number used as the index
AvgTotalHemoglobinConc []uint16 // Array: [N]; Scale: 100; Units: g/dL; Avg saturated and unsaturated hemoglobin
MinTotalHemoglobinConc []uint16 // Array: [N]; Scale: 100; Units: g/dL; Min saturated and unsaturated hemoglobin
MaxTotalHemoglobinConc []uint16 // Array: [N]; Scale: 100; Units: g/dL; Max saturated and unsaturated hemoglobin
AvgSaturatedHemoglobinPercent []uint16 // Array: [N]; Scale: 10; Units: %; Avg percentage of hemoglobin saturated with oxygen
MinSaturatedHemoglobinPercent []uint16 // Array: [N]; Scale: 10; Units: %; Min percentage of hemoglobin saturated with oxygen
MaxSaturatedHemoglobinPercent []uint16 // Array: [N]; Scale: 10; Units: %; Max percentage of hemoglobin saturated with oxygen
SportProfileName string // Sport name from associated sport mesg
AvgLeftPowerPhase []uint8 // Array: [N]; Scale: 0.7111111; Units: degrees; Average left power phase angles. Indexes defined by power_phase_type.
AvgLeftPowerPhasePeak []uint8 // Array: [N]; Scale: 0.7111111; Units: degrees; Average left power phase peak angles. Data value indexes defined by power_phase_type.
AvgRightPowerPhase []uint8 // Array: [N]; Scale: 0.7111111; Units: degrees; Average right power phase angles. Data value indexes defined by power_phase_type.
AvgRightPowerPhasePeak []uint8 // Array: [N]; Scale: 0.7111111; Units: degrees; Average right power phase peak angles data value indexes defined by power_phase_type.
AvgPowerPosition []uint16 // Array: [N]; Units: watts; Average power by position. Data value indexes defined by rider_position_type.
MaxPowerPosition []uint16 // Array: [N]; Units: watts; Maximum power by position. Data value indexes defined by rider_position_type.
AvgCadencePosition []uint8 // Array: [N]; Units: rpm; Average cadence by position. Data value indexes defined by rider_position_type.
MaxCadencePosition []uint8 // Array: [N]; Units: rpm; Maximum cadence by position. Data value indexes defined by rider_position_type.
StartPositionLat int32 // Units: semicircles
StartPositionLong int32 // Units: semicircles
TotalElapsedTime uint32 // Scale: 1000; Units: s; Time (includes pauses)
TotalTimerTime uint32 // Scale: 1000; Units: s; Timer Time (excludes pauses)
TotalDistance uint32 // Scale: 100; Units: m
TotalCycles uint32 // Units: cycles
NecLat int32 // Units: semicircles; North east corner latitude
NecLong int32 // Units: semicircles; North east corner longitude
SwcLat int32 // Units: semicircles; South west corner latitude
SwcLong int32 // Units: semicircles; South west corner longitude
EndPositionLat int32 // Units: semicircles
EndPositionLong int32 // Units: semicircles
AvgStrokeCount uint32 // Scale: 10; Units: strokes/lap
TotalWork uint32 // Units: J
TotalMovingTime uint32 // Scale: 1000; Units: s
AvgLapTime uint32 // Scale: 1000; Units: s
TimeStanding uint32 // Scale: 1000; Units: s; Total time spend in the standing position
EnhancedAvgSpeed uint32 // Scale: 1000; Units: m/s; total_distance / total_timer_time
EnhancedMaxSpeed uint32 // Scale: 1000; Units: m/s
EnhancedAvgAltitude uint32 // Scale: 5; Offset: 500; Units: m
EnhancedMinAltitude uint32 // Scale: 5; Offset: 500; Units: m
EnhancedMaxAltitude uint32 // Scale: 5; Offset: 500; Units: m
AvgDepth uint32 // Scale: 1000; Units: m; 0 if above water
MaxDepth uint32 // Scale: 1000; Units: m; 0 if above water
SurfaceInterval uint32 // Units: s; Time since end of last dive
DiveNumber uint32
TrainingLoadPeak int32 // Scale: 65536
TotalGrit float32 // Units: kGrit; The grit score estimates how challenging a route could be for a cyclist in terms of time spent going over sharp turns or large grade slopes.
TotalFlow float32 // Units: Flow; The flow score estimates how long distance wise a cyclist deaccelerates over intervals where deacceleration is unnecessary such as smooth turns or small grade angle intervals.
AvgGrit float32 // Units: kGrit; The grit score estimates how challenging a route could be for a cyclist in terms of time spent going over sharp turns or large grade slopes.
AvgFlow float32 // Units: Flow; The flow score estimates how long distance wise a cyclist deaccelerates over intervals where deacceleration is unnecessary such as smooth turns or small grade angle intervals.
MessageIndex typedef.MessageIndex // Selected bit is set for the current session.
TotalCalories uint16 // Units: kcal
TotalFatCalories uint16 // Units: kcal
AvgSpeed uint16 // Scale: 1000; Units: m/s; total_distance / total_timer_time
MaxSpeed uint16 // Scale: 1000; Units: m/s
AvgPower uint16 // Units: watts; total_power / total_timer_time if non_zero_avg_power otherwise total_power / total_elapsed_time
MaxPower uint16 // Units: watts
TotalAscent uint16 // Units: m
TotalDescent uint16 // Units: m
FirstLapIndex uint16
NumLaps uint16
NumLengths uint16 // Units: lengths; # of lengths of swim pool
NormalizedPower uint16 // Units: watts
TrainingStressScore uint16 // Scale: 10; Units: tss
IntensityFactor uint16 // Scale: 1000; Units: if
LeftRightBalance typedef.LeftRightBalance100
AvgStrokeDistance uint16 // Scale: 100; Units: m
PoolLength uint16 // Scale: 100; Units: m
ThresholdPower uint16 // Units: watts
NumActiveLengths uint16 // Units: lengths; # of active lengths of swim pool
AvgAltitude uint16 // Scale: 5; Offset: 500; Units: m
MaxAltitude uint16 // Scale: 5; Offset: 500; Units: m
AvgGrade int16 // Scale: 100; Units: %
AvgPosGrade int16 // Scale: 100; Units: %
AvgNegGrade int16 // Scale: 100; Units: %
MaxPosGrade int16 // Scale: 100; Units: %
MaxNegGrade int16 // Scale: 100; Units: %
AvgPosVerticalSpeed int16 // Scale: 1000; Units: m/s
AvgNegVerticalSpeed int16 // Scale: 1000; Units: m/s
MaxPosVerticalSpeed int16 // Scale: 1000; Units: m/s
MaxNegVerticalSpeed int16 // Scale: 1000; Units: m/s
BestLapIndex uint16
MinAltitude uint16 // Scale: 5; Offset: 500; Units: m
PlayerScore uint16
OpponentScore uint16
MaxBallSpeed uint16 // Scale: 100; Units: m/s
AvgBallSpeed uint16 // Scale: 100; Units: m/s
AvgVerticalOscillation uint16 // Scale: 10; Units: mm
AvgStanceTimePercent uint16 // Scale: 100; Units: percent
AvgStanceTime uint16 // Scale: 10; Units: ms
StandCount uint16 // Number of transitions to the standing state
AvgLevMotorPower uint16 // Units: watts; lev average motor power during session
MaxLevMotorPower uint16 // Units: watts; lev maximum motor power during session
AvgVerticalRatio uint16 // Scale: 100; Units: percent
AvgStanceTimeBalance uint16 // Scale: 100; Units: percent
AvgStepLength uint16 // Scale: 10; Units: mm
AvgVam uint16 // Scale: 1000; Units: m/s
StartN2 uint16 // Units: percent
EndN2 uint16 // Units: percent
O2Toxicity uint16 // Units: OTUs
EnhancedAvgRespirationRate uint16 // Scale: 100; Units: Breaths/min
EnhancedMaxRespirationRate uint16 // Scale: 100; Units: Breaths/min
EnhancedMinRespirationRate uint16 // Scale: 100
JumpCount uint16
AvgCoreTemperature uint16 // Scale: 100; Units: C
MinCoreTemperature uint16 // Scale: 100; Units: C
MaxCoreTemperature uint16 // Scale: 100; Units: C
Event typedef.Event // session
EventType typedef.EventType // stop
Sport typedef.Sport
SubSport typedef.SubSport
AvgHeartRate uint8 // Units: bpm; average heart rate (excludes pause time)
MaxHeartRate uint8 // Units: bpm
AvgCadence uint8 // Units: rpm; total_cycles / total_timer_time if non_zero_avg_cadence otherwise total_cycles / total_elapsed_time
MaxCadence uint8 // Units: rpm
TotalTrainingEffect uint8 // Scale: 10
EventGroup uint8
Trigger typedef.SessionTrigger
SwimStroke typedef.SwimStroke // Units: swim_stroke
PoolLengthUnit typedef.DisplayMeasure
GpsAccuracy uint8 // Units: m
AvgTemperature int8 // Units: C
MaxTemperature int8 // Units: C
MinHeartRate uint8 // Units: bpm
AvgFractionalCadence uint8 // Scale: 128; Units: rpm; fractional part of the avg_cadence
MaxFractionalCadence uint8 // Scale: 128; Units: rpm; fractional part of the max_cadence
TotalFractionalCycles uint8 // Scale: 128; Units: cycles; fractional part of the total_cycles
AvgLeftTorqueEffectiveness uint8 // Scale: 2; Units: percent
AvgRightTorqueEffectiveness uint8 // Scale: 2; Units: percent
AvgLeftPedalSmoothness uint8 // Scale: 2; Units: percent
AvgRightPedalSmoothness uint8 // Scale: 2; Units: percent
AvgCombinedPedalSmoothness uint8 // Scale: 2; Units: percent
SportIndex uint8
AvgLeftPco int8 // Units: mm; Average platform center offset Left
AvgRightPco int8 // Units: mm; Average platform center offset Right
LevBatteryConsumption uint8 // Scale: 2; Units: percent; lev battery consumption during session
TotalAnaerobicTrainingEffect uint8 // Scale: 10
StartCns uint8 // Units: percent
EndCns uint8 // Units: percent
AvgRespirationRate uint8
MaxRespirationRate uint8
MinRespirationRate uint8
MinTemperature int8 // Units: C
WorkoutFeel uint8 // A 0-100 scale representing how a user felt while performing a workout. Low values are considered feeling bad, while high values are good.
WorkoutRpe uint8 // Common Borg CR10 / 0-10 RPE scale, multiplied 10x.. Aggregate score for all workouts in a single session.
AvgSpo2 uint8 // Units: percent; Average SPO2 for the monitoring session
AvgStress uint8 // Units: percent; Average stress for the monitoring session
SdrrHrv uint8 // Units: mS; Standard deviation of R-R interval (SDRR) - Heart rate variability measure most useful for wellness users.
RmssdHrv uint8 // Units: mS; Root mean square successive difference (RMSSD) - Heart rate variability measure most useful for athletes
TotalFractionalAscent uint8 // Scale: 100; Units: m; fractional part of total_ascent
TotalFractionalDescent uint8 // Scale: 100; Units: m; fractional part of total_descent
state [23]uint8 // Used for tracking expanded fields.
UnknownFields []proto.Field // UnknownFields are fields that are exist but they are not defined in Profile.xlsx
DeveloperFields []proto.DeveloperField // DeveloperFields are custom data fields [Added since protocol version 2.0]
}
// NewSession creates new Session struct based on given mesg.
// If mesg is nil, it will return Session with all fields being set to its corresponding invalid value.
func NewSession(mesg *proto.Message) *Session {
vals := [255]proto.Value{}
var state [23]uint8
var unknownFields []proto.Field
var developerFields []proto.DeveloperField
if mesg != nil {
arr := pool.Get().(*[poolsize]proto.Field)
unknownFields = arr[:0]
for i := range mesg.Fields {
if mesg.Fields[i].Num > 254 || mesg.Fields[i].Name == factory.NameUnknown {
unknownFields = append(unknownFields, mesg.Fields[i])
continue
}
if mesg.Fields[i].Num < 181 && mesg.Fields[i].IsExpandedField {
pos := mesg.Fields[i].Num / 8
state[pos] |= 1 << (mesg.Fields[i].Num - (8 * pos))
}
vals[mesg.Fields[i].Num] = mesg.Fields[i].Value
}
unknownFields = sliceutil.Clone(unknownFields)
*arr = [poolsize]proto.Field{}
pool.Put(arr)
developerFields = mesg.DeveloperFields
}
return &Session{
MessageIndex: typedef.MessageIndex(vals[254].Uint16()),
Timestamp: datetime.ToTime(vals[253].Uint32()),
Event: typedef.Event(vals[0].Uint8()),
EventType: typedef.EventType(vals[1].Uint8()),
StartTime: datetime.ToTime(vals[2].Uint32()),
StartPositionLat: vals[3].Int32(),
StartPositionLong: vals[4].Int32(),
Sport: typedef.Sport(vals[5].Uint8()),
SubSport: typedef.SubSport(vals[6].Uint8()),
TotalElapsedTime: vals[7].Uint32(),
TotalTimerTime: vals[8].Uint32(),
TotalDistance: vals[9].Uint32(),
TotalCycles: vals[10].Uint32(),
TotalCalories: vals[11].Uint16(),
TotalFatCalories: vals[13].Uint16(),
AvgSpeed: vals[14].Uint16(),
MaxSpeed: vals[15].Uint16(),
AvgHeartRate: vals[16].Uint8(),
MaxHeartRate: vals[17].Uint8(),
AvgCadence: vals[18].Uint8(),
MaxCadence: vals[19].Uint8(),
AvgPower: vals[20].Uint16(),
MaxPower: vals[21].Uint16(),
TotalAscent: vals[22].Uint16(),
TotalDescent: vals[23].Uint16(),
TotalTrainingEffect: vals[24].Uint8(),
FirstLapIndex: vals[25].Uint16(),
NumLaps: vals[26].Uint16(),
EventGroup: vals[27].Uint8(),
Trigger: typedef.SessionTrigger(vals[28].Uint8()),
NecLat: vals[29].Int32(),
NecLong: vals[30].Int32(),
SwcLat: vals[31].Int32(),
SwcLong: vals[32].Int32(),
NumLengths: vals[33].Uint16(),
NormalizedPower: vals[34].Uint16(),
TrainingStressScore: vals[35].Uint16(),
IntensityFactor: vals[36].Uint16(),
LeftRightBalance: typedef.LeftRightBalance100(vals[37].Uint16()),
EndPositionLat: vals[38].Int32(),
EndPositionLong: vals[39].Int32(),
AvgStrokeCount: vals[41].Uint32(),
AvgStrokeDistance: vals[42].Uint16(),
SwimStroke: typedef.SwimStroke(vals[43].Uint8()),
PoolLength: vals[44].Uint16(),
ThresholdPower: vals[45].Uint16(),
PoolLengthUnit: typedef.DisplayMeasure(vals[46].Uint8()),
NumActiveLengths: vals[47].Uint16(),
TotalWork: vals[48].Uint32(),
AvgAltitude: vals[49].Uint16(),
MaxAltitude: vals[50].Uint16(),
GpsAccuracy: vals[51].Uint8(),
AvgGrade: vals[52].Int16(),
AvgPosGrade: vals[53].Int16(),
AvgNegGrade: vals[54].Int16(),
MaxPosGrade: vals[55].Int16(),
MaxNegGrade: vals[56].Int16(),
AvgTemperature: vals[57].Int8(),
MaxTemperature: vals[58].Int8(),
TotalMovingTime: vals[59].Uint32(),
AvgPosVerticalSpeed: vals[60].Int16(),
AvgNegVerticalSpeed: vals[61].Int16(),
MaxPosVerticalSpeed: vals[62].Int16(),
MaxNegVerticalSpeed: vals[63].Int16(),
MinHeartRate: vals[64].Uint8(),
TimeInHrZone: vals[65].SliceUint32(),
TimeInSpeedZone: vals[66].SliceUint32(),
TimeInCadenceZone: vals[67].SliceUint32(),
TimeInPowerZone: vals[68].SliceUint32(),
AvgLapTime: vals[69].Uint32(),
BestLapIndex: vals[70].Uint16(),
MinAltitude: vals[71].Uint16(),
PlayerScore: vals[82].Uint16(),
OpponentScore: vals[83].Uint16(),
OpponentName: vals[84].String(),
StrokeCount: vals[85].SliceUint16(),
ZoneCount: vals[86].SliceUint16(),
MaxBallSpeed: vals[87].Uint16(),
AvgBallSpeed: vals[88].Uint16(),
AvgVerticalOscillation: vals[89].Uint16(),
AvgStanceTimePercent: vals[90].Uint16(),
AvgStanceTime: vals[91].Uint16(),
AvgFractionalCadence: vals[92].Uint8(),
MaxFractionalCadence: vals[93].Uint8(),
TotalFractionalCycles: vals[94].Uint8(),
AvgTotalHemoglobinConc: vals[95].SliceUint16(),
MinTotalHemoglobinConc: vals[96].SliceUint16(),
MaxTotalHemoglobinConc: vals[97].SliceUint16(),
AvgSaturatedHemoglobinPercent: vals[98].SliceUint16(),
MinSaturatedHemoglobinPercent: vals[99].SliceUint16(),
MaxSaturatedHemoglobinPercent: vals[100].SliceUint16(),
AvgLeftTorqueEffectiveness: vals[101].Uint8(),
AvgRightTorqueEffectiveness: vals[102].Uint8(),
AvgLeftPedalSmoothness: vals[103].Uint8(),
AvgRightPedalSmoothness: vals[104].Uint8(),
AvgCombinedPedalSmoothness: vals[105].Uint8(),
SportProfileName: vals[110].String(),
SportIndex: vals[111].Uint8(),
TimeStanding: vals[112].Uint32(),
StandCount: vals[113].Uint16(),
AvgLeftPco: vals[114].Int8(),
AvgRightPco: vals[115].Int8(),
AvgLeftPowerPhase: vals[116].SliceUint8(),
AvgLeftPowerPhasePeak: vals[117].SliceUint8(),
AvgRightPowerPhase: vals[118].SliceUint8(),
AvgRightPowerPhasePeak: vals[119].SliceUint8(),
AvgPowerPosition: vals[120].SliceUint16(),
MaxPowerPosition: vals[121].SliceUint16(),
AvgCadencePosition: vals[122].SliceUint8(),
MaxCadencePosition: vals[123].SliceUint8(),
EnhancedAvgSpeed: vals[124].Uint32(),
EnhancedMaxSpeed: vals[125].Uint32(),
EnhancedAvgAltitude: vals[126].Uint32(),
EnhancedMinAltitude: vals[127].Uint32(),
EnhancedMaxAltitude: vals[128].Uint32(),
AvgLevMotorPower: vals[129].Uint16(),
MaxLevMotorPower: vals[130].Uint16(),
LevBatteryConsumption: vals[131].Uint8(),
AvgVerticalRatio: vals[132].Uint16(),
AvgStanceTimeBalance: vals[133].Uint16(),
AvgStepLength: vals[134].Uint16(),
TotalAnaerobicTrainingEffect: vals[137].Uint8(),
AvgVam: vals[139].Uint16(),
AvgDepth: vals[140].Uint32(),
MaxDepth: vals[141].Uint32(),
SurfaceInterval: vals[142].Uint32(),
StartCns: vals[143].Uint8(),
EndCns: vals[144].Uint8(),
StartN2: vals[145].Uint16(),
EndN2: vals[146].Uint16(),
AvgRespirationRate: vals[147].Uint8(),
MaxRespirationRate: vals[148].Uint8(),
MinRespirationRate: vals[149].Uint8(),
MinTemperature: vals[150].Int8(),
O2Toxicity: vals[155].Uint16(),
DiveNumber: vals[156].Uint32(),
TrainingLoadPeak: vals[168].Int32(),
EnhancedAvgRespirationRate: vals[169].Uint16(),
EnhancedMaxRespirationRate: vals[170].Uint16(),
EnhancedMinRespirationRate: vals[180].Uint16(),
TotalGrit: vals[181].Float32(),
TotalFlow: vals[182].Float32(),
JumpCount: vals[183].Uint16(),
AvgGrit: vals[186].Float32(),
AvgFlow: vals[187].Float32(),
WorkoutFeel: vals[192].Uint8(),
WorkoutRpe: vals[193].Uint8(),
AvgSpo2: vals[194].Uint8(),
AvgStress: vals[195].Uint8(),
SdrrHrv: vals[197].Uint8(),
RmssdHrv: vals[198].Uint8(),
TotalFractionalAscent: vals[199].Uint8(),
TotalFractionalDescent: vals[200].Uint8(),
AvgCoreTemperature: vals[208].Uint16(),
MinCoreTemperature: vals[209].Uint16(),
MaxCoreTemperature: vals[210].Uint16(),
state: state,
UnknownFields: unknownFields,
DeveloperFields: developerFields,
}
}
// ToMesg converts Session into proto.Message. If options is nil, default options will be used.
func (m *Session) ToMesg(options *Options) proto.Message {
if options == nil {
options = defaultOptions
} else if options.Factory == nil {
options.Factory = factory.StandardFactory()
}
fac := options.Factory
arr := pool.Get().(*[poolsize]proto.Field)
fields := arr[:0]
mesg := proto.Message{Num: typedef.MesgNumSession}
if m.MessageIndex != typedef.MessageIndexInvalid {
field := fac.CreateField(mesg.Num, 254)
field.Value = proto.Uint16(uint16(m.MessageIndex))
fields = append(fields, field)
}
if !m.Timestamp.Before(datetime.Epoch()) {
field := fac.CreateField(mesg.Num, 253)
field.Value = proto.Uint32(uint32(m.Timestamp.Sub(datetime.Epoch()).Seconds()))
fields = append(fields, field)
}
if m.Event != typedef.EventInvalid {
field := fac.CreateField(mesg.Num, 0)
field.Value = proto.Uint8(byte(m.Event))
fields = append(fields, field)
}
if m.EventType != typedef.EventTypeInvalid {
field := fac.CreateField(mesg.Num, 1)
field.Value = proto.Uint8(byte(m.EventType))
fields = append(fields, field)
}
if !m.StartTime.Before(datetime.Epoch()) {
field := fac.CreateField(mesg.Num, 2)
field.Value = proto.Uint32(uint32(m.StartTime.Sub(datetime.Epoch()).Seconds()))
fields = append(fields, field)
}
if m.StartPositionLat != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 3)
field.Value = proto.Int32(m.StartPositionLat)
fields = append(fields, field)
}
if m.StartPositionLong != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 4)
field.Value = proto.Int32(m.StartPositionLong)
fields = append(fields, field)
}
if m.Sport != typedef.SportInvalid {
field := fac.CreateField(mesg.Num, 5)
field.Value = proto.Uint8(byte(m.Sport))
fields = append(fields, field)
}
if m.SubSport != typedef.SubSportInvalid {
field := fac.CreateField(mesg.Num, 6)
field.Value = proto.Uint8(byte(m.SubSport))
fields = append(fields, field)
}
if m.TotalElapsedTime != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 7)
field.Value = proto.Uint32(m.TotalElapsedTime)
fields = append(fields, field)
}
if m.TotalTimerTime != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 8)
field.Value = proto.Uint32(m.TotalTimerTime)
fields = append(fields, field)
}
if m.TotalDistance != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 9)
field.Value = proto.Uint32(m.TotalDistance)
fields = append(fields, field)
}
if m.TotalCycles != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 10)
field.Value = proto.Uint32(m.TotalCycles)
fields = append(fields, field)
}
if m.TotalCalories != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 11)
field.Value = proto.Uint16(m.TotalCalories)
fields = append(fields, field)
}
if m.TotalFatCalories != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 13)
field.Value = proto.Uint16(m.TotalFatCalories)
fields = append(fields, field)
}
if m.AvgSpeed != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 14)
field.Value = proto.Uint16(m.AvgSpeed)
fields = append(fields, field)
}
if m.MaxSpeed != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 15)
field.Value = proto.Uint16(m.MaxSpeed)
fields = append(fields, field)
}
if m.AvgHeartRate != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 16)
field.Value = proto.Uint8(m.AvgHeartRate)
fields = append(fields, field)
}
if m.MaxHeartRate != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 17)
field.Value = proto.Uint8(m.MaxHeartRate)
fields = append(fields, field)
}
if m.AvgCadence != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 18)
field.Value = proto.Uint8(m.AvgCadence)
fields = append(fields, field)
}
if m.MaxCadence != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 19)
field.Value = proto.Uint8(m.MaxCadence)
fields = append(fields, field)
}
if m.AvgPower != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 20)
field.Value = proto.Uint16(m.AvgPower)
fields = append(fields, field)
}
if m.MaxPower != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 21)
field.Value = proto.Uint16(m.MaxPower)
fields = append(fields, field)
}
if m.TotalAscent != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 22)
field.Value = proto.Uint16(m.TotalAscent)
fields = append(fields, field)
}
if m.TotalDescent != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 23)
field.Value = proto.Uint16(m.TotalDescent)
fields = append(fields, field)
}
if m.TotalTrainingEffect != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 24)
field.Value = proto.Uint8(m.TotalTrainingEffect)
fields = append(fields, field)
}
if m.FirstLapIndex != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 25)
field.Value = proto.Uint16(m.FirstLapIndex)
fields = append(fields, field)
}
if m.NumLaps != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 26)
field.Value = proto.Uint16(m.NumLaps)
fields = append(fields, field)
}
if m.EventGroup != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 27)
field.Value = proto.Uint8(m.EventGroup)
fields = append(fields, field)
}
if m.Trigger != typedef.SessionTriggerInvalid {
field := fac.CreateField(mesg.Num, 28)
field.Value = proto.Uint8(byte(m.Trigger))
fields = append(fields, field)
}
if m.NecLat != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 29)
field.Value = proto.Int32(m.NecLat)
fields = append(fields, field)
}
if m.NecLong != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 30)
field.Value = proto.Int32(m.NecLong)
fields = append(fields, field)
}
if m.SwcLat != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 31)
field.Value = proto.Int32(m.SwcLat)
fields = append(fields, field)
}
if m.SwcLong != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 32)
field.Value = proto.Int32(m.SwcLong)
fields = append(fields, field)
}
if m.NumLengths != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 33)
field.Value = proto.Uint16(m.NumLengths)
fields = append(fields, field)
}
if m.NormalizedPower != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 34)
field.Value = proto.Uint16(m.NormalizedPower)
fields = append(fields, field)
}
if m.TrainingStressScore != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 35)
field.Value = proto.Uint16(m.TrainingStressScore)
fields = append(fields, field)
}
if m.IntensityFactor != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 36)
field.Value = proto.Uint16(m.IntensityFactor)
fields = append(fields, field)
}
if m.LeftRightBalance != typedef.LeftRightBalance100Invalid {
field := fac.CreateField(mesg.Num, 37)
field.Value = proto.Uint16(uint16(m.LeftRightBalance))
fields = append(fields, field)
}
if m.EndPositionLat != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 38)
field.Value = proto.Int32(m.EndPositionLat)
fields = append(fields, field)
}
if m.EndPositionLong != basetype.Sint32Invalid {
field := fac.CreateField(mesg.Num, 39)
field.Value = proto.Int32(m.EndPositionLong)
fields = append(fields, field)
}
if m.AvgStrokeCount != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 41)
field.Value = proto.Uint32(m.AvgStrokeCount)
fields = append(fields, field)
}
if m.AvgStrokeDistance != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 42)
field.Value = proto.Uint16(m.AvgStrokeDistance)
fields = append(fields, field)
}
if m.SwimStroke != typedef.SwimStrokeInvalid {
field := fac.CreateField(mesg.Num, 43)
field.Value = proto.Uint8(byte(m.SwimStroke))
fields = append(fields, field)
}
if m.PoolLength != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 44)
field.Value = proto.Uint16(m.PoolLength)
fields = append(fields, field)
}
if m.ThresholdPower != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 45)
field.Value = proto.Uint16(m.ThresholdPower)
fields = append(fields, field)
}
if m.PoolLengthUnit != typedef.DisplayMeasureInvalid {
field := fac.CreateField(mesg.Num, 46)
field.Value = proto.Uint8(byte(m.PoolLengthUnit))
fields = append(fields, field)
}
if m.NumActiveLengths != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 47)
field.Value = proto.Uint16(m.NumActiveLengths)
fields = append(fields, field)
}
if m.TotalWork != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 48)
field.Value = proto.Uint32(m.TotalWork)
fields = append(fields, field)
}
if m.AvgAltitude != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 49)
field.Value = proto.Uint16(m.AvgAltitude)
fields = append(fields, field)
}
if m.MaxAltitude != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 50)
field.Value = proto.Uint16(m.MaxAltitude)
fields = append(fields, field)
}
if m.GpsAccuracy != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 51)
field.Value = proto.Uint8(m.GpsAccuracy)
fields = append(fields, field)
}
if m.AvgGrade != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 52)
field.Value = proto.Int16(m.AvgGrade)
fields = append(fields, field)
}
if m.AvgPosGrade != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 53)
field.Value = proto.Int16(m.AvgPosGrade)
fields = append(fields, field)
}
if m.AvgNegGrade != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 54)
field.Value = proto.Int16(m.AvgNegGrade)
fields = append(fields, field)
}
if m.MaxPosGrade != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 55)
field.Value = proto.Int16(m.MaxPosGrade)
fields = append(fields, field)
}
if m.MaxNegGrade != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 56)
field.Value = proto.Int16(m.MaxNegGrade)
fields = append(fields, field)
}
if m.AvgTemperature != basetype.Sint8Invalid {
field := fac.CreateField(mesg.Num, 57)
field.Value = proto.Int8(m.AvgTemperature)
fields = append(fields, field)
}
if m.MaxTemperature != basetype.Sint8Invalid {
field := fac.CreateField(mesg.Num, 58)
field.Value = proto.Int8(m.MaxTemperature)
fields = append(fields, field)
}
if m.TotalMovingTime != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 59)
field.Value = proto.Uint32(m.TotalMovingTime)
fields = append(fields, field)
}
if m.AvgPosVerticalSpeed != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 60)
field.Value = proto.Int16(m.AvgPosVerticalSpeed)
fields = append(fields, field)
}
if m.AvgNegVerticalSpeed != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 61)
field.Value = proto.Int16(m.AvgNegVerticalSpeed)
fields = append(fields, field)
}
if m.MaxPosVerticalSpeed != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 62)
field.Value = proto.Int16(m.MaxPosVerticalSpeed)
fields = append(fields, field)
}
if m.MaxNegVerticalSpeed != basetype.Sint16Invalid {
field := fac.CreateField(mesg.Num, 63)
field.Value = proto.Int16(m.MaxNegVerticalSpeed)
fields = append(fields, field)
}
if m.MinHeartRate != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 64)
field.Value = proto.Uint8(m.MinHeartRate)
fields = append(fields, field)
}
if m.TimeInHrZone != nil {
field := fac.CreateField(mesg.Num, 65)
field.Value = proto.SliceUint32(m.TimeInHrZone)
fields = append(fields, field)
}
if m.TimeInSpeedZone != nil {
field := fac.CreateField(mesg.Num, 66)
field.Value = proto.SliceUint32(m.TimeInSpeedZone)
fields = append(fields, field)
}
if m.TimeInCadenceZone != nil {
field := fac.CreateField(mesg.Num, 67)
field.Value = proto.SliceUint32(m.TimeInCadenceZone)
fields = append(fields, field)
}
if m.TimeInPowerZone != nil {
field := fac.CreateField(mesg.Num, 68)
field.Value = proto.SliceUint32(m.TimeInPowerZone)
fields = append(fields, field)
}
if m.AvgLapTime != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 69)
field.Value = proto.Uint32(m.AvgLapTime)
fields = append(fields, field)
}
if m.BestLapIndex != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 70)
field.Value = proto.Uint16(m.BestLapIndex)
fields = append(fields, field)
}
if m.MinAltitude != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 71)
field.Value = proto.Uint16(m.MinAltitude)
fields = append(fields, field)
}
if m.PlayerScore != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 82)
field.Value = proto.Uint16(m.PlayerScore)
fields = append(fields, field)
}
if m.OpponentScore != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 83)
field.Value = proto.Uint16(m.OpponentScore)
fields = append(fields, field)
}
if m.OpponentName != basetype.StringInvalid {
field := fac.CreateField(mesg.Num, 84)
field.Value = proto.String(m.OpponentName)
fields = append(fields, field)
}
if m.StrokeCount != nil {
field := fac.CreateField(mesg.Num, 85)
field.Value = proto.SliceUint16(m.StrokeCount)
fields = append(fields, field)
}
if m.ZoneCount != nil {
field := fac.CreateField(mesg.Num, 86)
field.Value = proto.SliceUint16(m.ZoneCount)
fields = append(fields, field)
}
if m.MaxBallSpeed != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 87)
field.Value = proto.Uint16(m.MaxBallSpeed)
fields = append(fields, field)
}
if m.AvgBallSpeed != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 88)
field.Value = proto.Uint16(m.AvgBallSpeed)
fields = append(fields, field)
}
if m.AvgVerticalOscillation != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 89)
field.Value = proto.Uint16(m.AvgVerticalOscillation)
fields = append(fields, field)
}
if m.AvgStanceTimePercent != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 90)
field.Value = proto.Uint16(m.AvgStanceTimePercent)
fields = append(fields, field)
}
if m.AvgStanceTime != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 91)
field.Value = proto.Uint16(m.AvgStanceTime)
fields = append(fields, field)
}
if m.AvgFractionalCadence != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 92)
field.Value = proto.Uint8(m.AvgFractionalCadence)
fields = append(fields, field)
}
if m.MaxFractionalCadence != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 93)
field.Value = proto.Uint8(m.MaxFractionalCadence)
fields = append(fields, field)
}
if m.TotalFractionalCycles != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 94)
field.Value = proto.Uint8(m.TotalFractionalCycles)
fields = append(fields, field)
}
if m.AvgTotalHemoglobinConc != nil {
field := fac.CreateField(mesg.Num, 95)
field.Value = proto.SliceUint16(m.AvgTotalHemoglobinConc)
fields = append(fields, field)
}
if m.MinTotalHemoglobinConc != nil {
field := fac.CreateField(mesg.Num, 96)
field.Value = proto.SliceUint16(m.MinTotalHemoglobinConc)
fields = append(fields, field)
}
if m.MaxTotalHemoglobinConc != nil {
field := fac.CreateField(mesg.Num, 97)
field.Value = proto.SliceUint16(m.MaxTotalHemoglobinConc)
fields = append(fields, field)
}
if m.AvgSaturatedHemoglobinPercent != nil {
field := fac.CreateField(mesg.Num, 98)
field.Value = proto.SliceUint16(m.AvgSaturatedHemoglobinPercent)
fields = append(fields, field)
}
if m.MinSaturatedHemoglobinPercent != nil {
field := fac.CreateField(mesg.Num, 99)
field.Value = proto.SliceUint16(m.MinSaturatedHemoglobinPercent)
fields = append(fields, field)
}
if m.MaxSaturatedHemoglobinPercent != nil {
field := fac.CreateField(mesg.Num, 100)
field.Value = proto.SliceUint16(m.MaxSaturatedHemoglobinPercent)
fields = append(fields, field)
}
if m.AvgLeftTorqueEffectiveness != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 101)
field.Value = proto.Uint8(m.AvgLeftTorqueEffectiveness)
fields = append(fields, field)
}
if m.AvgRightTorqueEffectiveness != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 102)
field.Value = proto.Uint8(m.AvgRightTorqueEffectiveness)
fields = append(fields, field)
}
if m.AvgLeftPedalSmoothness != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 103)
field.Value = proto.Uint8(m.AvgLeftPedalSmoothness)
fields = append(fields, field)
}
if m.AvgRightPedalSmoothness != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 104)
field.Value = proto.Uint8(m.AvgRightPedalSmoothness)
fields = append(fields, field)
}
if m.AvgCombinedPedalSmoothness != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 105)
field.Value = proto.Uint8(m.AvgCombinedPedalSmoothness)
fields = append(fields, field)
}
if m.SportProfileName != basetype.StringInvalid {
field := fac.CreateField(mesg.Num, 110)
field.Value = proto.String(m.SportProfileName)
fields = append(fields, field)
}
if m.SportIndex != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 111)
field.Value = proto.Uint8(m.SportIndex)
fields = append(fields, field)
}
if m.TimeStanding != basetype.Uint32Invalid {
field := fac.CreateField(mesg.Num, 112)
field.Value = proto.Uint32(m.TimeStanding)
fields = append(fields, field)
}
if m.StandCount != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 113)
field.Value = proto.Uint16(m.StandCount)
fields = append(fields, field)
}
if m.AvgLeftPco != basetype.Sint8Invalid {
field := fac.CreateField(mesg.Num, 114)
field.Value = proto.Int8(m.AvgLeftPco)
fields = append(fields, field)
}
if m.AvgRightPco != basetype.Sint8Invalid {
field := fac.CreateField(mesg.Num, 115)
field.Value = proto.Int8(m.AvgRightPco)
fields = append(fields, field)
}
if m.AvgLeftPowerPhase != nil {
field := fac.CreateField(mesg.Num, 116)
field.Value = proto.SliceUint8(m.AvgLeftPowerPhase)
fields = append(fields, field)
}
if m.AvgLeftPowerPhasePeak != nil {
field := fac.CreateField(mesg.Num, 117)
field.Value = proto.SliceUint8(m.AvgLeftPowerPhasePeak)
fields = append(fields, field)
}
if m.AvgRightPowerPhase != nil {
field := fac.CreateField(mesg.Num, 118)
field.Value = proto.SliceUint8(m.AvgRightPowerPhase)
fields = append(fields, field)
}
if m.AvgRightPowerPhasePeak != nil {
field := fac.CreateField(mesg.Num, 119)
field.Value = proto.SliceUint8(m.AvgRightPowerPhasePeak)
fields = append(fields, field)
}
if m.AvgPowerPosition != nil {
field := fac.CreateField(mesg.Num, 120)
field.Value = proto.SliceUint16(m.AvgPowerPosition)
fields = append(fields, field)
}
if m.MaxPowerPosition != nil {
field := fac.CreateField(mesg.Num, 121)
field.Value = proto.SliceUint16(m.MaxPowerPosition)
fields = append(fields, field)
}
if m.AvgCadencePosition != nil {
field := fac.CreateField(mesg.Num, 122)
field.Value = proto.SliceUint8(m.AvgCadencePosition)
fields = append(fields, field)
}
if m.MaxCadencePosition != nil {
field := fac.CreateField(mesg.Num, 123)
field.Value = proto.SliceUint8(m.MaxCadencePosition)
fields = append(fields, field)
}
if m.EnhancedAvgSpeed != basetype.Uint32Invalid {
if expanded := m.IsExpandedField(124); !expanded || (expanded && options.IncludeExpandedFields) {
field := fac.CreateField(mesg.Num, 124)
field.Value = proto.Uint32(m.EnhancedAvgSpeed)
field.IsExpandedField = expanded
fields = append(fields, field)
}
}
if m.EnhancedMaxSpeed != basetype.Uint32Invalid {
if expanded := m.IsExpandedField(125); !expanded || (expanded && options.IncludeExpandedFields) {
field := fac.CreateField(mesg.Num, 125)
field.Value = proto.Uint32(m.EnhancedMaxSpeed)
field.IsExpandedField = expanded
fields = append(fields, field)
}
}
if m.EnhancedAvgAltitude != basetype.Uint32Invalid {
if expanded := m.IsExpandedField(126); !expanded || (expanded && options.IncludeExpandedFields) {
field := fac.CreateField(mesg.Num, 126)
field.Value = proto.Uint32(m.EnhancedAvgAltitude)
field.IsExpandedField = expanded
fields = append(fields, field)
}
}
if m.EnhancedMinAltitude != basetype.Uint32Invalid {
if expanded := m.IsExpandedField(127); !expanded || (expanded && options.IncludeExpandedFields) {
field := fac.CreateField(mesg.Num, 127)
field.Value = proto.Uint32(m.EnhancedMinAltitude)
field.IsExpandedField = expanded
fields = append(fields, field)
}
}
if m.EnhancedMaxAltitude != basetype.Uint32Invalid {
if expanded := m.IsExpandedField(128); !expanded || (expanded && options.IncludeExpandedFields) {
field := fac.CreateField(mesg.Num, 128)
field.Value = proto.Uint32(m.EnhancedMaxAltitude)
field.IsExpandedField = expanded
fields = append(fields, field)
}
}
if m.AvgLevMotorPower != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 129)
field.Value = proto.Uint16(m.AvgLevMotorPower)
fields = append(fields, field)
}
if m.MaxLevMotorPower != basetype.Uint16Invalid {
field := fac.CreateField(mesg.Num, 130)
field.Value = proto.Uint16(m.MaxLevMotorPower)
fields = append(fields, field)
}
if m.LevBatteryConsumption != basetype.Uint8Invalid {
field := fac.CreateField(mesg.Num, 131)
field.Value = proto.Uint8(m.LevBatteryConsumption)
fields = append(fields, field)