Skip to main content

Module model

Module model 

Source
Expand description

The virtual device: what an instruction actually means.

S2’s three state-machine control types describe an abstract device, and an instruction names a state and a number between zero and one. Turning that into watts needs the description that was sent — the S2 documentation, Operation modes gives the arithmetic: power = (end − start) × factor + start.

Both roles need exactly the same arithmetic, and they must not disagree about it. A Resource Manager reads an instruction and works out what its hardware should do; a Customer Energy Manager works out what to ask for, and later reconciles the measurement it gets back. Two implementations of one formula is how those two stop agreeing, so there is one here and both sides call it.

Everything in this module is a pure function of a description, an instruction and — where a rate depends on it — a fill level. Nothing reads a clock.

use s2_kit::prelude::*;
use s2_kit::model;

// The heat pump from docs `learn/examples/heat-pump`: 500 W to 2000 W.
let range = PowerRange::new(500.0, 2000.0, CommodityQuantity::ElectricPowerL1);
assert_eq!(model::interpolate(&[range], 0.0)[0].value, 500.0);
assert_eq!(model::interpolate(&[range], 1.0)[0].value, 2000.0);
assert_eq!(model::interpolate(&[range], 0.5)[0].value, 1250.0);

Re-exports§

pub use explain::Explanation;
pub use explain::explain;

Modules§

explain
Saying, in one value, what an instruction will actually do.

Structs§

DdbcResolution
What a DDBC.Instruction means.
Factor
An operation-mode factor: a number in [0, 1].
FrbcResolution
What an FRBC.Instruction means, read against the system description.
Limits
A ceiling and a floor, as a PEBC.Instruction sets them.
OmbcResolution
What an OMBC.Instruction means.
PpbcResolution
What a PPBC instruction means.
SequenceWindow
Where one chosen sequence has to fall for the whole profile to fit its window.

Enums§

ResolveError
Why an instruction could not be read against the description that was sent.
ScheduleProblem
Why a concrete set of start times will not do.

Functions§

all_limits_at
The envelope the resource is under for each quantity the instruction bounds.
blocking_timers
Which timers block a move from from to to, given what is known about them.
energy_window
The average power an energy constraint demands over its window, as a range.
factor_for_power
The factor that produces power for quantity, if the ranges determine one.
interpolate
The power a set of ranges implies at a factor.
is_schedulable
Whether a set of choices can be run inside the profile’s window at all.
limits_at
The limits a PEBC.Instruction puts on one quantity at a moment.
project_fill_level
Where the fill level ends up after duration in one operation mode.
resolve_ddbc
Read a DDBC.Instruction against the description that was sent.
resolve_frbc
Read an FRBC.Instruction against the description that was sent.
resolve_ombc
Read an OMBC.Instruction against the description that was sent.
resolve_ppbc
Read a PPBC instruction’s three identifiers against the profile that was published.
schedule
When each chosen sequence may run, given that containers run in the order the profile lists them.
sequence_power_at
The power a sequence draws offset after it started.
starts_are_feasible
Whether concrete start times run the profile as the standard says it must be run.
supply_range_of
The whole span of demand one actuator can supply, across all of its operation modes.
timer_label
The timer with this identifier, for a diagnostic.
transition_duration
How long a transition takes to take effect. Absent means negligible.
within
Whether a power obeys the limits.