renamed HDG->HDT, MHDG->HDM

This commit is contained in:
quantenschaum 2024-08-22 15:16:23 +02:00
parent 54d6d51519
commit 1fa1049759
3 changed files with 28 additions and 27 deletions

View File

@ -177,8 +177,8 @@ class GwBoatData{
GWBOATDATA(double,COG,4000,formatCourse) // course over ground GWBOATDATA(double,COG,4000,formatCourse) // course over ground
GWBOATDATA(double,SOG,4000,formatKnots) // speed over ground GWBOATDATA(double,SOG,4000,formatKnots) // speed over ground
GWBOATDATA(double,HDG,4000,formatCourse) // true heading GWBOATDATA(double,HDT,4000,formatCourse) // true heading
GWBOATDATA(double,MHDG,4000,formatCourse) // magnetic heading GWBOATDATA(double,HDM,4000,formatCourse) // magnetic heading
GWBOATDATA(double,STW,4000,formatKnots) // water speed GWBOATDATA(double,STW,4000,formatKnots) // water speed
GWBOATDATA(double,VAR,4000,formatCourse) // variation GWBOATDATA(double,VAR,4000,formatCourse) // variation
GWBOATDATA(double,DEV,4000,formatCourse) // deviation GWBOATDATA(double,DEV,4000,formatCourse) // deviation

View File

@ -500,8 +500,8 @@ private:
shouldSend = updateDouble(boatData->TWD, WindDirection, msg.sourceId) && shouldSend = updateDouble(boatData->TWD, WindDirection, msg.sourceId) &&
updateDouble(boatData->TWS, WindSpeed, msg.sourceId); updateDouble(boatData->TWS, WindSpeed, msg.sourceId);
if (WindSpeed != NMEA0183DoubleNA) boatData->MaxTws->updateMax(WindSpeed); if (WindSpeed != NMEA0183DoubleNA) boatData->MaxTws->updateMax(WindSpeed);
if(shouldSend && boatData->HDG->isValid()) { if(shouldSend && boatData->HDT->isValid()) {
double twa = WindDirection-boatData->HDG->getData(); double twa = WindDirection-boatData->HDT->getData();
if(twa<0) { twa+=2*M_PI; } if(twa<0) { twa+=2*M_PI; }
updateDouble(boatData->TWA, twa, msg.sourceId); updateDouble(boatData->TWA, twa, msg.sourceId);
SetN2kWindSpeed(n2kMsg, 1, WindSpeed, twa, N2kWind_True_water); SetN2kWindSpeed(n2kMsg, 1, WindSpeed, twa, N2kWind_True_water);
@ -511,15 +511,15 @@ private:
} }
void convertHDM(const SNMEA0183Msg &msg){ void convertHDM(const SNMEA0183Msg &msg){
double MHDG=NMEA0183DoubleNA; double HDM=NMEA0183DoubleNA;
if (!NMEA0183ParseHDM_nc(msg, MHDG)) if (!NMEA0183ParseHDM_nc(msg, HDM))
{ {
LOG_DEBUG(GwLog::DEBUG, "failed to parse HDM %s", msg.line); LOG_DEBUG(GwLog::DEBUG, "failed to parse HDM %s", msg.line);
return; return;
} }
if (! UD(MHDG)) return; if (! UD(HDM)) return;
tN2kMsg n2kMsg; tN2kMsg n2kMsg;
SetN2kMagneticHeading(n2kMsg,1,MHDG, SetN2kMagneticHeading(n2kMsg,1,HDM,
boatData->VAR->getDataWithDefault(N2kDoubleNA), boatData->VAR->getDataWithDefault(N2kDoubleNA),
boatData->DEV->getDataWithDefault(N2kDoubleNA) boatData->DEV->getDataWithDefault(N2kDoubleNA)
); );
@ -527,28 +527,29 @@ private:
} }
void convertHDT(const SNMEA0183Msg &msg){ void convertHDT(const SNMEA0183Msg &msg){
double HDG=NMEA0183DoubleNA; double HDT=NMEA0183DoubleNA;
if (!NMEA0183ParseHDT_nc(msg, HDG)) if (!NMEA0183ParseHDT_nc(msg, HDT))
{ {
LOG_DEBUG(GwLog::DEBUG, "failed to parse HDT %s", msg.line); LOG_DEBUG(GwLog::DEBUG, "failed to parse HDT %s", msg.line);
return; return;
} }
if (! UD(HDG)) return; if (! UD(HDT)) return;
tN2kMsg n2kMsg; tN2kMsg n2kMsg;
SetN2kTrueHeading(n2kMsg,1,HDG); SetN2kTrueHeading(n2kMsg,1,HDT);
send(n2kMsg,msg.sourceId); send(n2kMsg,msg.sourceId);
} }
void convertHDG(const SNMEA0183Msg &msg){ void convertHDG(const SNMEA0183Msg &msg){
double MHDG=NMEA0183DoubleNA; double HDM=NMEA0183DoubleNA;
double VAR=NMEA0183DoubleNA;
double DEV=NMEA0183DoubleNA; double DEV=NMEA0183DoubleNA;
double VAR=NMEA0183DoubleNA;
if (msg.FieldCount() < 5) if (msg.FieldCount() < 5)
{ {
LOG_DEBUG(GwLog::DEBUG, "failed to parse HDG %s", msg.line); LOG_DEBUG(GwLog::DEBUG, "failed to parse HDG %s", msg.line);
return; return;
} }
if (msg.FieldLen(0)>0){ if (msg.FieldLen(0)>0){
MHDG=formatDegToRad(atof(msg.Field(0))); HDM=formatDegToRad(atof(msg.Field(0)));
} }
else{ else{
return; return;
@ -562,11 +563,11 @@ private:
if (msg.Field(4)[0] == 'W') VAR=-VAR; if (msg.Field(4)[0] == 'W') VAR=-VAR;
} }
if (! UD(MHDG)) return; if (! UD(HDM)) return;
UD(VAR); UD(VAR);
UD(DEV); UD(DEV);
tN2kMsg n2kMsg; tN2kMsg n2kMsg;
SetN2kMagneticHeading(n2kMsg,1,MHDG,DEV,VAR); SetN2kMagneticHeading(n2kMsg,1,HDM,DEV,VAR);
send(n2kMsg,msg.sourceId,"127250M"); send(n2kMsg,msg.sourceId,"127250M");
} }
@ -702,11 +703,11 @@ private:
return; return;
} }
tN2kMsg n2kMsg; tN2kMsg n2kMsg;
if (updateDouble(boatData->HDG,TrueHeading,msg.sourceId)){ if (updateDouble(boatData->HDT,TrueHeading,msg.sourceId)){
SetN2kTrueHeading(n2kMsg,1,TrueHeading); SetN2kTrueHeading(n2kMsg,1,TrueHeading);
send(n2kMsg,msg.sourceId); send(n2kMsg,msg.sourceId);
} }
if(updateDouble(boatData->MHDG,MagneticHeading,msg.sourceId)){ if(updateDouble(boatData->HDM,MagneticHeading,msg.sourceId)){
SetN2kMagneticHeading(n2kMsg,1,MagneticHeading, SetN2kMagneticHeading(n2kMsg,1,MagneticHeading,
boatData->DEV->getDataWithDefault(N2kDoubleNA), boatData->DEV->getDataWithDefault(N2kDoubleNA),
boatData->VAR->getDataWithDefault(N2kDoubleNA) boatData->VAR->getDataWithDefault(N2kDoubleNA)

View File

@ -185,13 +185,13 @@ private:
if (N2kIsNA(Variation)){ if (N2kIsNA(Variation)){
//no variation //no variation
if (ref == N2khr_magnetic){ if (ref == N2khr_magnetic){
updateDouble(boatData->MHDG,Heading); updateDouble(boatData->HDM,Heading);
if (NMEA0183SetHDM(NMEA0183Msg,Heading,talkerId)){ if (NMEA0183SetHDM(NMEA0183Msg,Heading,talkerId)){
SendMessage(NMEA0183Msg); SendMessage(NMEA0183Msg);
} }
} }
if (ref == N2khr_true){ if (ref == N2khr_true){
updateDouble(boatData->HDG,Heading); updateDouble(boatData->HDT,Heading);
if (NMEA0183SetHDT(NMEA0183Msg,Heading,talkerId)){ if (NMEA0183SetHDT(NMEA0183Msg,Heading,talkerId)){
SendMessage(NMEA0183Msg); SendMessage(NMEA0183Msg);
} }
@ -206,8 +206,8 @@ private:
if (ref == N2khr_true){ if (ref == N2khr_true){
MagneticHeading=Heading-Variation; MagneticHeading=Heading-Variation;
} }
updateDouble(boatData->MHDG,MagneticHeading); updateDouble(boatData->HDM,MagneticHeading);
updateDouble(boatData->HDG,Heading); updateDouble(boatData->HDT,Heading);
if (!N2kIsNA(MagneticHeading)){ if (!N2kIsNA(MagneticHeading)){
if (NMEA0183SetHDG(NMEA0183Msg, MagneticHeading,_Deviation, if (NMEA0183SetHDG(NMEA0183Msg, MagneticHeading,_Deviation,
Variation,talkerId)) Variation,talkerId))
@ -252,8 +252,8 @@ private:
tNMEA0183Msg NMEA0183Msg; tNMEA0183Msg NMEA0183Msg;
updateDouble(boatData->STW, WaterReferenced); updateDouble(boatData->STW, WaterReferenced);
unsigned long now = millis(); unsigned long now = millis();
double MagneticHeading = (boatData->HDG->isValid(now) && boatData->VAR->isValid(now)) ? boatData->HDG->getData() + boatData->VAR->getData() : NMEA0183DoubleNA; double MagneticHeading = (boatData->HDT->isValid(now) && boatData->VAR->isValid(now)) ? boatData->HDT->getData() + boatData->VAR->getData() : NMEA0183DoubleNA;
if (NMEA0183SetVHW(NMEA0183Msg, boatData->HDG->getDataWithDefault(NMEA0183DoubleNA), MagneticHeading, WaterReferenced,talkerId)) if (NMEA0183SetVHW(NMEA0183Msg, boatData->HDT->getDataWithDefault(NMEA0183DoubleNA), MagneticHeading, WaterReferenced,talkerId))
{ {
SendMessage(NMEA0183Msg); SendMessage(NMEA0183Msg);
} }
@ -492,8 +492,8 @@ private:
updateDouble(boatData->TWS, WindSpeed); updateDouble(boatData->TWS, WindSpeed);
setMax(boatData->MaxTws, boatData->TWS); setMax(boatData->MaxTws, boatData->TWS);
shouldSend = true; shouldSend = true;
if (boatData->HDG->isValid()) { if (boatData->HDT->isValid()) {
double twd = WindAngle+boatData->HDG->getData(); double twd = WindAngle+boatData->HDT->getData();
if (twd>2*M_PI) { twd-=2*M_PI; } if (twd>2*M_PI) { twd-=2*M_PI; }
updateDouble(boatData->TWD, twd); updateDouble(boatData->TWD, twd);
} }