6#include <nlohmann/json.hpp>
94 std::optional<std::string>
error;
150std::vector<ProgressStep>
stepsFrom(std::initializer_list<std::string_view> ids);
182 return "stringArray";
234void to_json(nlohmann::json& j,
const ProcedureParameter& parameter);
244 nlohmann::json defaultValue, int64_t minValue,
249 nlohmann::json defaultValue);
254 nlohmann::json defaultValue, std::vector<ParameterOption> options);
264 nlohmann::json defaultValue);
274 std::string
description, nlohmann::json defaultValue);
285 nlohmann::json defaultValue);
333 void start(std::string_view
id);
337 void succeed(std::string_view
id);
345 template <
typename T>
346 void succeed(std::string_view
id,
const T& value) {
347 succeed(
id, nlohmann::json(value));
351 void succeed(std::string_view
id, nlohmann::json value);
354 void fail(std::string_view
id, std::string error);
357 std::vector<ProgressStep>
steps()
const;
360 mutable std::mutex mutex_;
361 std::vector<ProgressStep> steps_;
The handle a procedure body uses to report where it has got to.
Definition procedure.h:327
std::vector< ProgressStep > steps() const
A copy of the current step array — the snapshot's steps.
Definition procedure.cc:63
void succeed(std::string_view id, const T &value)
Marks the step id as succeeded, recording what it produced.
Definition procedure.h:346
void start(std::string_view id)
Marks the step id as running, clearing any value or error left by a previous run.
Definition procedure.cc:32
void fail(std::string_view id, std::string error)
Marks the step id as failed, recording error as the reason.
Definition procedure.cc:54
ProgressReporter(std::vector< ProgressStep > steps)
Seeds the reporter from a procedure's step template.
Definition procedure.h:330
void succeed(std::string_view id)
Marks the step id as succeeded with no value — the step did something rather than measured something.
Definition procedure.cc:42
std::string description
Catalogue description of the block.
Definition eni_request.cc:38
std::string name
Catalogue name, e.g. "sm2".
Definition eni_request.cc:37
Definition bus_health_source.h:7
ProcedureParameter stringParameter(std::string name, std::string title, std::string description, nlohmann::json defaultValue)
A free-text parameter. defaultValue as in integerParameter.
Definition procedure.cc:200
std::string_view toString(FirmwareMatch match)
What a match is called, for a message or a JSON body: "none", "assembly", "device".
Definition firmware_package.cc:295
ProcedureStatus
Overall status of a procedure run — the single field a polling client checks.
Definition procedure.h:48
@ kRunning
A run is in progress.
@ kSucceeded
The last run completed successfully.
@ kCancelled
The last run was stopped by the user before it finished.
@ kFailed
The last run failed; the failing step carries the reason.
@ kIdle
Never run on this device (or cleared by a rescan).
ProcedureParameter stringArrayParameter(std::string name, std::string title, std::string description, nlohmann::json defaultValue)
A parameter taking a list of strings, which the client renders as an editable list.
Definition procedure.cc:211
void to_json(nlohmann::json &j, const Cia402Status &s)
Serialises a Cia402Status. Emits state/modeName as human-readable strings alongside the numeric statu...
Definition cia402_drive.cc:13
ProcedureParameter enumParameter(std::string name, std::string title, std::string description, nlohmann::json defaultValue, std::vector< ParameterOption > options)
A parameter whose value is one of options. defaultValue as in integerParameter, and it should be one ...
Definition procedure.cc:176
ProgressStatus
Status of one step within a procedure.
Definition procedure.h:20
@ kRunning
Started and not yet finished.
@ kSucceeded
Finished; ProgressStep::value carries its measurement, if it has one.
@ kFailed
Finished badly; ProgressStep::error says why.
@ kIdle
Not started (the initial state of every step in a template).
ParameterType
What kind of value a procedure parameter takes — the client's cue for which control to render,...
Definition procedure.h:158
@ kFile
A file's contents, base64-encoded; a client renders a file picker.
@ kByteArray
Exactly length byte values (the raw OS command's request bytes).
@ kString
Free text — a filename, a label.
@ kEnum
One of options — a value the client picks rather than types.
@ kInteger
A whole number, bounded by minValue / maxValue.
@ kStringArray
A list of free-text values the user edits as a list.
ProcedureParameter integerParameter(std::string name, std::string title, std::string description, nlohmann::json defaultValue, int64_t minValue, int64_t maxValue)
A whole-number parameter accepting minValue to maxValue inclusive.
Definition procedure.cc:151
ProcedureParameter byteArrayParameter(std::string name, std::string title, std::string description, size_t length)
A parameter taking exactly length byte values.
Definition procedure.cc:189
ProcedureParameter fileParameter(std::string name, std::string title, std::string description, nlohmann::json defaultValue)
A parameter carrying a whole file, base64-encoded in a JSON string.
Definition procedure.cc:222
ProcedureSnapshot idleSnapshot(std::vector< ProgressStep > steps)
A well-formed snapshot for a procedure that never ran — idle, no timestamps, and every step idle from...
Definition procedure.cc:94
ProcedureParameter booleanParameter(std::string name, std::string title, std::string description, nlohmann::json defaultValue)
A true/false parameter. defaultValue as in integerParameter.
Definition procedure.cc:165
std::vector< ProgressStep > stepsFrom(std::initializer_list< std::string_view > ids)
A procedure's step template: the given ids, in order, all idle.
Definition procedure.cc:83
std::string_view step
Definition somanet_procedures.cc:427
One choice of a kEnum parameter: the value that goes on the wire, and its label.
Definition procedure.h:190
std::string title
What the user picks, e.g. "Encoder 1".
Definition procedure.h:192
nlohmann::json value
What the request body carries when this option is chosen.
Definition procedure.h:191
What a procedure is, independent of any run — the half of the catalogue a client needs to render a co...
Definition procedure.h:298
std::string description
What the procedure does, in a sentence or two.
Definition procedure.h:301
std::vector< ProgressStep > steps
Definition procedure.h:313
std::vector< ProcedureParameter > parameters
Definition procedure.h:309
std::vector< std::string > caveats
What a user must know before running it; may be empty.
Definition procedure.h:302
bool requiresEnabled
True if the drive must be enabled first.
Definition procedure.h:304
std::string title
Short human-readable name, e.g. "OS command".
Definition procedure.h:300
bool movesMotor
True if running it can move the shaft.
Definition procedure.h:303
std::string name
Identifier: the URL segment, and the key its snapshot is retained under.
Definition procedure.h:299
One named parameter a procedure accepts — enough for a client to render a field for it and for a user...
Definition procedure.h:217
ParameterType type
Definition procedure.h:221
std::vector< ParameterOption > options
kEnum only — the values that may be chosen.
Definition procedure.h:229
std::optional< size_t > length
kByteArray only — the exact number of bytes.
Definition procedure.h:228
std::string name
The key in the request body, e.g. "registerAddress".
Definition procedure.h:218
std::optional< int64_t > maxValue
kInteger only — largest accepted value.
Definition procedure.h:227
nlohmann::json defaultValue
What the procedure uses when the request omits this parameter; null makes it required.
Definition procedure.h:224
bool required() const
Whether a request must carry this parameter — true exactly when it has no default.
Definition procedure.h:232
std::string title
Short label, e.g. "Register address".
Definition procedure.h:219
std::string description
What it does and what a sensible value is.
Definition procedure.h:220
std::optional< int64_t > minValue
kInteger only — smallest accepted value.
Definition procedure.h:226
The complete state of a procedure on one device — everything a client polling GET /api/devices/:pos/p...
Definition procedure.h:111
std::optional< int64_t > startedAt
Epoch ms the run began; absent when never run.
Definition procedure.h:123
std::optional< int64_t > finishedAt
Epoch ms the run ended; absent while running.
Definition procedure.h:124
uint32_t runCount
How many runs this device accepted since the last rescan (a rejected start does not count).
Definition procedure.h:121
std::vector< ProgressStep > steps
The ordered step array, always the full template.
Definition procedure.h:125
ProcedureStatus status
The one field a polling loop checks.
Definition procedure.h:112
std::optional< std::string > error
Why the run failed, when no step captured it.
Definition procedure.h:133
One step of a procedure — an entry in the fixed, ordered array a procedure publishes.
Definition procedure.h:90
std::optional< std::string > error
Why the step failed.
Definition procedure.h:94
nlohmann::json value
What the step produced; null if nothing.
Definition procedure.h:93
std::string id
Stable identifier, e.g. "phase-resistance".
Definition procedure.h:91
ProgressStatus status
How far this step got.
Definition procedure.h:92