Skip to main content

Conversation

Struct Conversation 

Source
pub struct Conversation {
    pub rm: RmSession,
    pub cem: CemSession,
    pub now: Timestamp,
    /* private fields */
}
Available on crate feature testing only.
Expand description

A Resource Manager and a Customer Energy Manager, talking to each other.

Fields§

§rm: RmSession

The resource’s side.

§cem: CemSession

The manager’s side.

§now: Timestamp

The virtual clock.

Implementations§

Source§

impl Conversation

Source

pub fn new( rm_config: RmConfig, details: ResourceManagerDetails, cem_config: CemConfig, ) -> Self

A conversation between the given two configurations.

Source

pub fn battery() -> Self

A conversation with a 20 kWh home battery, the FRBC example implementation.

Source

pub fn pv() -> Self

A conversation with a 4 kWp curtailable PV inverter, the PEBC example.

Source

pub fn open(&mut self)

Open both sides and run the conversation until it goes quiet.

Source

pub fn pump(&mut self)

Deliver everything either side wants to send, until neither has anything left.

Bounded, so a session that answers its own answers cannot hang a test.

§Panics

When the conversation does not settle within a thousand rounds, which means one of the engines is acknowledging acknowledgements.

Source

pub fn advance(&mut self, by: Duration)

Move the clock forward, letting both sides notice.

Source

pub fn advance_silently(&mut self, by: Duration)

Move the clock forward without delivering anything, so that a message can be dropped on the floor.

Source

pub fn drop_rm_traffic(&mut self)

Throw away everything the Resource Manager is trying to say, as a lost connection would.

Source

pub fn drop_cem_traffic(&mut self)

Throw away everything the manager is trying to say.

Source

pub fn transcript(&self) -> &[TranscriptEntry]

Everything that has crossed the wire.

Source

pub fn to_s2log(&self) -> String

The transcript as a .s2log file.

Source

pub fn flow(&self) -> Vec<(Direction, MessageKind)>

Every message type that has crossed, in order.

Source

pub fn flow_without_acks(&self) -> Vec<(Direction, MessageKind)>

Every message type that has crossed, ignoring the acknowledgements.

Source

pub fn take_rm_events(&mut self) -> Vec<RmEvent>

Everything the Resource Manager has reported, clearing the list.

Source

pub fn take_cem_events(&mut self) -> Vec<CemEvent>

Everything the manager has reported, clearing the list.

Source

pub fn first_instruction(&mut self) -> Option<Instructed>

The first instruction the Resource Manager was handed, if any.

Source

pub fn refusals(&self) -> Vec<String>

Whether either side refused anything.

Source

pub fn assert_no_refusals(&self)

Assert that nothing was refused. The message names what was.

§Panics

When either side refused a message.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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