ControllerCtx

Struct ControllerCtx 

Source
#[non_exhaustive]
pub struct ControllerCtx {
Show 15 fields pub op_name: String, pub op_dir: PathBuf, pub dt_ns: u32, pub timeout_to_operating_ns: u32, pub binding_timeout_ms: u16, pub configuring_timeout_ms: u16, pub peripheral_loss_of_contact_limit: u16, pub controller_loss_of_contact_limit: u16, pub termination_criteria: Option<Termination>, pub loss_of_contact_policy: LossOfContactPolicy, pub loop_method: LoopMethod, pub user_ctx: BTreeMap<String, String>, pub user_channels: Arc<RwLock<BTreeMap<String, Channel>>>, pub manual_inputs: ManualInputMap, pub enable_manual_inputs: bool,
}
Expand description

Operation context, provided to appendages during init

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§op_name: String

A name for this controller op, which will be used as the name of the file/table/bucket/etc of each data dispatcher and must be compatible with that use.

§op_dir: PathBuf

A directory to find file inputs and place outputs.

§dt_ns: u32

Control cycle period in nanoseconds

§timeout_to_operating_ns: u32

Delay from end of configuration window after which the peripherals time out to the Operating state

§binding_timeout_ms: u16

Duration to wait for responses to binding

§configuring_timeout_ms: u16

Duration for peripherals to wait to receive configuration after being bound

§peripheral_loss_of_contact_limit: u16

Number of consecutive missed control inputs after which the peripheral should assume contact has been lost, de-energize their outputs, and wait to bind a controller again.

§controller_loss_of_contact_limit: u16

Number of consecutive missed responses from a peripheral after which the controller should assume contact has been lost

§termination_criteria: Option<Termination>

A condition for exiting the control loop, to be checked at each cycle

§loss_of_contact_policy: LossOfContactPolicy

Response to losing contact with a peripheral

§loop_method: LoopMethod

Whether to prioritize performance or efficiency in the control loop.

§user_ctx: BTreeMap<String, String>

An escape hatch for sideloading user context (likely json-encoded) that is not yet implemented as a standalone field.

§user_channels: Arc<RwLock<BTreeMap<String, Channel>>>

An escape hatch for sideloading communication between appendages. Each channel is a bidirectional MPMC message pipe.

Because bidirectional channels may not close until the program terminates on its own, the status of these channels should not be used to indicate when a freerunning thread should terminate, as this will often result in a resource leak.

§manual_inputs: ManualInputMap

Manual input overrides that can be written while the controller is running.

§enable_manual_inputs: bool

Whether manual input overrides should be applied during the control loop.

Implementations§

Source§

impl ControllerCtx

Source

pub fn source_endpoint(&self, channel_name: &str) -> Endpoint

Get a handle to a source endpoint tx/rx pair for the channel, creating the channel if it does not exist.

Examples found in repository?
examples/sideloading.rs (line 113)
106    fn init(
107        &mut self,
108        ctx: ControllerCtx,
109        _input_indices: Vec<usize>,
110        output_range: Range<usize>,
111    ) -> Result<(), String> {
112        self.output_index = output_range.clone().next().unwrap();
113        self.endpoint = ctx.source_endpoint(&self.channel_name);
114        self.prefix = ctx.user_ctx.get("speaker_prefix").unwrap().to_owned();
115        Ok(())
116    }
Source

pub fn sink_endpoint(&self, channel_name: &str) -> Endpoint

Get a handle to a sink endpoint tx/rx pair for the channel, creating the channel if it does not exist.

Examples found in repository?
examples/sideloading.rs (line 196)
189    fn init(
190        &mut self,
191        ctx: ControllerCtx,
192        _input_indices: Vec<usize>,
193        output_range: Range<usize>,
194    ) -> Result<(), String> {
195        self.output_index = output_range.clone().next().unwrap();
196        self.endpoint = ctx.sink_endpoint(&self.channel_name);
197        Ok(())
198    }

Trait Implementations§

Source§

impl Clone for ControllerCtx

Source§

fn clone(&self) -> ControllerCtx

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ControllerCtx

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ControllerCtx

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ControllerCtx

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ControllerCtx

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Ungil for T
where T: Send,