Motion Master 6.0.0-alpha.86
Next-generation motion control software
Loading...
Searching...
No Matches
procedure_catalogue.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <expected>
5#include <functional>
6#include <nlohmann/json_fwd.hpp>
7#include <string>
8#include <string_view>
9#include <variant>
10#include <vector>
11
12#include "node/device.h"
13#include "node/device_manager.h"
14#include "node/procedure.h"
16
17namespace mm::node {
18
31
35
41 std::function<bool(Device& device)> applies;
42
52 std::function<std::expected<ProcedureBody, std::string>(const nlohmann::json& request)> makeBody;
53};
54
59const std::vector<ProcedureCatalogueEntry>& procedureCatalogue();
60
71void to_json(nlohmann::json& j, const ProcedureListing& listing);
72
76std::expected<std::vector<ProcedureListing>, ProcedureError> listProcedures(
77 DeviceManager& deviceManager, ProcedureManager& procedureManager, uint16_t devicePosition);
78
84std::expected<ProcedureSnapshot, ProcedureError> procedureSnapshot(
85 DeviceManager& deviceManager, ProcedureManager& procedureManager, uint16_t devicePosition,
86 std::string_view name);
87
92std::expected<ProcedureSnapshot, ProcedureError> startProcedure(DeviceManager& deviceManager,
93 ProcedureManager& procedureManager,
94 uint16_t devicePosition,
95 std::string_view name,
96 const nlohmann::json& request);
97
105std::expected<void, ProcedureError> cancelProcedure(DeviceManager& deviceManager,
106 ProcedureManager& procedureManager,
107 uint16_t devicePosition, std::string_view name);
108
109} // namespace mm::node
Owns the fieldbus driver and node collection, and drives PDO exchange.
Definition device_manager.h:287
Represents a single node on the fieldbus.
Definition device.h:116
Runs off-RT command-and-wait procedures and remembers how each one went.
Definition procedure_manager.h:121
std::string name
Catalogue name, e.g. "sm2".
Definition eni_request.cc:37
Definition bus_health_source.h:7
std::expected< ProcedureSnapshot, ProcedureError > procedureSnapshot(DeviceManager &deviceManager, ProcedureManager &procedureManager, uint16_t devicePosition, std::string_view name)
The current or last-run state of one procedure on one device.
Definition procedure_catalogue.cc:1117
std::expected< ProcedureSnapshot, ProcedureError > startProcedure(DeviceManager &deviceManager, ProcedureManager &procedureManager, uint16_t devicePosition, std::string_view name, const nlohmann::json &request)
Starts name on devicePosition with request as its parameters.
Definition procedure_catalogue.cc:1127
std::expected< void, ProcedureError > cancelProcedure(DeviceManager &deviceManager, ProcedureManager &procedureManager, uint16_t devicePosition, std::string_view name)
Asks the running name on devicePosition to stop.
Definition procedure_catalogue.cc:1150
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
std::expected< std::vector< ProcedureListing >, ProcedureError > listProcedures(DeviceManager &deviceManager, ProcedureManager &procedureManager, uint16_t devicePosition)
Every procedure devicePosition supports, each with its current or last-run snapshot.
Definition procedure_catalogue.cc:1101
const std::vector< ProcedureCatalogueEntry > & procedureCatalogue()
Every procedure the server knows, in the order a client should present them.
Definition procedure_catalogue.cc:1089
One procedure, as the catalogue knows it: what it is, who has it, and how to run it.
Definition procedure_catalogue.h:33
std::function< bool(Device &device)> applies
Whether device supports this procedure.
Definition procedure_catalogue.h:41
ProcedureDescriptor descriptor
What a client is told about it.
Definition procedure_catalogue.h:34
std::function< std::expected< ProcedureBody, std::string >(const nlohmann::json &request)> makeBody
Turns a client's request into the body that will run.
Definition procedure_catalogue.h:52
What a procedure is, independent of any run — the half of the catalogue a client needs to render a co...
Definition procedure.h:298
Why a procedure operation could not be performed. A caller must branch on this — an HTTP handler maps...
Definition procedure_manager.h:69
One procedure paired with how its last run on a device went — an entry of GET /api/devices/:pos/proce...
Definition procedure_catalogue.h:67
ProcedureSnapshot snapshot
Definition procedure_catalogue.h:69
ProcedureDescriptor descriptor
Definition procedure_catalogue.h:68
The complete state of a procedure on one device — everything a client polling GET /api/devices/:pos/p...
Definition procedure.h:111