|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
PT Calibration Manager. More...
#include <PTCalibration.hpp>
Public Member Functions | |
| PTCalibrationManager (bool auto_load=true) | |
| ~PTCalibrationManager ()=default | |
| bool | load_from_json (const std::string &json_path, bool merge_missing_only=false) |
| Load calibration from JSON file (from calibration GUI). | |
| bool | load_from_csv (const std::string &csv_path) |
| Load calibration from CSV file (from DiabloAvionics). | |
| bool | load_calibration () |
| Auto-load calibration from default paths Default: factory CSV first, then newest GUI JSON overlays every channel it lists (fixes CSV PT6≠GN2 ch6). | |
| const PTCalibrationCoeffs * | get_calibration (uint8_t channel_id) const |
| Get calibration coefficients for a sensor channel. | |
| bool | is_calibrated (uint8_t channel_id) const |
| Check if a channel has calibration. | |
| double | calculate_pressure (uint8_t channel_id, int32_t adc_code) const |
| Calculate calibrated pressure for a channel. | |
| size_t | get_calibrated_count () const |
| Get number of calibrated channels. | |
| void | set_calibration (uint8_t channel_id, const PTCalibrationCoeffs &coeffs) |
| Set/replace the cubic coefficients for a logical channel at runtime. | |
| void | clear_calibration (uint8_t channel_id) |
| Remove any cubic for a logical channel, so is_calibrated() returns false again. | |
Static Public Member Functions | |
| static void | set_default_paths (const std::string &json_dir, const std::string &csv_path) |
| Set default calibration file paths. | |
Private Member Functions | |
| bool | parse_json_file (const std::string &json_path) |
| bool | parse_csv_file (const std::string &csv_path) |
| std::string | find_latest_json_file (const std::string &json_dir) const |
Private Attributes | |
| std::map< uint8_t, PTCalibrationCoeffs > | calibrations_ |
Static Private Attributes | |
| static std::string | default_json_dir_ = "scripts/calibration/calibrations" |
| static std::string | default_csv_path_ |
PT Calibration Manager.
Loads and manages PT calibration coefficients from JSON or CSV files. Provides calibrated pressure values for sensor channels.
Definition at line 67 of file PTCalibration.hpp.
|
explicit |
Definition at line 88 of file PTCalibration.cpp.
References load_calibration().
|
default |
| double fsw::calibration::PTCalibrationManager::calculate_pressure | ( | uint8_t | channel_id, |
| int32_t | adc_code ) const |
Calculate calibrated pressure for a channel.
| channel_id | Sensor channel ID |
| adc_code | Raw ADC code |
Definition at line 313 of file PTCalibration.cpp.
References get_calibration(), and p.
Referenced by invert_abort_psi_to_adc(), and main().
| void fsw::calibration::PTCalibrationManager::clear_calibration | ( | uint8_t | channel_id | ) |
Remove any cubic for a logical channel, so is_calibrated() returns false again.
Used by the calibration service's "clear" so a cleared/uncalibrated cubic sensor streams nothing (0) rather than reverting to a factory/baseline curve.
Definition at line 309 of file PTCalibration.cpp.
References calibrations_.
Referenced by main().
|
private |
Definition at line 378 of file PTCalibration.cpp.
References fs::exists(), fs::is_directory(), and fsw::calibration::skip_json_for_pt_polynomial_load().
Referenced by load_calibration().
|
inline |
Get number of calibrated channels.
Definition at line 124 of file PTCalibration.hpp.
References calibrations_.
Referenced by main().
| const PTCalibrationCoeffs * fsw::calibration::PTCalibrationManager::get_calibration | ( | uint8_t | channel_id | ) | const |
Get calibration coefficients for a sensor channel.
| channel_id | Sensor channel ID (1-indexed) |
Definition at line 293 of file PTCalibration.cpp.
References calibrations_.
Referenced by calculate_pressure().
| bool fsw::calibration::PTCalibrationManager::is_calibrated | ( | uint8_t | channel_id | ) | const |
Check if a channel has calibration.
| channel_id | Sensor channel ID |
Definition at line 301 of file PTCalibration.cpp.
References calibrations_.
Referenced by invert_abort_psi_to_adc(), and main().
| bool fsw::calibration::PTCalibrationManager::load_calibration | ( | ) |
Auto-load calibration from default paths Default: factory CSV first, then newest GUI JSON overlays every channel it lists (fixes CSV PT6≠GN2 ch6).
CAL_PT_JSON_MISSING_ONLY=1 — JSON only fills gaps (legacy). CAL_PT_JSON_FIRST=1 — JSON only, then CSV.
Definition at line 94 of file PTCalibration.cpp.
References calibrations_, default_csv_path_, default_json_dir_, fs::exists(), find_latest_json_file(), load_from_csv(), and load_from_json().
Referenced by main(), and PTCalibrationManager().
| bool fsw::calibration::PTCalibrationManager::load_from_csv | ( | const std::string & | csv_path | ) |
Load calibration from CSV file (from DiabloAvionics).
| csv_path | Path to CSV calibration file |
Definition at line 212 of file PTCalibration.cpp.
References calibrations_, and end().
Referenced by load_calibration().
| bool fsw::calibration::PTCalibrationManager::load_from_json | ( | const std::string & | json_path, |
| bool | merge_missing_only = false ) |
Load calibration from JSON file (from calibration GUI).
| json_path | Path to JSON calibration file |
| merge_missing_only | If true, only add channels not already present after CSV; if false, every channel in JSON overwrites the same logical key (GUI per-connector calibration). |
Definition at line 166 of file PTCalibration.cpp.
References calibrations_, ch(), and is_number.
Referenced by load_calibration().
|
private |
|
private |
| void fsw::calibration::PTCalibrationManager::set_calibration | ( | uint8_t | channel_id, |
| const PTCalibrationCoeffs & | coeffs ) |
Set/replace the cubic coefficients for a logical channel at runtime.
Used by the calibration service when an operator builds a cubic live from captured reference points — the new fit takes effect immediately on the streaming path (which evaluates these coefficients per packet).
| channel_id | is the logical calibration channel (pt_logical_calibration_channel), not a board-local connector. |
Definition at line 305 of file PTCalibration.cpp.
References calibrations_.
Referenced by main().
|
static |
Set default calibration file paths.
Definition at line 357 of file PTCalibration.cpp.
References default_csv_path_, and default_json_dir_.
Referenced by main().
|
private |
Definition at line 153 of file PTCalibration.hpp.
Referenced by clear_calibration(), get_calibrated_count(), get_calibration(), is_calibrated(), load_calibration(), load_from_csv(), load_from_json(), and set_calibration().
|
staticprivate |
Definition at line 157 of file PTCalibration.hpp.
Referenced by load_calibration(), and set_default_paths().
|
staticprivate |
Definition at line 156 of file PTCalibration.hpp.
Referenced by load_calibration(), and set_default_paths().