diff --git a/lib/obp60task/BoatDataCalibration.cpp b/lib/obp60task/BoatDataCalibration.cpp index a9c5b5c..dcfd8ba 100644 --- a/lib/obp60task/BoatDataCalibration.cpp +++ b/lib/obp60task/BoatDataCalibration.cpp @@ -17,14 +17,6 @@ void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger) double slope; double smooth; - // Approximate mid-range values in m/s for Beaufort scale 0–12 - // hier geht's weiter mit den Bft-Werten: was muss ich bei welcher Windstärke addieren bzw. wie ist der Multiplikator? - /* static const std::array, 12> mps = {{ - {0.2, 1.3}, {1.5, 1.8}, {3.3, 2.1}, {5.4, 2.5}, - {7.9, 2.8}, {10.7, 3.1}, {13.8, 3.3}, {17.1, 3.6}, - {20.7, 3.7}, {24.4, 4.0}, {28.4, 4.2}, {32.6, 4.2} - }}; */ - String calInstance = ""; String calOffset = ""; String calSlope = ""; @@ -66,7 +58,7 @@ void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger) offset *= 2 + (offset / 2); // Convert Bft to m/s (approx) -> to be improved } - } else if (instance == "AWA" || instance == "TWA" || instance == "TWD" || instance == "HDM" || instance == "PRPOS" || instance == "RPOS") { + } 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") { @@ -76,7 +68,7 @@ void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger) offset /= 3.28084; // Convert ft to m } - } else if (instance == "STW") { + } else if (instance == "SOG" || instance == "STW") { if (speedFormat == "m/s") { // No conversion needed } else if (speedFormat == "km/h") { @@ -115,36 +107,6 @@ void CalibrationDataList::readConfig(GwConfigHandler* config, GwLog* logger) LOG_DEBUG(GwLog::LOG, "all calibration data read"); } -/* -int CalibrationDataList::getInstanceListNo(std::string instance) -// Method to get the index of the requested instance in the list -{ - // Check if instance is in the list - auto it = calibrationData.list.begin(); - std::advance(it, 1); // Move iterator to the second element - if (it != calibrationData.list.end()) { - std::string secondKey = it->first; // Get the key of the second value pair - LOG_DEBUG(GwLog::DEBUG, "Second key in calibration data list: %s", secondKey.c_str()); - } else { - LOG_DEBUG(GwLog::DEBUG, "Calibration data list has less than two elements."); - } - - // Iterate through the map and retrieve keys - for (const auto& pair : list) { - std::cout << "Key: " << pair.first << ", Value: " << pair.second << std::endl; - } - - - - for (int i = 0; i < maxCalibrationData; i++) { - if (calibrationData.list[i].instance == instance) { - return i; - } - } - return -1; // instance not found -} -*/ - void CalibrationDataList::calibrateInstance(GwApi::BoatValue* boatDataValue, GwLog* logger) // Method to calibrate the boat data value { @@ -184,6 +146,7 @@ void CalibrationDataList::calibrateInstance(GwApi::BoatValue* boatDataValue, GwL } else if (format == "kelvinToC") { // instance is of type temperature dataValue = ((dataValue - 273.15) * slope) + offset + 273.15; } else { + dataValue = (dataValue * slope) + offset; } diff --git a/lib/obp60task/BoatDataCalibration.h b/lib/obp60task/BoatDataCalibration.h index b0624d4..5a0606b 100644 --- a/lib/obp60task/BoatDataCalibration.h +++ b/lib/obp60task/BoatDataCalibration.h @@ -10,7 +10,6 @@ #define MAX_CALIBRATION_DATA 3 // maximum number of calibration data instances typedef struct { -// String instance; // data type/instance to be calibrated double offset; // calibration offset double slope; // calibration slope double smooth; // smoothing factor @@ -20,11 +19,9 @@ typedef struct { class CalibrationDataList { public: -// CalibData list[maxCalibrationData]; // list of calibration data instances static std::unordered_map calibMap; // list of calibration data instances void readConfig(GwConfigHandler* config, GwLog* logger); -// int getInstanceListNo(std::string instance); void calibrateInstance(GwApi::BoatValue* boatDataValue, GwLog* logger); void smoothInstance(GwApi::BoatValue* boatDataValue, GwLog* logger); diff --git a/lib/obp60task/config.json b/lib/obp60task/config.json index 7c9fadb..23df2f9 100644 --- a/lib/obp60task/config.json +++ b/lib/obp60task/config.json @@ -696,10 +696,12 @@ "---", "AWA", "AWS", + "COG", "DBT", "HDM", "PRPOS", "RPOS", + "SOG", "STW", "TWA", "TWS", @@ -724,10 +726,12 @@ "condition": [ { "calInstance1": "AWA" }, { "calInstance1": "AWS" }, + { "calInstance2": "COG" }, { "calInstance1": "DBT" }, { "calInstance1": "HDM" }, { "calInstance1": "PRPOS" }, { "calInstance1": "RPOS" }, + { "calInstance1": "SOG" }, { "calInstance1": "STW" }, { "calInstance1": "TWA" }, { "calInstance1": "TWS" }, @@ -747,10 +751,12 @@ "condition": [ { "calInstance1": "AWA" }, { "calInstance1": "AWS" }, + { "calInstance2": "COG" }, { "calInstance1": "DBT" }, { "calInstance1": "HDM" }, { "calInstance1": "PRPOS" }, { "calInstance1": "RPOS" }, + { "calInstance1": "SOG" }, { "calInstance1": "STW" }, { "calInstance1": "TWA" }, { "calInstance1": "TWS" }, @@ -773,10 +779,12 @@ "condition": [ { "calInstance1": "AWA" }, { "calInstance1": "AWS" }, + { "calInstance2": "COG" }, { "calInstance1": "DBT" }, { "calInstance1": "HDM" }, { "calInstance1": "PRPOS" }, { "calInstance1": "RPOS" }, + { "calInstance1": "SOG" }, { "calInstance1": "STW" }, { "calInstance1": "TWA" }, { "calInstance1": "TWS" }, @@ -793,10 +801,12 @@ "---", "AWA", "AWS", + "COG", "DBT", "HDM", "PRPOS", "RPOS", + "SOG", "STW", "TWA", "TWS", @@ -821,10 +831,12 @@ "condition": [ { "calInstance2": "AWA" }, { "calInstance2": "AWS" }, + { "calInstance2": "COG" }, { "calInstance2": "DBT" }, { "calInstance2": "HDM" }, { "calInstance2": "PRPOS" }, { "calInstance2": "RPOS" }, + { "calInstance2": "SOG" }, { "calInstance2": "STW" }, { "calInstance2": "TWA" }, { "calInstance2": "TWS" }, @@ -844,10 +856,12 @@ "condition": [ { "calInstance2": "AWA" }, { "calInstance2": "AWS" }, + { "calInstance2": "COG" }, { "calInstance2": "DBT" }, { "calInstance2": "HDM" }, { "calInstance2": "PRPOS" }, { "calInstance2": "RPOS" }, + { "calInstance2": "SOG" }, { "calInstance2": "STW" }, { "calInstance2": "TWA" }, { "calInstance2": "TWS" }, @@ -870,10 +884,12 @@ "condition": [ { "calInstance2": "AWA" }, { "calInstance2": "AWS" }, + { "calInstance2": "COG" }, { "calInstance2": "DBT" }, { "calInstance2": "HDM" }, { "calInstance2": "PRPOS" }, { "calInstance2": "RPOS" }, + { "calInstance2": "SOG" }, { "calInstance2": "STW" }, { "calInstance2": "TWA" }, { "calInstance2": "TWS" }, @@ -890,10 +906,12 @@ "---", "AWA", "AWS", + "COG", "DBT", "HDM", "PRPOS", "RPOS", + "SOG", "STW", "TWA", "TWS", @@ -918,10 +936,12 @@ "condition": [ { "calInstance3": "AWA" }, { "calInstance3": "AWS" }, + { "calInstance3": "COG" }, { "calInstance3": "DBT" }, { "calInstance3": "HDM" }, { "calInstance3": "PRPOS" }, { "calInstance3": "RPOS" }, + { "calInstance3": "SOG" }, { "calInstance3": "STW" }, { "calInstance3": "TWA" }, { "calInstance3": "TWS" }, @@ -941,10 +961,12 @@ "condition": [ { "calInstance3": "AWA" }, { "calInstance3": "AWS" }, + { "calInstance3": "COG" }, { "calInstance3": "DBT" }, { "calInstance3": "HDM" }, { "calInstance3": "PRPOS" }, { "calInstance3": "RPOS" }, + { "calInstance3": "SOG" }, { "calInstance3": "STW" }, { "calInstance3": "TWA" }, { "calInstance3": "TWS" }, @@ -967,10 +989,12 @@ "condition": [ { "calInstance3": "AWA" }, { "calInstance3": "AWS" }, + { "calInstance3": "COG" }, { "calInstance3": "DBT" }, { "calInstance3": "HDM" }, { "calInstance3": "PRPOS" }, { "calInstance3": "RPOS" }, + { "calInstance3": "SOG" }, { "calInstance3": "STW" }, { "calInstance3": "TWA" }, { "calInstance3": "TWS" },