[][src]Struct dwfv::signaldb::Signal

pub struct Signal {
    pub id: String,
    pub name: String,
    pub width: usize,
    pub path: Vec<String>,
    // some fields omitted
}

Representation of a single signal

Fields

id: String

Identifier of the signal

name: String

Full name of the signal

width: usize

Width of the signal in bits

path: Vec<String>

Implementations

impl Signal[src]

pub fn new(id: &str, name: &str, width: usize) -> Signal[src]

Create a new Signal.

Example

use dwfv::signaldb::Signal;
let signal = Signal::new("0", "foo", 32);
assert_eq!(signal.id, "0");
assert_eq!(signal.name, "foo");
assert_eq!(signal.width, 32);

pub fn add_event(&mut self, timestamp: Timestamp, new_value: SignalValue)[src]

Add an event in the Signal

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 32);
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(1337));

pub fn value_at(&self, timestamp: Timestamp) -> SignalValue[src]

Get value of the Signal at a given time.

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 32);
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(1337));
assert_eq!(signal.value_at(Timestamp::new(43, Scale::Picosecond)), SignalValue::new(1337));

pub fn event_at(&self, timestamp: Timestamp) -> Option<SignalValue>[src]

Get event of the Signal reported at a given time.

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 32);
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(1337));
assert_eq!(
    signal.event_at(Timestamp::new(42, Scale::Picosecond)).unwrap(),
    SignalValue::new(1337)
);
assert_eq!(signal.event_at(Timestamp::new(43, Scale::Picosecond)).is_none(), true);

pub fn events_between(
    &self,
    begin: Timestamp,
    end: Timestamp
) -> (SignalValue, usize, SignalValue)
[src]

Get summary of the events for a time period.

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 32);
signal.add_event(Timestamp::new(0, Scale::Picosecond), SignalValue::new(0));
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(1337));
signal.add_event(Timestamp::new(43, Scale::Picosecond), SignalValue::new(1338));
assert_eq!(
    signal.events_between(
        Timestamp::new(40, Scale::Picosecond), Timestamp::new(45, Scale::Picosecond)
    ),
    (SignalValue::new(0), 2, SignalValue::new(1338))
)

pub fn get_next_rising_edge(&self, timestamp: Timestamp) -> Option<Timestamp>[src]

Get the timestamp of the next rising edge.

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 1);
signal.add_event(Timestamp::new(0, Scale::Picosecond), SignalValue::new(0));
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(1));
signal.add_event(Timestamp::new(43, Scale::Picosecond), SignalValue::new(0));

assert_eq!(
    signal.get_next_rising_edge(Timestamp::new(40, Scale::Picosecond)).unwrap(),
    Timestamp::new(42, Scale::Picosecond)
);
assert_eq!(signal.get_next_rising_edge(
    Timestamp::new(43, Scale::Picosecond)).is_none(),
    true
);

assert_eq!(signal.get_previous_rising_edge(
    Timestamp::new(44, Scale::Picosecond)).unwrap(), Timestamp::new(42, Scale::Picosecond)
);
assert_eq!(
    signal.get_previous_rising_edge(Timestamp::new(40, Scale::Picosecond)).is_none(),
    true
);

assert_eq!(
    signal.get_next_falling_edge(Timestamp::new(40, Scale::Picosecond)).unwrap(),
    Timestamp::new(43, Scale::Picosecond)
);
assert_eq!(
    signal.get_next_falling_edge(Timestamp::new(44, Scale::Picosecond)).is_none(),
    true
);

assert_eq!(signal.get_first_event().unwrap(), Timestamp::new(0, Scale::Picosecond));
assert_eq!(signal.get_last_event().unwrap(), Timestamp::new(43, Scale::Picosecond));

pub fn get_next_falling_edge(&self, timestamp: Timestamp) -> Option<Timestamp>[src]

Get the timestamp of the next falling edge.

Example

See get_next_rising_edge.

pub fn get_previous_rising_edge(
    &self,
    timestamp: Timestamp
) -> Option<Timestamp>
[src]

Get the timestamp of the previous rising edge.

Example

See get_next_rising_edge.

pub fn get_first_event(&self) -> Option<Timestamp>[src]

Get the timestamp of the first event.

Example

See get_next_rising_edge.

pub fn get_last_event(&self) -> Option<Timestamp>[src]

Get the timestamp of the last event.

Example

See get_next_rising_edge.

pub fn format_stats(&self, output: &mut dyn Write)[src]

Format some stats of the signal.

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 32);
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(1337));
signal.add_event(Timestamp::new(43, Scale::Picosecond), SignalValue::new(1338));

let mut buf = Vec::new();
signal.format_stats(&mut buf);
assert_eq!(
    String::from_utf8(buf).unwrap(),
    "0 (foo) - width: 32, edges: 2, from: 42ps, to: 43ps\n"
)

pub fn format_value_at(&self, output: &mut dyn Write, timestamp: Timestamp)[src]

Format the value of a signal at a given time.

Example

use dwfv::signaldb::{Scale, Signal, SignalValue, Timestamp};
let mut signal = Signal::new("0", "foo", 32);
signal.add_event(Timestamp::new(42, Scale::Picosecond), SignalValue::new(0x1337));

let mut buf = Vec::new();
signal.format_value_at(&mut buf, Timestamp::new(43, Scale::Picosecond));
assert_eq!(
    String::from_utf8(buf).unwrap(),
    "0 (foo) = h00001337\n"
)

pub fn get_fullname(&self) -> String[src]

Construct the fullname of the signal.

Example

use dwfv::signaldb::{Signal, SignalDB};
let mut signal = Signal::new("0", "foo", 32);

assert_eq!(signal.get_fullname(), "foo[:32]")

Trait Implementations

impl Display for Signal[src]

Auto Trait Implementations

impl RefUnwindSafe for Signal

impl Send for Signal

impl Sync for Signal

impl Unpin for Signal

impl UnwindSafe for Signal

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.