Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
mm::node::ProgressReporter Class Reference

The handle a procedure body uses to report where it has got to. More...

#include <procedure.h>

Public Member Functions

 ProgressReporter (std::vector< ProgressStep > steps)
 Seeds the reporter from a procedure's step template.
 
void start (std::string_view id)
 Marks the step id as running, clearing any value or error left by a previous run.
 
void succeed (std::string_view id)
 Marks the step id as succeeded with no value — the step did something rather than measured something.
 
template<typename T >
void succeed (std::string_view id, const T &value)
 Marks the step id as succeeded, recording what it produced.
 
void succeed (std::string_view id, nlohmann::json value)
 Marks the step id as succeeded with an already-built JSON value.
 
void fail (std::string_view id, std::string error)
 Marks the step id as failed, recording error as the reason.
 
std::vector< ProgressStepsteps () const
 A copy of the current step array — the snapshot's steps.
 

Detailed Description

The handle a procedure body uses to report where it has got to.

A body is a plain function over one of these — runXxx(SomanetDrive&, ProgressReporter&, std::stop_token) — which is what keeps the orchestration transport-free and testable: a test drives the body with its own reporter and asserts the resulting step array, with no manager, no thread, and no HTTP anywhere near it.

Seeded from the procedure's step template (ids in order, all kIdle) and mutated in place as the run progresses. Thread-safe: the body writes from its own thread while a poll reads steps from an HTTP thread.

Constructor & Destructor Documentation

◆ ProgressReporter()

mm::node::ProgressReporter::ProgressReporter ( std::vector< ProgressStep steps)
inlineexplicit

Seeds the reporter from a procedure's step template.

Member Function Documentation

◆ fail()

void mm::node::ProgressReporter::fail ( std::string_view  id,
std::string  error 
)

Marks the step id as failed, recording error as the reason.

◆ start()

void mm::node::ProgressReporter::start ( std::string_view  id)

Marks the step id as running, clearing any value or error left by a previous run.

◆ steps()

std::vector< ProgressStep > mm::node::ProgressReporter::steps ( ) const

A copy of the current step array — the snapshot's steps.

◆ succeed() [1/3]

void mm::node::ProgressReporter::succeed ( std::string_view  id)

Marks the step id as succeeded with no value — the step did something rather than measured something.

◆ succeed() [2/3]

template<typename T >
void mm::node::ProgressReporter::succeed ( std::string_view  id,
const T &  value 
)
inline

Marks the step id as succeeded, recording what it produced.

value is anything convertible to JSON: a number, a string, a byte vector, or — the usual case for a measurement — a procedure-specific struct with its own to_json declared beside the procedure. The conversion happens here so each body keeps its own typed vocabulary without every procedure needing a distinct step or snapshot type.

◆ succeed() [3/3]

void mm::node::ProgressReporter::succeed ( std::string_view  id,
nlohmann::json  value 
)

Marks the step id as succeeded with an already-built JSON value.


The documentation for this class was generated from the following files: