epics_seq/variables.rs
1use epics_base_rs::types::EpicsValue;
2
3/// Trait implemented by generated program variable structs.
4///
5/// Each SNL program generates a struct holding all program variables.
6/// This trait provides channel-value accessors so the runtime can
7/// transfer values between the channel store and the local snapshot.
8pub trait ProgramVars: Clone + Send + Sync + 'static {
9 /// Read the value of a channel-assigned variable.
10 fn get_channel_value(&self, ch_id: usize) -> EpicsValue;
11
12 /// Write a channel value into the local variable.
13 fn set_channel_value(&mut self, ch_id: usize, value: &EpicsValue);
14}
15
16/// Channel definition: static metadata from the compiled program.
17#[derive(Debug, Clone)]
18pub struct ChannelDef {
19 /// Variable name in the SNL source.
20 pub var_name: String,
21 /// PV name template (may contain macros like {P}).
22 pub pv_name: String,
23 /// Whether this channel has a `monitor` declaration.
24 pub monitored: bool,
25 /// Event flag id synced to this channel (via `sync`), if any.
26 pub sync_ef: Option<usize>,
27}
28
29/// Static program metadata provided by generated code.
30pub trait ProgramMeta {
31 const NUM_CHANNELS: usize;
32 const NUM_EVENT_FLAGS: usize;
33 const NUM_STATE_SETS: usize;
34
35 fn channel_defs() -> Vec<ChannelDef>;
36
37 /// Maps event flag id → list of synced channel ids.
38 fn event_flag_sync_map() -> Vec<Vec<usize>>;
39}