Struct SignalStatus

Source
pub struct SignalStatus(/* private fields */);
Expand description

A struct that represents the status of a signal instance. When this struct is created by Signal::get_status(), the flags was_set_remote and was_set_local will be reset.

Implementations§

Source§

impl SignalStatus

Source

pub fn was_set_remote(&self) -> bool

Returns true if the signal was set remotely since the last time the status was queried.

Examples found in repository?
examples/vector_signal.rs (line 27)
5fn main() {
6    let dev = Device::create("rustmapper");
7    loop {
8        dev.poll_and_block(Duration::from_millis(10));
9        if dev.is_ready() {
10            break;
11        }
12    }
13
14    println!("Device became ready!");
15    let mut sig = dev.create_vector_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT, 2);
16    let debug_sig = dev.create_vector_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN, 2);
17    loop {
18        dev.poll_and_block(Duration::from_millis(100));
19        let time = (SystemTime::now()
20            .duration_since(UNIX_EPOCH)
21            .unwrap()
22            .as_millis() as u64) as f64
23            / 1000f64;
24
25        let values = [time.sin(), time.cos()];
26        sig.set_value(&values).unwrap();
27        if debug_sig.get_status().was_set_remote() {
28            println!(
29                "Received debug message: {:?}",
30                debug_sig.get_value::<f64>().unwrap().0
31            );
32        }
33    }
34}
More examples
Hide additional examples
examples/signal.rs (line 31)
5fn main() {
6    let dev = Device::create("rustmapper");
7    loop {
8        dev.poll_and_block(Duration::from_millis(10));
9        if dev.is_ready() {
10            break;
11        }
12    }
13
14    println!("Device became ready!");
15    let mut sig = dev.create_signal::<f64>("test_sin", mpr_dir::MPR_DIR_OUT);
16    sig.set_property(mpr_prop::MPR_PROP_MIN, -1.0);
17    sig.set_property(mpr_prop::MPR_PROP_MAX, 1.0);
18    
19    let debug_sig = dev.create_signal::<f64>("debug_msg", mpr_dir::MPR_DIR_IN);
20
21    assert!(debug_sig.get_property::<f64>(mpr_prop::MPR_PROP_MIN).is_err());
22    loop {
23        dev.poll_and_block(Duration::from_millis(100));
24        let time = ((SystemTime::now()
25            .duration_since(UNIX_EPOCH)
26            .unwrap()
27            .as_millis() as u64) as f64
28            / 1000f64)
29            .sin();
30        sig.set_value_single(&time).unwrap();
31        if debug_sig.get_status().was_set_remote() {
32            println!(
33                "Received debug message: {:?}",
34                debug_sig.get_value_single::<f64>().unwrap()
35            );
36        }
37    }
38}
Source

pub fn was_set_local(&self) -> bool

Returns true if the signal was set locally since the last time the status was queried.

Source

pub fn has_value(&self) -> bool

Returns true if the signal has a value (i.e. Signal::get_value* will return Some).

Source

pub fn is_active(&self) -> bool

If the signal is active

Source

pub fn value_updated(&self) -> bool

If the actual numerical value of the signal has changed since the last time the status was queried.

Trait Implementations§

Source§

impl Clone for SignalStatus

Source§

fn clone(&self) -> SignalStatus

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 SignalStatus

Source§

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

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

impl PartialEq for SignalStatus

Source§

fn eq(&self, other: &SignalStatus) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for SignalStatus

Source§

impl Eq for SignalStatus

Source§

impl StructuralPartialEq for SignalStatus

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, 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> 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.