1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// #![warn(missing_docs)]
//! 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.
//!
//! <div class="warning">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.</div>
//!
//! 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 std::time::Duration;
//! 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());
//! # break
//! tokio::time::sleep(Duration::from_secs(3)).await;
//! }
//! }
//! ```
//!
//! [EPICS CA protocol]:
//! https://docs.epics-controls.org/en/latest/internal/ca_protocol.html
//! [epics-base]: https://github.com/epics-base/epics-base
//! ["DBR" types]:
//! https://docs.epics-controls.org/en/latest/internal/ca_protocol.html#payload-data-types
pub use crateProvider;
pub use crateServer;
pub use crateServerBuilder;