STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_lc_linear_fit.cpp File Reference
#include <cmath>
#include <cstdio>
#include <filesystem>
#include <fstream>
#include <nlohmann/json.hpp>
#include <string>
#include <vector>
#include "calibration/CubicCalibrationStore.hpp"
#include "calibration/LcTareStore.hpp"
Include dependency graph for test_lc_linear_fit.cpp:

Go to the source code of this file.

Classes

struct  CubicChannel
 Per-sensor calibration record: identity, captured points, and the current fit. More...
struct  CubicFit
 Result of a least-squares polynomial fit over a channel's captured points. More...
struct  CubicPoint
 One operator-captured calibration point: raw ADC code paired with a known reference PSI. More...
class  LcTareStore
 Owns the per-channel tares for the calibration service. More...

Namespaces

namespace  anonymous_namespace{test_lc_linear_fit.cpp}

Macros

#define CHECK(cond, ...)

Enumerations

enum class  SensorKind
 Which family of sensor a channel belongs to. More...

Functions

std::string anonymous_namespace{test_lc_linear_fit.cpp}::scratch (const char *name)
double anonymous_namespace{test_lc_linear_fit.cpp}::eval_norm (const CubicFit &f, double adc)
 Evaluate a fit the way the browser does (normalized form).
double anonymous_namespace{test_lc_linear_fit.cpp}::eval_raw (const CubicFit &f, double adc)
 Evaluate a fit the way calibration_service does (raw A..D, PolynomialCalibration).
std::vector< CubicPoint > anonymous_namespace{test_lc_linear_fit.cpp}::drifting_scale_points ()
 A real load cell over 400-500k: 100 kg across 100k counts, linear, with the few-tenths-of-a-kg scatter an operator's captures carry (a settling load, a mass placed slightly off-centre).
void anonymous_namespace{test_lc_linear_fit.cpp}::fill (CubicCalibrationStore &s, const std::string &model, const std::vector< CubicPoint > &pts)
void anonymous_namespace{test_lc_linear_fit.cpp}::linear_model_fits_a_line ()
void anonymous_namespace{test_lc_linear_fit.cpp}::linear_needs_two_points ()
void anonymous_namespace{test_lc_linear_fit.cpp}::cubic_model_is_unchanged ()
void anonymous_namespace{test_lc_linear_fit.cpp}::a_model_change_refits_without_a_capture ()
double anonymous_namespace{test_lc_linear_fit.cpp}::tared_reading (const CubicFit &f, double zero_code, double tank_kg)
 The scenario.
void anonymous_namespace{test_lc_linear_fit.cpp}::tare_cancels_zero_drift_on_linear_not_cubic ()
void anonymous_namespace{test_lc_linear_fit.cpp}::both_fits_are_serialized ()
void anonymous_namespace{test_lc_linear_fit.cpp}::raw_coefficients_match_the_normalized_form ()
int main ()
std::string lc_tare_entity (uint8_t board_id, uint8_t connector)
 The publish-path entity name for an LC channel: "LC<slot>_Cal.CH<connector>", where slot is board_id % 10 with 0 -> 10 — the same rule DatabaseConfig uses to name the calibrated LC VTables, and the same board_number the LC publish path already holds.

Variables

static int g_failures = 0
constexpr uint16_t anonymous_namespace{test_lc_linear_fit.cpp}::kUid = 4201

Macro Definition Documentation

◆ CHECK

Enumeration Type Documentation

◆ SensorKind

enum class fsw::calibration::SensorKind
strong

Which family of sensor a channel belongs to.

logical_ch is (slot - 1) * 10 + connector with slot = board_id % 10, and check_board_slots only prevents two boards of the SAME kind sharing a slot. So PT board 22 and LC board 42 are both slot 2, and PT uid 2201 and LC uid 4201 both land on logical channel 11. The logical-channel maps below are written from a uid-ordered map, so the higher uid silently won: on 2026-09-13 a load cell's curve overwrote a 5000 psi transducer's on disk. The kind namespaces those maps so the two cannot collide.

Definition at line 49 of file CubicCalibrationStore.hpp.

Function Documentation

◆ lc_tare_entity()

std::string fsw::calibration::lc_tare_entity ( uint8_t board_id,
uint8_t connector )

The publish-path entity name for an LC channel: "LC<slot>_Cal.CH<connector>", where slot is board_id % 10 with 0 -> 10 — the same rule DatabaseConfig uses to name the calibrated LC VTables, and the same board_number the LC publish path already holds.

It exists as one shared function because the failure mode of a second copy is specific and has already happened: slot is NOT board_id, so PT board 22 and LC board 42 are both slot 2, and deriving a uid back out of an entity string collides them. Node must key on this string rather than re-derive it.

Definition at line 29 of file LcTareStore.cpp.

Referenced by anonymous_namespace{test_lc_tare.cpp}::fingerprint_tracks_what_the_curve_does(), anonymous_namespace{test_lc_tare.cpp}::non_finite_offset_is_never_recorded(), anonymous_namespace{test_lc_tare.cpp}::recompute_carries_tare_across_a_better_fit(), anonymous_namespace{test_lc_tare.cpp}::save_load_round_trip(), anonymous_namespace{test_lc_tare.cpp}::stale_audit_finds_a_missed_recompute(), anonymous_namespace{test_lc_linear_fit.cpp}::tared_reading(), and anonymous_namespace{test_lc_tare.cpp}::untrusted_curves_keep_the_last_good_offset().

◆ main()

Variable Documentation

◆ g_failures

int g_failures = 0
static

Definition at line 40 of file test_lc_linear_fit.cpp.