1
0
mirror of https://github.com/thooge/esp32-nmea2000-obp60.git synced 2025-12-14 06:23:07 +01:00

correctly handle data timeouts, always set source if for updates

This commit is contained in:
andreas
2024-10-13 16:09:17 +02:00
parent 98a95e62f7
commit e982389c75
3 changed files with 10 additions and 12 deletions

View File

@@ -47,7 +47,6 @@ GwBoatItemBase::GwBoatItemBase(String name, String format, GwBoatItemBase::TOTyp
this->format = format;
this->type = 0;
this->lastUpdateSource = -1;
this->toType=TOType::user;
}
void GwBoatItemBase::setInvalidTime(unsigned long it, bool force){
if (toType != TOType::user || force ){
@@ -375,7 +374,7 @@ GwBoatItem<T> *GwBoatData::getOrCreate(T initial, GwBoatItemNameProvider *provid
provider->getBoatItemFormat(),
provider->getInvalidTime(),
&values);
rt->update(initial);
rt->update(initial,-1);
LOG_DEBUG(GwLog::LOG, "creating boatItem %s, type %d",
name.c_str(), rt->getCurrentType());
return rt;

View File

@@ -105,8 +105,8 @@ template<class T> class GwBoatItem : public GwBoatItemBase{
GwBoatItem(String name,String formatInfo,unsigned long invalidTime=INVALID_TIME,GwBoatItemMap *map=NULL);
GwBoatItem(String name,String formatInfo,TOType toType,GwBoatItemMap *map=NULL);
virtual ~GwBoatItem(){}
bool update(T nv, int source=-1);
bool updateMax(T nv,int sourceId=-1);
bool update(T nv, int source);
bool updateMax(T nv,int sourceId);
T getData(){
return data;
}
@@ -185,7 +185,6 @@ public:
#define GWSPECBOATDATA(clazz,name,toType,fmt) \
clazz *name=new clazz(#name,GwBoatItemBase::fmt,toType,&values) ;
class GwBoatData{
static const unsigned long DEF_TIME=4000;
private:
GwLog *logger;
GwBoatItemBase::GwBoatItemMap values;