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§
- Ddbc
Resolution - What a
DDBC.Instructionmeans. - Factor
- An operation-mode factor: a number in
[0, 1]. - Frbc
Resolution - What an
FRBC.Instructionmeans, read against the system description. - Limits
- A ceiling and a floor, as a
PEBC.Instructionsets them. - Ombc
Resolution - What an
OMBC.Instructionmeans. - Ppbc
Resolution - What a PPBC instruction means.
- Sequence
Window - Where one chosen sequence has to fall for the whole profile to fit its window.
Enums§
- Resolve
Error - Why an instruction could not be read against the description that was sent.
- Schedule
Problem - 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
fromtoto, 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
powerforquantity, 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.Instructionputs on one quantity at a moment. - project_
fill_ level - Where the fill level ends up after
durationin one operation mode. - resolve_
ddbc - Read a
DDBC.Instructionagainst the description that was sent. - resolve_
frbc - Read an
FRBC.Instructionagainst the description that was sent. - resolve_
ombc - Read an
OMBC.Instructionagainst 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
offsetafter 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.