[−][src]Struct temporal_networks::schedule::Schedule
A Schedule
orchestrates events and the timing constraints between them. It allows for querying arbitrary timing information with knowledge of the underlying data structure.
Example
Creating a Schedule and adding Episodes with constraints in Rust
use temporal_networks::schedule::Schedule; use temporal_networks::interval::Interval; // create a Schedule let mut schedule = Schedule::new(); // add an Episode to the Schedule that takes between 6 and 17 time units to complete let Episode1 = schedule.add_episode(Some(vec![6., 17.])); // add another Episode and a constraint that the second occurs after the first let Episode2 = schedule.add_episode(Some(vec![8., 29.])); schedule.add_constraint(Episode1.end(), Episode2.start(), None); // find the [lower, upper] interval between the start of the Schedule and the start of the second Episode let root = schedule.root().unwrap(); let result = schedule.interval(root, Episode2.start()).unwrap(); // you may notice the interval between the start of the Schedule and the second Episode is just the duration of the first Episode! assert_eq!(result, Interval::new(6., 17.));
Methods
impl Schedule
[src]
pub fn new() -> Schedule
[src]
pub fn root(&mut self) -> Option<EventID>
[src]
Get the first event in the Schedule. Found implicitly based on the current constraints
pub fn order(&self) -> Vec<EventID>
[src]
List event IDs in chronological order
pub fn create_event(&mut self) -> EventID
[src]
Low-level API for creating nodes in the graph. Advanced use only. If you can't explain why you should use this over addEpisode
, use addEpisode
instead
pub fn add_episode(&mut self, duration: Option<Vec<f64>>) -> Episode
Create a new Episode and add it to this Schedule
pub fn get_duration(&self, s: &Episode) -> Interval
[src]
Get the controllable duration of an Episode
pub fn compile(&mut self) -> Result<(), JsValue>
[src]
Compile the Schedule into a dispatchable form. A dispatchable form is required to query the Schedule for almost any scheduling information. This method is called implicitly when you attempt to query the Schedule when the dispatchable graph is not up-to-date. However, you can proactively call compile
at a time that is computationally convenient for your application to avoid paying the performance penalty when querying the Schedule
pub fn commit_event(&mut self, event: EventID, time: f64) -> Result<(), JsValue>
[src]
Low-level API for marking an event complete. Advanced use only. If you can't explain why you should use this over completeEpisode
, use completeEpisode
instead. Commits an event to a time within its interval and greedily updates the schedule for remaining events. Time is in elapsed time since the Schedule started
pub fn complete_episode(
&mut self,
episode: &Episode,
time: f64
) -> Result<(), JsValue>
[src]
&mut self,
episode: &Episode,
time: f64
) -> Result<(), JsValue>
Mark an Episode complete to update the schedule to following Episodes. The time should be the elapsed time since the Schedule started (in the same units as well)
pub fn window(&mut self, event: EventID) -> Result<Interval, JsValue>
[src]
Get the execution window of an Event
pub fn interval(
&mut self,
source: EventID,
target: EventID
) -> Result<Interval, JsValue>
[src]
&mut self,
source: EventID,
target: EventID
) -> Result<Interval, JsValue>
Get the interval between two events
pub fn event_distance(
&mut self,
source: EventID,
target: EventID
) -> Result<JsValue, JsValue>
[src]
&mut self,
source: EventID,
target: EventID
) -> Result<JsValue, JsValue>
Low-level API to get the directional distance between two events. Advanced use only. If you can't explain why you should use this over interval
, use interval
instead
pub fn update_interval(
&mut self,
source: EventID,
target: EventID,
interval: Vec<f64>
)
[src]
&mut self,
source: EventID,
target: EventID,
interval: Vec<f64>
)
pub fn add_constraint(
&mut self,
source: EventID,
target: EventID,
interval: Option<Vec<f64>>
) -> Result<(), JsValue>
&mut self,
source: EventID,
target: EventID,
interval: Option<Vec<f64>>
) -> Result<(), JsValue>
Add a constraint between the start or end of two events. Errs if either source or target is not already in the Schedule. Defaults to a [0, 0] interval between events
pub fn remove_constraint(
&mut self,
source: EventID,
target: EventID
) -> Result<(), JsValue>
[src]
&mut self,
source: EventID,
target: EventID
) -> Result<(), JsValue>
Remove the constraint between two events. Only errs if an Event is missing
pub fn remove_constraints(
&mut self,
source: &Episode,
target: &Episode
) -> Result<(), JsValue>
[src]
&mut self,
source: &Episode,
target: &Episode
) -> Result<(), JsValue>
Remove all constraints between two episodes
pub fn free_episode(&mut self, episode: &Episode) -> Result<(), JsValue>
[src]
Remove any constraints around this Episode, except the constraints between the start and end of the Episode. This should be performed prior to moving an episode in the STN
Trait Implementations
impl Debug for Schedule
[src]
impl Default for Schedule
[src]
impl From<Schedule> for JsValue
[src]
impl FromWasmAbi for Schedule
[src]
type Abi = u32
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
unsafe fn from_abi(js: u32) -> Self
[src]
impl IntoWasmAbi for Schedule
[src]
type Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self) -> u32
[src]
impl OptionFromWasmAbi for Schedule
[src]
impl OptionIntoWasmAbi for Schedule
[src]
impl RefFromWasmAbi for Schedule
[src]
type Abi = u32
The wasm ABI type references to Self
are recovered from.
type Anchor = Ref<'static, Schedule>
The type that holds the reference to Self
for the duration of the invocation of the function that has an &Self
parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl RefMutFromWasmAbi for Schedule
[src]
type Abi = u32
Same as RefFromWasmAbi::Abi
type Anchor = RefMut<'static, Schedule>
Same as RefFromWasmAbi::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl WasmDescribe for Schedule
[src]
Auto Trait Implementations
impl RefUnwindSafe for Schedule
impl Send for Schedule
impl Sync for Schedule
impl Unpin for Schedule
impl UnwindSafe for Schedule
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
[src]
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,