Skip to main content

TuneResultRow

Struct TuneResultRow 

Source
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

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> TuneResultRow

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TuneResultRow

Source§

impl Debug for TuneResultRow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for TuneResultRow

Source§

fn eq(&self, other: &TuneResultRow) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for TuneResultRow

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more