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

Every procedure the server knows, and the four operations a client performs against it. More...

#include <procedure_registry.h>

Public Member Functions

 ProcedureRegistry (DeviceManager &deviceManager, ProcedureManager &procedureManager, ProcedureRegistryConfig config)
 
const std::vector< ProcedureRegistryEntry > & entries () const
 Every entry, in the order a client should present them.
 
std::expected< std::vector< ProcedureListing >, ProcedureError > list (uint16_t devicePosition) const
 Every procedure devicePosition supports, each with its current or last-run snapshot.
 
std::expected< ProcedureSnapshot, ProcedureError > snapshot (uint16_t devicePosition, std::string_view name) const
 The current or last-run state of one procedure on one device.
 
std::expected< ProcedureSnapshot, ProcedureError > start (uint16_t devicePosition, std::string_view name, const nlohmann::json &request) const
 Starts name on devicePosition with request as its parameters.
 
std::expected< void, ProcedureError > cancel (uint16_t devicePosition, std::string_view name) const
 Asks the running name on devicePosition to stop.
 

Detailed Description

Every procedure the server knows, and the four operations a client performs against it.

Built once, in the composition root, with the collaborators every procedure body shares and the callbacks of ProcedureRegistryConfig. Entries are never added or removed after construction, so a caller may hold a pointer into entries().

Constructor & Destructor Documentation

◆ ProcedureRegistry()

mm::node::ProcedureRegistry::ProcedureRegistry ( DeviceManager &  deviceManager,
ProcedureManager &  procedureManager,
ProcedureRegistryConfig  config 
)
Parameters
deviceManagerWhere a device is looked up. Must outlive the registry.
procedureManagerWhere a run is started, cancelled and polled. Must outlive the registry.
configThe outside callbacks, copied in.

Member Function Documentation

◆ cancel()

std::expected< void, ProcedureError > mm::node::ProcedureRegistry::cancel ( uint16_t  devicePosition,
std::string_view  name 
) const

Asks the running name on devicePosition to stop.

Cancels the run, not the record: the retained snapshot stays behind reporting how far it got.

Returns
Void if a run was in flight and got the stop request. kUnknownProcedure covers both an unrecognised name and a recognised one with nothing running — from a client's side both mean "there is no run here to cancel".

◆ entries()

const std::vector< ProcedureRegistryEntry > & mm::node::ProcedureRegistry::entries ( ) const
inline

Every entry, in the order a client should present them.

◆ list()

std::expected< std::vector< ProcedureListing >, ProcedureError > mm::node::ProcedureRegistry::list ( uint16_t  devicePosition) const

Every procedure devicePosition supports, each with its current or last-run snapshot.

Returns
The listings (empty if the device supports none), or kUnknownDevice.

◆ snapshot()

std::expected< ProcedureSnapshot, ProcedureError > mm::node::ProcedureRegistry::snapshot ( uint16_t  devicePosition,
std::string_view  name 
) const

The current or last-run state of one procedure on one device.

Never-run is not an error: it reports the descriptor's all-idle snapshot, so a client polls one shape whether or not the procedure has ever been run. kUnknownProcedure is reserved for a name that does not exist or that this device does not support — a genuine addressing mistake.

◆ start()

std::expected< ProcedureSnapshot, ProcedureError > mm::node::ProcedureRegistry::start ( uint16_t  devicePosition,
std::string_view  name,
const nlohmann::json &  request 
) const

Starts name on devicePosition with request as its parameters.

Returns
The initial snapshot (status running, runCount already bumped), or why it could not start — any of the four ProcedureError kinds.

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