mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-08-18 18:32:30 +02:00
Clear old code fragments from history buffer class
This commit is contained in:
@@ -265,20 +265,7 @@ void HstryBuf::handle(bool useSimuData, CommonData& common)
|
|||||||
HstryBuffers::HstryBuffers(int size, BoatValueList* boatValues, GwLog* log)
|
HstryBuffers::HstryBuffers(int size, BoatValueList* boatValues, GwLog* log)
|
||||||
: size(size)
|
: size(size)
|
||||||
, boatValueList(boatValues)
|
, boatValueList(boatValues)
|
||||||
, logger(log)
|
, logger(log) { };
|
||||||
{
|
|
||||||
|
|
||||||
// collect boat values for true wind calculation
|
|
||||||
// should all have been already created at true wind object initialization
|
|
||||||
// potentially to be moved to history buffer handling
|
|
||||||
awaBVal = boatValueList->findValueOrCreate("AWA");
|
|
||||||
hdtBVal = boatValueList->findValueOrCreate("HDT");
|
|
||||||
hdmBVal = boatValueList->findValueOrCreate("HDM");
|
|
||||||
varBVal = boatValueList->findValueOrCreate("VAR");
|
|
||||||
cogBVal = boatValueList->findValueOrCreate("COG");
|
|
||||||
sogBVal = boatValueList->findValueOrCreate("SOG");
|
|
||||||
awdBVal = boatValueList->findValueOrCreate("AWD");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create history buffer for boat data type
|
// Create history buffer for boat data type
|
||||||
void HstryBuffers::addBuffer(const String& name)
|
void HstryBuffers::addBuffer(const String& name)
|
||||||
@@ -290,8 +277,6 @@ void HstryBuffers::addBuffer(const String& name)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hstryBuffers[name] = std::unique_ptr<HstryBuf>(new HstryBuf(name, size, boatValueList, logger));
|
|
||||||
|
|
||||||
// Initialize metadata for buffer
|
// Initialize metadata for buffer
|
||||||
String valueFormat = bufferParams[name].format; // Data format of boat data type
|
String valueFormat = bufferParams[name].format; // Data format of boat data type
|
||||||
// String valueFormat = boatValueList->findValueOrCreate(name)->getFormat().c_str(); // Unfortunately, format is not yet available during system initialization
|
// String valueFormat = boatValueList->findValueOrCreate(name)->getFormat().c_str(); // Unfortunately, format is not yet available during system initialization
|
||||||
@@ -300,6 +285,7 @@ void HstryBuffers::addBuffer(const String& name)
|
|||||||
double bufferMinVal = bufferParams[name].bufferMinVal; // Min value for this history buffer
|
double bufferMinVal = bufferParams[name].bufferMinVal; // Min value for this history buffer
|
||||||
double bufferMaxVal = bufferParams[name].bufferMaxVal; // Max value for this history buffer
|
double bufferMaxVal = bufferParams[name].bufferMaxVal; // Max value for this history buffer
|
||||||
|
|
||||||
|
hstryBuffers[name] = std::unique_ptr<HstryBuf>(new HstryBuf(name, size, boatValueList, logger));
|
||||||
hstryBuffers[name]->init(valueFormat, hstryUpdFreq, mltplr, bufferMinVal, bufferMaxVal);
|
hstryBuffers[name]->init(valueFormat, hstryUpdFreq, mltplr, bufferMinVal, bufferMaxVal);
|
||||||
LOG_DEBUG(GwLog::DEBUG, "HstryBuffers: new buffer added: name: %s, format: %s, multiplier: %d, min value: %.2f, max value: %.2f", name, valueFormat, mltplr, bufferMinVal, bufferMaxVal);
|
LOG_DEBUG(GwLog::DEBUG, "HstryBuffers: new buffer added: name: %s, format: %s, multiplier: %d, min value: %.2f, max value: %.2f", name, valueFormat, mltplr, bufferMinVal, bufferMaxVal);
|
||||||
}
|
}
|
||||||
@@ -318,9 +304,10 @@ RingBuffer<uint16_t>* HstryBuffers::getBuffer(const String& name)
|
|||||||
auto it = hstryBuffers.find(name);
|
auto it = hstryBuffers.find(name);
|
||||||
if (it != hstryBuffers.end()) {
|
if (it != hstryBuffers.end()) {
|
||||||
return &it->second->hstryBuf;
|
return &it->second->hstryBuf;
|
||||||
}
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// --- End Class HstryBuffers ---------------
|
// --- End Class HstryBuffers ---------------
|
||||||
|
|
||||||
// --- Class WindUtils --------------
|
// --- Class WindUtils --------------
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
bool smoothInstance(GwApi::BoatValue* boatDataValue); // Smooth single boat data value
|
bool smoothInstance(GwApi::BoatValue* boatDataValue); // Smooth single boat data value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Class for a single history buffer of boat values
|
||||||
class HstryBuf {
|
class HstryBuf {
|
||||||
private:
|
private:
|
||||||
RingBuffer<uint16_t> hstryBuf; // Circular buffer to store history values
|
RingBuffer<uint16_t> hstryBuf; // Circular buffer to store history values
|
||||||
@@ -50,14 +51,13 @@ public:
|
|||||||
void handle(bool useSimuData, CommonData& common);
|
void handle(bool useSimuData, CommonData& common);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Manage history buffer for supported boat data; used by boat data charts
|
// Manage list of history buffers for supported boat data; used by boat data charts
|
||||||
class HstryBuffers {
|
class HstryBuffers {
|
||||||
private:
|
private:
|
||||||
std::map<String, std::unique_ptr<HstryBuf>> hstryBuffers;
|
std::map<String, std::unique_ptr<HstryBuf>> hstryBuffers;
|
||||||
int size; // size of all history buffers
|
int size; // size of all history buffers
|
||||||
BoatValueList* boatValueList;
|
BoatValueList* boatValueList;
|
||||||
GwLog* logger;
|
GwLog* logger;
|
||||||
GwApi::BoatValue *awaBVal, *hdtBVal, *hdmBVal, *varBVal, *cogBVal, *sogBVal, *awdBVal; // boat values for true wind calculation
|
|
||||||
|
|
||||||
struct HistoryParams {
|
struct HistoryParams {
|
||||||
int hstryUpdFreq; // update frequency of history buffer (documentation only)
|
int hstryUpdFreq; // update frequency of history buffer (documentation only)
|
||||||
|
|||||||
@@ -479,7 +479,8 @@ void OBP60Task(GwApi *api){
|
|||||||
pages[i].parameters.values.push_back(value);
|
pages[i].parameters.values.push_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the specified boat data types of relevant pages and create a history buffer for each type
|
// Read the specified boat data types of relevant pages and create a history buffer for each type for later use in charts
|
||||||
|
// applies only for pages that uses charts
|
||||||
if (pages[i].parameters.pageName == "OneValue" || pages[i].parameters.pageName == "TwoValues" || pages[i].parameters.pageName == "WindPlot") {
|
if (pages[i].parameters.pageName == "OneValue" || pages[i].parameters.pageName == "TwoValues" || pages[i].parameters.pageName == "WindPlot") {
|
||||||
for (auto pVal : pages[i].parameters.values) {
|
for (auto pVal : pages[i].parameters.values) {
|
||||||
hstryBufferList.addBuffer(pVal->getName());
|
hstryBufferList.addBuffer(pVal->getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user