bhtune_core/lib.rs
1//! `bhtune-core` — the pure, I/O-free domain crate.
2//!
3//! This crate holds (once implemented — see `AGENTS.md` for phase status):
4//! - The MRFT (Modified Relay Feedback Test) tuning algorithm, as a pure
5//! state machine: `fn step(&mut self, tick: Tick) -> Vec<Action>`. No
6//! clock reads, no network calls, no UI access — that constraint is what
7//! makes it possible to replay a recorded trace and assert the engine
8//! produces bit-identical results across changes.
9//! - The tuning-constant lookup matrices and PID unit conversion math.
10//! - The domain data model: tag maps, loop configuration, DCS/PLC template
11//! semantics, and the enums that model PID parameter types and controller
12//! direction.
13//!
14//! Deliberately has no I/O, no async, and no clock reads (`chrono`'s `clock`/`now`
15//! features are disabled workspace-wide, so `Utc::now()` cannot even compile here — see
16//! `core-mrft` in AGENTS.md). This is a narrower rule than "no dependencies": `toml` is a
17//! real dependency (`template-catalog`), justified because parsing an `include_str!`-
18//! embedded `&'static str` is not I/O; the optional, feature-gated `utoipa` dependency
19//! (`openapi-contract`) is justified the same way — a compile-time `derive` macro that
20//! describes a type's shape, with zero runtime behavior of its own. Anything added here
21//! must be justified by the pure domain logic itself (or, for `utoipa`, by describing it
22//! accurately to a consumer), not by a consumer's I/O or presentation needs — those belong
23//! in `bhtune-driver`, `bhtune-db`, `bhtune-cli`, or `bhtune-server`.
24
25pub mod constants;
26pub mod controller_type;
27pub mod direction;
28pub mod loop_config;
29pub mod mrft;
30pub mod pid_config;
31pub mod process_type;
32pub mod range;
33pub mod tags;
34pub mod template;
35pub mod tuning_math;
36
37pub use constants::{ResponseLevel, TuningConstants, lookup};
38pub use controller_type::ControllerType;
39pub use direction::ControllerDirection;
40pub use loop_config::{LoopConfig, LoopConfigError};
41pub use mrft::{Action, InitialReadings, MrftCompat, MrftEngine, MrftState, Tick};
42pub use pid_config::{DerivativeType, IntegralType, ProportionalType, TimeUnit};
43pub use process_type::ProcessType;
44pub use range::{MvRange, PvRange, RangeError};
45pub use tags::{LoopTags, TagOrValue, TagOverrides, TagOverridesError, derive_tag};
46pub use template::{DcsTemplate, built_in_templates};
47pub use tuning_math::{
48 CheckedTuningResult, OpcWriteValues, Oscillation, PidParameters, TuningMathCompat,
49 TuningResult, TuningResultInvalidReason, TuningResultStatus, calculate_all,
50 calculate_all_checked, calculate_pid_parameters, calculate_tuning_result, measure_oscillation,
51 opc_write_values,
52};