Struct Config

Source
pub struct Config<TMessage, I, Q, S>
where TMessage: MsgDataBound, I: Clone + Default + Serialize, Q: Clone + Default + Serialize, S: Clone + Default + Serialize, FunctionBlockBase<I, Q, S>: IFunctionBlock<I, Q, S>,
{ pub fn_input: fn(&mut I, &Message<TMessage>), pub fn_output: fn(&Q) -> Vec<Message<TMessage>>, pub fb_main: FunctionBlockBase<I, Q, S>, pub period: Duration, }
Expand description

Конфигурация компонента ПЛК

§Шаблон функционального блока

//! Шаблон для нового функционального блока

use serde::{Deserialize, Serialize};

use crate::plc::function_block_base::{FunctionBlockBase, IFunctionBlock};

#[derive(Clone, Default, Deserialize, Serialize)] pub struct I {}

#[derive(Clone, Default, Deserialize, Serialize)] pub struct Q {}

#[derive(Clone, Default, Deserialize, Serialize)] pub struct S {}

impl IFunctionBlock<I, Q, S> for FunctionBlockBase<I, Q, S> { fn logic(_input: &I, _stat: &mut S) -> Q { Q {} } }

#[allow(dead_code)] pub type FB = FunctionBlockBase<I, Q, S>;

Fields§

§fn_input: fn(&mut I, &Message<TMessage>)

Функция преобразования входящих сообщений во входную структуру ПЛК.

§Примеры

fn_input: |input: &mut fb_main::I, msg: &TMessage| match msg {}
§fn_output: fn(&Q) -> Vec<Message<TMessage>>

Функция преобразования выходной структуры ПЛК в исходящие сообщения.

§Примеры

fn_output: |output: &fb_main::Q| vec![]
§fb_main: FunctionBlockBase<I, Q, S>

Главный функциональный блок ПЛК

§Примеры

fb_main: fb_main::FB::new()
§period: Duration

Периодичность выполнения логики ПЛК

§Примеры

period: Duration::from_millis(100)

Trait Implementations§

Source§

impl<TMessage, I, Q, S> Clone for Config<TMessage, I, Q, S>
where TMessage: MsgDataBound + Clone, I: Clone + Default + Serialize + Clone, Q: Clone + Default + Serialize + Clone, S: Clone + Default + Serialize + Clone, FunctionBlockBase<I, Q, S>: IFunctionBlock<I, Q, S>,

Source§

fn clone(&self) -> Config<TMessage, I, Q, S>

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<TMsg, I, Q, S> IComponentProcess<Config<TMsg, I, Q, S>, TMsg> for Component<Config<TMsg, I, Q, S>, TMsg>
where TMsg: MsgDataBound + 'static, I: Clone + Default + Send + Serialize + 'static + Sync, Q: Clone + Default + Send + Serialize + 'static + Sync, S: Clone + Default + Send + Serialize + 'static + Sync, FunctionBlockBase<I, Q, S>: IFunctionBlock<I, Q, S>,

Source§

fn process<'life0, 'async_trait>( &'life0 self, config: Config<TMsg, I, Q, S>, in_out: CmpInOut<TMsg>, ) -> Pin<Box<dyn Future<Output = Result<(), ComponentError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

§

impl<TMessage, I, Q, S> Freeze for Config<TMessage, I, Q, S>
where I: Freeze, Q: Freeze, S: Freeze,

§

impl<TMessage, I, Q, S> RefUnwindSafe for Config<TMessage, I, Q, S>

§

impl<TMessage, I, Q, S> Send for Config<TMessage, I, Q, S>
where I: Send, Q: Send, S: Send,

§

impl<TMessage, I, Q, S> Sync for Config<TMessage, I, Q, S>
where I: Sync, Q: Sync, S: Sync,

§

impl<TMessage, I, Q, S> Unpin for Config<TMessage, I, Q, S>
where I: Unpin, Q: Unpin, S: Unpin,

§

impl<TMessage, I, Q, S> UnwindSafe for Config<TMessage, I, Q, S>
where I: UnwindSafe, Q: UnwindSafe, S: UnwindSafe,

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