cu29::prelude

Trait CuSinkTask

Source
pub trait CuSinkTask<'cl>: Freezable {
    type Input: CuMsgPack<'cl>;

    // Required methods
    fn new(_config: Option<&ComponentConfig>) -> Result<Self, CuError>
       where Self: Sized;
    fn process(
        &mut self,
        _clock: &RobotClock,
        input: Self::Input,
    ) -> Result<(), CuError>;

    // Provided methods
    fn start(&mut self, _clock: &RobotClock) -> Result<(), CuError> { ... }
    fn preprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError> { ... }
    fn postprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError> { ... }
    fn stop(&mut self, _clock: &RobotClock) -> Result<(), CuError> { ... }
}
Expand description

A Sink Task is a task that only consumes messages. For example drivers for actuators are Sink Tasks.

Required Associated Types§

Required Methods§

Source

fn new(_config: Option<&ComponentConfig>) -> Result<Self, CuError>
where Self: Sized,

Here you need to initialize everything your task will need for the duration of its lifetime. The config allows you to access the configuration of the task.

Source

fn process( &mut self, _clock: &RobotClock, input: Self::Input, ) -> Result<(), CuError>

Process is the most critical execution of the task. The goal will be to produce the output message as soon as possible. Use preprocess to prepare the task to make this method as short as possible.

Provided Methods§

Source

fn start(&mut self, _clock: &RobotClock) -> Result<(), CuError>

Start is called between the creation of the task and the first call to pre/process.

Source

fn preprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError>

This is a method called by the runtime before “process”. This is a kind of best effort, as soon as possible call to give a chance for the task to do some work before to prepare to make “process” as short as possible.

Source

fn postprocess(&mut self, _clock: &RobotClock) -> Result<(), CuError>

This is a method called by the runtime after “process”. It is best effort a chance for the task to update some state after process is out of the way. It can be use for example to maintain statistics etc. that are not time-critical for the robot.

Source

fn stop(&mut self, _clock: &RobotClock) -> Result<(), CuError>

Called to stop the task. It signals that the *process method won’t be called until start is called again.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'cl, T> CuSinkTask<'cl> for CuSimSinkTask<T>
where T: CuMsgPayload + 'cl,

Source§

type Input = &'cl CuMsg<T>