Implemented for few std. types - DBT missing
This commit is contained in:
parent
a5494ccee4
commit
2fb59fb118
|
@ -1,80 +1,79 @@
|
||||||
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
#if defined BOARD_OBP60S3 || defined BOARD_OBP40S3
|
||||||
|
|
||||||
#include "BoatDataCalibration.h"
|
#include "BoatDataCalibration.h"
|
||||||
|
#include <cmath>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
CalibrationDataList calibrationData;
|
CalibrationDataList calibrationData;
|
||||||
|
|
||||||
void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger)
|
void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger)
|
||||||
// Initial load of calibration data into internal list
|
// Initial load of calibration data into internal list
|
||||||
// This function is called once at init phase of <OBP60task> to read the configuration values
|
// This method is called once at init phase of <OBP60task> to read the configuration values
|
||||||
{
|
{
|
||||||
// Load user configuration values
|
// Load user format configuration values
|
||||||
String lengthFormat = config->getString(config->lengthFormat); // [m|ft]
|
String lengthFormat = config->getString(config->lengthFormat); // [m|ft]
|
||||||
String distanceFormat = config->getString(config->distanceFormat); // [m|km|nm]
|
String distanceFormat = config->getString(config->distanceFormat); // [m|km|nm]
|
||||||
String speedFormat = config->getString(config->speedFormat); // [m/s|km/h|kn]
|
String speedFormat = config->getString(config->speedFormat); // [m/s|km/h|kn]
|
||||||
String windspeedFormat = config->getString(config->windspeedFormat); // [m/s|km/h|kn|bft]
|
String windspeedFormat = config->getString(config->windspeedFormat); // [m/s|km/h|kn|bft]
|
||||||
String tempFormat = config->getString(config->tempFormat); // [K|°C|°F]
|
String tempFormat = config->getString(config->tempFormat); // [K|C|F]
|
||||||
|
|
||||||
// Read calibration settings for DBT
|
// Read calibration settings for data instances
|
||||||
calibrationData.list[0].instance = "DBT";
|
for (int i = 0; i < maxCalibrationData; i++) {
|
||||||
calibrationData.list[0].offset = (config->getString(config->calOffsetDBT)).toFloat();
|
String instance = "calInstance" + String(i+1);
|
||||||
if (lengthFormat == "ft") { // Convert DBT to SI standard meters
|
String offset = "calOffset" + String(i+1);
|
||||||
calibrationData.list[0].offset *= 0.3048;
|
String slope = "calSlope" + String(i+1);
|
||||||
}
|
calibrationData.list[i] = { "", 0.0f, 1.0f, 0.0f, false };
|
||||||
calibrationData.list[0].slope = 1.0; // No slope for DBT
|
|
||||||
calibrationData.list[0].isCalibrated = false;
|
|
||||||
|
|
||||||
// Read calibration settings for other data instances
|
|
||||||
for (int i = 1; i < maxCalibrationData; i++) {
|
|
||||||
String instance = "calInstance" + String(i);
|
|
||||||
String offset = "calOffset" + String(i);
|
|
||||||
String slope = "calSlope" + String(i);
|
|
||||||
|
|
||||||
// calibrationData = new CalibrationDataList;
|
|
||||||
calibrationData.list[i].instance = config->getString(instance, "");
|
calibrationData.list[i].instance = config->getString(instance, "");
|
||||||
|
if (calibrationData.list[i].instance == "") {
|
||||||
|
LOG_DEBUG(GwLog::LOG, "no calibration data for instance no. %d", i+1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
calibrationData.list[i].offset = (config->getString(offset, "")).toFloat();
|
calibrationData.list[i].offset = (config->getString(offset, "")).toFloat();
|
||||||
calibrationData.list[i].slope = (config->getString(slope, "")).toFloat();
|
calibrationData.list[i].slope = (config->getString(slope, "")).toFloat();
|
||||||
if (calibrationData.list[i].instance == "AWA" || calibrationData.list[i].instance == "AWS") {
|
|
||||||
if (windspeedFormat == "m/s") { // Convert calibration values to SI standard m/s
|
// Convert calibration values to internal standard formats
|
||||||
|
if (calibrationData.list[i].instance == "AWS") {
|
||||||
|
if (windspeedFormat == "m/s") {
|
||||||
// No conversion needed
|
// No conversion needed
|
||||||
} else if (windspeedFormat == "km/h") {
|
} else if (windspeedFormat == "km/h") {
|
||||||
calibrationData.list[i].offset /= 3.6; // Convert km/h to m/s
|
calibrationData.list[i].offset /= 3.6; // Convert km/h to m/s
|
||||||
calibrationData.list[i].slope /= 3.6; // Convert km/h to m/s
|
|
||||||
} else if (windspeedFormat == "kn") {
|
} else if (windspeedFormat == "kn") {
|
||||||
calibrationData.list[i].offset /= 1.94384; // Convert kn to m/s
|
calibrationData.list[i].offset /= 1.94384; // Convert kn to m/s
|
||||||
calibrationData.list[i].slope /= 1.94384; // Convert kn to m/s
|
|
||||||
} else if (windspeedFormat == "bft") {
|
} else if (windspeedFormat == "bft") {
|
||||||
calibrationData.list[i].offset *= 0.5; // Convert Bft to m/s (approx) -> to be improved
|
calibrationData.list[i].offset *= 0.5; // Convert Bft to m/s (approx) -> to be improved
|
||||||
calibrationData.list[i].slope *= 0.5; // Convert km/h to m/s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (calibrationData.list[i].instance == "AWA" || calibrationData.list[i].instance == "HDM") {
|
||||||
|
calibrationData.list[i].offset *= M_PI / 180; // Convert deg to rad
|
||||||
|
|
||||||
} else if (calibrationData.list[i].instance == "STW") {
|
} else if (calibrationData.list[i].instance == "STW") {
|
||||||
if (speedFormat == "m/s") {
|
if (speedFormat == "m/s") {
|
||||||
// No conversion needed
|
// No conversion needed
|
||||||
} else if (speedFormat == "km/h") {
|
} else if (speedFormat == "km/h") {
|
||||||
calibrationData.list[i].offset /= 3.6; // Convert km/h to m/s
|
calibrationData.list[i].offset /= 3.6; // Convert km/h to m/s
|
||||||
calibrationData.list[i].slope /= 3.6; // Convert km/h to m/s
|
|
||||||
} else if (speedFormat == "kn") {
|
} else if (speedFormat == "kn") {
|
||||||
calibrationData.list[i].offset /= 1.94384; // Convert kn to m/s
|
calibrationData.list[i].offset /= 1.94384; // Convert kn to m/s
|
||||||
calibrationData.list[i].slope /= 1.94384; // Convert kn to m/s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (calibrationData.list[i].instance == "WTemp") {
|
} else if (calibrationData.list[i].instance == "WTemp") {
|
||||||
if (tempFormat == "K" || tempFormat == "C") {
|
if (tempFormat == "K" || tempFormat == "C") {
|
||||||
// No conversion needed
|
// No conversion needed
|
||||||
} else if (tempFormat == "F") {
|
} else if (tempFormat == "F") {
|
||||||
calibrationData.list[i].offset *= 5.0 / 9.0; // Convert °F to K
|
calibrationData.list[i].offset *= 9.0 / 5.0; // Convert °F to K
|
||||||
calibrationData.list[i].slope *= 5.0 / 9.0; // Convert °F to K
|
calibrationData.list[i].slope *= 9.0 / 5.0; // Convert °F to K
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
calibrationData.list[i].isCalibrated = false;
|
calibrationData.list[i].isCalibrated = false;
|
||||||
|
|
||||||
LOG_DEBUG(GwLog::LOG, "stored calibration data: %s, offset: %f, slope: %f", calibrationData.list[i].instance.c_str(), calibrationData.list[i].offset, calibrationData.list[i].slope);
|
LOG_DEBUG(GwLog::LOG, "stored calibration data: %s, offset: %f, slope: %f", calibrationData.list[i].instance.c_str(), calibrationData.list[i].offset, calibrationData.list[i].slope);
|
||||||
}
|
}
|
||||||
|
LOG_DEBUG(GwLog::LOG, "all calibration data read");
|
||||||
}
|
}
|
||||||
|
|
||||||
int CalibrationDataList::getInstanceListNo(String instance)
|
int CalibrationDataList::getInstanceListNo(String instance)
|
||||||
// Function to get the index of the requested instance in the list
|
// Method to get the index of the requested instance in the list
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check if instance is in the list
|
// Check if instance is in the list
|
||||||
for (int i = 0; i < maxCalibrationData; i++) {
|
for (int i = 0; i < maxCalibrationData; i++) {
|
||||||
if (calibrationData.list[i].instance == instance) {
|
if (calibrationData.list[i].instance == instance) {
|
||||||
|
@ -96,27 +95,51 @@ int CalibrationDataList::getInstanceListNo(String instance)
|
||||||
} */
|
} */
|
||||||
|
|
||||||
void CalibrationDataList::calibrateInstance(String instance, GwApi::BoatValue* boatDataValue, GwLog* logger)
|
void CalibrationDataList::calibrateInstance(String instance, GwApi::BoatValue* boatDataValue, GwLog* logger)
|
||||||
// Function to calibrate the boat data value
|
// Method to calibrate the boat data value
|
||||||
{
|
{
|
||||||
double offset = 0;
|
double offset = 0;
|
||||||
double slope = 1.0;
|
double slope = 1.0;
|
||||||
|
double dataValue = 0;
|
||||||
|
|
||||||
int listNo = getInstanceListNo(instance);
|
int listNo = getInstanceListNo(instance);
|
||||||
if (listNo >= 0) {
|
if (listNo < 0) {
|
||||||
|
LOG_DEBUG(GwLog::LOG, "BoatDataCalibration: %s not found in calibration data list", instance.c_str());
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
offset = calibrationData.list[listNo].offset;
|
offset = calibrationData.list[listNo].offset;
|
||||||
slope = calibrationData.list[listNo].slope;
|
slope = calibrationData.list[listNo].slope;
|
||||||
|
|
||||||
if (!boatDataValue->valid) { // no valid boat data value, so we don't want to apply calibration data
|
if (!boatDataValue->valid) { // no valid boat data value, so we don't want to apply calibration data
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
boatDataValue->value = (boatDataValue->value * slope) + offset;
|
dataValue = boatDataValue->value;
|
||||||
calibrationData.list[listNo].value = boatDataValue->value;
|
LOG_DEBUG(GwLog::LOG, "BoatDataCalibration: name: %s: value: %f format: %s", boatDataValue->getName().c_str(), boatDataValue->value, boatDataValue->getFormat().c_str());
|
||||||
calibrationData.list[listNo].isCalibrated = true;
|
|
||||||
LOG_DEBUG(GwLog::LOG, "BoatDataCalibration: %s: Offset: %f Slope: %f Result: %f", instance.c_str(), offset, slope, boatDataValue->value);
|
|
||||||
|
|
||||||
|
if (boatDataValue->getFormat() == "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 (boatDataValue->getFormat() == "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 (boatDataValue->getFormat() == "kelvinToC") { // instance is of type temperature
|
||||||
|
dataValue = ((dataValue - 273.15) * slope) + offset + 273.15;
|
||||||
|
} else {
|
||||||
|
dataValue = (dataValue * slope) + offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
calibrationData.list[listNo].value = dataValue;
|
||||||
|
calibrationData.list[listNo].isCalibrated = true;
|
||||||
|
boatDataValue->value = dataValue;
|
||||||
|
LOG_DEBUG(GwLog::LOG, "BoatDataCalibration: %s: Offset: %f Slope: %f Result: %f", instance.c_str(), offset, slope, boatDataValue->value);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
LOG_DEBUG(GwLog::LOG, "BoatDataCalibration: %s not found in calibration data list", instance.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ public:
|
||||||
static void calibrateInstance(String instance, GwApi::BoatValue* boatDataValue, GwLog* logger);
|
static void calibrateInstance(String instance, GwApi::BoatValue* boatDataValue, GwLog* logger);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// GwLog* logger;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CalibrationDataList calibrationData; // this list holds all calibration data
|
extern CalibrationDataList calibrationData; // this list holds all calibration data
|
||||||
|
|
|
@ -48,7 +48,7 @@ class PageFourValues : public Page
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class PageFourValues : public Page
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class PageFourValues : public Page
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name3, bvalue3, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name3, bvalue3, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value
|
String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class PageFourValues : public Page
|
||||||
name4 = name4.substring(0, 6); // String length limit for value name
|
name4 = name4.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name4, bvalue4, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name4, bvalue4, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value
|
String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ class PageFourValues2 : public Page
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class PageFourValues2 : public Page
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class PageFourValues2 : public Page
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name3, bvalue3, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name3, bvalue3, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value
|
String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class PageFourValues2 : public Page
|
||||||
name4 = name4.substring(0, 6); // String length limit for value name
|
name4 = name4.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name4, bvalue4, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name4, bvalue4, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value
|
String unit4 = formatValue(bvalue4, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
|
|
@ -40,9 +40,9 @@ class PageOneValue : 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
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class PageOneValue : public Page
|
||||||
|
|
||||||
// Logging boat values
|
// Logging boat values
|
||||||
if (bvalue1 == NULL) return;
|
if (bvalue1 == NULL) return;
|
||||||
LOG_DEBUG(GwLog::LOG,"Drawing at PageOneValue, %s: %f", name1.c_str(), value1);
|
LOG_DEBUG(GwLog::LOG,"Drawing at PageOneValue, %s: %f", name1.c_str(), bvalue1);
|
||||||
|
|
||||||
// Draw page
|
// Draw page
|
||||||
//***********************************************************
|
//***********************************************************
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "Pagedata.h"
|
#include "Pagedata.h"
|
||||||
#include "OBP60Extensions.h"
|
#include "OBP60Extensions.h"
|
||||||
|
#include "BoatDataCalibration.h"
|
||||||
|
|
||||||
#include "DSEG7Classic-BoldItalic26pt7b.h"
|
#include "DSEG7Classic-BoldItalic26pt7b.h"
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ class PageSixValues : public Page
|
||||||
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
|
||||||
DataValue[i] = bvalue->value; // Value as double in SI unit
|
DataValue[i] = bvalue->value; // Value as double in SI unit
|
||||||
|
calibrationData.calibrateInstance(DataName[i], bvalue, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
DataUnits[i] = formatValue(bvalue, *commonData).unit;
|
DataUnits[i] = formatValue(bvalue, *commonData).unit;
|
||||||
|
|
|
@ -46,7 +46,7 @@ class PageThreeValues : public Page
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class PageThreeValues : public Page
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ class PageThreeValues : public Page
|
||||||
name3 = name3.substring(0, 6); // String length limit for value name
|
name3 = name3.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name3, bvalue3, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name3, bvalue3, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value
|
String unit3 = formatValue(bvalue3, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class PageTwoValues : public Page
|
||||||
name1 = name1.substring(0, 6); // String length limit for value name
|
name1 = name1.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name1, bvalue1, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
String unit1 = formatValue(bvalue1, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class PageTwoValues : public Page
|
||||||
name2 = name2.substring(0, 6); // String length limit for value name
|
name2 = name2.substring(0, 6); // String length limit for value name
|
||||||
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
|
||||||
CalibrationDataList::calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
calibrationData.calibrateInstance(name2, bvalue2, logger); // Check if boat data value is to be calibrated
|
||||||
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
|
||||||
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
String unit2 = formatValue(bvalue2, *commonData).unit; // Unit of value
|
||||||
|
|
||||||
|
|
|
@ -219,17 +219,6 @@
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "calOffsetDBT",
|
|
||||||
"label": "Offset DBT",
|
|
||||||
"type": "number",
|
|
||||||
"default": "0.00",
|
|
||||||
"description": "Offset for depth transducer; positive for depth from surface, negative for depth below keel",
|
|
||||||
"category": "OBP60 Settings",
|
|
||||||
"capabilities": {
|
|
||||||
"obp60":"true"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "lengthFormat",
|
"name": "lengthFormat",
|
||||||
"label": "Length Format",
|
"label": "Length Format",
|
||||||
|
@ -706,6 +695,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
"STW",
|
"STW",
|
||||||
"WTemp"
|
"WTemp"
|
||||||
|
@ -746,6 +736,7 @@
|
||||||
"list": [
|
"list": [
|
||||||
"AWA",
|
"AWA",
|
||||||
"AWS",
|
"AWS",
|
||||||
|
"DBT",
|
||||||
"HDM",
|
"HDM",
|
||||||
"STW",
|
"STW",
|
||||||
"WTemp"
|
"WTemp"
|
||||||
|
@ -777,6 +768,47 @@
|
||||||
"obp60":"true"
|
"obp60":"true"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "calInstance3",
|
||||||
|
"label": "Calibration Data Instance 3",
|
||||||
|
"type": "list",
|
||||||
|
"default": "",
|
||||||
|
"description": "Data instance for calibration",
|
||||||
|
"list": [
|
||||||
|
"AWA",
|
||||||
|
"AWS",
|
||||||
|
"DBT",
|
||||||
|
"HDM",
|
||||||
|
"STW",
|
||||||
|
"WTemp"
|
||||||
|
],
|
||||||
|
"category": "OBP60 Calibrations",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "calOffset3",
|
||||||
|
"label": "Calibration Data Instance 3 Offset",
|
||||||
|
"type": "number",
|
||||||
|
"default": "0.00",
|
||||||
|
"description": "Offset for data instance 3",
|
||||||
|
"category": "OBP60 Calibrations",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "calSlope3",
|
||||||
|
"label": "Calibration Data Instance 3 Slope",
|
||||||
|
"type": "number",
|
||||||
|
"default": "1.00",
|
||||||
|
"description": "Slope for data instance 3",
|
||||||
|
"category": "OBP60 Calibrations",
|
||||||
|
"capabilities": {
|
||||||
|
"obp60":"true"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "display",
|
"name": "display",
|
||||||
"label": "Display Mode",
|
"label": "Display Mode",
|
||||||
|
|
|
@ -386,10 +386,6 @@ void OBP60Task(GwApi *api){
|
||||||
commonData.logger=logger;
|
commonData.logger=logger;
|
||||||
commonData.config=config;
|
commonData.config=config;
|
||||||
|
|
||||||
// Read all calibration data settings from config
|
|
||||||
CalibrationDataList::readConfig(config, logger);
|
|
||||||
LOG_DEBUG(GwLog::LOG,"Calibration data read from config");
|
|
||||||
|
|
||||||
#ifdef HARDWARE_V21
|
#ifdef HARDWARE_V21
|
||||||
// Keyboard coordinates for page footer
|
// Keyboard coordinates for page footer
|
||||||
initKeys(commonData);
|
initKeys(commonData);
|
||||||
|
@ -529,6 +525,9 @@ void OBP60Task(GwApi *api){
|
||||||
// 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);
|
||||||
|
|
||||||
|
// Read all calibration data settings from 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
|
||||||
api->registerRequestHandler("screenshot", [api, &pageNumber, pages](AsyncWebServerRequest *request) {
|
api->registerRequestHandler("screenshot", [api, &pageNumber, pages](AsyncWebServerRequest *request) {
|
||||||
|
|
Loading…
Reference in New Issue