lacteApp
C++17 service for Lacte hardware
Loading...
Searching...
No Matches
AppRuntime.hpp
Go to the documentation of this file.
1#pragma once
2
17
18#include <string>
19#include <string_view>
20#include <tuple>
21
22#include "protocols/lacte/LacteProtocol.hpp"
23
24using namespace std::string_view_literals;
25using namespace std::string_literals;
26
27struct SoftVersion : std::string {
28 constexpr static auto NAME = "LacteApp version"sv;
29 using std::string::string;
30 [[nodiscard]] auto to_string() // NOLINT(bugprone-exception-escape)
31 const noexcept -> std::string {
32 return *this;
33 }
34};
35
36inline auto to_string(const SoftVersion& version) -> std::string {
37 return version;
38}
39
41 constexpr static auto NAME = "board is online"sv;
42 bool online{};
43
44 explicit BoardOnlineStatus(const std::string_view name) {
45 if (name == "true"sv or name == "online"sv) {
46 online = true;
47 }
48 }
49
50 [[nodiscard]] auto to_string() // NOLINT(bugprone-exception-escape)
51 const noexcept -> std::string {
52 return online ? "online"s : "offline"s;
53 }
54
55 auto operator==(const BoardOnlineStatus& other) const -> bool {
56 return online == other.online;
57 }
58};
59
60inline auto to_string(const BoardOnlineStatus& status) -> std::string {
61 return status.to_string();
62}
63
64// Список полей платы живёт здесь в единственном экземпляре - и LacteApp.hpp
65// (называющий его собственным RuntimeFieldsTuple у ConsoleApp), и Model.h
66// (строящий из него свои алиасы LacteRuntime/BoardData) ссылаются на один
67// и тот же кортеж, вместо того чтобы каждый объявлял свой собственный.
69 std::tuple<BoardOnlineStatus, proto::lacte::InfoPacketType,
70 proto::lacte::BoardErrorDiff, proto::lacte::VersionPacketType,
71 proto::lacte::UIDPacketType, proto::lacte::RFIDNumberType,
72 proto::lacte::MagicWord, proto::lacte::LacteId,
73 proto::lacte::LacteSn, proto::lacte::ProductVolume,
74 proto::lacte::ProdDate, proto::lacte::ProductShelfLife,
75 proto::lacte::UsageTime, proto::lacte::McuUid,
76 proto::lacte::MachineSn, proto::lacte::ActivationTime,
77 proto::lacte::MilkCounter, proto::lacte::TimeCounter,
78 SoftVersion, proto::lacte::AerationParam>;
std::tuple< BoardOnlineStatus, proto::lacte::InfoPacketType, proto::lacte::BoardErrorDiff, proto::lacte::VersionPacketType, proto::lacte::UIDPacketType, proto::lacte::RFIDNumberType, proto::lacte::MagicWord, proto::lacte::LacteId, proto::lacte::LacteSn, proto::lacte::ProductVolume, proto::lacte::ProdDate, proto::lacte::ProductShelfLife, proto::lacte::UsageTime, proto::lacte::McuUid, proto::lacte::MachineSn, proto::lacte::ActivationTime, proto::lacte::MilkCounter, proto::lacte::TimeCounter, SoftVersion, proto::lacte::AerationParam > RuntimeFields
auto to_string(const SoftVersion &version) -> std::string
static constexpr auto NAME
BoardOnlineStatus(const std::string_view name)
auto operator==(const BoardOnlineStatus &other) const -> bool
auto to_string() const noexcept -> std::string
auto to_string() const noexcept -> std::string
static constexpr auto NAME