Debian Codegraph @

Hardware/Hsi88.h

raw symbols SCIP
1 /*
2 RailControl - Model Railway Control Software
3
4 Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org
5
6 RailControl is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 RailControl is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with RailControl; see the file LICENCE. If not see
18 <http://www.gnu.org/licenses/>.
19 */
20
21 #pragma once
22
23 #include <mutex>
24 #include <string>
25
26 #include "HardwareInterface.h"
27 #include "HardwareParams.h"
28 #include "Logger/Logger.h"
29 #include "Network/Serial.h"
30
31 namespace Hardware
32 {
33 class Hsi88 : HardwareInterface
34 {
35 public:
36 Hsi88() = delete;
37 Hsi88(const Hsi88&) = delete;
38 Hsi88& operator=(const Hsi88&) = delete;
39
40 Hsi88(const HardwareParams* params);
41 ~Hsi88();
42
43 inline Hardware::Capabilities GetCapabilities() const override
44 {
45 return Hardware::CapabilityFeedback;
46 }
47
48 static void GetArgumentTypesAndHint(std::map<unsigned char,ArgumentType>& argumentTypes, std::string& hint)
49 {
50 argumentTypes[1] = ArgumentTypeSerialPort;
51 argumentTypes[2] = ArgumentTypeS88Modules;
52 argumentTypes[3] = ArgumentTypeS88Modules;
53 argumentTypes[4] = ArgumentTypeS88Modules;
54 hint = Languages::GetText(Languages::TextHintHsi88);
55 }
56
57 private:
58 static const unsigned char MaxS88Modules = 62;
59
60 Network::Serial serialLine;
61 volatile bool run;
62 unsigned char s88Modules1;
63 unsigned char s88Modules2;
64 unsigned char s88Modules3;
65 unsigned short s88Modules;
66
67 std::thread checkEventsThread;
68 unsigned char s88Init[MaxS88Modules];
69 unsigned char s88Memory[MaxS88Modules];
70
71 std::string ReadUntilCR();
72 std::string GetVersion();
73 unsigned char ConfigureS88();
74 void ReadData();
75
76 inline ssize_t SendData(const unsigned char* data, const size_t size)
77 {
78 logger->HexOut(data, size);
79 return serialLine.Send(data, size);
80 }
81
82 void CheckFeedbackByte(const unsigned char dataByte, const unsigned char module);
83
84 void CheckEventsWorker();
85 };
86 } // namespace
87