Expand description
Shared application runtime for BHTune’s command-line and HTTP adapters.
This crate owns configuration resolution, database bootstrap, logging, history retention,
driver setup, tune orchestration and safety, shared OPC helpers, and sample export
serialization. Its source and direct dependencies do not use clap or an HTTP framework;
adapters convert their own inputs into runtime types and keep transport-specific output at
the boundary. The OPC DA gRPC client may bring transport crates transitively, but they are
not exposed through this runtime API.
Modules§
- cancel
- A single, process-wide Ctrl+C listener shared by every await point in a tune. Registering
the signal exactly once, as early in the process as possible, closes the gap where a
Ctrl+C delivered while no listener happens to be alive is silently swallowed – tokio
installs a process-wide
SIGINThandler the first timectrl_c()is polled and never reverts to the OS default, so a lost signal isn’t merely unhandled, it’s gone. - config
- Global bhtune configuration, including the shared
[tuning]timing policy and theCLI flag > env var > TOML config file > built-in defaultprecedence used by settings that expose command-line or environment overrides. - db
- Opens the CLI’s database for mutating commands, seeds the built-in and user-catalog
DCS/PLC templates, and runs the retention sweep. Read-only commands such as
bhtune checkuse a separate connection that skips bootstrap and retention. - driver
- Constructs the selected
bhtune_driver::Driverimplementation from aTuneRequest. - export
- Shared serialization for persisted run samples.
- gateway
- Shared opcda-bridge compatibility checks for live mutations and inspection surfaces.
- history
- Shared history operations that can affect a live controller.
- live_
ownership - Process-shared and database-backed ownership for live controller mutations.
- logging
- Shared structured application logging, matching
opcda-bridge-gateway’s owntracingstack andlog.*configuration conventions (level/directory/format/rotation, resolved with the sameCLI flag > env var > config file > defaultprecedence as every other bhtune setting) – seecrate::config::LogConfig/resolve_log_settings. - retention
- Age-based deletion of old tune runs.
- tune
bhtune tune/bhtune simulate: runs a full MRFT test end-to-end — resolving a template, deriving tags, transitioning the loop to Manual, polling the driver and driving a real [bhtune_core::MrftEngine], persisting every tick and the final calculated results, then restoring the loop and optionally writing back the chosen PID constants.