45 releases

new 0.1.45 Apr 20, 2024
0.1.44 Apr 20, 2024
0.1.23 Mar 31, 2024

#141 in Concurrency

Download history 415/week @ 2024-03-02 1038/week @ 2024-03-09 473/week @ 2024-03-16 520/week @ 2024-03-23 1037/week @ 2024-03-30 541/week @ 2024-04-06

2,896 downloads per month
Used in 2 crates

Apache-2.0

190KB
5K SLoC

RoboPLC crates.io page docs.rs page

RoboPLC is an ultimate pack of a framework and tools for creating real-time micro-services, PLCs and industrial-grade robots in Rust.

The crate is designed to let using all its components both separately and together.

RoboPLC is a part of EVA ICS industrial automation platform.

Technical documentation

Available at https://info.bma.ai/en/actual/roboplc/index.html

Examples

Can be found at https://github.com/roboplc/roboplc/tree/main/examples

DataBuffer

buf::DataBuffer covers a typical data exchange pattern when data frames are collected (cached) from a single or multiple producers, then taken by a single consumer in bulk and submitted, e.g. into a local database or into an external bus.

  • always has got a fixed capacity

  • thread-safe out-of-the-box

  • frames may be forcibly pushed, overriding the previous ones, like in a ring-buffer.

Hub

hub::Hub implements a data-hub (in-process pub/sub) model, when multiple clients (usually thread workers) exchange data via a single virtual bus instead of using direct channels.

This brings some additional overhead into data exchange, however makes the architecture significantly clearer, lowers code support costs and brings additional features.

  • classic pub/sub patterns with no data serialization overhead

  • based on pchannel which allows to mix different kinds of data and apply additional policies if required

  • a fully passive model with no "server" thread.

pdeque and pchannel

A policy-based deque pdeque::Deque is a component to build policy-based channels.

pchannel is a channel module, based on the policy-based deque.

Data policies supported:

  • Always a frame is always delivered
  • Latest a frame is always delivered, previous are dropped if no room (acts like a ring-buffer)
  • Optional a frame can be skipped if no room
  • Single a frame must be delivered only once (the latest one)
  • SingleOptional a frame must be delivered only once (the latest one) and is optional

Additionally, components support ordering by data priority and automatically drop expired data if the data type has got an expiration marker method implemented.

pchannel is a real-time safe channel, mean it may be not so fast as popular channel implementations (it may be even slower than channels provided by std::sync::mpsc). But it is completely safe for real-time applications, mean there are no spin loops, data is always delivered with minimal latency and threads do not block each other.

Real-time

thread_rt::Builder provides a thread builder component, which extends the standard thread builder with real-time capabilities: scheduler policies and CPU affinity (Linux only).

supervisor::Supervisor provides a lightweight task supervisor to manage launched threads.

Controller

controller::Controller is the primary component of mixing up all the functionality together.

I/O

[io] module provides a set of tools to work with field devices and SCADA buses.

Currently supported:

Dependencies

~8–46MB
~712K SLoC