max handling also from 0183, satInfo cleanup
This commit is contained in:
parent
28abd16749
commit
08af807cf9
|
@ -52,6 +52,7 @@ class GwBoatItemBase{
|
||||||
virtual void toJsonDoc(JsonDocument *doc, unsigned long minTime)=0;
|
virtual void toJsonDoc(JsonDocument *doc, unsigned long minTime)=0;
|
||||||
virtual size_t getJsonSize(){return JSON_OBJECT_SIZE(15);}
|
virtual size_t getJsonSize(){return JSON_OBJECT_SIZE(15);}
|
||||||
virtual int getLastSource()=0;
|
virtual int getLastSource()=0;
|
||||||
|
virtual void refresh(unsigned long ts=0){uls(ts);}
|
||||||
};
|
};
|
||||||
class GwBoatData;
|
class GwBoatData;
|
||||||
template<class T> class GwBoatItem : public GwBoatItemBase{
|
template<class T> class GwBoatItem : public GwBoatItemBase{
|
||||||
|
@ -82,6 +83,19 @@ template<class T> class GwBoatItem : public GwBoatItemBase{
|
||||||
uls(now);
|
uls(now);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool updateMax(T nv,int sourceId=-1){
|
||||||
|
unsigned long now=millis();
|
||||||
|
if (! isValid(now)){
|
||||||
|
return update(nv,sourceId);
|
||||||
|
}
|
||||||
|
if (getData() < nv){
|
||||||
|
data=nv;
|
||||||
|
lastUpdateSource=sourceId;
|
||||||
|
uls(now);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
T getData(){
|
T getData(){
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -173,6 +187,10 @@ public:
|
||||||
data.update(info);
|
data.update(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
virtual void toJsonDoc(JsonDocument *doc, unsigned long minTime){
|
||||||
|
data.houseKeeping();
|
||||||
|
GwBoatItem<GwSatInfoList>::toJsonDoc(doc,minTime);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -216,8 +234,8 @@ class GwBoatData{
|
||||||
GWBOATDATA(double,BTW,4000,formatCourse)
|
GWBOATDATA(double,BTW,4000,formatCourse)
|
||||||
GWBOATDATA(double,WPLatitude,4000,formatLatitude)
|
GWBOATDATA(double,WPLatitude,4000,formatLatitude)
|
||||||
GWBOATDATA(double,WPLongitude,4000,formatLongitude)
|
GWBOATDATA(double,WPLongitude,4000,formatLongitude)
|
||||||
GWBOATDATA(uint32_t,Log,0,mtr2nm)
|
GWBOATDATA(uint32_t,Log,16000,mtr2nm)
|
||||||
GWBOATDATA(uint32_t,TripLog,0,mtr2nm)
|
GWBOATDATA(uint32_t,TripLog,16000,mtr2nm)
|
||||||
GWBOATDATA(uint32_t,DaysSince1970,4000,formatFixed0)
|
GWBOATDATA(uint32_t,DaysSince1970,4000,formatFixed0)
|
||||||
GWBOATDATA(int16_t,Timezone,8000,formatFixed0)
|
GWBOATDATA(int16_t,Timezone,8000,formatFixed0)
|
||||||
GWSPECBOATDATA(GwBoatDataSatList,SatInfo,GwSatInfoList::lifeTime,formatFixed0);
|
GWSPECBOATDATA(GwBoatDataSatList,SatInfo,GwSatInfoList::lifeTime,formatFixed0);
|
||||||
|
|
|
@ -247,11 +247,13 @@ private:
|
||||||
n2kRef=N2kWind_Apparent;
|
n2kRef=N2kWind_Apparent;
|
||||||
shouldSend=updateDouble(boatData->AWA,WindAngle,msg.sourceId) &&
|
shouldSend=updateDouble(boatData->AWA,WindAngle,msg.sourceId) &&
|
||||||
updateDouble(boatData->AWS,WindSpeed,msg.sourceId);
|
updateDouble(boatData->AWS,WindSpeed,msg.sourceId);
|
||||||
|
if (WindSpeed != NMEA0183DoubleNA) boatData->MaxAws->updateMax(WindSpeed);
|
||||||
break;
|
break;
|
||||||
case NMEA0183Wind_True:
|
case NMEA0183Wind_True:
|
||||||
n2kRef=N2kWind_True_North;
|
n2kRef=N2kWind_True_North;
|
||||||
shouldSend=updateDouble(boatData->TWD,WindAngle,msg.sourceId) &&
|
shouldSend=updateDouble(boatData->TWD,WindAngle,msg.sourceId) &&
|
||||||
updateDouble(boatData->TWS,WindSpeed,msg.sourceId);
|
updateDouble(boatData->TWS,WindSpeed,msg.sourceId);
|
||||||
|
if (WindSpeed != NMEA0183DoubleNA) boatData->MaxTws->updateMax(WindSpeed);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_DEBUG(GwLog::DEBUG,"unknown wind reference %d in %s",(int)Reference,msg.line);
|
LOG_DEBUG(GwLog::DEBUG,"unknown wind reference %d in %s",(int)Reference,msg.line);
|
||||||
|
@ -295,6 +297,7 @@ private:
|
||||||
bool shouldSend = false;
|
bool shouldSend = false;
|
||||||
shouldSend = updateDouble(boatData->AWA, WindAngle, msg.sourceId) &&
|
shouldSend = updateDouble(boatData->AWA, WindAngle, msg.sourceId) &&
|
||||||
updateDouble(boatData->AWS, WindSpeed, msg.sourceId);
|
updateDouble(boatData->AWS, WindSpeed, msg.sourceId);
|
||||||
|
if (WindSpeed != NMEA0183DoubleNA) boatData->MaxAws->updateMax(WindSpeed);
|
||||||
if (shouldSend)
|
if (shouldSend)
|
||||||
{
|
{
|
||||||
SetN2kWindSpeed(n2kMsg, 1, WindSpeed, WindAngle, N2kWind_Apparent);
|
SetN2kWindSpeed(n2kMsg, 1, WindSpeed, WindAngle, N2kWind_Apparent);
|
||||||
|
@ -337,6 +340,7 @@ private:
|
||||||
if (WindAngle != NMEA0183DoubleNA){
|
if (WindAngle != NMEA0183DoubleNA){
|
||||||
shouldSend = updateDouble(boatData->TWD, WindAngle, msg.sourceId) &&
|
shouldSend = updateDouble(boatData->TWD, WindAngle, msg.sourceId) &&
|
||||||
updateDouble(boatData->TWS, WindSpeed, msg.sourceId);
|
updateDouble(boatData->TWS, WindSpeed, msg.sourceId);
|
||||||
|
if (WindSpeed != NMEA0183DoubleNA) boatData->MaxTws->updateMax(WindSpeed);
|
||||||
}
|
}
|
||||||
if (shouldSend)
|
if (shouldSend)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,10 +71,7 @@ private:
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
if (!item->isValid(now))
|
if (!item->isValid(now))
|
||||||
return;
|
return;
|
||||||
if (item->getData() > maxItem->getData() || !maxItem->isValid(now))
|
maxItem->updateMax(item->getData(),sourceId);
|
||||||
{
|
|
||||||
maxItem->update(item->getData(),sourceId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void updateDouble(GwBoatItem<double> *item, double value)
|
void updateDouble(GwBoatItem<double> *item, double value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue