mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-02-11 15:13:06 +01:00
Update data calibration: calibration in main loop on boat data values:
- modified code to calibrate affected boat data each second in main obp60task loop; - removed individual calibration call in all pages - moved code from BoatDataCalibration to OBPDataOperations - added DBS and HDT to list of supported data calibration types - changed output format for wind angles from [-180..180] to [0..360], because negative value are not displayed properly on pages
This commit is contained in:
@@ -1,190 +0,0 @@
|
|||||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
|
||||||
|
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
#include <cmath>
|
|
||||||
#include <math.h>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
CalibrationDataList calibrationData;
|
|
||||||
std::unordered_map<std::string, TypeCalibData> CalibrationDataList::calibMap; // list of calibration data instances
|
|
||||||
|
|
||||||
void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger)
|
|
||||||
// Initial load of calibration data into internal list
|
|
||||||
// This method is called once at init phase of <obp60task> to read the configuration values
|
|
||||||
{
|
|
||||||
std::string instance;
|
|
||||||
double offset;
|
|
||||||
double slope;
|
|
||||||
double smooth;
|
|
||||||
|
|
||||||
String calInstance = "";
|
|
||||||
String calOffset = "";
|
|
||||||
String calSlope = "";
|
|
||||||
String calSmooth = "";
|
|
||||||
|
|
||||||
// Load user format configuration values
|
|
||||||
String lengthFormat = config->getString(config->lengthFormat); // [m|ft]
|
|
||||||
String distanceFormat = config->getString(config->distanceFormat); // [m|km|nm]
|
|
||||||
String speedFormat = config->getString(config->speedFormat); // [m/s|km/h|kn]
|
|
||||||
String windspeedFormat = config->getString(config->windspeedFormat); // [m/s|km/h|kn|bft]
|
|
||||||
String tempFormat = config->getString(config->tempFormat); // [K|C|F]
|
|
||||||
|
|
||||||
// Read calibration settings for data instances
|
|
||||||
for (int i = 0; i < MAX_CALIBRATION_DATA; i++) {
|
|
||||||
calInstance = "calInstance" + String(i + 1);
|
|
||||||
calOffset = "calOffset" + String(i + 1);
|
|
||||||
calSlope = "calSlope" + String(i + 1);
|
|
||||||
calSmooth = "calSmooth" + String(i + 1);
|
|
||||||
|
|
||||||
instance = std::string(config->getString(calInstance, "---").c_str());
|
|
||||||
if (instance == "---") {
|
|
||||||
LOG_DEBUG(GwLog::LOG, "no calibration data for instance no. %d", i + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
calibMap[instance] = { 0.0f, 1.0f, 1.0f, 0.0f, false };
|
|
||||||
offset = (config->getString(calOffset, "")).toFloat();
|
|
||||||
slope = (config->getString(calSlope, "")).toFloat();
|
|
||||||
smooth = (config->getString(calSmooth, "")).toInt(); // user input is int; further math is done with double
|
|
||||||
|
|
||||||
// Convert calibration values to internal standard formats
|
|
||||||
if (instance == "AWS" || instance == "TWS") {
|
|
||||||
if (windspeedFormat == "m/s") {
|
|
||||||
// No conversion needed
|
|
||||||
} else if (windspeedFormat == "km/h") {
|
|
||||||
offset /= 3.6; // Convert km/h to m/s
|
|
||||||
} else if (windspeedFormat == "kn") {
|
|
||||||
offset /= 1.94384; // Convert kn to m/s
|
|
||||||
} else if (windspeedFormat == "bft") {
|
|
||||||
offset *= 2 + (offset / 2); // Convert Bft to m/s (approx) -> to be improved
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (instance == "AWA" || instance == "COG" || instance == "TWA" || instance == "TWD" || instance == "HDM" || instance == "PRPOS" || instance == "RPOS") {
|
|
||||||
offset *= M_PI / 180; // Convert deg to rad
|
|
||||||
|
|
||||||
} else if (instance == "DBT") {
|
|
||||||
if (lengthFormat == "m") {
|
|
||||||
// No conversion needed
|
|
||||||
} else if (lengthFormat == "ft") {
|
|
||||||
offset /= 3.28084; // Convert ft to m
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (instance == "SOG" || instance == "STW") {
|
|
||||||
if (speedFormat == "m/s") {
|
|
||||||
// No conversion needed
|
|
||||||
} else if (speedFormat == "km/h") {
|
|
||||||
offset /= 3.6; // Convert km/h to m/s
|
|
||||||
} else if (speedFormat == "kn") {
|
|
||||||
offset /= 1.94384; // Convert kn to m/s
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (instance == "WTemp") {
|
|
||||||
if (tempFormat == "K" || tempFormat == "C") {
|
|
||||||
// No conversion needed
|
|
||||||
} else if (tempFormat == "F") {
|
|
||||||
offset *= 9.0 / 5.0; // Convert °F to K
|
|
||||||
slope *= 9.0 / 5.0; // Convert °F to K
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// transform smoothing factor from {0.01..10} to {0.3..0.95} and invert for exponential smoothing formula
|
|
||||||
if (smooth <= 0) {
|
|
||||||
smooth = 0;
|
|
||||||
} else {
|
|
||||||
if (smooth > 10) {
|
|
||||||
smooth = 10;
|
|
||||||
}
|
|
||||||
smooth = 0.3 + ((smooth - 0.01) * (0.95 - 0.3) / (10 - 0.01));
|
|
||||||
}
|
|
||||||
smooth = 1 - smooth;
|
|
||||||
|
|
||||||
calibMap[instance].offset = offset;
|
|
||||||
calibMap[instance].slope = slope;
|
|
||||||
calibMap[instance].smooth = smooth;
|
|
||||||
calibMap[instance].isCalibrated = false;
|
|
||||||
LOG_DEBUG(GwLog::LOG, "calibration data: %s, offset: %f, slope: %f, smoothing: %f", instance.c_str(),
|
|
||||||
calibMap[instance].offset, calibMap[instance].slope, calibMap[instance].smooth);
|
|
||||||
}
|
|
||||||
LOG_DEBUG(GwLog::LOG, "all calibration data read");
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalibrationDataList::calibrateInstance(GwApi::BoatValue* boatDataValue, GwLog* logger)
|
|
||||||
// Method to calibrate the boat data value
|
|
||||||
{
|
|
||||||
std::string instance = boatDataValue->getName().c_str();
|
|
||||||
double offset = 0;
|
|
||||||
double slope = 1.0;
|
|
||||||
double dataValue = 0;
|
|
||||||
std::string format = "";
|
|
||||||
|
|
||||||
if (calibMap.find(instance) == calibMap.end()) {
|
|
||||||
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s not in calibration list", instance.c_str());
|
|
||||||
return;
|
|
||||||
} else if (!boatDataValue->valid) { // no valid boat data value, so we don't want to apply calibration data
|
|
||||||
calibMap[instance].isCalibrated = false;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
offset = calibMap[instance].offset;
|
|
||||||
slope = calibMap[instance].slope;
|
|
||||||
dataValue = boatDataValue->value;
|
|
||||||
format = boatDataValue->getFormat().c_str();
|
|
||||||
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s: value: %f, format: %s", instance.c_str(), dataValue, format.c_str());
|
|
||||||
|
|
||||||
if (format == "formatWind") { // instance is of type angle
|
|
||||||
dataValue = (dataValue * slope) + offset;
|
|
||||||
dataValue = fmod(dataValue, 2 * M_PI);
|
|
||||||
if (dataValue > (M_PI)) {
|
|
||||||
dataValue -= (2 * M_PI);
|
|
||||||
} else if (dataValue < (M_PI * -1)) {
|
|
||||||
dataValue += (2 * M_PI);
|
|
||||||
}
|
|
||||||
} else if (format == "formatCourse") { // instance is of type direction
|
|
||||||
dataValue = (dataValue * slope) + offset;
|
|
||||||
dataValue = fmod(dataValue, 2 * M_PI);
|
|
||||||
if (dataValue < 0) {
|
|
||||||
dataValue += (2 * M_PI);
|
|
||||||
}
|
|
||||||
} else if (format == "kelvinToC") { // instance is of type temperature
|
|
||||||
dataValue = ((dataValue - 273.15) * slope) + offset + 273.15;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
dataValue = (dataValue * slope) + offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
calibMap[instance].isCalibrated = true;
|
|
||||||
boatDataValue->value = dataValue;
|
|
||||||
|
|
||||||
calibrationData.smoothInstance(boatDataValue, logger); // smooth the boat data value
|
|
||||||
calibMap[instance].value = boatDataValue->value; // store the calibrated + smoothed value in the list
|
|
||||||
|
|
||||||
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s: Offset: %f, Slope: %f, Result: %f", instance.c_str(), offset, slope, calibMap[instance].value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CalibrationDataList::smoothInstance(GwApi::BoatValue* boatDataValue, GwLog* logger)
|
|
||||||
// Method to smoothen the boat data value
|
|
||||||
{
|
|
||||||
static std::unordered_map<std::string, double> lastValue; // array for last values of smoothed boat data values
|
|
||||||
|
|
||||||
std::string instance = boatDataValue->getName().c_str();
|
|
||||||
double oldValue = 0;
|
|
||||||
double dataValue = boatDataValue->value;
|
|
||||||
double smoothFactor = 0;
|
|
||||||
|
|
||||||
if (!boatDataValue->valid) { // no valid boat data value, so we don't want to smoothen value
|
|
||||||
return;
|
|
||||||
} else if (calibMap.find(instance) == calibMap.end()) {
|
|
||||||
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: smooth factor for %s not found in calibration list", instance.c_str());
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
smoothFactor = calibMap[instance].smooth;
|
|
||||||
|
|
||||||
if (lastValue.find(instance) != lastValue.end()) {
|
|
||||||
oldValue = lastValue[instance];
|
|
||||||
dataValue = oldValue + (smoothFactor * (dataValue - oldValue)); // exponential smoothing algorithm
|
|
||||||
}
|
|
||||||
lastValue[instance] = dataValue; // store the new value for next cycle; first time, store only the current value and return
|
|
||||||
boatDataValue->value = dataValue; // set the smoothed value to the boat data value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
// Functions lib for data instance calibration
|
|
||||||
|
|
||||||
#ifndef _BOATDATACALIBRATION_H
|
|
||||||
#define _BOATDATACALIBRATION_H
|
|
||||||
|
|
||||||
// #include "Pagedata.h"
|
|
||||||
#include "GwApi.h"
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#define MAX_CALIBRATION_DATA 3 // maximum number of calibration data instances
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
double offset; // calibration offset
|
|
||||||
double slope; // calibration slope
|
|
||||||
double smooth; // smoothing factor
|
|
||||||
double value; // calibrated data value
|
|
||||||
bool isCalibrated; // is data instance value calibrated?
|
|
||||||
} TypeCalibData;
|
|
||||||
|
|
||||||
class CalibrationDataList {
|
|
||||||
public:
|
|
||||||
static std::unordered_map<std::string, TypeCalibData> calibMap; // list of calibration data instances
|
|
||||||
|
|
||||||
void readConfig(GwConfigHandler* config, GwLog* logger);
|
|
||||||
void calibrateInstance(GwApi::BoatValue* boatDataValue, GwLog* logger);
|
|
||||||
void smoothInstance(GwApi::BoatValue* boatDataValue, GwLog* logger);
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CalibrationDataList calibrationData; // this list holds all calibration data
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,5 +1,221 @@
|
|||||||
#include "OBPDataOperations.h"
|
#include "OBPDataOperations.h"
|
||||||
#include "BoatDataCalibration.h" // Functions lib for data instance calibration
|
//#include "BoatDataCalibration.h" // Functions lib for data instance calibration
|
||||||
|
|
||||||
|
// --- Class CalibrationData ---------------
|
||||||
|
CalibrationData::CalibrationData(GwLog* log)
|
||||||
|
{
|
||||||
|
logger = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CalibrationData::readConfig(GwConfigHandler* config)
|
||||||
|
// Initial load of calibration data into internal list
|
||||||
|
// This method is called once at init phase of <obp60task> to read the configuration values
|
||||||
|
{
|
||||||
|
std::string instance;
|
||||||
|
double offset;
|
||||||
|
double slope;
|
||||||
|
double smooth;
|
||||||
|
|
||||||
|
String calInstance = "";
|
||||||
|
String calOffset = "";
|
||||||
|
String calSlope = "";
|
||||||
|
String calSmooth = "";
|
||||||
|
|
||||||
|
// Load user format configuration values
|
||||||
|
String lengthFormat = config->getString(config->lengthFormat); // [m|ft]
|
||||||
|
String distanceFormat = config->getString(config->distanceFormat); // [m|km|nm]
|
||||||
|
String speedFormat = config->getString(config->speedFormat); // [m/s|km/h|kn]
|
||||||
|
String windspeedFormat = config->getString(config->windspeedFormat); // [m/s|km/h|kn|bft]
|
||||||
|
String tempFormat = config->getString(config->tempFormat); // [K|C|F]
|
||||||
|
|
||||||
|
// Read calibration settings for data instances
|
||||||
|
for (int i = 0; i < MAX_CALIBRATION_DATA; i++) {
|
||||||
|
calInstance = "calInstance" + String(i + 1);
|
||||||
|
calOffset = "calOffset" + String(i + 1);
|
||||||
|
calSlope = "calSlope" + String(i + 1);
|
||||||
|
calSmooth = "calSmooth" + String(i + 1);
|
||||||
|
|
||||||
|
instance = std::string(config->getString(calInstance, "---").c_str());
|
||||||
|
if (instance == "---") {
|
||||||
|
LOG_DEBUG(GwLog::LOG, "No calibration data for instance no. %d", i + 1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
calibrationMap[instance] = { 0.0f, 1.0f, 1.0f, 0.0f, false };
|
||||||
|
offset = (config->getString(calOffset, "")).toDouble();
|
||||||
|
slope = (config->getString(calSlope, "")).toDouble();
|
||||||
|
smooth = (config->getString(calSmooth, "")).toInt(); // user input is int; further math is done with double
|
||||||
|
|
||||||
|
if (slope == 0.0) {
|
||||||
|
slope = 1.0; // eliminate adjustment if user selected "0" -> that would set the calibrated value to "0"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert calibration values from user input format to internal standard SI format
|
||||||
|
if (instance == "AWS" || instance == "TWS") {
|
||||||
|
if (windspeedFormat == "m/s") {
|
||||||
|
// No conversion needed
|
||||||
|
} else if (windspeedFormat == "km/h") {
|
||||||
|
offset /= 3.6; // Convert km/h to m/s
|
||||||
|
} else if (windspeedFormat == "kn") {
|
||||||
|
offset /= 1.94384; // Convert kn to m/s
|
||||||
|
} else if (windspeedFormat == "bft") {
|
||||||
|
offset *= 2 + (offset / 2); // Convert Bft to m/s (approx) -> to be improved
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (instance == "AWA" || instance == "COG" || instance == "HDM" || instance == "HDT" || instance == "PRPOS" || instance == "RPOS" || instance == "TWA" || instance == "TWD") {
|
||||||
|
offset *= DEG_TO_RAD; // Convert deg to rad
|
||||||
|
|
||||||
|
} else if (instance == "DBS" || instance == "DBT") {
|
||||||
|
if (lengthFormat == "m") {
|
||||||
|
// No conversion needed
|
||||||
|
} else if (lengthFormat == "ft") {
|
||||||
|
offset /= 3.28084; // Convert ft to m
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (instance == "SOG" || instance == "STW") {
|
||||||
|
if (speedFormat == "m/s") {
|
||||||
|
// No conversion needed
|
||||||
|
} else if (speedFormat == "km/h") {
|
||||||
|
offset /= 3.6; // Convert km/h to m/s
|
||||||
|
} else if (speedFormat == "kn") {
|
||||||
|
offset /= 1.94384; // Convert kn to m/s
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (instance == "WTemp") {
|
||||||
|
if (tempFormat == "K" || tempFormat == "C") {
|
||||||
|
// No conversion needed
|
||||||
|
} else if (tempFormat == "F") {
|
||||||
|
offset *= 9.0 / 5.0; // Convert °F to K
|
||||||
|
slope *= 9.0 / 5.0; // Convert °F to K
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// transform smoothing factor from [0.01..10] to [0.3..0.95] and invert for exponential smoothing formula
|
||||||
|
if (smooth <= 0) {
|
||||||
|
smooth = 0;
|
||||||
|
} else {
|
||||||
|
if (smooth > 10) {
|
||||||
|
smooth = 10;
|
||||||
|
}
|
||||||
|
smooth = 0.3 + ((smooth - 0.01) * (0.95 - 0.3) / (10 - 0.01));
|
||||||
|
}
|
||||||
|
smooth = 1 - smooth;
|
||||||
|
|
||||||
|
calibrationMap[instance].offset = offset;
|
||||||
|
calibrationMap[instance].slope = slope;
|
||||||
|
calibrationMap[instance].smooth = smooth;
|
||||||
|
calibrationMap[instance].isCalibrated = false;
|
||||||
|
LOG_DEBUG(GwLog::LOG, "Calibration data type added: %s, offset: %f, slope: %f, smoothing: %f", instance.c_str(),
|
||||||
|
calibrationMap[instance].offset, calibrationMap[instance].slope, calibrationMap[instance].smooth);
|
||||||
|
}
|
||||||
|
// LOG_DEBUG(GwLog::LOG, "All calibration data read");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle calibrationMap and calibrate all boat data values
|
||||||
|
void CalibrationData::handleCalibration(BoatValueList* boatValueList)
|
||||||
|
{
|
||||||
|
GwApi::BoatValue* bValue;
|
||||||
|
|
||||||
|
for (const auto& cMap : calibrationMap) {
|
||||||
|
std::string instance = cMap.first.c_str();
|
||||||
|
bValue = boatValueList->findValueOrCreate(String(instance.c_str()));
|
||||||
|
|
||||||
|
calibrateInstance(bValue);
|
||||||
|
smoothInstance(bValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calibrate single boat data value
|
||||||
|
// Return calibrated boat value or DBL_MAX, if no calibration was performed
|
||||||
|
bool CalibrationData::calibrateInstance(GwApi::BoatValue* boatDataValue)
|
||||||
|
{
|
||||||
|
std::string instance = boatDataValue->getName().c_str();
|
||||||
|
double offset = 0;
|
||||||
|
double slope = 1.0;
|
||||||
|
double dataValue = 0;
|
||||||
|
std::string format = "";
|
||||||
|
|
||||||
|
// we test this earlier, but for safety reason ...
|
||||||
|
if (calibrationMap.find(instance) == calibrationMap.end()) {
|
||||||
|
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s not in calibration list", instance.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
calibrationMap[instance].isCalibrated = false; // reset calibration flag until properly calibrated
|
||||||
|
|
||||||
|
if (!boatDataValue->valid) { // no valid boat data value, so we don't want to apply calibration data
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset = calibrationMap[instance].offset;
|
||||||
|
slope = calibrationMap[instance].slope;
|
||||||
|
dataValue = boatDataValue->value;
|
||||||
|
format = boatDataValue->getFormat().c_str();
|
||||||
|
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s: value: %f, format: %s", instance.c_str(), dataValue, format.c_str());
|
||||||
|
|
||||||
|
if (format == "formatWind") { // instance is of type angle
|
||||||
|
dataValue = (dataValue * slope) + offset;
|
||||||
|
// dataValue = WindUtils::toPI(dataValue);
|
||||||
|
dataValue = WindUtils::to2PI(dataValue); // we should call <toPI> for format of [-180..180], but pages cannot handle negative values yet
|
||||||
|
|
||||||
|
} else if (format == "formatCourse") { // instance is of type direction
|
||||||
|
dataValue = (dataValue * slope) + offset;
|
||||||
|
dataValue = WindUtils::to2PI(dataValue);
|
||||||
|
|
||||||
|
} else if (format == "kelvinToC") { // instance is of type temperature
|
||||||
|
dataValue = ((dataValue - 273.15) * slope) + offset + 273.15;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
dataValue = (dataValue * slope) + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
boatDataValue->value = dataValue; // update boat data value with calibrated value
|
||||||
|
calibrationMap[instance].value = dataValue; // store the calibrated value in the list
|
||||||
|
calibrationMap[instance].isCalibrated = true;
|
||||||
|
|
||||||
|
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s: Offset: %f, Slope: %f, Result: %f", instance.c_str(), offset, slope, calibrationMap[instance].value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Smooth single boat data value
|
||||||
|
// Return smoothed boat value or DBL_MAX, if no smoothing was performed
|
||||||
|
bool CalibrationData::smoothInstance(GwApi::BoatValue* boatDataValue)
|
||||||
|
{
|
||||||
|
std::string instance = boatDataValue->getName().c_str();
|
||||||
|
double oldValue = 0;
|
||||||
|
double dataValue = boatDataValue->value;
|
||||||
|
double smoothFactor = 0;
|
||||||
|
|
||||||
|
// we test this earlier, but for safety reason ...
|
||||||
|
if (calibrationMap.find(instance) == calibrationMap.end()) {
|
||||||
|
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s not in calibration list", instance.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
calibrationMap[instance].isCalibrated = false; // reset calibration flag until properly calibrated
|
||||||
|
|
||||||
|
if (!boatDataValue->valid) { // no valid boat data value, so we don't need to do anything
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
smoothFactor = calibrationMap[instance].smooth;
|
||||||
|
|
||||||
|
if (lastValue.find(instance) != lastValue.end()) {
|
||||||
|
oldValue = lastValue[instance];
|
||||||
|
dataValue = oldValue + (smoothFactor * (dataValue - oldValue)); // exponential smoothing algorithm
|
||||||
|
}
|
||||||
|
lastValue[instance] = dataValue; // store the new value for next cycle; first time, store only the current value and return
|
||||||
|
|
||||||
|
boatDataValue->value = dataValue; // update boat data value with smoothed value
|
||||||
|
calibrationMap[instance].value = dataValue; // store the smoothed value in the list
|
||||||
|
calibrationMap[instance].isCalibrated = true;
|
||||||
|
|
||||||
|
LOG_DEBUG(GwLog::DEBUG, "BoatDataCalibration: %s: smooth: %f, oldValue: %f, result: %f", instance.c_str(), smoothFactor, oldValue, calibrationMap[instance].value);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// --- End Class CalibrationData ---------------
|
||||||
|
|
||||||
// --- Class HstryBuf ---------------
|
// --- Class HstryBuf ---------------
|
||||||
HstryBuf::HstryBuf(const String& name, int size, BoatValueList* boatValues, GwLog* log)
|
HstryBuf::HstryBuf(const String& name, int size, BoatValueList* boatValues, GwLog* log)
|
||||||
@@ -43,12 +259,15 @@ void HstryBuf::handle(bool useSimuData, CommonData& common)
|
|||||||
|
|
||||||
if (boatValue->valid) {
|
if (boatValue->valid) {
|
||||||
// Calibrate boat value before adding it to history buffer
|
// Calibrate boat value before adding it to history buffer
|
||||||
calibrationData.calibrateInstance(tmpBVal.get(), logger);
|
//calibrationData.calibrateInstance(tmpBVal.get(), logger);
|
||||||
add(tmpBVal->value);
|
//add(tmpBVal->value);
|
||||||
|
add(boatValue->value);
|
||||||
|
|
||||||
} else if (useSimuData) { // add simulated value to history buffer
|
} else if (useSimuData) { // add simulated value to history buffer
|
||||||
double simValue = formatValue(tmpBVal.get(), common).value; // simulated value is generated at <formatValue>
|
double simSIValue = formatValue(tmpBVal.get(), common).value; // simulated value is generated at <formatValue>; here: retreive SI value
|
||||||
add(simValue);
|
add(simSIValue);
|
||||||
|
} else {
|
||||||
|
// here we will add invalid (DBL_MAX) value; this will mark periods of missing data in buffer together with a timestamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// --- End Class HstryBuf ---------------
|
// --- End Class HstryBuf ---------------
|
||||||
|
|||||||
@@ -1,9 +1,36 @@
|
|||||||
// Function lib for history buffer handling, true wind calculation, and other operations on boat data
|
// Function lib for boat data calibration, history buffer handling, true wind calculation, and other operations on boat data
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "OBPRingBuffer.h"
|
#include "OBPRingBuffer.h"
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "obp60task.h"
|
#include "obp60task.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
// Calibration of boat data values, when user setting available
|
||||||
|
// supported boat data types are: AWA, AWS, COG, DBS, DBT, HDM, HDT, PRPOS, RPOS, SOG, STW, TWA, TWS, TWD, WTemp
|
||||||
|
class CalibrationData {
|
||||||
|
private:
|
||||||
|
typedef struct {
|
||||||
|
double offset; // calibration offset
|
||||||
|
double slope; // calibration slope
|
||||||
|
double smooth; // smoothing factor
|
||||||
|
double value; // calibrated data value (for future use)
|
||||||
|
bool isCalibrated; // is data instance value calibrated? (for future use)
|
||||||
|
} tCalibrationData;
|
||||||
|
|
||||||
|
std::unordered_map<std::string, tCalibrationData> calibrationMap; // list of calibration data instances
|
||||||
|
std::unordered_map<std::string, double> lastValue; // array for last smoothed values of boat data values
|
||||||
|
GwLog* logger;
|
||||||
|
|
||||||
|
static constexpr int8_t MAX_CALIBRATION_DATA = 3; // maximum number of calibration data instances
|
||||||
|
|
||||||
|
public:
|
||||||
|
CalibrationData(GwLog* log);
|
||||||
|
void readConfig(GwConfigHandler* config);
|
||||||
|
void handleCalibration(BoatValueList* boatValues); // Handle calibrationMap and calibrate all boat data values
|
||||||
|
bool calibrateInstance(GwApi::BoatValue* boatDataValue); // Calibrate single boat data value
|
||||||
|
bool smoothInstance(GwApi::BoatValue* boatDataValue); // Smooth single boat data value
|
||||||
|
};
|
||||||
|
|
||||||
class HstryBuf {
|
class HstryBuf {
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
class PageFourValues : public Page
|
class PageFourValues : public Page
|
||||||
{
|
{
|
||||||
@@ -46,7 +45,6 @@ class PageFourValues : public Page
|
|||||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bvalue1->value; // Value as double in SI unit
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -56,7 +54,6 @@ class PageFourValues : public Page
|
|||||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
||||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value2 = bvalue2->value; // Value as double in SI unit
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
bool valid2 = bvalue2->valid; // Valid information
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -66,7 +63,6 @@ class PageFourValues : public Page
|
|||||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
||||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value3 = bvalue3->value; // Value as double in SI unit
|
double value3 = bvalue3->value; // Value as double in SI unit
|
||||||
bool valid3 = bvalue3->valid; // Valid information
|
bool valid3 = bvalue3->valid; // Valid information
|
||||||
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -76,7 +72,6 @@ class PageFourValues : public Page
|
|||||||
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Fourth element in list
|
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Fourth element in list
|
||||||
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
||||||
name4 = name4.substring(0, 6); // String length limit for value name
|
name4 = name4.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value4 = bvalue4->value; // Value as double in SI unit
|
double value4 = bvalue4->value; // Value as double in SI unit
|
||||||
bool valid4 = bvalue4->valid; // Valid information
|
bool valid4 = bvalue4->valid; // Valid information
|
||||||
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
class PageFourValues2 : public Page
|
class PageFourValues2 : public Page
|
||||||
{
|
{
|
||||||
@@ -46,7 +45,6 @@ class PageFourValues2 : public Page
|
|||||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bvalue1->value; // Value as double in SI unit
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -56,7 +54,6 @@ class PageFourValues2 : public Page
|
|||||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list (only one value by PageOneValue)
|
||||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value2 = bvalue2->value; // Value as double in SI unit
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
bool valid2 = bvalue2->valid; // Valid information
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -66,7 +63,6 @@ class PageFourValues2 : public Page
|
|||||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Second element in list (only one value by PageOneValue)
|
||||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value3 = bvalue3->value; // Value as double in SI unit
|
double value3 = bvalue3->value; // Value as double in SI unit
|
||||||
bool valid3 = bvalue3->valid; // Valid information
|
bool valid3 = bvalue3->valid; // Valid information
|
||||||
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -76,7 +72,6 @@ class PageFourValues2 : public Page
|
|||||||
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Second element in list (only one value by PageOneValue)
|
||||||
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
||||||
name4 = name4.substring(0, 6); // String length limit for value name
|
name4 = name4.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value4 = bvalue4->value; // Value as double in SI unit
|
double value4 = bvalue4->value; // Value as double in SI unit
|
||||||
bool valid4 = bvalue4->valid; // Valid information
|
bool valid4 = bvalue4->valid; // Valid information
|
||||||
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
#include "OBPDataOperations.h"
|
#include "OBPDataOperations.h"
|
||||||
#include "OBPcharts.h"
|
#include "OBPcharts.h"
|
||||||
|
|
||||||
@@ -88,7 +87,6 @@ private:
|
|||||||
|
|
||||||
String name1 = xdrDelete(bValue1->getName()); // Value name
|
String name1 = xdrDelete(bValue1->getName()); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bValue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bValue1->value; // Value as double in SI unit
|
double value1 = bValue1->value; // Value as double in SI unit
|
||||||
bool valid1 = bValue1->valid; // Valid information
|
bool valid1 = bValue1->valid; // Valid information
|
||||||
String sValue1 = formatValue(bValue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String sValue1 = formatValue(bValue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
class PageRudderPosition : public Page
|
class PageRudderPosition : public Page
|
||||||
{
|
{
|
||||||
@@ -41,7 +40,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list
|
||||||
String name1 = bvalue1->getName().c_str(); // Value name
|
String name1 = bvalue1->getName().c_str(); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
value1 = bvalue1->value; // Raw value without unit convertion
|
value1 = bvalue1->value; // Raw value without unit convertion
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
const int SixValues_x1 = 5;
|
const int SixValues_x1 = 5;
|
||||||
const int SixValues_DeltaX = 200;
|
const int SixValues_DeltaX = 200;
|
||||||
@@ -57,7 +56,6 @@ class PageSixValues : public Page
|
|||||||
bvalue = pageData.values[i];
|
bvalue = pageData.values[i];
|
||||||
DataName[i] = xdrDelete(bvalue->getName());
|
DataName[i] = xdrDelete(bvalue->getName());
|
||||||
DataName[i] = DataName[i].substring(0, 6); // String length limit for value name
|
DataName[i] = DataName[i].substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue, logger); // Check if boat data value is to be calibrated
|
|
||||||
DataValue[i] = bvalue->value; // Value as double in SI unit
|
DataValue[i] = bvalue->value; // Value as double in SI unit
|
||||||
DataValid[i] = bvalue->valid;
|
DataValid[i] = bvalue->valid;
|
||||||
DataText[i] = formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
DataText[i] = formatValue(bvalue, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
class PageThreeValues : public Page
|
class PageThreeValues : public Page
|
||||||
{
|
{
|
||||||
@@ -44,7 +43,6 @@ class PageThreeValues : public Page
|
|||||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bvalue1->value; // Value as double in SI unit
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -54,7 +52,6 @@ class PageThreeValues : public Page
|
|||||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
||||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value2 = bvalue2->value; // Value as double in SI unit
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
bool valid2 = bvalue2->valid; // Valid information
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -64,7 +61,6 @@ class PageThreeValues : public Page
|
|||||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
||||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value3 = bvalue3->value; // Value as double in SI unit
|
double value3 = bvalue3->value; // Value as double in SI unit
|
||||||
bool valid3 = bvalue3->valid; // Valid information
|
bool valid3 = bvalue3->valid; // Valid information
|
||||||
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
#include "OBPDataOperations.h"
|
#include "OBPDataOperations.h"
|
||||||
#include "OBPcharts.h"
|
#include "OBPcharts.h"
|
||||||
|
|
||||||
@@ -69,7 +68,6 @@ private:
|
|||||||
int yOffset = YOFFSET * i;
|
int yOffset = YOFFSET * i;
|
||||||
String name = xdrDelete(bValue[i]->getName()); // Value name
|
String name = xdrDelete(bValue[i]->getName()); // Value name
|
||||||
name = name.substring(0, 6); // String length limit for value name
|
name = name.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bValue[i], logger); // Check if boat data value is to be calibrated
|
|
||||||
double value = bValue[i]->value; // Value as double in SI unit
|
double value = bValue[i]->value; // Value as double in SI unit
|
||||||
bool valid = bValue[i]->valid; // Valid information
|
bool valid = bValue[i]->valid; // Valid information
|
||||||
String sValue = formatValue(bValue[i], *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String sValue = formatValue(bValue[i], *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "N2kMessages.h"
|
#include "N2kMessages.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
#define front_width 120
|
#define front_width 120
|
||||||
#define front_height 162
|
#define front_height 162
|
||||||
@@ -324,7 +323,6 @@ public:
|
|||||||
}
|
}
|
||||||
String name1 = bvalue1->getName().c_str(); // Value name
|
String name1 = bvalue1->getName().c_str(); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bvalue1->value; // Value as double in SI unit
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
// bool valid1 = bvalue1->valid; // Valid information
|
// bool valid1 = bvalue1->valid; // Valid information
|
||||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -338,7 +336,6 @@ public:
|
|||||||
}
|
}
|
||||||
String name2 = bvalue2->getName().c_str(); // Value name
|
String name2 = bvalue2->getName().c_str(); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value2 = bvalue2->value; // Value as double in SI unit
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
// bool valid2 = bvalue2->valid; // Valid information
|
// bool valid2 = bvalue2->valid; // Valid information
|
||||||
if (simulation) {
|
if (simulation) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
class PageWindRose : public Page
|
class PageWindRose : public Page
|
||||||
{
|
{
|
||||||
@@ -52,7 +51,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
GwApi::BoatValue *bvalue1 = pageData.values[0]; // First element in list (only one value by PageOneValue)
|
||||||
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
String name1 = xdrDelete(bvalue1->getName()); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bvalue1->value; // Value as double in SI unit
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
value1 = formatValue(bvalue1, *commonData).value;// Format only nesaccery for simulation data for pointer
|
value1 = formatValue(bvalue1, *commonData).value;// Format only nesaccery for simulation data for pointer
|
||||||
@@ -67,7 +65,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
GwApi::BoatValue *bvalue2 = pageData.values[1]; // Second element in list
|
||||||
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
String name2 = xdrDelete(bvalue2->getName()); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value2 = bvalue2->value; // Value as double in SI unit
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
bool valid2 = bvalue2->valid; // Valid information
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue2 = formatValue(bvalue2, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -81,7 +78,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
GwApi::BoatValue *bvalue3 = pageData.values[2]; // Third element in list
|
||||||
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
String name3 = xdrDelete(bvalue3->getName()); // Value name
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value3 = bvalue3->value; // Value as double in SI unit
|
double value3 = bvalue3->value; // Value as double in SI unit
|
||||||
bool valid3 = bvalue3->valid; // Valid information
|
bool valid3 = bvalue3->valid; // Valid information
|
||||||
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -95,7 +91,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Fourth element in list
|
GwApi::BoatValue *bvalue4 = pageData.values[3]; // Fourth element in list
|
||||||
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
String name4 = xdrDelete(bvalue4->getName()); // Value name
|
||||||
name4 = name4.substring(0, 6); // String length limit for value name
|
name4 = name4.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value4 = bvalue4->value; // Value as double in SI unit
|
double value4 = bvalue4->value; // Value as double in SI unit
|
||||||
bool valid4 = bvalue4->valid; // Valid information
|
bool valid4 = bvalue4->valid; // Valid information
|
||||||
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -109,7 +104,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue5 = pageData.values[4]; // Fifth element in list
|
GwApi::BoatValue *bvalue5 = pageData.values[4]; // Fifth element in list
|
||||||
String name5 = xdrDelete(bvalue5->getName()); // Value name
|
String name5 = xdrDelete(bvalue5->getName()); // Value name
|
||||||
name5 = name5.substring(0, 6); // String length limit for value name
|
name5 = name5.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue5, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value5 = bvalue5->value; // Value as double in SI unit
|
double value5 = bvalue5->value; // Value as double in SI unit
|
||||||
bool valid5 = bvalue5->valid; // Valid information
|
bool valid5 = bvalue5->valid; // Valid information
|
||||||
String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -123,7 +117,6 @@ public:
|
|||||||
GwApi::BoatValue *bvalue6 = pageData.values[5]; // Sixth element in list
|
GwApi::BoatValue *bvalue6 = pageData.values[5]; // Sixth element in list
|
||||||
String name6 = xdrDelete(bvalue6->getName()); // Value name
|
String name6 = xdrDelete(bvalue6->getName()); // Value name
|
||||||
name6 = name6.substring(0, 6); // String length limit for value name
|
name6 = name6.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue6, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value6 = bvalue6->value; // Value as double in SI unit
|
double value6 = bvalue6->value; // Value as double in SI unit
|
||||||
bool valid6 = bvalue6->valid; // Valid information
|
bool valid6 = bvalue6->valid; // Valid information
|
||||||
String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
#include "BoatDataCalibration.h"
|
|
||||||
|
|
||||||
class PageWindRoseFlex : public Page
|
class PageWindRoseFlex : public Page
|
||||||
{
|
{
|
||||||
@@ -79,7 +78,6 @@ public:
|
|||||||
}
|
}
|
||||||
String name1 = bvalue1->getName().c_str(); // Value name
|
String name1 = bvalue1->getName().c_str(); // Value name
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue1, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value1 = bvalue1->value; // Value as double in SI unit
|
double value1 = bvalue1->value; // Value as double in SI unit
|
||||||
bool valid1 = bvalue1->valid; // Valid information
|
bool valid1 = bvalue1->valid; // Valid information
|
||||||
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue1 = formatValue(bvalue1, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -97,7 +95,6 @@ public:
|
|||||||
}
|
}
|
||||||
String name2 = bvalue2->getName().c_str(); // Value name
|
String name2 = bvalue2->getName().c_str(); // Value name
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
calibrationData.calibrateInstance(bvalue2, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value2 = bvalue2->value; // Value as double in SI unit
|
double value2 = bvalue2->value; // Value as double in SI unit
|
||||||
bool valid2 = bvalue2->valid; // Valid information
|
bool valid2 = bvalue2->valid; // Valid information
|
||||||
if (simulation) {
|
if (simulation) {
|
||||||
@@ -122,7 +119,6 @@ public:
|
|||||||
else{
|
else{
|
||||||
name3font=Ubuntu_Bold12pt8b;
|
name3font=Ubuntu_Bold12pt8b;
|
||||||
}
|
}
|
||||||
calibrationData.calibrateInstance(bvalue3, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value3 = bvalue3->value; // Value as double in SI unit
|
double value3 = bvalue3->value; // Value as double in SI unit
|
||||||
bool valid3 = bvalue3->valid; // Valid information
|
bool valid3 = bvalue3->valid; // Valid information
|
||||||
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue3 = formatValue(bvalue3, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -142,7 +138,6 @@ public:
|
|||||||
else{
|
else{
|
||||||
name4font=Ubuntu_Bold12pt8b;
|
name4font=Ubuntu_Bold12pt8b;
|
||||||
}
|
}
|
||||||
calibrationData.calibrateInstance(bvalue4, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value4 = bvalue4->value; // Value as double in SI unit
|
double value4 = bvalue4->value; // Value as double in SI unit
|
||||||
bool valid4 = bvalue4->valid; // Valid information
|
bool valid4 = bvalue4->valid; // Valid information
|
||||||
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue4 = formatValue(bvalue4, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -162,7 +157,6 @@ public:
|
|||||||
else{
|
else{
|
||||||
name5font=Ubuntu_Bold12pt8b;
|
name5font=Ubuntu_Bold12pt8b;
|
||||||
}
|
}
|
||||||
calibrationData.calibrateInstance(bvalue5, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value5 = bvalue5->value; // Value as double in SI unit
|
double value5 = bvalue5->value; // Value as double in SI unit
|
||||||
bool valid5 = bvalue5->valid; // Valid information
|
bool valid5 = bvalue5->valid; // Valid information
|
||||||
String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue5 = formatValue(bvalue5, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
@@ -182,7 +176,6 @@ public:
|
|||||||
else{
|
else{
|
||||||
name6font=Ubuntu_Bold8pt8b;
|
name6font=Ubuntu_Bold8pt8b;
|
||||||
}
|
}
|
||||||
calibrationData.calibrateInstance(bvalue6, logger); // Check if boat data value is to be calibrated
|
|
||||||
double value6 = bvalue6->value; // Value as double in SI unit
|
double value6 = bvalue6->value; // Value as double in SI unit
|
||||||
bool valid6 = bvalue6->valid; // Valid information
|
bool valid6 = bvalue6->valid; // Valid information
|
||||||
String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
String svalue6 = formatValue(bvalue6, *commonData).svalue; // Formatted value as string including unit conversion and switching decimal places
|
||||||
|
|||||||
@@ -708,8 +708,10 @@
|
|||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
"COG",
|
"COG",
|
||||||
|
"DBS",
|
||||||
"DBT",
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
|
"HDT",
|
||||||
"PRPOS",
|
"PRPOS",
|
||||||
"RPOS",
|
"RPOS",
|
||||||
"SOG",
|
"SOG",
|
||||||
@@ -735,7 +737,7 @@
|
|||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance1": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance1": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -743,13 +745,13 @@
|
|||||||
"label": "Data Instance 1 Calibration Slope",
|
"label": "Data Instance 1 Calibration Slope",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "1.00",
|
"default": "1.00",
|
||||||
"description": "Slope for data instance 1",
|
"description": "Slope for data instance 1; Default: 1(!)",
|
||||||
"category": "OBP60 Calibrations",
|
"category": "OBP60 Calibrations",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance1": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance1": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -766,7 +768,7 @@
|
|||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance1": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance1": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -780,8 +782,10 @@
|
|||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
"COG",
|
"COG",
|
||||||
|
"DBS",
|
||||||
"DBT",
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
|
"HDT",
|
||||||
"PRPOS",
|
"PRPOS",
|
||||||
"RPOS",
|
"RPOS",
|
||||||
"SOG",
|
"SOG",
|
||||||
@@ -807,7 +811,7 @@
|
|||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance2": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance2": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -815,13 +819,13 @@
|
|||||||
"label": "Data Instance 2 Calibration Slope",
|
"label": "Data Instance 2 Calibration Slope",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "1.00",
|
"default": "1.00",
|
||||||
"description": "Slope for data instance 2",
|
"description": "Slope for data instance 2; Default: 1(!)",
|
||||||
"category": "OBP60 Calibrations",
|
"category": "OBP60 Calibrations",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance2": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance2": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -838,7 +842,7 @@
|
|||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance2": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance2": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -852,8 +856,10 @@
|
|||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
"COG",
|
"COG",
|
||||||
|
"DBS",
|
||||||
"DBT",
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
|
"HDT",
|
||||||
"PRPOS",
|
"PRPOS",
|
||||||
"RPOS",
|
"RPOS",
|
||||||
"SOG",
|
"SOG",
|
||||||
@@ -879,7 +885,7 @@
|
|||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance3": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -887,13 +893,13 @@
|
|||||||
"label": "Data Instance 3 Calibration Slope",
|
"label": "Data Instance 3 Calibration Slope",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "1.00",
|
"default": "1.00",
|
||||||
"description": "Slope for data instance 3",
|
"description": "Slope for data instance 3; Default: 1(!)",
|
||||||
"category": "OBP60 Calibrations",
|
"category": "OBP60 Calibrations",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance3": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -910,7 +916,7 @@
|
|||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance3": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -719,8 +719,10 @@
|
|||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
"COG",
|
"COG",
|
||||||
|
"DBS",
|
||||||
"DBT",
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
|
"HDT",
|
||||||
"PRPOS",
|
"PRPOS",
|
||||||
"RPOS",
|
"RPOS",
|
||||||
"SOG",
|
"SOG",
|
||||||
@@ -746,7 +748,7 @@
|
|||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance1": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance1": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -754,13 +756,13 @@
|
|||||||
"label": "Data Instance 1 Calibration Slope",
|
"label": "Data Instance 1 Calibration Slope",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "1.00",
|
"default": "1.00",
|
||||||
"description": "Slope for data instance 1",
|
"description": "Slope for data instance 1, Default: 1(!)",
|
||||||
"category": "OBP40 Calibrations",
|
"category": "OBP40 Calibrations",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance1": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance1": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -777,7 +779,7 @@
|
|||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance1": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance1": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -791,8 +793,10 @@
|
|||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
"COG",
|
"COG",
|
||||||
|
"DBS",
|
||||||
"DBT",
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
|
"HDT",
|
||||||
"PRPOS",
|
"PRPOS",
|
||||||
"RPOS",
|
"RPOS",
|
||||||
"SOG",
|
"SOG",
|
||||||
@@ -818,7 +822,7 @@
|
|||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance2": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance2": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -826,13 +830,13 @@
|
|||||||
"label": "Data Instance 2 Calibration Slope",
|
"label": "Data Instance 2 Calibration Slope",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "1.00",
|
"default": "1.00",
|
||||||
"description": "Slope for data instance 2",
|
"description": "Slope for data instance 2; Default: 1(!)",
|
||||||
"category": "OBP40 Calibrations",
|
"category": "OBP40 Calibrations",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance2": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance2": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -849,7 +853,7 @@
|
|||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance2": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance2": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -863,8 +867,10 @@
|
|||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
"COG",
|
"COG",
|
||||||
|
"DBS",
|
||||||
"DBT",
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
|
"HDT",
|
||||||
"PRPOS",
|
"PRPOS",
|
||||||
"RPOS",
|
"RPOS",
|
||||||
"SOG",
|
"SOG",
|
||||||
@@ -890,7 +896,7 @@
|
|||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance3": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -898,13 +904,13 @@
|
|||||||
"label": "Data Instance 3 Calibration Slope",
|
"label": "Data Instance 3 Calibration Slope",
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": "1.00",
|
"default": "1.00",
|
||||||
"description": "Slope for data instance 3",
|
"description": "Slope for data instance 3, Default: 1(!)",
|
||||||
"category": "OBP40 Calibrations",
|
"category": "OBP40 Calibrations",
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance3": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -921,7 +927,7 @@
|
|||||||
"obp40":"true"
|
"obp40":"true"
|
||||||
},
|
},
|
||||||
"condition": [
|
"condition": [
|
||||||
{ "calInstance3": ["AWA", "AWS", "COG", "DBT", "HDM", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
{ "calInstance3": ["AWA", "AWS", "COG", "DBS", "DBT", "HDM", "HDT", "PRPOS", "RPOS", "SOG", "STW", "TWA", "TWS", "TWD", "WTemp" ] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include <GxEPD2_BW.h> // GxEPD2 lib for b/w E-Ink displays
|
#include <GxEPD2_BW.h> // GxEPD2 lib for b/w E-Ink displays
|
||||||
#include "OBP60Extensions.h" // Functions lib for extension board
|
#include "OBP60Extensions.h" // Functions lib for extension board
|
||||||
#include "OBP60Keypad.h" // Functions for keypad
|
#include "OBP60Keypad.h" // Functions for keypad
|
||||||
#include "BoatDataCalibration.h" // Functions lib for data instance calibration
|
|
||||||
#include "OBPDataOperations.h" // Functions lib for data operations such as true wind calculation
|
#include "OBPDataOperations.h" // Functions lib for data operations such as true wind calculation
|
||||||
|
|
||||||
#ifdef BOARD_OBP40S3
|
#ifdef BOARD_OBP40S3
|
||||||
@@ -147,7 +146,6 @@ void keyboardTask(void *param){
|
|||||||
vTaskDelete(NULL);
|
vTaskDelete(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scorgan: moved class declaration to header file <obp60task.h> to make class available to other functions
|
|
||||||
// --- Class BoatValueList --------------
|
// --- Class BoatValueList --------------
|
||||||
bool BoatValueList::addValueToList(GwApi::BoatValue *v){
|
bool BoatValueList::addValueToList(GwApi::BoatValue *v){
|
||||||
for (int i=0;i<numValues;i++){
|
for (int i=0;i<numValues;i++){
|
||||||
@@ -172,7 +170,7 @@ GwApi::BoatValue *BoatValueList::findValueOrCreate(String name){
|
|||||||
addValueToList(rt);
|
addValueToList(rt);
|
||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
// --- Class BoatValueList --------------
|
// --- End Class BoatValueList --------------
|
||||||
|
|
||||||
//we want to have a list that has all our page definitions
|
//we want to have a list that has all our page definitions
|
||||||
//this way each page can easily be added here
|
//this way each page can easily be added here
|
||||||
@@ -435,10 +433,9 @@ void OBP60Task(GwApi *api){
|
|||||||
int lastPage=-1; // initialize with an impiossible value, so we can detect wether we are during startup and no page has been displayed yet
|
int lastPage=-1; // initialize with an impiossible value, so we can detect wether we are during startup and no page has been displayed yet
|
||||||
|
|
||||||
BoatValueList boatValues; //all the boat values for the api query
|
BoatValueList boatValues; //all the boat values for the api query
|
||||||
HstryBuffers hstryBufList(1920, &boatValues, logger); // Create empty list of boat data history buffers
|
HstryBuffers hstryBufferList(1920, &boatValues, logger); // Create empty list of boat data history buffers (1.920 values = seconds = 32 min.)
|
||||||
WindUtils trueWind(&boatValues, logger); // Create helper object for true wind calculation
|
WindUtils trueWind(&boatValues, logger); // Create helper object for true wind calculation
|
||||||
//commonData.distanceformat=config->getString(xxx);
|
CalibrationData calibrationDataList(logger); // all boat data types which are supposed to be calibrated
|
||||||
//add all necessary data to common data
|
|
||||||
|
|
||||||
//fill the page data from config
|
//fill the page data from config
|
||||||
numPages=config->getInt(config->visiblePages,1);
|
numPages=config->getInt(config->visiblePages,1);
|
||||||
@@ -480,26 +477,25 @@ void OBP60Task(GwApi *api){
|
|||||||
pages[i].parameters.values.push_back(value);
|
pages[i].parameters.values.push_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the specified boat data type 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
|
||||||
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) {
|
||||||
hstryBufList.addBuffer(pVal->getName());
|
hstryBufferList.addBuffer(pVal->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add list of history buffers to page parameters
|
// Add list of history buffers to page parameters
|
||||||
pages[i].parameters.hstryBuffers = &hstryBufList;
|
pages[i].parameters.hstryBuffers = &hstryBufferList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add out of band system page (always available)
|
// add out of band system page (always available)
|
||||||
Page *syspage = allPages.pages[0]->creator(commonData);
|
Page *syspage = allPages.pages[0]->creator(commonData);
|
||||||
|
|
||||||
// Check user settings for true wind calculation
|
// Read user settings from config file
|
||||||
bool calcTrueWnds = api->getConfig()->getBool(api->getConfig()->calcTrueWnds, false);
|
bool calcTrueWnds = api->getConfig()->getBool(api->getConfig()->calcTrueWnds, false);
|
||||||
bool useSimuData = api->getConfig()->getBool(api->getConfig()->useSimuData, false);
|
bool useSimuData = api->getConfig()->getBool(api->getConfig()->useSimuData, false);
|
||||||
|
// Read user calibration data settings from config file
|
||||||
// Read all calibration data settings from config
|
calibrationDataList.readConfig(config);
|
||||||
calibrationData.readConfig(config, logger);
|
|
||||||
|
|
||||||
// Display screenshot handler for HTTP request
|
// Display screenshot handler for HTTP request
|
||||||
// http://192.168.15.1/api/user/OBP60Task/screenshot
|
// http://192.168.15.1/api/user/OBP60Task/screenshot
|
||||||
@@ -814,10 +810,10 @@ void OBP60Task(GwApi *api){
|
|||||||
api->getStatus(commonData.status);
|
api->getStatus(commonData.status);
|
||||||
|
|
||||||
if (calcTrueWnds) {
|
if (calcTrueWnds) {
|
||||||
trueWind.addWinds();
|
trueWind.addWinds(); // calculate true wind data from apparent wind values
|
||||||
}
|
}
|
||||||
// Handle history buffers for certain boat data for windplot page and other usage
|
calibrationDataList.handleCalibration(&boatValues); // Process calibration for all boat data in <calibrationDataList>
|
||||||
hstryBufList.handleHstryBufs(useSimuData, commonData);
|
hstryBufferList.handleHstryBufs(useSimuData, commonData); // Handle history buffers for certain boat data for windplot page and other usage
|
||||||
|
|
||||||
// Clear display
|
// Clear display
|
||||||
// getdisplay().fillRect(0, 0, getdisplay().width(), getdisplay().height(), commonData.bgcolor);
|
// getdisplay().fillRect(0, 0, getdisplay().width(), getdisplay().height(), commonData.bgcolor);
|
||||||
|
|||||||
Reference in New Issue
Block a user