Skip to main content

ControllerCtx

Struct ControllerCtx 

Source
#[non_exhaustive]
pub struct ControllerCtx {
Show 20 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, pub channel_units: Vec<Option<String>>, pub calibration_offline_only: bool, pub calibration_local_sources: Vec<PathBuf>, pub calibration_allow_missing: bool, pub use_no_calibrations: 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.

§channel_units: Vec<Option<String>>

Units for each dispatched channel, in the same order as channel_names. None indicates the unit is unknown or dimensionless. Populated by the controller assembly pass before dispatchers are initialized. #[serde(default)] so snapshots serialized before this field was added deserialize to an empty Vec and are re-populated by the assembly pass.

§calibration_offline_only: bool

Whether calibration lookup should be restricted to local stores.

When true, the controller will not attempt to retrieve calibration records from deimoscontrols.com.

§calibration_local_sources: Vec<PathBuf>

Additional local calibration stores to search after the default user cache.

Each path is treated as the root of a calibration tree, so a peripheral with slug kind/sn is looked up at <path>/kind/sn/cal.json.

§calibration_allow_missing: bool

Whether missing calibration records should fall back to peripheral defaults.

This defaults to true to preserve the historical behavior where standard calcs were built with an empty calibration string. Applications that require explicit calibration records should set this to false.

§use_no_calibrations: bool

Whether peripherals should ignore discovered calibration records.

When true, the controller always passes Peripheral::default_cals() to standard_calcs(). This is useful for calibration procedures that need to generate a new calibration record even when an older one exists in a local or remote store.

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 116)
109    fn init(
110        &mut self,
111        ctx: ControllerCtx,
112        _input_indices: Vec<usize>,
113        output_range: Range<usize>,
114    ) -> Result<(), String> {
115        self.output_index = output_range.clone().next().unwrap();
116        self.endpoint = ctx.source_endpoint(&self.channel_name);
117        self.prefix = ctx.user_ctx.get("speaker_prefix").unwrap().to_owned();
118        Ok(())
119    }
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 199)
192    fn init(
193        &mut self,
194        ctx: ControllerCtx,
195        _input_indices: Vec<usize>,
196        output_range: Range<usize>,
197    ) -> Result<(), String> {
198        self.output_index = output_range.clone().next().unwrap();
199        self.endpoint = ctx.sink_endpoint(&self.channel_name);
200        Ok(())
201    }

Trait Implementations§

Source§

impl Clone for ControllerCtx

Source§

fn clone(&self) -> ControllerCtx

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> 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> 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<T> Ungil for T
where T: Send,

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