Struct sep2_client::event::Schedule
source · pub struct Schedule<E>where
E: SEEvent,{ /* private fields */ }
event
only.Expand description
Schedule for a given function set, and a specific server.
Schedules are bound by the SEEvent
pertaining to a specific function set,
and an EventCallback
that is passed event updates, such that clients can make device changes,
and dictate the response sent to the server.
Multi-server interactions are handled gracefully as the replyTo
field on Events contains the hostname of the server.
A Schedule
instance is a handle to a handful of shared state.
Cloning this struct is relatively cheap, and will involve incrementing all internal atomic reference counts.
However, schedules currently do not clean up their background tasks when all are dropped,
thus Schedule::shutdown
will perform a graceful shutdown.
Implementations§
source§impl<E> Schedule<E>where
E: SEEvent,
impl<E> Schedule<E>where E: SEEvent,
sourcepub fn update_time(&mut self, time: Time)
pub fn update_time(&mut self, time: Time)
Updates the schedule-specific time offset. “If FunctionSetAssignments contain both Event-based function sets (e.g., DRLC, pricing, message) and a Time resource, then devices SHALL use the Time resource from the same FunctionSetAssignments when executing the events from the associated Event-based function set.”
pub fn shutdown(&mut self)
Trait Implementations§
source§impl Scheduler<DERControl> for Schedule<DERControl>
Available on crate feature der
only.
impl Scheduler<DERControl> for Schedule<DERControl>
der
only.DER is a function set where events exhibit ‘direct control’, according to the specification. Thus, this Schedule will determine when overlapping or superseded events should be superseded based off their target, their primacy, and their creation time and when they are no longer superseded, if their superseding event is cancelled.
source§fn new(
client: Client,
device: Arc<RwLock<SEDevice>>,
handler: impl EventCallback<DERControl>,
tickrate: Duration
) -> Self
Available on crate feature event
only.
fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<DERControl>, tickrate: Duration ) -> Self
event
only.§type Program = DERProgram
type Program = DERProgram
event
only.source§fn add_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: DERControl,
program: &'life1 Self::Program,
server_id: u8
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: DERControl, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
event
only.source§impl Scheduler<EndDeviceControl> for Schedule<EndDeviceControl>
Available on crate feature drlc
only.
impl Scheduler<EndDeviceControl> for Schedule<EndDeviceControl>
drlc
only.§type Program = DemandResponseProgram
type Program = DemandResponseProgram
event
only.source§fn new(
client: Client,
device: Arc<RwLock<SEDevice>>,
handler: impl EventCallback<EndDeviceControl>,
tickrate: Duration
) -> Self
fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<EndDeviceControl>, tickrate: Duration ) -> Self
event
only.source§fn add_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: EndDeviceControl,
program: &'life1 Self::Program,
server_id: u8
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: EndDeviceControl, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
event
only.source§impl Scheduler<FlowReservationResponse> for Schedule<FlowReservationResponse>
Available on crate feature flow_reservation
only.
impl Scheduler<FlowReservationResponse> for Schedule<FlowReservationResponse>
flow_reservation
only.§type Program = ()
type Program = ()
event
only.source§fn new(
client: Client,
device: Arc<RwLock<SEDevice>>,
handler: impl EventCallback<FlowReservationResponse>,
tickrate: Duration
) -> Self
fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<FlowReservationResponse>, tickrate: Duration ) -> Self
event
only.source§fn add_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: FlowReservationResponse,
program: &'life1 Self::Program,
server_id: u8
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: FlowReservationResponse, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
event
only.source§impl Scheduler<TextMessage> for Schedule<TextMessage>
Available on crate feature messaging
only.
impl Scheduler<TextMessage> for Schedule<TextMessage>
messaging
only.Messaging is NOT a function set where events exhibit ‘direct control’. Unlike direct control function sets, multiple text messages can be active at any given time.
This schedule simply calls the given handler when the start time arrives, if and when the event is cancelled, The supplied handler is given the primacy, and the priority of the text message, and it is up to them how they are displayed.
TODO: This implementation currently does not support manual acknowledgement of text messages, as while the client’s handler is called, a lock is acquired on the scheduler, meaning it cannot progress.
§type Program = MessagingProgram
type Program = MessagingProgram
event
only.source§fn new(
client: Client,
device: Arc<RwLock<SEDevice>>,
handler: impl EventCallback<TextMessage>,
tickrate: Duration
) -> Self
fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<TextMessage>, tickrate: Duration ) -> Self
event
only.source§fn add_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: TextMessage,
program: &'life1 Self::Program,
server_id: u8
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: TextMessage, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
event
only.source§impl Scheduler<TimeTariffInterval> for Schedule<TimeTariffInterval>
Available on crate feature pricing
only.
impl Scheduler<TimeTariffInterval> for Schedule<TimeTariffInterval>
pricing
only.§type Program = (TariffProfile, RateComponent)
type Program = (TariffProfile, RateComponent)
event
only.source§fn new(
client: Client,
device: Arc<RwLock<SEDevice>>,
handler: impl EventCallback<TimeTariffInterval>,
tickrate: Duration
) -> Self
fn new( client: Client, device: Arc<RwLock<SEDevice>>, handler: impl EventCallback<TimeTariffInterval>, tickrate: Duration ) -> Self
event
only.source§fn add_event<'life0, 'life1, 'async_trait>(
&'life0 mut self,
event: TimeTariffInterval,
program: &'life1 Self::Program,
server_id: u8
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_event<'life0, 'life1, 'async_trait>( &'life0 mut self, event: TimeTariffInterval, program: &'life1 Self::Program, server_id: u8 ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
event
only.