pub struct StateSetContext<V: ProgramVars> {
pub local_vars: V,
pub ss_id: usize,
/* private fields */
}Expand description
Context for a single state set’s execution.
Each state set runs as an independent tokio task with its own
local variable snapshot. The main loop evaluates when conditions
and performs state transitions.
Fields§
§local_vars: VLocal variable snapshot — updated from channel store at sync points.
ss_id: usizeState set index.
Implementations§
Source§impl<V: ProgramVars> StateSetContext<V>
impl<V: ProgramVars> StateSetContext<V>
pub fn new( initial_vars: V, ss_id: usize, num_channels: usize, wakeup: Arc<Notify>, store: Arc<ChannelStore>, channels: Arc<Vec<Channel>>, event_flags: Arc<EventFlagSet>, shutdown: Arc<AtomicBool>, ) -> Self
Sourcepub fn dirty_flags(&self) -> Arc<Vec<AtomicBool>>
pub fn dirty_flags(&self) -> Arc<Vec<AtomicBool>>
Get a clone of the dirty flags Arc (needed for monitor setup).
Sourcepub fn current_state(&self) -> usize
pub fn current_state(&self) -> usize
Get the current state index.
Sourcepub fn transition_to(&mut self, state: usize)
pub fn transition_to(&mut self, state: usize)
Signal a transition to a new state. The transition completes after the current when-action finishes.
Sourcepub fn has_transition(&self) -> bool
pub fn has_transition(&self) -> bool
Check if a transition is pending.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Check if shutdown was requested.
Sourcepub fn delay(&mut self, seconds: f64) -> bool
pub fn delay(&mut self, seconds: f64) -> bool
SNL delay(t) — returns true if enough time has elapsed since
entering the current state.
If not yet elapsed, registers a wakeup at the remaining time so the state set re-evaluates when the delay expires.
Sourcepub async fn pv_get(&mut self, ch_id: usize, comp: CompType) -> PvStat
pub async fn pv_get(&mut self, ch_id: usize, comp: CompType) -> PvStat
pvGet: read value from IOC via CA.
Default/Sync: synchronous with 5s timeout. Returns PvStat.Async: starts background task. Check withpv_get_complete().
Sourcepub async fn pv_put(&mut self, ch_id: usize, comp: CompType) -> PvStat
pub async fn pv_put(&mut self, ch_id: usize, comp: CompType) -> PvStat
pvPut: write local var value to IOC via CA.
Default: fire-and-forget (start put, don’t wait). Returns PvStat.Sync: synchronous with 5s timeout.Async: starts background task. Check withpv_put_complete().
Sourcepub async fn pv_get_complete(&mut self, ch_id: usize) -> bool
pub async fn pv_get_complete(&mut self, ch_id: usize) -> bool
Check if async pvGet has completed. If safe mode, copies value from store. Returns true if complete (idempotent — can be called multiple times).
Sourcepub async fn pv_put_complete(&mut self, ch_id: usize) -> bool
pub async fn pv_put_complete(&mut self, ch_id: usize) -> bool
Check if async pvPut has completed.
Sourcepub async fn pv_get_cancel(&mut self, ch_id: usize)
pub async fn pv_get_cancel(&mut self, ch_id: usize)
Cancel pending async pvGet.
Sourcepub async fn pv_put_cancel(&mut self, ch_id: usize)
pub async fn pv_put_cancel(&mut self, ch_id: usize)
Cancel pending async pvPut.
Sourcepub fn pv_status(&self, ch_id: usize) -> PvStat
pub fn pv_status(&self, ch_id: usize) -> PvStat
Get the PvStat of the last completed operation on a channel.
Sourcepub fn pv_severity(&self, ch_id: usize) -> i16
pub fn pv_severity(&self, ch_id: usize) -> i16
Get the severity of the last completed operation on a channel.
Sourcepub fn pv_message(&self, ch_id: usize) -> Option<&str>
pub fn pv_message(&self, ch_id: usize) -> Option<&str>
Get the message of the last completed operation on a channel.
Sourcepub fn ef_test(&mut self, ef_id: usize) -> bool
pub fn ef_test(&mut self, ef_id: usize) -> bool
Test an event flag. If true, also performs selective sync of channels synced to this flag.
Sourcepub fn ef_test_and_clear(&mut self, ef_id: usize) -> bool
pub fn ef_test_and_clear(&mut self, ef_id: usize) -> bool
Test and clear an event flag atomically. If was set, also performs selective sync.
Sourcepub fn pv_connected(&self, ch_id: usize) -> bool
pub fn pv_connected(&self, ch_id: usize) -> bool
Check if a specific channel is connected.
Sourcepub fn pv_connect_count(&self) -> usize
pub fn pv_connect_count(&self) -> usize
Count of connected channels.
Sourcepub fn pv_channel_count(&self) -> usize
pub fn pv_channel_count(&self) -> usize
Total channel count.
Sourcepub fn sync_dirty_vars(&mut self)
pub fn sync_dirty_vars(&mut self)
Synchronize all dirty channel values from the store into local_vars. Called once per when-evaluation cycle to maintain snapshot atomicity.
Sourcepub fn reset_wakeup(&mut self)
pub fn reset_wakeup(&mut self)
Reset wakeup timer for a new evaluation cycle.
Sourcepub async fn wait_for_wakeup(&self)
pub async fn wait_for_wakeup(&self)
Wait for the next wakeup event (notification, timeout, or shutdown).
Sourcepub fn enter_state(&mut self, state: usize)
pub fn enter_state(&mut self, state: usize)
Enter a new state: reset time_entered and clear transition.
Sourcepub fn should_run_entry(&self) -> bool
pub fn should_run_entry(&self) -> bool
Should entry actions run? (prev_state != current_state)
Sourcepub fn should_run_exit(&self) -> bool
pub fn should_run_exit(&self) -> bool
Should exit actions run? (next_state != current_state)
Sourcepub fn take_transition(&mut self) -> Option<usize>
pub fn take_transition(&mut self) -> Option<usize>
Consume the pending transition, returning the target state.