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
impl SignalStatus
Sourcepub fn was_set_remote(&self) -> bool
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
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}
Sourcepub fn was_set_local(&self) -> bool
pub fn was_set_local(&self) -> bool
Returns true if the signal was set locally since the last time the status was queried.
Sourcepub fn has_value(&self) -> bool
pub fn has_value(&self) -> bool
Returns true if the signal has a value (i.e. Signal::get_value* will return Some).
Sourcepub fn value_updated(&self) -> bool
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
impl Clone for SignalStatus
Source§fn clone(&self) -> SignalStatus
fn clone(&self) -> SignalStatus
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SignalStatus
impl Debug for SignalStatus
Source§impl PartialEq for SignalStatus
impl PartialEq for SignalStatus
impl Copy for SignalStatus
impl Eq for SignalStatus
impl StructuralPartialEq for SignalStatus
Auto Trait Implementations§
impl Freeze for SignalStatus
impl RefUnwindSafe for SignalStatus
impl Send for SignalStatus
impl Sync for SignalStatus
impl Unpin for SignalStatus
impl UnwindSafe for SignalStatus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more