Firmware
0.9.0
Toggle main menu visibility
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
26
namespace
mw::dcc
{
27
28
using namespace
::dcc;
29
namespace
z21 = ::z21;
30
32
struct
NvTurnoutBase
: z21::TurnoutInfo {
33
constexpr
NvTurnoutBase
() =
default
;
34
explicit
NvTurnoutBase
(JsonVariantConst src);
35
36
void
fromJson
(JsonVariantConst src);
37
JsonDocument
toJson
()
const
;
38
39
std::string
name
{};
40
enum
Type
: uint16_t {
41
// Special
42
Unknown
,
43
Hidden
,
44
Custom
,
45
46
// Track (move)
47
TurnoutRight
= 256u,
48
TurnoutLeft
,
49
TurnoutY
,
50
Turnout3Way
,
51
52
// Signal (guide)
53
Signal2Aspects
= 512u,
54
Signal3Aspects
,
55
Signal4Aspects
,
56
SignalBlocking
,
57
SignalSemaphore2Aspects
,
58
SignalSemaphore3Aspects
,
59
60
// Scenery (world)
61
Light
= 768u,
62
CrossingGate
,
63
Relay
,
64
66
AT
= 1024u,
67
}
type
{};
68
struct
Group
{
69
std::vector<Address::value_type>
addresses
{};
70
std::vector<std::vector<Position>>
positions
{};
71
}
group
{};
72
};
73
75
struct
Turnout
:
NvTurnoutBase
{
76
constexpr
Turnout
() =
default
;
77
explicit
Turnout
(JsonVariantConst src);
78
79
void
fromJson
(JsonVariantConst src);
80
JsonDocument
toJson
()
const
;
81
82
TickType_t
timeout_tick
{};
83
};
84
85
}
// namespace mw::dcc
mw::dcc
Definition
config.hpp:576
mw::dcc::NvTurnoutBase::Group
Definition
turnout.hpp:68
mw::dcc::NvTurnoutBase::Group::positions
std::vector< std::vector< Position > > positions
Definition
turnout.hpp:70
mw::dcc::NvTurnoutBase::Group::addresses
std::vector< Address::value_type > addresses
Definition
turnout.hpp:69
mw::dcc::NvTurnoutBase::NvTurnoutBase
constexpr NvTurnoutBase()=default
mw::dcc::NvTurnoutBase::group
struct mw::dcc::NvTurnoutBase::Group group
mw::dcc::NvTurnoutBase::Type
Type
Definition
turnout.hpp:40
mw::dcc::NvTurnoutBase::Signal4Aspects
@ Signal4Aspects
Definition
turnout.hpp:55
mw::dcc::NvTurnoutBase::TurnoutY
@ TurnoutY
Definition
turnout.hpp:49
mw::dcc::NvTurnoutBase::Relay
@ Relay
Definition
turnout.hpp:63
mw::dcc::NvTurnoutBase::Signal2Aspects
@ Signal2Aspects
Definition
turnout.hpp:53
mw::dcc::NvTurnoutBase::SignalSemaphore2Aspects
@ SignalSemaphore2Aspects
Definition
turnout.hpp:57
mw::dcc::NvTurnoutBase::Signal3Aspects
@ Signal3Aspects
Definition
turnout.hpp:54
mw::dcc::NvTurnoutBase::CrossingGate
@ CrossingGate
Definition
turnout.hpp:62
mw::dcc::NvTurnoutBase::Unknown
@ Unknown
Definition
turnout.hpp:42
mw::dcc::NvTurnoutBase::Light
@ Light
Definition
turnout.hpp:61
mw::dcc::NvTurnoutBase::TurnoutRight
@ TurnoutRight
Definition
turnout.hpp:47
mw::dcc::NvTurnoutBase::AT
@ AT
Definition
turnout.hpp:66
mw::dcc::NvTurnoutBase::SignalSemaphore3Aspects
@ SignalSemaphore3Aspects
Definition
turnout.hpp:58
mw::dcc::NvTurnoutBase::Turnout3Way
@ Turnout3Way
Definition
turnout.hpp:50
mw::dcc::NvTurnoutBase::SignalBlocking
@ SignalBlocking
Definition
turnout.hpp:56
mw::dcc::NvTurnoutBase::Custom
@ Custom
Definition
turnout.hpp:44
mw::dcc::NvTurnoutBase::TurnoutLeft
@ TurnoutLeft
Definition
turnout.hpp:48
mw::dcc::NvTurnoutBase::Hidden
@ Hidden
Definition
turnout.hpp:43
mw::dcc::NvTurnoutBase::toJson
JsonDocument toJson() const
Definition
turnout.cpp:61
mw::dcc::NvTurnoutBase::name
std::string name
Definition
turnout.hpp:39
mw::dcc::NvTurnoutBase::type
enum mw::dcc::NvTurnoutBase::Type type
mw::dcc::NvTurnoutBase::fromJson
void fromJson(JsonVariantConst src)
Definition
turnout.cpp:25
mw::dcc::Turnout::toJson
JsonDocument toJson() const
Definition
turnout.cpp:89
mw::dcc::Turnout::fromJson
void fromJson(JsonVariantConst src)
Definition
turnout.cpp:86
mw::dcc::Turnout::timeout_tick
TickType_t timeout_tick
Definition
turnout.hpp:82
mw::dcc::Turnout::Turnout
constexpr Turnout()=default
src
mw
dcc
turnout.hpp
Firmware 0.9.0