Motion Master 6.0.0-alpha.111
Next-generation motion control software
Loading...
Searching...
No Matches
profile_procedures.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <expected>
5#include <nlohmann/json_fwd.hpp>
6#include <stop_token>
7#include <string>
8#include <string_view>
9#include <vector>
10
11#include "node/device.h"
12#include "node/procedure.h"
13#include "node/profile_device.h"
14
15namespace mm::node {
16
29
31inline constexpr std::string_view kStoreParametersProcedure = "store-parameters";
32
34inline constexpr std::string_view kStoreParametersStep = "store";
35
37std::vector<ProgressStep> storeParametersSteps();
38
63std::expected<void, std::string> runStoreParametersProcedure(Device& device,
64 ProgressReporter& reporter,
65 std::stop_token stop,
66 StoreParametersConfig config = {});
67
70inline constexpr std::string_view kRestoreDefaultParametersProcedure = "restore-default-parameters";
71
73inline constexpr std::string_view kRestoreDefaultParametersStep = "restore";
74
82
90std::expected<RestoreDefaultParametersRequest, std::string> parseRestoreDefaultParametersRequest(
91 const nlohmann::json& body);
92
94std::vector<ProcedureParameter> restoreDefaultParametersParameters();
95
97std::vector<ProgressStep> restoreDefaultParametersSteps();
98
116std::expected<void, std::string> runRestoreDefaultParametersProcedure(
117 Device& device, ProgressReporter& reporter, std::stop_token stop,
118 const RestoreDefaultParametersRequest& request, RestoreDefaultParametersConfig config = {});
119
121inline constexpr std::string_view kDeviceLocateProcedure = "device-locate";
122
124inline constexpr std::string_view kDeviceLocateStep = "locate";
125
129 std::chrono::seconds duration{10};
130};
131
134std::expected<DeviceLocateRequest, std::string> parseDeviceLocateRequest(
135 const nlohmann::json& body);
136
138std::vector<ProcedureParameter> deviceLocateParameters();
139
141std::vector<ProgressStep> deviceLocateSteps();
142
147std::expected<void, std::string> runDeviceLocateProcedure(Device& device,
148 ProgressReporter& reporter,
149 const std::stop_token& stop,
150 const DeviceLocateRequest& request);
151
152} // namespace mm::node
Represents a single node on the fieldbus.
Definition device.h:120
The handle a procedure body uses to report where it has got to.
Definition procedure.h:327
Definition bus_health_source.h:7
constexpr std::string_view kDeviceLocateProcedure
Procedure name for blinking a device's LEDs, as it appears in its URL and snapshot key.
Definition profile_procedures.h:121
std::vector< ProcedureParameter > deviceLocateParameters()
What blinking the LEDs accepts, as its descriptor advertises it.
Definition profile_procedures.cc:126
std::expected< void, std::string > runDeviceLocateProcedure(Device &device, ProgressReporter &reporter, const std::stop_token &stop, const DeviceLocateRequest &request)
Blinks the device's LEDs for request.duration, so that someone can find it.
Definition profile_procedures.cc:135
std::expected< void, std::string > runRestoreDefaultParametersProcedure(Device &device, ProgressReporter &reporter, std::stop_token stop, const RestoreDefaultParametersRequest &request, RestoreDefaultParametersConfig config)
Runs a restore of default parameters (0x1011) as a procedure body.
Definition profile_procedures.cc:86
constexpr std::string_view kStoreParametersProcedure
Procedure name for storing parameters, as it appears in its URL and its snapshot key.
Definition profile_procedures.h:31
constexpr std::string_view kDeviceLocateStep
The single step blinking the LEDs reports against.
Definition profile_procedures.h:124
RestoreGroup
Which group of default parameters to restore (which 0x1011 sub-entry to command). The enum value is t...
Definition profile_device.h:59
@ kAll
0x1011:01 — all default parameters.
std::vector< ProgressStep > deviceLocateSteps()
The locate procedure's step template — one step, idle.
Definition profile_procedures.cc:133
std::expected< DeviceLocateRequest, std::string > parseDeviceLocateRequest(const nlohmann::json &body)
Parses and validates a client's locate request body: {"duration": 10}, in seconds,...
Definition profile_procedures.cc:108
std::expected< void, std::string > runStoreParametersProcedure(Device &device, ProgressReporter &reporter, std::stop_token stop, StoreParametersConfig config)
Runs a parameter store (0x1010) as a procedure body.
Definition profile_procedures.cc:15
std::expected< RestoreDefaultParametersRequest, std::string > parseRestoreDefaultParametersRequest(const nlohmann::json &body)
Parses and validates a client's restore request body.
Definition profile_procedures.cc:37
std::vector< ProgressStep > restoreDefaultParametersSteps()
Restore default parameters' step template — one step, idle.
Definition profile_procedures.cc:82
constexpr std::string_view kStoreParametersStep
The single step storing parameters reports against.
Definition profile_procedures.h:34
constexpr std::string_view kRestoreDefaultParametersProcedure
Procedure name for restoring default parameters, as it appears in its URL and its snapshot key.
Definition profile_procedures.h:70
std::vector< ProgressStep > storeParametersSteps()
Store parameters' step template — one step, idle.
Definition profile_procedures.cc:13
constexpr std::string_view kRestoreDefaultParametersStep
The single step restoring default parameters reports against.
Definition profile_procedures.h:73
std::vector< ProcedureParameter > restoreDefaultParametersParameters()
What restoring default parameters accepts, as its descriptor advertises it.
Definition profile_procedures.cc:61
What one locate run was asked to do.
Definition profile_procedures.h:127
std::chrono::seconds duration
How long the LEDs blink before they stop.
Definition profile_procedures.h:129
What one restore was asked to do.
Definition profile_procedures.h:76
RestoreGroup group
Definition profile_procedures.h:80
Timing for the store-parameters confirmation walk (ProfileDevice::runStoreParameters).
Definition profile_device.h:93