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

Go to the source code of this file.

Classes

struct  LcTare
 One load cell's tare: the scale reads zero at the load it was holding when the operator pressed Tare. More...

Namespaces

namespace  anonymous_namespace{test_lc_tare.cpp}

Macros

#define CHECK(cond, ...)

Functions

std::string anonymous_namespace{test_lc_tare.cpp}::scratch (const char *name)
 A unique scratch path per test — hermetic, no committed fixtures, parallel-safe.
std::string anonymous_namespace{test_lc_tare.cpp}::read_text (const std::string &path)
LcTareStore::Evaluator anonymous_namespace{test_lc_tare.cpp}::linear (double kg_per_count)
 A linear adc->kg curve, standing in for select_lc_kg.
void anonymous_namespace{test_lc_tare.cpp}::recompute_carries_tare_across_a_better_fit ()
void anonymous_namespace{test_lc_tare.cpp}::untrusted_curves_keep_the_last_good_offset ()
void anonymous_namespace{test_lc_tare.cpp}::non_finite_offset_is_never_recorded ()
void anonymous_namespace{test_lc_tare.cpp}::entity_matches_the_publish_path ()
void anonymous_namespace{test_lc_tare.cpp}::loaded_tare_is_corrected_by_recompute ()
void anonymous_namespace{test_lc_tare.cpp}::fingerprint_tracks_what_the_curve_does ()
void anonymous_namespace{test_lc_tare.cpp}::stale_audit_finds_a_missed_recompute ()
void anonymous_namespace{test_lc_tare.cpp}::save_load_round_trip ()
void anonymous_namespace{test_lc_tare.cpp}::unreadable_file_is_not_overwritten ()
int main ()
std::string lc_tare_entity (uint8_t board_id, uint8_t connector)
 LcTareStore — the guards that keep a load-cell tare from becoming a confident wrong number.

Variables

static int g_failures = 0

Macro Definition Documentation

◆ CHECK

Function Documentation

◆ lc_tare_entity()

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

LcTareStore — the guards that keep a load-cell tare from becoming a confident wrong number.

The bug this whole store exists to prevent, in the operator's words: a 20 kg tank sits on a scale whose calibration is a bad two-point fit reading it as 18. The operator tares and the display reads 0. Later they add points, the fit improves, and the same tank evaluates to 20. A tare persisted as "18 kg" then displays 2 kg for a tank that never moved — plausible enough that nobody questions it. Persisting the ADC CODE instead and re-deriving through the current curve gives 20 - 20 = 0. Case 1 pins exactly that.

  1. recompute_carries_tare_across_a_better_fit — the 2 kg bug
  2. untrusted_curves_keep_the_last_good_offset — a failed cubic load must not zero a tare
  3. non_finite_offset_is_never_recorded — a degenerate fit kills the series downstream
  4. entity_matches_the_publish_path — Node keys on this string; slot != board_id
  5. loaded_tare_is_corrected_by_recompute — startup ordering: stale offset must self-heal
  6. fingerprint_tracks_what_the_curve_does — staleness is detectable, not assumed
  7. stale_audit_finds_a_missed_recompute — a hook nobody added still gets caught

Definition at line 29 of file LcTareStore.cpp.

Referenced by anonymous_namespace{test_lc_tare.cpp}::entity_matches_the_publish_path().

◆ main()

Variable Documentation

◆ g_failures

int g_failures = 0
static

Definition at line 35 of file test_lc_tare.cpp.