pub struct TuneResultRow {
pub id: i64,
pub run_id: i64,
pub response_level: ResponseLevel,
pub kp: Option<f32>,
pub ti_minutes: Option<f32>,
pub td_minutes: Option<f32>,
pub proportional: Option<f32>,
pub integral: Option<f32>,
pub derivative: Option<f32>,
pub status: TuningResultStatus,
pub invalid_reason: Option<TuningResultInvalidReason>,
}Expand description
One row of tune_results: the calculated PID result for one ResponseLevel of one run.
Flattened rather than nesting TuningResult/PidParameters directly, since both of
those types carry their own response_level field — nesting both would mean either two
redundant copies that could disagree, or an awkward “just trust the outer one” rule. One
flat set of columns matching the table exactly avoids that.
Fields§
§id: i64§run_id: i64§response_level: ResponseLevel§kp: Option<f32>§ti_minutes: Option<f32>§td_minutes: Option<f32>§proportional: Option<f32>§integral: Option<f32>§derivative: Option<f32>§status: TuningResultStatus§invalid_reason: Option<TuningResultInvalidReason>Implementations§
Source§impl TuneResultRow
impl TuneResultRow
Sourcepub fn from_calculated(
run_id: i64,
tuning: TuningResult,
pid: PidParameters,
) -> TuneResultRow
pub fn from_calculated( run_id: i64, tuning: TuningResult, pid: PidParameters, ) -> TuneResultRow
Builds a (not-yet-inserted, id = 0) row from a matching TuningResult/
PidParameters pair, as produced together by
bhtune_core::tuning_math::calculate_tuning_result/
bhtune_core::tuning_math::calculate_pid_parameters for the same ResponseLevel.
§Panics
Panics if tuning.response_level != pid.response_level: pairing results for different
response levels together is always a caller bug, never a runtime data problem, the
same contract bhtune_core::tuning_math::measure_oscillation documents for its own
caller-contract panics.
Sourcepub fn from_checked(run_id: i64, checked: CheckedTuningResult) -> TuneResultRow
pub fn from_checked(run_id: i64, checked: CheckedTuningResult) -> TuneResultRow
Builds a row from the checked calculation path. Invalid results retain their response level and reason while leaving every numeric value absent, so they cannot be mistaken for writable PID constants.
Sourcepub async fn insert(
pool: &SqlitePool,
row: &TuneResultRow,
) -> DbResult<TuneResultRow>
pub async fn insert( pool: &SqlitePool, row: &TuneResultRow, ) -> DbResult<TuneResultRow>
Inserts row (typically built via Self::from_calculated), returning the persisted
copy with its assigned id. (run_id, response_level) is unique (see the migration)
— a successfully completed run writes exactly the 3 ResponseLevel rows once, at
completion.
Sourcepub async fn list_for_run(
pool: &SqlitePool,
run_id: i64,
) -> DbResult<Vec<TuneResultRow>>
pub async fn list_for_run( pool: &SqlitePool, run_id: i64, ) -> DbResult<Vec<TuneResultRow>>
Lists every calculated result of run_id, ordered by ResponseLevel (which sorts
alphabetically as Aggressive, Moderate, Sluggish — the same order
bhtune_core::constants::ResponseLevel::ALL enumerates them in). 0 rows for a run
that never completed, up to 3 for one that did.
Trait Implementations§
Source§impl Clone for TuneResultRow
impl Clone for TuneResultRow
Source§fn clone(&self) -> TuneResultRow
fn clone(&self) -> TuneResultRow
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TuneResultRow
Source§impl Debug for TuneResultRow
impl Debug for TuneResultRow
Source§impl PartialEq for TuneResultRow
impl PartialEq for TuneResultRow
Source§fn eq(&self, other: &TuneResultRow) -> bool
fn eq(&self, other: &TuneResultRow) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for TuneResultRow
Auto Trait Implementations§
impl Freeze for TuneResultRow
impl RefUnwindSafe for TuneResultRow
impl Send for TuneResultRow
impl Sync for TuneResultRow
impl Unpin for TuneResultRow
impl UnsafeUnpin for TuneResultRow
impl UnwindSafe for TuneResultRow
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more