pub struct Registry {Show 15 fields
pub details: Option<ResourceManagerDetails>,
pub frbc: Option<SystemDescription>,
pub ombc: Option<SystemDescription>,
pub ddbc: Option<SystemDescription>,
pub scheduled: Vec<(Timestamp, Message)>,
pub pebc_constraints: Vec<PowerConstraints>,
pub pebc_energy: Vec<EnergyConstraint>,
pub ppbc_profiles: Vec<PowerProfileDefinition>,
pub instructions: Vec<Id>,
pub instruction_messages: Vec<(Id, Id)>,
pub instruction_statuses: Vec<(Id, InstructionStatus)>,
pub published: Vec<(RevokableObjects, Id)>,
pub active_modes: Vec<(Id, Id)>,
pub timers: Vec<TimerState>,
pub fill_level: Option<f64>,
}Expand description
Everything either side has published on this session.
Every table is bounded: a peer cannot grow memory by sending identifiers it never
resolves (Registry::MAX_TRACKED).
Fields§
§details: Option<ResourceManagerDetails>The resource’s details.
frbc: Option<SystemDescription>The FRBC system description in force.
ombc: Option<SystemDescription>The OMBC system description in force.
ddbc: Option<SystemDescription>The DDBC system description in force.
scheduled: Vec<(Timestamp, Message)>Descriptions whose valid_from is still in the future.
pebc_constraints: Vec<PowerConstraints>Power constraints in force.
pebc_energy: Vec<EnergyConstraint>Energy constraints in force.
ppbc_profiles: Vec<PowerProfileDefinition>Power profiles published.
instructions: Vec<Id>Instruction identifiers used.
instruction_messages: Vec<(Id, Id)>(message_id, instruction_id) for every instruction seen on this session.
Kept so that an InstructionStatusUpdate naming an identifier nobody instructed
can say why: the commonest cause by far is a peer echoing the instruction’s
message_id instead of its id, and the two are both IDs and both present in
the message it is answering. The official s2-example-implementations battery
does exactly this, so anybody who talks to it meets the mistake on their first
instruction.
instruction_statuses: Vec<(Id, InstructionStatus)>The latest status of each instruction.
published: Vec<(RevokableObjects, Id)>Objects that could be revoked.
active_modes: Vec<(Id, Id)>The operation mode each actuator is in (Id::NIL for OMBC’s single machine).
timers: Vec<TimerState>When each actuator’s timers finish, keyed by actuator and timer: a timer identifier is unique only within the description that declares it.
fill_level: Option<f64>The present fill level, once a storage status has arrived.
Implementations§
Source§impl Registry
impl Registry
Sourcepub const MAX_TRACKED: usize = 4096
pub const MAX_TRACKED: usize = 4096
The most identifiers of any one kind that are remembered.
Sourcepub const MAX_SCHEDULED: usize = 16
pub const MAX_SCHEDULED: usize = 16
The most descriptions that may be queued for a future valid_from.
Far smaller than MAX_TRACKED because each entry is a whole
decoded message rather than an identifier. An eviction drops the description
furthest from taking effect.
Sourcepub fn record(&mut self, message: &Message, now: Option<Timestamp>)
pub fn record(&mut self, message: &Message, now: Option<Timestamp>)
Record what a message publishes, whichever direction it went.
A description whose valid_from is in the future is held until it becomes
effective; Registry::activate_due promotes it.
Sourcepub fn activate_due(&mut self, now: Timestamp) -> Vec<Message>
pub fn activate_due(&mut self, now: Timestamp) -> Vec<Message>
Promote every scheduled description whose time has come.
Sourcepub fn next_activation(&self) -> Option<Timestamp>
pub fn next_activation(&self) -> Option<Timestamp>
The earliest scheduled description still waiting.
Sourcepub fn revoke(&mut self, object_type: RevokableObjects, object_id: Id)
pub fn revoke(&mut self, object_type: RevokableObjects, object_id: Id)
Withdraw an object.
A system description has no id of its own, so the standard has its message_id
stand in (Message::revokable_id). That
makes the identifier load-bearing rather than decorative: a Resource Manager that
has published description B and then revokes the superseded A must not
lose B. So the stored description is cleared only when it is the one named.
Sourcepub fn context<'a>(
&'a self,
profile: WireProfile,
sender: EnergyManagementRole,
phase: Phase,
s2_connect: bool,
now: Timestamp,
seen: &'a [Id],
skew_tolerance: Duration,
) -> Context<'a>
pub fn context<'a>( &'a self, profile: WireProfile, sender: EnergyManagementRole, phase: Phase, s2_connect: bool, now: Timestamp, seen: &'a [Id], skew_tolerance: Duration, ) -> Context<'a>
The validation context this registry supports.
The argument list is long because a Context is: every one of these is a fact a
cross-message rule needs and the registry does not own.