-
Notifications
You must be signed in to change notification settings - Fork 224
/
N2kMessages.h
1488 lines (1300 loc) · 86.6 KB
/
N2kMessages.h
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
/*
N2kMessages.h
Copyright (c) 2015-2021 Timo Lappalainen, Kave Oy, www.kave.fi
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This is collection of functions for handling NMEA2000 bus messages.
Library contains functions to e.g. create message named with PGN like SetN2kPGN129025 and
inline alias for them like SetN2kLatLonRapid.
Each Setxxx funtion sets related message PGN and its default priority. So if you want to change
priority on function, you have to do it after Setxxx call.
If you do not send anything to NMEA2000 bus, you do not need this library. Funtions for
BUS handling PGN:s like 60928 "ISO Address Claim" has been defined in bus device library
NMEA2000.h
*/
#ifndef _N2kMessages_H_
#define _N2kMessages_H_
#include "N2kMsg.h"
#include "N2kTypes.h"
#include <stdint.h>
inline double RadToDeg(double v) { return N2kIsNA(v)?v:v*180.0/3.1415926535897932384626433832795L; }
inline double DegToRad(double v) { return N2kIsNA(v)?v:v/180.0*3.1415926535897932384626433832795L; }
inline double CToKelvin(double v) { return N2kIsNA(v)?v:v+273.15L; }
inline double KelvinToC(double v) { return N2kIsNA(v)?v:v-273.15L; }
inline double FToKelvin(double v) { return N2kIsNA(v)?v:(v-32)*5.0/9.0+273.15; }
inline double KelvinToF(double v) { return N2kIsNA(v)?v:(v-273.15)*9.0/5.0+32; }
inline double mBarToPascal(double v) { return N2kIsNA(v)?v:v*100L; }
inline double PascalTomBar(double v) { return N2kIsNA(v)?v:v/100L; }
inline double hPAToPascal(double v) { return N2kIsNA(v)?v:v*100L; }
inline double PascalTohPA(double v) { return N2kIsNA(v)?v:v/100L; }
inline double AhToCoulomb(double v) { return N2kIsNA(v)?v:v*3600L; }
inline double CoulombToAh(double v) { return N2kIsNA(v)?v:v/3600L; }
inline double hToSeconds(double v) { return N2kIsNA(v)?v:v*3600L; }
inline double SecondsToh(double v) { return N2kIsNA(v)?v:v/3600L; }
inline double msToKnots(double v) { return N2kIsNA(v)?v:v*1.9438444924406047516198704103672L; } // 3600L/1852.0L
inline double KnotsToms(double v) { return N2kIsNA(v)?v:v*0.51444444444444444444444444444444L; } // 1852L/3600.0L
//*****************************************************************************
// System date/time
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and heading at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - SystemDate Days since 1970-01-01
// - SystemTime seconds since midnight
// - TimeSource see tN2kTimeSource
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN126992(tN2kMsg &N2kMsg, unsigned char SID, uint16_t SystemDate,
double SystemTime, tN2kTimeSource TimeSource=N2ktimes_GPS);
inline void SetN2kSystemTime(tN2kMsg &N2kMsg, unsigned char SID, uint16_t SystemDate,
double SystemTime, tN2kTimeSource TimeSource=N2ktimes_GPS) {
SetN2kPGN126992(N2kMsg,SID,SystemDate,SystemTime,TimeSource);
}
bool ParseN2kPGN126992(const tN2kMsg &N2kMsg, unsigned char &SID, uint16_t &SystemDate,
double &SystemTime, tN2kTimeSource &TimeSource);
inline bool ParseN2kSystemTime(const tN2kMsg &N2kMsg, unsigned char &SID, uint16_t &SystemDate,
double &SystemTime, tN2kTimeSource &TimeSource) {
return ParseN2kPGN126992(N2kMsg,SID,SystemDate,SystemTime,TimeSource);
}
//*****************************************************************************
// Rudder
// Input:
// - RudderPosition Current rudder postion in radians.
// - Instance Rudder instance.
// - RudderDirectionOrder See tN2kRudderDirectionOrder. Direction, where rudder should be turned.
// - AngleOrder In radians angle where rudder should be turned.
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127245(tN2kMsg &N2kMsg, double RudderPosition, unsigned char Instance=0,
tN2kRudderDirectionOrder RudderDirectionOrder=N2kRDO_NoDirectionOrder, double AngleOrder=N2kDoubleNA);
inline void SetN2kRudder(tN2kMsg &N2kMsg, double RudderPosition, unsigned char Instance=0,
tN2kRudderDirectionOrder RudderDirectionOrder=N2kRDO_NoDirectionOrder, double AngleOrder=N2kDoubleNA) {
SetN2kPGN127245(N2kMsg,RudderPosition,Instance,RudderDirectionOrder,AngleOrder);
}
bool ParseN2kPGN127245(const tN2kMsg &N2kMsg, double &RudderPosition, unsigned char &Instance,
tN2kRudderDirectionOrder &RudderDirectionOrder, double &AngleOrder);
inline bool ParseN2kRudder(const tN2kMsg &N2kMsg, double &RudderPosition, unsigned char &Instance,
tN2kRudderDirectionOrder &RudderDirectionOrder, double &AngleOrder) {
return ParseN2kPGN127245(N2kMsg,RudderPosition,Instance,RudderDirectionOrder,AngleOrder);
}
inline bool ParseN2kRudder(const tN2kMsg &N2kMsg, double &RudderPosition) {
tN2kRudderDirectionOrder RudderDirectionOrder;
double AngleOrder;
unsigned char Instance;
return ParseN2kPGN127245(N2kMsg,RudderPosition,Instance,RudderDirectionOrder,AngleOrder);
}
//*****************************************************************************
// Vessel Heading
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and heading at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - Heading Heading in radians
// - Deviation Magnetic deviation in radians. Use N2kDoubleNA for undefined value.
// - Variation Magnetic variation in radians. Use N2kDoubleNA for undefined value.
// - ref Heading reference. See definition of tN2kHeadingReference.
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127250(tN2kMsg &N2kMsg, unsigned char SID, double Heading, double Deviation, double Variation, tN2kHeadingReference ref);
inline void SetN2kTrueHeading(tN2kMsg &N2kMsg, unsigned char SID, double Heading) {
SetN2kPGN127250(N2kMsg,SID,Heading,N2kDoubleNA,N2kDoubleNA,N2khr_true);
}
inline void SetN2kMagneticHeading(tN2kMsg &N2kMsg, unsigned char SID, double Heading, double Deviation=N2kDoubleNA, double Variation=N2kDoubleNA) {
SetN2kPGN127250(N2kMsg,SID,Heading,Deviation,Variation,N2khr_magnetic);
}
bool ParseN2kPGN127250(const tN2kMsg &N2kMsg, unsigned char &SID, double &Heading, double &Deviation, double &Variation, tN2kHeadingReference &ref);
inline bool ParseN2kHeading(const tN2kMsg &N2kMsg, unsigned char &SID, double &Heading, double &Deviation, double &Variation, tN2kHeadingReference &ref) {
return ParseN2kPGN127250(N2kMsg,SID,Heading,Deviation,Variation,ref);
}
//*****************************************************************************
// Rate of Turn
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and heading at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - Rate of turn Change in heading in radians per second
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127251(tN2kMsg &N2kMsg, unsigned char SID, double RateOfTurn);
inline void SetN2kRateOfTurn(tN2kMsg &N2kMsg, unsigned char SID, double RateOfTurn) {
SetN2kPGN127251(N2kMsg,SID,RateOfTurn);
}
bool ParseN2kPGN127251(const tN2kMsg &N2kMsg, unsigned char &SID, double &RateOfTurn);
inline bool ParseN2kRateOfTurn(const tN2kMsg &N2kMsg, unsigned char &SID, double &RateOfTurn) {
return ParseN2kPGN127251(N2kMsg,SID,RateOfTurn);
}
//*****************************************************************************
// Attitude
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and heading at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - Yaw Heading in radians.
// - Pitch Pitch in radians. Positive, when your bow rises.
// - Roll Roll in radians. Positive, when tilted right.
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127257(tN2kMsg &N2kMsg, unsigned char SID, double Yaw, double Pitch, double Roll);
inline void SetN2kAttitude(tN2kMsg &N2kMsg, unsigned char SID, double Yaw, double Pitch, double Roll) {
SetN2kPGN127257(N2kMsg,SID, Yaw, Pitch, Roll);
}
bool ParseN2kPGN127257(const tN2kMsg &N2kMsg, unsigned char &SID, double &Yaw, double &Pitch, double &Roll);
inline bool ParseN2kAttitude(const tN2kMsg &N2kMsg, unsigned char &SID, double &Yaw, double &Pitch, double &Roll) {
return ParseN2kPGN127257(N2kMsg,SID, Yaw, Pitch, Roll);
}
//*****************************************************************************
// Magnetic Variation
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and heading at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - Source How was the variation value generated
// - DaysSince1970 Days since January 1, 1970
// - Variation Magnetic variation/declination in radians
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127258(tN2kMsg &N2kMsg, unsigned char SID, tN2kMagneticVariation Source, uint16_t DaysSince1970, double Variation);
inline void SetN2kMagneticVariation(tN2kMsg &N2kMsg, unsigned char SID, tN2kMagneticVariation Source, uint16_t DaysSince1970, double Variation) {
SetN2kPGN127258(N2kMsg, SID, Source, DaysSince1970, Variation);
}
bool ParseN2kPGN127258(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kMagneticVariation &Source, uint16_t &DaysSince1970, double &Variation);
inline bool ParseN2kMagneticVariation(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kMagneticVariation &Source, uint16_t &DaysSince1970, double &Variation) {
return ParseN2kPGN127258(N2kMsg, SID, Source, DaysSince1970, Variation);
}
//*****************************************************************************
// Engine parameters rapid
// Input:
// - EngineInstance Engine instance.
// - EngineSpeed RPM (Revolutions Per Minute)
// - EngineBoostPressure in Pascal
// - EngineTiltTrim in %
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127488(tN2kMsg &N2kMsg, unsigned char EngineInstance, double EngineSpeed,
double EngineBoostPressure=N2kDoubleNA, int8_t EngineTiltTrim=N2kInt8NA);
inline void SetN2kEngineParamRapid(tN2kMsg &N2kMsg, unsigned char EngineInstance, double EngineSpeed,
double EngineBoostPressure=N2kDoubleNA, int8_t EngineTiltTrim=N2kInt8NA) {
SetN2kPGN127488(N2kMsg,EngineInstance,EngineSpeed,EngineBoostPressure,EngineTiltTrim);
}
bool ParseN2kPGN127488(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineSpeed,
double &EngineBoostPressure, int8_t &EngineTiltTrim);
inline bool ParseN2kEngineParamRapid(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineSpeed,
double &EngineBoostPressure, int8_t &EngineTiltTrim) {
return ParseN2kPGN127488(N2kMsg,EngineInstance,EngineSpeed,EngineBoostPressure,EngineTiltTrim);
}
//*****************************************************************************
// Engine parameters dynamic
// Input:
// - EngineInstance Engine instance.
// - EngineOilPress in Pascal
// - EngineOilTemp in Kelvin
// - EngineCoolantTemp in Kelvin
// - AltenatorVoltage in Voltage
// - FuelRate in litres/hour
// - EngineHours in seconds
// - EngineCoolantPress in Pascal
// - EngineFuelPress in Pascal
// - EngineLoad in %
// - EngineTorque in %
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127489(tN2kMsg &N2kMsg, unsigned char EngineInstance, double EngineOilPress, double EngineOilTemp, double EngineCoolantTemp, double AltenatorVoltage,
double FuelRate, double EngineHours, double EngineCoolantPress=N2kDoubleNA, double EngineFuelPress=N2kDoubleNA,
int8_t EngineLoad=N2kInt8NA, int8_t EngineTorque=N2kInt8NA,
tN2kEngineDiscreteStatus1 Status1=0, tN2kEngineDiscreteStatus2 Status2=0);
inline void SetN2kEngineDynamicParam(tN2kMsg &N2kMsg, unsigned char EngineInstance, double EngineOilPress, double EngineOilTemp, double EngineCoolantTemp, double AltenatorVoltage,
double FuelRate, double EngineHours, double EngineCoolantPress=N2kDoubleNA, double EngineFuelPress=N2kDoubleNA,
int8_t EngineLoad=N2kInt8NA, int8_t EngineTorque=N2kInt8NA,
tN2kEngineDiscreteStatus1 Status1=0, tN2kEngineDiscreteStatus2 Status2=0) {
SetN2kPGN127489(N2kMsg,EngineInstance, EngineOilPress, EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours, EngineCoolantPress, EngineFuelPress, EngineLoad, EngineTorque,
Status1,Status2);
}
inline void SetN2kPGN127489(tN2kMsg &N2kMsg, unsigned char EngineInstance, double EngineOilPress, double EngineOilTemp, double EngineCoolantTemp, double AltenatorVoltage,
double FuelRate, double EngineHours, double EngineCoolantPress=N2kDoubleNA, double EngineFuelPress=N2kDoubleNA,
int8_t EngineLoad=N2kInt8NA, int8_t EngineTorque=N2kInt8NA,
bool flagCheckEngine=false, bool flagOverTemp=false, bool flagLowOilPress=false, bool flagLowOilLevel=false,
bool flagLowFuelPress=false, bool flagLowSystemVoltage=false, bool flagLowCoolantLevel=false, bool flagWaterFlow=false,
bool flagWaterInFuel=false, bool flagChargeIndicator=false, bool flagPreheatIndicator=false, bool flagHighBoostPress=false,
bool flagRevLimitExceeded=false, bool flagEgrSystem=false, bool flagTPS=false, bool flagEmergencyStopMode=false,
bool flagWarning1=false, bool flagWarning2=false, bool flagPowerReduction=false, bool flagMaintenanceNeeded=false,
bool flagEngineCommError=false, bool flagSubThrottle=false, bool flagNeutralStartProtect=false, bool flagEngineShuttingDown=false) {
tN2kEngineDiscreteStatus1 Status1;
tN2kEngineDiscreteStatus2 Status2;
Status1.Bits.CheckEngine=flagCheckEngine;
Status1.Bits.OverTemperature=flagOverTemp;
Status1.Bits.LowOilPressure=flagLowOilPress;
Status1.Bits.LowOilLevel=flagLowOilLevel;
Status1.Bits.LowFuelPressure=flagLowFuelPress;
Status1.Bits.LowSystemVoltage=flagLowSystemVoltage;
Status1.Bits.LowCoolantLevel=flagLowCoolantLevel;
Status1.Bits.WaterFlow=flagWaterFlow;
Status1.Bits.WaterInFuel=flagWaterInFuel;
Status1.Bits.ChargeIndicator=flagChargeIndicator;
Status1.Bits.PreheatIndicator=flagPreheatIndicator;
Status1.Bits.HighBoostPressure=flagHighBoostPress;
Status1.Bits.RevLimitExceeded=flagRevLimitExceeded;
Status1.Bits.EGRSystem=flagEgrSystem;
Status1.Bits.ThrottlePositionSensor=flagTPS;
Status1.Bits.EngineEmergencyStopMode=flagEmergencyStopMode;
Status2.Bits.WarningLevel1=flagWarning1;
Status2.Bits.WarningLevel2=flagWarning2;
Status2.Bits.LowOiPowerReduction=flagPowerReduction;
Status2.Bits.MaintenanceNeeded=flagMaintenanceNeeded;
Status2.Bits.EngineCommError=flagEngineCommError;
Status2.Bits.SubOrSecondaryThrottle=flagSubThrottle;
Status2.Bits.NeutralStartProtect=flagNeutralStartProtect;
Status2.Bits.EngineShuttingDown=flagEngineShuttingDown;
SetN2kPGN127489(N2kMsg,EngineInstance, EngineOilPress, EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours, EngineCoolantPress, EngineFuelPress, EngineLoad, EngineTorque,
Status1,Status2);
}
inline void SetN2kEngineDynamicParam(tN2kMsg &N2kMsg, unsigned char EngineInstance, double EngineOilPress, double EngineOilTemp, double EngineCoolantTemp, double AltenatorVoltage,
double FuelRate, double EngineHours, double EngineCoolantPress=N2kDoubleNA, double EngineFuelPress=N2kDoubleNA,
int8_t EngineLoad=N2kInt8NA, int8_t EngineTorque=N2kInt8NA,
bool flagCheckEngine=false, bool flagOverTemp=false, bool flagLowOilPress=false, bool flagLowOilLevel=false,
bool flagLowFuelPress=false, bool flagLowSystemVoltage=false, bool flagLowCoolantLevel=false, bool flagWaterFlow=false,
bool flagWaterInFuel=false, bool flagChargeIndicator=false, bool flagPreheatIndicator=false, bool flagHighBoostPress=false,
bool flagRevLimitExceeded=false, bool flagEgrSystem=false, bool flagTPS=false, bool flagEmergencyStopMode=false,
bool flagWarning1=false, bool flagWarning2=false, bool flagPowerReduction=false, bool flagMaintenanceNeeded=false,
bool flagEngineCommError=false, bool flagSubThrottle=false, bool flagNeutralStartProtect=false, bool flagEngineShuttingDown=false) {
SetN2kPGN127489(N2kMsg,EngineInstance, EngineOilPress, EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours, EngineCoolantPress, EngineFuelPress, EngineLoad, EngineTorque,
flagCheckEngine, flagOverTemp, flagLowOilPress, flagLowOilLevel,
flagLowFuelPress, flagLowSystemVoltage, flagLowCoolantLevel, flagWaterFlow,
flagWaterInFuel, flagChargeIndicator, flagPreheatIndicator, flagHighBoostPress,
flagRevLimitExceeded, flagEgrSystem, flagTPS, flagEmergencyStopMode,
flagWarning1, flagWarning2, flagPowerReduction, flagMaintenanceNeeded,
flagEngineCommError, flagSubThrottle, flagNeutralStartProtect, flagEngineShuttingDown);
}
bool ParseN2kPGN127489(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineOilPress,
double &EngineOilTemp, double &EngineCoolantTemp, double &AltenatorVoltage,
double &FuelRate, double &EngineHours, double &EngineCoolantPress, double &EngineFuelPress,
int8_t &EngineLoad, int8_t &EngineTorque,
tN2kEngineDiscreteStatus1 &Status1, tN2kEngineDiscreteStatus2 &Status2);
inline bool ParseN2kPGN127489(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineOilPress,
double &EngineOilTemp, double &EngineCoolantTemp, double &AltenatorVoltage,
double &FuelRate, double &EngineHours, double &EngineCoolantPress, double &EngineFuelPress,
int8_t &EngineLoad, int8_t &EngineTorque) {
tN2kEngineDiscreteStatus1 Status1;
tN2kEngineDiscreteStatus2 Status2;
return ParseN2kPGN127489(N2kMsg, EngineInstance, EngineOilPress,
EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours,EngineCoolantPress, EngineFuelPress,
EngineLoad, EngineTorque,Status1,Status2);
}
inline bool ParseN2kEngineDynamicParam(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineOilPress,
double &EngineOilTemp, double &EngineCoolantTemp, double &AltenatorVoltage,
double &FuelRate, double &EngineHours, double &EngineCoolantPress, double &EngineFuelPress,
int8_t &EngineLoad, int8_t &EngineTorque) {
return ParseN2kPGN127489(N2kMsg, EngineInstance, EngineOilPress,
EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours,EngineCoolantPress, EngineFuelPress,
EngineLoad, EngineTorque);
}
inline bool ParseN2kEngineDynamicParam(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineOilPress,
double &EngineOilTemp, double &EngineCoolantTemp, double &AltenatorVoltage,
double &FuelRate, double &EngineHours, double &EngineCoolantPress, double &EngineFuelPress,
int8_t &EngineLoad, int8_t &EngineTorque,
tN2kEngineDiscreteStatus1 &Status1, tN2kEngineDiscreteStatus2 &Status2) {
return ParseN2kPGN127489(N2kMsg, EngineInstance, EngineOilPress,
EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours,EngineCoolantPress, EngineFuelPress,
EngineLoad, EngineTorque,
Status1, Status2);
}
inline bool ParseN2kEngineDynamicParam(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &EngineOilPress,
double &EngineOilTemp, double &EngineCoolantTemp, double &AltenatorVoltage,
double &FuelRate, double &EngineHours) {
double EngineCoolantPress, EngineFuelPress;
int8_t EngineLoad, EngineTorque;
tN2kEngineDiscreteStatus1 Status1;
tN2kEngineDiscreteStatus2 Status2;
return ParseN2kPGN127489(N2kMsg, EngineInstance, EngineOilPress,
EngineOilTemp, EngineCoolantTemp, AltenatorVoltage,
FuelRate, EngineHours,EngineCoolantPress, EngineFuelPress,
EngineLoad, EngineTorque,Status1,Status2);
}
//*****************************************************************************
// Transmission parameters, dynamic
// Input:
// - EngineInstance Engine instance.
// - TransmissionGear Selected transmission. See tN2kTransmissionGear
// - OilPressure in Pascal
// - OilTemperature in K
// - EngineTiltTrim in %
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127493(tN2kMsg &N2kMsg, unsigned char EngineInstance, tN2kTransmissionGear TransmissionGear,
double OilPressure, double OilTemperature, unsigned char DiscreteStatus1=0);
inline void SetN2kTransmissionParameters(tN2kMsg &N2kMsg, unsigned char EngineInstance, tN2kTransmissionGear TransmissionGear,
double OilPressure, double OilTemperature, unsigned char DiscreteStatus1=0) {
SetN2kPGN127493(N2kMsg, EngineInstance, TransmissionGear, OilPressure, OilTemperature, DiscreteStatus1);
}
inline void SetN2kTransmissionParameters(tN2kMsg &N2kMsg, unsigned char EngineInstance, tN2kTransmissionGear TransmissionGear,
double OilPressure, double OilTemperature,
bool flagCheck, bool flagOverTemp, bool flagLowOilPressure=false, bool flagLowOilLevel=false,
bool flagSailDrive=false) {
unsigned char DiscreteStatus1=0;
if (flagCheck) DiscreteStatus1 |= BIT(0);
if (flagOverTemp) DiscreteStatus1 |= BIT(1);
if (flagLowOilPressure) DiscreteStatus1 |= BIT(2);
if (flagLowOilLevel) DiscreteStatus1 |= BIT(3);
if (flagSailDrive) DiscreteStatus1 |= BIT(4);
SetN2kPGN127493(N2kMsg, EngineInstance, TransmissionGear, OilPressure, OilTemperature,DiscreteStatus1);
}
bool ParseN2kPGN127493(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, tN2kTransmissionGear &TransmissionGear,
double &OilPressure, double &OilTemperature, unsigned char &DiscreteStatus1);
inline bool ParseN2kTransmissionParameters(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, tN2kTransmissionGear &TransmissionGear,
double &OilPressure, double &OilTemperature, unsigned char &DiscreteStatus1) {
return ParseN2kPGN127493(N2kMsg, EngineInstance, TransmissionGear, OilPressure, OilTemperature, DiscreteStatus1);
}
inline bool ParseN2kTransmissionParameters(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, tN2kTransmissionGear &TransmissionGear,
double &OilPressure, double &OilTemperature,
bool &flagCheck, bool &flagOverTemp, bool &flagLowOilPressure, bool &flagLowOilLevel,
bool &flagSailDrive) {
unsigned char DiscreteStatus1;
bool ret=ParseN2kPGN127493(N2kMsg, EngineInstance, TransmissionGear, OilPressure, OilTemperature, DiscreteStatus1);
if (ret) {
flagCheck = ((DiscreteStatus1 & BIT(0))!=0);
flagOverTemp = ((DiscreteStatus1 & BIT(1))!=0);
flagLowOilPressure = ((DiscreteStatus1 & BIT(2))!=0);
flagLowOilLevel = ((DiscreteStatus1 & BIT(3))!=0);
flagSailDrive = ((DiscreteStatus1 & BIT(4))!=0);
}
return ret;
}
//*****************************************************************************
// Trip Parameters, Engine
// Input:
// - EngineInstance Engine instance.
// - TripFuelUsed in litres
// - FuelRateAverage in litres/hour
// - FuelRateEconomy in litres/hour
// - InstantaneousFuelEconomy in litres/hour
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127497(tN2kMsg &N2kMsg, unsigned char EngineInstance, double TripFuelUsed,
double FuelRateAverage,
double FuelRateEconomy=N2kDoubleNA, double InstantaneousFuelEconomy=N2kDoubleNA);
inline void SetN2kEngineTripParameters(tN2kMsg &N2kMsg, unsigned char EngineInstance, double TripFuelUsed,
double FuelRateAverage,
double FuelRateEconomy=N2kDoubleNA, double InstantaneousFuelEconomy=N2kDoubleNA) {
SetN2kPGN127497(N2kMsg,EngineInstance,TripFuelUsed,FuelRateAverage,FuelRateEconomy,InstantaneousFuelEconomy);
}
bool ParseN2kPGN127497(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &TripFuelUsed,
double &FuelRateAverage,
double &FuelRateEconomy, double &InstantaneousFuelEconomy);
inline bool ParseN2kEngineTripParameters(const tN2kMsg &N2kMsg, unsigned char &EngineInstance, double &TripFuelUsed,
double &FuelRateAverage,
double &FuelRateEconomy, double &InstantaneousFuelEconomy) {
return ParseN2kPGN127497(N2kMsg,EngineInstance,TripFuelUsed,FuelRateAverage,FuelRateEconomy, InstantaneousFuelEconomy);
}
typedef uint64_t tN2kBinaryStatus;
//*****************************************************************************
// Returns single status of full binary bank status returned by ParseN2kPGN127501 or ParseN2kBinaryStatus.
// Status - Full bank status read by ParseN2kPGN127501 or ParseN2kBinaryStatus
// ItemIndex - Status item index 1-28
tN2kOnOff N2kGetStatusOnBinaryStatus(tN2kBinaryStatus BankStatus, uint8_t ItemIndex=1);
//*****************************************************************************
// Reset all single binary status values to not available
inline void N2kResetBinaryStatus(tN2kBinaryStatus &BankStatus) { BankStatus=0xffffffffffffffffULL; }
//*****************************************************************************
// Set single status to full binary bank status.
void N2kSetStatusBinaryOnStatus(tN2kBinaryStatus &BankStatus, tN2kOnOff ItemStatus, uint8_t ItemIndex=1);
//*****************************************************************************
// Binary status report
// BankStatus - Full bank status. Read single status by using N2kGetBinaryStatus
void SetN2kPGN127501(tN2kMsg &N2kMsg, unsigned char DeviceBankInstance, tN2kBinaryStatus BankStatus);
inline void SetN2kBinaryStatus(tN2kMsg &N2kMsg, unsigned char DeviceBankInstance, tN2kBinaryStatus BankStatus) {
SetN2kPGN127501(N2kMsg,DeviceBankInstance,BankStatus);
}
//*****************************************************************************
// Binary status report
void SetN2kPGN127501(tN2kMsg &N2kMsg, unsigned char DeviceBankInstance
,tN2kOnOff Status1
,tN2kOnOff Status2=N2kOnOff_Unavailable
,tN2kOnOff Status3=N2kOnOff_Unavailable
,tN2kOnOff Status4=N2kOnOff_Unavailable
);
inline void SetN2kBinaryStatus(tN2kMsg &N2kMsg, unsigned char DeviceBankInstance
,tN2kOnOff Status1
,tN2kOnOff Status2=N2kOnOff_Unavailable
,tN2kOnOff Status3=N2kOnOff_Unavailable
,tN2kOnOff Status4=N2kOnOff_Unavailable
) {
SetN2kPGN127501(N2kMsg, DeviceBankInstance,Status1,Status2,Status3,Status4);
}
// Parse four first status of binary status report.
bool ParseN2kPGN127501(const tN2kMsg &N2kMsg, unsigned char &DeviceBankInstance
,tN2kOnOff &Status1
,tN2kOnOff &Status2
,tN2kOnOff &Status3
,tN2kOnOff &Status4
);
inline bool ParseN2kBinaryStatus(const tN2kMsg &N2kMsg, unsigned char &DeviceBankInstance
,tN2kOnOff &Status1
,tN2kOnOff &Status2
,tN2kOnOff &Status3
,tN2kOnOff &Status4
) {
return ParseN2kPGN127501(N2kMsg,DeviceBankInstance,Status1,Status2,Status3,Status4);
}
// Parse bank status of binary status report. Use N2kGetBinaryStatus to read specific status
bool ParseN2kPGN127501(const tN2kMsg &N2kMsg, unsigned char &DeviceBankInstance, tN2kBinaryStatus &BankStatus);
inline bool ParseN2kBinaryStatus(const tN2kMsg &N2kMsg, unsigned char &DeviceBankInstance, tN2kBinaryStatus &BankStatus) {
return ParseN2kPGN127501(N2kMsg,DeviceBankInstance,BankStatus);
}
//*****************************************************************************
// Fluid level
// Input:
// - Instance Tank instance. Different devices handles this a bit differently. So it is best to have instance unique over
// all devices on the bus.
// - FluidType Defines type of fluid. See definition of tN2kFluidType
// - Level Tank level in % of full tank.
// - Capacity Tank Capacity in litres
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN127505(tN2kMsg &N2kMsg, unsigned char Instance, tN2kFluidType FluidType, double Level, double Capacity);
inline void SetN2kFluidLevel(tN2kMsg &N2kMsg, unsigned char Instance, tN2kFluidType FluidType, double Level, double Capacity) {
SetN2kPGN127505(N2kMsg, Instance, FluidType, Level, Capacity);
}
// Parse fluid level message
// Output:
// - Instance Tank instance.
// - FluidType Defines type of fluid. See definition of tN2kFluidType
// - Level Tank level in % of full tank.
// - Capacity Tank Capacity in litres
bool ParseN2kPGN127505(const tN2kMsg &N2kMsg, unsigned char &Instance, tN2kFluidType &FluidType, double &Level, double &Capacity);
inline bool ParseN2kFluidLevel(const tN2kMsg &N2kMsg, unsigned char &Instance, tN2kFluidType &FluidType, double &Level, double &Capacity) {
return ParseN2kPGN127505(N2kMsg, Instance, FluidType, Level, Capacity);
}
//*****************************************************************************
// DC Detailed Status
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and heading at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - DCInstance DC instance.
// - DCType Defines type of DC source. See definition of tN2kDCType
// - StateOfCharge % of charge
// - StateOfHealth % of heath
// - TimeRemaining Time remaining in seconds
// - RippleVoltage DC output voltage ripple in V
// - Capacity Battery capacity in coulombs
void SetN2kPGN127506(tN2kMsg &N2kMsg, unsigned char SID, unsigned char DCInstance, tN2kDCType DCType,
unsigned char StateOfCharge, unsigned char StateOfHealth, double TimeRemaining, double RippleVoltage, double Capacity);
inline void SetN2kDCStatus(tN2kMsg &N2kMsg, unsigned char SID, unsigned char DCInstance, tN2kDCType DCType,
unsigned char StateOfCharge, unsigned char StateOfHealth, double TimeRemaining, double RippleVoltage, double Capacity) {
SetN2kPGN127506(N2kMsg,SID,DCInstance,DCType,StateOfCharge,StateOfHealth,TimeRemaining,RippleVoltage,Capacity);
}
bool ParseN2kPGN127506(const tN2kMsg &N2kMsg, unsigned char &SID, unsigned char &DCInstance, tN2kDCType &DCType,
unsigned char &StateOfCharge, unsigned char &StateOfHealth, double &TimeRemaining, double &RippleVoltage, double &Capacity);
inline bool ParseN2kDCStatus(const tN2kMsg &N2kMsg, unsigned char &SID, unsigned char &DCInstance, tN2kDCType &DCType,
unsigned char &StateOfCharge, unsigned char &StateOfHealth, double &TimeRemaining, double &RippleVoltage, double &Capacity) {
return ParseN2kPGN127506(N2kMsg,SID,DCInstance,DCType,StateOfCharge,StateOfHealth,TimeRemaining,RippleVoltage, Capacity);
}
//*****************************************************************************
// Charger Status
// Input:
// - Instance ChargerInstance.
// - BatteryInstance BatteryInstance.
// - Operating State see. tN2kChargeState
// - Charger Mode see. tN2kChargerMode
// - Charger Enable/Disable boolean
// - Equalization Pending boolean
// - Equalization Time Remaining double seconds
//
void SetN2kPGN127507(tN2kMsg &N2kMsg, unsigned char Instance, unsigned char BatteryInstance,
tN2kChargeState ChargeState, tN2kChargerMode ChargerMode=N2kCM_Standalone,
tN2kOnOff Enabled=N2kOnOff_On, tN2kOnOff EqualizationPending=N2kOnOff_Unavailable, double EqualizationTimeRemaining=N2kDoubleNA);
inline void SetN2kChargerStatus(tN2kMsg &N2kMsg, unsigned char Instance, unsigned char BatteryInstance,
tN2kChargeState ChargeState, tN2kChargerMode ChargerMode=N2kCM_Standalone,
tN2kOnOff Enabled=N2kOnOff_On, tN2kOnOff EqualizationPending=N2kOnOff_Unavailable, double EqualizationTimeRemaining=N2kDoubleNA) {
SetN2kPGN127507(N2kMsg, Instance,BatteryInstance,ChargeState,ChargerMode,Enabled,EqualizationPending,EqualizationTimeRemaining);
}
bool ParseN2kPGN127507(tN2kMsg &N2kMsg, unsigned char &Instance, unsigned char &BatteryInstance,
tN2kChargeState &ChargeState, tN2kChargerMode &ChargerMode,
tN2kOnOff &Enabled, tN2kOnOff &EqualizationPending, double &EqualizationTimeRemaining);
inline bool ParseN2kChargerStatus(tN2kMsg &N2kMsg, unsigned char &Instance, unsigned char &BatteryInstance,
tN2kChargeState &ChargeState, tN2kChargerMode &ChargerMode,
tN2kOnOff &Enabled, tN2kOnOff &EqualizationPending, double &EqualizationTimeRemaining) {
return ParseN2kPGN127507(N2kMsg, Instance,BatteryInstance,ChargeState,ChargerMode,Enabled,EqualizationPending,EqualizationTimeRemaining);
}
//*****************************************************************************
// Battery Status
// Input:
// - BatteryInstance BatteryInstance.
// - BatteryVoltage Battery voltage in V
// - BatteryCurrent Current in A
// - BatteryTemperature Battery temperature in K. Use function CToKelvin, if you want to use °C.
// - SID Sequence ID.
void SetN2kPGN127508(tN2kMsg &N2kMsg, unsigned char BatteryInstance, double BatteryVoltage, double BatteryCurrent=N2kDoubleNA,
double BatteryTemperature=N2kDoubleNA, unsigned char SID=1);
inline void SetN2kDCBatStatus(tN2kMsg &N2kMsg, unsigned char BatteryInstance, double BatteryVoltage, double BatteryCurrent=N2kDoubleNA,
double BatteryTemperature=N2kDoubleNA, unsigned char SID=1) {
SetN2kPGN127508(N2kMsg,BatteryInstance,BatteryVoltage,BatteryCurrent,BatteryTemperature,SID);
}
bool ParseN2kPGN127508(const tN2kMsg &N2kMsg, unsigned char &BatteryInstance, double &BatteryVoltage, double &BatteryCurrent,
double &BatteryTemperature, unsigned char &SID);
inline bool ParseN2kDCBatStatus(const tN2kMsg &N2kMsg, unsigned char &BatteryInstance, double &BatteryVoltage, double &BatteryCurrent,
double &BatteryTemperature, unsigned char &SID) {
return ParseN2kPGN127508(N2kMsg, BatteryInstance, BatteryVoltage, BatteryCurrent, BatteryTemperature, SID);
}
//*****************************************************************************
// Battery Configuration Status
// Note this has not yet confirmed to be right. Specially Peukert Exponent can have in
// this configuration values from 1 to 1.504. And I expect on code that I have to send
// value PeukertExponent-1 to the bus.
// Input:
// - BatteryInstance BatteryInstance.
// - BatType Type of battery. See definition of tN2kBatType
// - SupportsEqual Supports equalization. See definition of tN2kBatEqSupport
// - BatNominalVoltage Battery nominal voltage. See definition of tN2kBatNomVolt
// - BatChemistry Battery See definition of tN2kBatChem
// - BatCapacity Battery capacity in Coulombs. Use AhToCoulombs, if you have your value in Ah.
// - BatTemperatureCoeff Battery temperature coefficient in %
// - PeukertExponent Peukert Exponent
// - ChargeEfficiencyFactor Charge efficiency factor
void SetN2kPGN127513(tN2kMsg &N2kMsg, unsigned char BatInstance, tN2kBatType BatType, tN2kBatEqSupport SupportsEqual,
tN2kBatNomVolt BatNominalVoltage, tN2kBatChem BatChemistry, double BatCapacity, int8_t BatTemperatureCoefficient,
double PeukertExponent, int8_t ChargeEfficiencyFactor);
inline void SetN2kBatConf(tN2kMsg &N2kMsg, unsigned char BatInstance, tN2kBatType BatType, tN2kBatEqSupport SupportsEqual,
tN2kBatNomVolt BatNominalVoltage, tN2kBatChem BatChemistry, double BatCapacity, int8_t BatTemperatureCoefficient,
double PeukertExponent, int8_t ChargeEfficiencyFactor) {
SetN2kPGN127513(N2kMsg,BatInstance,BatType,SupportsEqual,BatNominalVoltage,BatChemistry,BatCapacity,BatTemperatureCoefficient,
PeukertExponent,ChargeEfficiencyFactor);
}
bool ParseN2kPGN127513(const tN2kMsg &N2kMsg, unsigned char &BatInstance, tN2kBatType &BatType, tN2kBatEqSupport &SupportsEqual,
tN2kBatNomVolt &BatNominalVoltage, tN2kBatChem &BatChemistry, double &BatCapacity, int8_t &BatTemperatureCoefficient,
double &PeukertExponent, int8_t &ChargeEfficiencyFactor);
inline bool ParseN2kBatConf(const tN2kMsg &N2kMsg, unsigned char &BatInstance, tN2kBatType &BatType, tN2kBatEqSupport &SupportsEqual,
tN2kBatNomVolt &BatNominalVoltage, tN2kBatChem &BatChemistry, double &BatCapacity, int8_t &BatTemperatureCoefficient,
double &PeukertExponent, int8_t &ChargeEfficiencyFactor) {
return ParseN2kPGN127513(N2kMsg,BatInstance,BatType,SupportsEqual,BatNominalVoltage,BatChemistry,BatCapacity,BatTemperatureCoefficient,
PeukertExponent,ChargeEfficiencyFactor);
}
//*****************************************************************************
// Leeway
// Input:
// - SID Sequence ID field
// - Leeway Nautical Leeway Angle, which is defined as the angle between the vessel’s heading (direction to which the
// vessel’s bow points) and its course (direction of its motion (track) through the water)
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN128000(tN2kMsg &N2kMsg, unsigned char SID, double Leeway);
inline void SetN2kLeeway(tN2kMsg &N2kMsg, unsigned char SID, double Leeway) {
SetN2kPGN128000(N2kMsg,SID,Leeway);
}
bool ParseN2kPGN128000(const tN2kMsg &N2kMsg, unsigned char &SID, double &Leeway);
inline bool ParseN2kLeeway(const tN2kMsg &N2kMsg, unsigned char &SID, double &Leeway) {
return ParseN2kPGN128000(N2kMsg, SID, Leeway);
}
//*****************************************************************************
// Boat speed
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and wind at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - WaterReferenced Speed over water in m/s
// - GroundReferenced Ground referenced speed in m/s
// - SWRT Type of transducer. See definition for tN2kSpeedWaterReferenceType
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN128259(tN2kMsg &N2kMsg, unsigned char SID, double WaterReferenced, double GroundReferenced=N2kDoubleNA, tN2kSpeedWaterReferenceType SWRT=N2kSWRT_Paddle_wheel);
inline void SetN2kBoatSpeed(tN2kMsg &N2kMsg, unsigned char SID, double WaterReferenced, double GroundReferenced=N2kDoubleNA, tN2kSpeedWaterReferenceType SWRT=N2kSWRT_Paddle_wheel) {
SetN2kPGN128259(N2kMsg,SID,WaterReferenced,GroundReferenced,SWRT);
}
bool ParseN2kPGN128259(const tN2kMsg &N2kMsg, unsigned char &SID, double &WaterReferenced, double &GroundReferenced, tN2kSpeedWaterReferenceType &SWRT);
inline bool ParseN2kBoatSpeed(const tN2kMsg &N2kMsg, unsigned char &SID, double &WaterReferenced, double &GroundReferenced, tN2kSpeedWaterReferenceType &SWRT) {
return ParseN2kPGN128259(N2kMsg, SID, WaterReferenced, GroundReferenced, SWRT);
}
//*****************************************************************************
// Water depth
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and depth at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - DepthBelowTransducer Depth below transducer in meters
// - Offset Distance in meters between transducer and surface (positive) or transducer and keel (negative)
// - Range Measuring range
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN128267(tN2kMsg &N2kMsg, unsigned char SID, double DepthBelowTransducer, double Offset, double Range=N2kDoubleNA);
inline void SetN2kWaterDepth(tN2kMsg &N2kMsg, unsigned char SID, double DepthBelowTransducer, double Offset, double Range=N2kDoubleNA) {
SetN2kPGN128267(N2kMsg,SID,DepthBelowTransducer,Offset,Range);
}
bool ParseN2kPGN128267(const tN2kMsg &N2kMsg, unsigned char &SID, double &DepthBelowTransducer, double &Offset, double &Range);
inline bool ParseN2kWaterDepth(const tN2kMsg &N2kMsg, unsigned char &SID, double &DepthBelowTransducer, double &Offset) {
double Range;
return ParseN2kPGN128267(N2kMsg, SID, DepthBelowTransducer, Offset, Range);
}
inline bool ParseN2kWaterDepth(const tN2kMsg &N2kMsg, unsigned char &SID, double &DepthBelowTransducer, double &Offset, double &Range) {
return ParseN2kPGN128267(N2kMsg, SID, DepthBelowTransducer, Offset, Range);
}
//*****************************************************************************
// Distance log
// Input:
// - DaysSince1970 Timestamp
// - SecondsSinceMidnight Timestamp
// - Log Total meters travelled
// - Trip Log Meters travelled since last reset
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN128275(tN2kMsg &N2kMsg, uint16_t DaysSince1970, double SecondsSinceMidnight, uint32_t Log, uint32_t TripLog);
inline void SetN2kDistanceLog(tN2kMsg &N2kMsg, uint16_t DaysSince1970, double SecondsSinceMidnight, uint32_t Log, uint32_t TripLog) {
SetN2kPGN128275(N2kMsg,DaysSince1970,SecondsSinceMidnight,Log,TripLog);
}
bool ParseN2kPGN128275(const tN2kMsg &N2kMsg, uint16_t &DaysSince1970, double &SecondsSinceMidnight, uint32_t &Log, uint32_t &TripLog);
inline bool ParseN2kDistanceLog(const tN2kMsg &N2kMsg, uint16_t &DaysSince1970, double &SecondsSinceMidnight, uint32_t &Log, uint32_t &TripLog) {
return ParseN2kPGN128275(N2kMsg,DaysSince1970,SecondsSinceMidnight,Log,TripLog);
}
//*****************************************************************************
// PGN128776 - Anchor Windlass Control Status
//
// Eg: SetN2kPGN128776(N2kMsg, SID, WindlassIdentifier, WindlassDirectionControl, SpeedControl);
// -- SID - message sequence id - use to tie together windlass status msgs
// -- WindlassIdentifier - instance of the windlass being reported
// -- WindlassDirectionControl - see tN2kWindlassDirectionControl
// -- SpeedControl - Single speed 0=off, 1-100=on; Dual speed: 0=off, 1-49=slow, 50-100=fast; Proporional speed: 0=off, 1-100=speed
// -- SpeedControlType (optional) - see tN2kSpeedType
// -- AnchorDockingControl (optional) - see tN2kGenericStatusPair
// -- PowerEnable (optional) - see tN2kDGenericStatusPair
// -- MechanicalLock (optional) - see tN2kDGenericStatusPair
// -- DeckAndAnchorWash (optional) - see tN2kDGenericStatusPair
// -- AnchorLight (optional) - see tN2kDGenericStatusPair
// -- CommandTimeout (optional) - range 0.25 ... 1.26 seconds
// -- WindlassControlEvents (optional) - see tN2kWindlassControlEvents
void SetN2kPGN128776(
tN2kMsg &N2kMsg,
unsigned char SID,
unsigned char WindlassIdentifier,
tN2kWindlassDirectionControl WindlassDirectionControl,
unsigned char SpeedControl,
tN2kSpeedType SpeedControlType = N2kDD488_DataNotAvailable,
tN2kGenericStatusPair AnchorDockingControl = N2kDD002_Unavailable,
tN2kGenericStatusPair PowerEnable = N2kDD002_Unavailable,
tN2kGenericStatusPair MechanicalLock = N2kDD002_Unavailable,
tN2kGenericStatusPair DeckAndAnchorWash = N2kDD002_Unavailable,
tN2kGenericStatusPair AnchorLight = N2kDD002_Unavailable,
double CommandTimeout = 0.4,
const tN2kWindlassControlEvents &WindlassControlEvents = tN2kWindlassControlEvents()
);
bool ParseN2kPGN128776(
const tN2kMsg &N2kMsg,
unsigned char &SID,
unsigned char &WindlassIdentifier,
tN2kWindlassDirectionControl &WindlassDirectionControl,
unsigned char &SpeedControl,
tN2kSpeedType &SpeedControlType,
tN2kGenericStatusPair &AnchorDockingControl,
tN2kGenericStatusPair &PowerEnable,
tN2kGenericStatusPair &MechanicalLock,
tN2kGenericStatusPair &DeckAndAnchorWash,
tN2kGenericStatusPair &AnchorLight,
double &CommandTimeout,
tN2kWindlassControlEvents &WindlassControlEvents
);
//*****************************************************************************
// PGN128777 - Anchor Windlass Operating Status
//
// Eg: SetN2kPGN128777(N2kMsg, SID, WindlassIdentifier, RodeCounterValue, WindlassLineSpeed);
// -- SID - message sequence id - use to tie together windlass status msgs
// -- WindlassIdentifier - instance of the windlass being reported
// -- RodeCounterValue - amount of rode deployed in metres
// -- WindlassLineSpeed (optional) - deployment speed in metres per second
// -- WindlassMotionStatus (optional) - see tN2kWindlassMotionStates
// -- RodeTypeStatus (optional) - see tN2kRodeTypeStates
// -- AnchorDockingStatus (optional) - see tN2kAnchorDockingStates
// -- WindlassOperatingEvents (optional) -- see tN2kWindlassOperatingEvents
void SetN2kPGN128777(
tN2kMsg &N2kMsg,
unsigned char SID,
unsigned char WindlassIdentifier,
double RodeCounterValue,
double WindlassLineSpeed = N2kDoubleNA,
tN2kWindlassMotionStates WindlassMotionStatus = N2kDD480_Unavailable,
tN2kRodeTypeStates RodeTypeStatus = N2kDD481_Unavailable,
tN2kDD482 AnchorDockingStatus = N2kDD482_DataNotAvailable,
const tN2kWindlassOperatingEvents &WindlassOperatingEvents = tN2kWindlassOperatingEvents()
);
bool ParseN2kPGN128777(
const tN2kMsg &N2kMsg,
unsigned char &SID,
unsigned char &WindlassIdentifier,
double &RodeCounterValue,
double &WindlassLineSpeed,
tN2kWindlassMotionStates &WindlassMotionStatus,
tN2kRodeTypeStates &RodeTypeStatus,
tN2kAnchorDockingStates &AnchorDockingStatus,
tN2kWindlassOperatingEvents &WindlassOperatingEvents
);
//*****************************************************************************
// PGN128778 - Anchor Windlass Monitoring Status
//
// Eg: SetN2kPGN128778(N2kMsg, SID, WindlassIdentifier, TotalMotorTime);
// -- SID - message sequence id - use to tie together windlass status msgs
// -- WindlassIdentifier - instance of the windlass being reported
// -- TotalMotorTime - total run time of the motor in seconds
// -- ControllerVoltage (optional) - voltage in Volts
// -- MotorCurrent (optional) - current in Amperes
// -- WindlassMonitoringEvents (optional) - see tN2kWindlassMonitoringEvents
void SetN2kPGN128778(
tN2kMsg &N2kMsg,
unsigned char SID,
unsigned char WindlassIdentifier,
double TotalMotorTime,
double ControllerVoltage = N2kDoubleNA,
double MotorCurrent = N2kDoubleNA,
const tN2kWindlassMonitoringEvents &WindlassMonitoringEvents = tN2kWindlassMonitoringEvents()
);
bool ParseN2kPGN128778(
const tN2kMsg &N2kMsg,
unsigned char &SID,
unsigned char &WindlassIdentifier,
double &TotalMotorTime,
double &ControllerVoltage,
double &MotorCurrent,
tN2kWindlassMonitoringEvents &WindlassMonitoringEvents
);
//*****************************************************************************
// Lat/lon rapid
// Input:
// - Latitude Latitude in degrees
// - Longitude Longitude in degrees
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN129025(tN2kMsg &N2kMsg, double Latitude, double Longitude);
inline void SetN2kLatLonRapid(tN2kMsg &N2kMsg, double Latitude, double Longitude) {
SetN2kPGN129025(N2kMsg,Latitude,Longitude);
}
bool ParseN2kPGN129025(const tN2kMsg &N2kMsg, double &Latitude, double &Longitude);
inline bool ParseN2kPositionRapid(const tN2kMsg &N2kMsg, double &Latitude, double &Longitude) {
return ParseN2kPGN129025(N2kMsg, Latitude, Longitude);
}
//*****************************************************************************
// COG SOG rapid
// Input:
// - COG Cource Over Ground in radians
// - SOG Speed Over Ground in m/s
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN129026(tN2kMsg &N2kMsg, unsigned char SID, tN2kHeadingReference ref, double COG, double SOG);
inline void SetN2kCOGSOGRapid(tN2kMsg &N2kMsg, unsigned char SID, tN2kHeadingReference ref, double COG, double SOG) {
SetN2kPGN129026(N2kMsg,SID,ref,COG,SOG);
}
bool ParseN2kPGN129026(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kHeadingReference &ref, double &COG, double &SOG);
inline bool ParseN2kCOGSOGRapid(const tN2kMsg &N2kMsg, unsigned char &SID, tN2kHeadingReference &ref, double &COG, double &SOG) {
return ParseN2kPGN129026(N2kMsg,SID,ref,COG,SOG);
}
//*****************************************************************************
// GNSS Position Data
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and GPS at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - DaysSince1970 Days since 1.1.1970. You can find sample how to convert e.g. NMEA0183 date info to this on my NMEA0183 library on
// NMEA0183Messages.cpp on function NMEA0183ParseRMC_nc
// - Latitude Latitude in degrees
// - Longitude Longitude in degrees
// - Altitude Altitude in meters
// - GNSStype GNSS type. See definition of tN2kGNSStype
// - GNSSmethod GNSS method type. See definition of tN2kGNSSmethod
// - nSatellites Number of satellites used for data
// - HDOP Horizontal Dilution Of Precision in meters.
// - PDOP Probable dilution of precision in meters.
// - GeoidalSeparation Geoidal separation in meters
// Output:
// - N2kMsg NMEA2000 message ready to be send.
void SetN2kPGN129029(tN2kMsg &N2kMsg, unsigned char SID, uint16_t DaysSince1970, double SecondsSinceMidnight,
double Latitude, double Longitude, double Altitude,
tN2kGNSStype GNSStype, tN2kGNSSmethod GNSSmethod,
unsigned char nSatellites, double HDOP, double PDOP=0, double GeoidalSeparation=0,
unsigned char nReferenceStations=0, tN2kGNSStype ReferenceStationType=N2kGNSSt_GPS, uint16_t ReferenceSationID=0,
double AgeOfCorrection=0
);
inline void SetN2kGNSS(tN2kMsg &N2kMsg, unsigned char SID, uint16_t DaysSince1970, double SecondsSinceMidnight,
double Latitude, double Longitude, double Altitude,
tN2kGNSStype GNSStype, tN2kGNSSmethod GNSSmethod,
unsigned char nSatellites, double HDOP, double PDOP=0, double GeoidalSeparation=0,
unsigned char nReferenceStations=0, tN2kGNSStype ReferenceStationType=N2kGNSSt_GPS, uint16_t ReferenceSationID=0,
double AgeOfCorrection=0
) {
SetN2kPGN129029(N2kMsg,SID,DaysSince1970,SecondsSinceMidnight,
Latitude,Longitude,Altitude,
GNSStype,GNSSmethod,
nSatellites,HDOP,PDOP,GeoidalSeparation,
nReferenceStations,ReferenceStationType,ReferenceSationID,
AgeOfCorrection);
}
bool ParseN2kPGN129029(const tN2kMsg &N2kMsg, unsigned char &SID, uint16_t &DaysSince1970, double &SecondsSinceMidnight,
double &Latitude, double &Longitude, double &Altitude,
tN2kGNSStype &GNSStype, tN2kGNSSmethod &GNSSmethod,
unsigned char &nSatellites, double &HDOP, double &PDOP, double &GeoidalSeparation,
unsigned char &nReferenceStations, tN2kGNSStype &ReferenceStationType, uint16_t &ReferenceSationID,
double &AgeOfCorrection
);
inline bool ParseN2kGNSS(const tN2kMsg &N2kMsg, unsigned char &SID, uint16_t &DaysSince1970, double &SecondsSinceMidnight,
double &Latitude, double &Longitude, double &Altitude,
tN2kGNSStype &GNSStype, tN2kGNSSmethod &GNSSmethod,
unsigned char &nSatellites, double &HDOP, double &PDOP, double &GeoidalSeparation,
unsigned char &nReferenceStations, tN2kGNSStype &ReferenceStationType, uint16_t &ReferenceSationID,
double &AgeOfCorrection
) {
return ParseN2kPGN129029(N2kMsg, SID, DaysSince1970, SecondsSinceMidnight,
Latitude, Longitude, Altitude,
GNSStype, GNSSmethod,
nSatellites, HDOP, PDOP, GeoidalSeparation,
nReferenceStations, ReferenceStationType, ReferenceSationID,
AgeOfCorrection
);
}
//*****************************************************************************
// Date,Time & Local offset ( see also PGN 126992 )
// Input:
// - DaysSince1970 Days since 1.1.1970. You can find sample how to convert e.g. NMEA0183 date info to this on my NMEA0183 library on
// NMEA0183Messages.cpp on function NMEA0183ParseRMC_nc
// - Time Seconds since midnight
// - Local offset Local offset in minutes
void SetN2kPGN129033(tN2kMsg &N2kMsg, uint16_t DaysSince1970, double SecondsSinceMidnight, int16_t LocalOffset);
inline void SetN2kLocalOffset(tN2kMsg &N2kMsg, uint16_t DaysSince1970, double SecondsSinceMidnight, int16_t LocalOffset) {
SetN2kPGN129033(N2kMsg,DaysSince1970,SecondsSinceMidnight,LocalOffset);
}
bool ParseN2kPGN129033(const tN2kMsg &N2kMsg, uint16_t &DaysSince1970, double &SecondsSinceMidnight, int16_t &LocalOffset);
inline bool ParseN2kLocalOffset(const tN2kMsg &N2kMsg, uint16_t &DaysSince1970, double &SecondsSinceMidnight, int16_t &LocalOffset) {
return ParseN2kPGN129033(N2kMsg,DaysSince1970,SecondsSinceMidnight,LocalOffset);
}
//*****************************************************************************
// GNSS DOP data
// Input:
// - SID Sequence ID. If your device is e.g. boat speed and GPS at same time, you can set same SID for different messages
// to indicate that they are measured at same time.
// - DesiredMode Desired DOP mode.
// - ActualMode Actual DOP mode.
// - HDOP Horizontal Dilution Of Precision in meters.
// - PDOP Probable dilution of precision in meters.