STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp Struct Reference

Everything one run needs, so the recursive walk can be free functions over one struct. More...

Collaboration diagram for sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp:
[legend]

Public Member Functions

bool stopped () const
double elapsed () const
bool pastDeadline () const
bool sleep (double seconds)
 Wait seconds, or until stopped / the deadline, whichever comes first.
std::string describeCondition (int32_t idx)
 The condition's operands as text, e.g.
bool eval (int32_t idx, double &out)
Flow execBlock (int32_t begin, int32_t end)
Flow exec (int32_t idx)

Static Public Member Functions

static const char * opText (Op op)
 Comparison operators, for the condition text in the log.

Public Attributes

const ScriptProgram & prog
const DynamicState & ds
const ScriptEnv & env
std::atomic< bool > & stop
std::mutex & mtx
std::condition_variable & cv
ScriptRunner::Clock::time_point started_at
ScriptRunner::Clock::time_point deadline
std::map< std::string, double > vars
uint64_t iterations = 0
uint64_t loop_passes = 0
 Completed passes of the outermost loop, and the last condition rendered — both exist so the end-of-run line can say how far it got and what the deciding numbers were.
std::string last_condition
std::string error
 Set when something went wrong; names it for the log.

Detailed Description

Everything one run needs, so the recursive walk can be free functions over one struct.

Definition at line 127 of file ScriptRunner.cpp.

Member Function Documentation

◆ describeCondition()

std::string sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::describeCondition ( int32_t idx)
inline

The condition's operands as text, e.g.

"117.7 < 82.1".

A probe, not part of evaluation: it re-evaluates the two sides and RESTORES error, so a failing read here can never invent a run-ending error that the real evaluation did not hit. Safe to repeat because expressions in this language have no side effects — pressure() is a guarded map read of the latest sample, and there is no assignment inside an expression. Returns empty for anything that is not a comparison, and the caller then simply omits the parenthetical.

Definition at line 205 of file ScriptRunner.cpp.

References a, b, error, eval(), fsw::script::Expr::kind, fsw::script::Expr::lhs, ok, fsw::script::Expr::op, opText(), prog, and fsw::script::Expr::rhs.

Referenced by exec().

◆ elapsed()

double sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::elapsed ( ) const
inline

Definition at line 171 of file ScriptRunner.cpp.

References started_at.

◆ eval()

bool sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::eval ( int32_t idx,
double & out )
inline

◆ exec()

◆ execBlock()

Flow sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::execBlock ( int32_t begin,
int32_t end )
inline

◆ opText()

const char * sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::opText ( Op op)
inlinestatic

Comparison operators, for the condition text in the log.

Non-comparisons return null.

Definition at line 148 of file ScriptRunner.cpp.

Referenced by describeCondition().

◆ pastDeadline()

bool sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::pastDeadline ( ) const
inline

Definition at line 175 of file ScriptRunner.cpp.

References deadline.

Referenced by exec(), execBlock(), and sleep().

◆ sleep()

bool sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::sleep ( double seconds)
inline

Wait seconds, or until stopped / the deadline, whichever comes first.

Returns
false if the run should end.

Definition at line 181 of file ScriptRunner.cpp.

References cv, deadline, sequencer::anonymous_namespace{ScriptRunner.cpp}::kMinDelaySeconds, lk, mtx, pastDeadline(), stop, and until().

Referenced by exec().

◆ stopped()

bool sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::stopped ( ) const
inline

Definition at line 167 of file ScriptRunner.cpp.

References stop.

Referenced by exec(), and execBlock().

Member Data Documentation

◆ cv

std::condition_variable& sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::cv

Definition at line 133 of file ScriptRunner.cpp.

Referenced by feedtwin.props.state.ThermoState::gamma(), and sleep().

◆ deadline

ScriptRunner::Clock::time_point sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::deadline

Definition at line 135 of file ScriptRunner.cpp.

Referenced by pastDeadline(), and sleep().

◆ ds

const DynamicState& sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::ds

Definition at line 129 of file ScriptRunner.cpp.

Referenced by eval(), and exec().

◆ env

const ScriptEnv& sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::env

Definition at line 130 of file ScriptRunner.cpp.

Referenced by eval(), and exec().

◆ error

std::string sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::error

Set when something went wrong; names it for the log.

Definition at line 145 of file ScriptRunner.cpp.

Referenced by test_ota_flash.FakeBoard::bind(), describeCondition(), eval(), exec(), execBlock(), test_ota_flash.FakeBoard::run(), and backend.routers.layerx.Job::view().

◆ iterations

uint64_t sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::iterations = 0

Definition at line 138 of file ScriptRunner.cpp.

Referenced by exec().

◆ last_condition

std::string sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::last_condition

Definition at line 143 of file ScriptRunner.cpp.

Referenced by exec().

◆ loop_passes

uint64_t sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::loop_passes = 0

Completed passes of the outermost loop, and the last condition rendered — both exist so the end-of-run line can say how far it got and what the deciding numbers were.

Without them a timeout and a loop that never ran are the same single word in the journal.

Definition at line 142 of file ScriptRunner.cpp.

Referenced by exec().

◆ mtx

std::mutex& sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::mtx

Definition at line 132 of file ScriptRunner.cpp.

Referenced by sleep().

◆ prog

const ScriptProgram& sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::prog

Definition at line 128 of file ScriptRunner.cpp.

Referenced by describeCondition(), eval(), exec(), and execBlock().

◆ started_at

ScriptRunner::Clock::time_point sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::started_at

Definition at line 134 of file ScriptRunner.cpp.

Referenced by elapsed().

◆ stop

std::atomic<bool>& sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::stop

Definition at line 131 of file ScriptRunner.cpp.

Referenced by sleep(), and stopped().

◆ vars

std::map<std::string, double> sequencer::anonymous_namespace{ScriptRunner.cpp}::Interp::vars

Definition at line 137 of file ScriptRunner.cpp.

Referenced by eval(), and exec().


The documentation for this struct was generated from the following file: