make seasmart working again, only show counter for enabled directions

This commit is contained in:
andreas 2024-11-07 20:16:58 +01:00
parent a5827e24d8
commit b0d5e27b5a
2 changed files with 11 additions and 7 deletions

View File

@ -58,8 +58,6 @@ GwChannel::GwChannel(GwLog *logger,
this->name=name;
this->sourceId=sourceId;
this->maxSourceId=maxSourceId;
this->countIn=new GwCounter<String>(String("count")+name+String("in"));
this->countOut=new GwCounter<String>(String("count")+name+String("out"));
this->impl=NULL;
this->receiver=new GwChannelMessageReceiver(logger,this);
this->actisenseReader=NULL;
@ -100,6 +98,12 @@ void GwChannel::begin(
actisenseReader->SetReadStream(channelStream);
}
}
if (nmeaIn || readActisense){
this->countIn=new GwCounter<String>(String("count")+name+String("in"));
}
if (nmeaOut || seaSmartOut || writeActisense){
this->countOut=new GwCounter<String>(String("count")+name+String("out"));
}
}
void GwChannel::setImpl(GwChannelInterface *impl){
this->impl=impl;
@ -135,10 +139,10 @@ void GwChannel::updateCounter(const char *msg, bool out)
}
if (key[0] == 0) return;
if (out){
countOut->add(key);
if (countOut) countOut->add(key);
}
else{
countIn->add(key);
if (countIn) countIn->add(key);
}
}
@ -209,7 +213,7 @@ void GwChannel::parseActisense(N2kHandler handler){
tN2kMsg N2kMsg;
while (actisenseReader->GetMessageFromStream(N2kMsg)) {
countIn->add(String(N2kMsg.PGN));
if(countIn) countIn->add(String(N2kMsg.PGN));
handler(N2kMsg,sourceId);
}
}
@ -220,7 +224,7 @@ void GwChannel::sendActisense(const tN2kMsg &msg, int sourceId){
//so we can check it here
if (maxSourceId < 0 && this->sourceId == sourceId) return;
if (sourceId >= this->sourceId && sourceId <= maxSourceId) return;
countOut->add(String(msg.PGN));
if(countOut) countOut->add(String(msg.PGN));
msg.SendInActisenseFormat(channelStream);
}

View File

@ -356,7 +356,7 @@ static GwChannel * createChannel(GwLog *logger, GwConfigHandler *config, int id,
canRead,
config->getString(param->readF),
config->getString(param->writeF),
false,
config->getBool(param->sendSeasmart),
config->getBool(param->toN2K),
config->getBool(param->readAct),
config->getBool(param->writeAct));