Firmware  0.4.1
Loading...
Searching...
No Matches
turnout.hpp
Go to the documentation of this file.
1// Copyright (C) 2025 Vincent Hamp
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation, either version 3 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16#pragma once
17
18#include <ArduinoJson.h>
19#include <dcc/dcc.hpp>
20#include <optional>
21#include <string>
22#include <type_traits>
23#include <z21/z21.hpp>
24#include <ztl/string.hpp>
25
26namespace mw::dcc {
27
28using namespace ::dcc;
29namespace z21 = ::z21;
30
32struct NvTurnoutBase : z21::TurnoutInfo {
33 constexpr NvTurnoutBase() = default;
34 explicit NvTurnoutBase(JsonDocument const& doc);
35
36 void fromJsonDocument(JsonDocument const& doc);
37 JsonDocument toJsonDocument() const;
38
39 std::string name{};
40 enum Type : uint16_t {
41 // Special
45
46 // Track (move)
51
52 // Signal (guide)
58
59 // Scenery (world)
60 Light = 768u,
63
65 AT = 1024u,
66 } type{};
67 struct Group {
68 std::vector<Address::value_type> addresses{};
69 std::vector<std::vector<Position>> states{};
70 } group{};
71};
72
75 constexpr Turnout() = default;
76 explicit Turnout(JsonDocument const& doc);
77
78 void fromJsonDocument(JsonDocument const& doc);
79 JsonDocument toJsonDocument() const;
80};
81
82} // namespace mw::dcc
Definition config.hpp:512
Definition turnout.hpp:67
std::vector< std::vector< Position > > states
Definition turnout.hpp:69
std::vector< Address::value_type > addresses
Definition turnout.hpp:68
constexpr NvTurnoutBase()=default
struct mw::dcc::NvTurnoutBase::Group group
Type
Definition turnout.hpp:40
@ Signal4Aspects
Definition turnout.hpp:55
@ TurnoutY
Definition turnout.hpp:49
@ Relay
Definition turnout.hpp:62
@ Signal2Aspects
Definition turnout.hpp:53
@ Signal3Aspects
Definition turnout.hpp:54
@ CrossingGate
Definition turnout.hpp:61
@ Unknown
Definition turnout.hpp:42
@ Light
Definition turnout.hpp:60
@ TurnoutRight
Definition turnout.hpp:47
@ AT
Definition turnout.hpp:65
@ Turnout3Way
Definition turnout.hpp:50
@ SignalSemaphore
Definition turnout.hpp:57
@ SignalBlocking
Definition turnout.hpp:56
@ Custom
Definition turnout.hpp:44
@ TurnoutLeft
Definition turnout.hpp:48
@ Hidden
Definition turnout.hpp:43
JsonDocument toJsonDocument() const
Definition turnout.cpp:57
std::string name
Definition turnout.hpp:39
void fromJsonDocument(JsonDocument const &doc)
Definition turnout.cpp:25
enum mw::dcc::NvTurnoutBase::Type type
void fromJsonDocument(JsonDocument const &doc)
Definition turnout.cpp:82
constexpr Turnout()=default
JsonDocument toJsonDocument() const
Definition turnout.cpp:87