Crate epicars

Crate epicars 

Source
Expand description

Rust implementation of EPICS CA protocol and basic variable access layers.

This crate is a pure-rust implementation of the EPICS CA protocol. It does not depend on the C-based epics-base project at all.

This is a very early version of this library. Interfaces or structure may be changed around wildly between versions until a comfortable final design is settled upon.

Whereas the full model of IOC and the EPICS database is extremely flexible and expansive, that comes at a complexity and tooling cost that is not necessary for a lot of smaller projects that just want to expose the ability to have a couple of variables exposed via what is likely the designated control layer for the facility.

EPICArs approaches the problem by separating:

  • Mapping and serialization/deserialization of message types, in module messages.
  • Representing data for transferring back and forth (“DBR” types) via CA in module dbr.
  • A Server that manages connection lifecycles and other connection protocols.
  • Provider, a trait that Server uses to talk to values in your application.
  • Example providers that provide built-in simple approaches to managing exposed variables. Included at this time are:
    • providers::IntercomProvider: Provides access objects to access record data as a natively mapped data type. The access objects can be cloned and passed across thread boundaries, and retain access to the same data (internally stored in an Arc<Mutex<dbr::DbrValue>>).

§Example

Here is an example of exposing a basic single i32 via the providers::IntercomProvider. You can run this and then caget NUMERIC_VALUE or caput NUMERIC_VALUE <new_value> from anywhere inside the same broadcast network:

use epicars::{ServerBuilder, providers::IntercomProvider};

#[tokio::main]
async fn main() {
    let mut provider = IntercomProvider::new();
    let mut value = provider.add_pv("NUMERIC_VALUE", 42i32).unwrap();
    let _server = ServerBuilder::new(provider).start().await.unwrap();
    loop {
        value.store(&(value.load() + 1));
        println!("Value is now: {}", value.load());
        tokio::time::sleep(Duration::from_secs(3)).await;
    }
}

Re-exports§

pub use crate::providers::Provider;

Modules§

dbr
Represent CA DBR representations, for data interchange.
messages
Implementations of CA message types and utilities to constrct/[de]serialize them
providers
Interface between the CA Server and rust code

Structs§

Server
Serve data to CA clients by managing the Circuit/Channel lifecycles and interfacing with Provider.
ServerBuilder
Construct a Server object by setting up multiple aspects before running