• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

traintastic / traintastic / 26121453997

19 May 2026 07:52PM UTC coverage: 25.063% (-0.6%) from 25.624%
26121453997

Pull #221

github

web-flow
Merge 598936246 into 15e38bcf7
Pull Request #221: Xpressnet new messages

49 of 1129 new or added lines in 16 files covered. (4.34%)

782 existing lines in 21 files now uncovered.

8483 of 33847 relevant lines covered (25.06%)

172.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/server/src/hardware/protocol/xpressnet/iohandler/simulationiohandler.hpp
1
/**
2
 * server/src/hardware/protocol/xpressnet/iohandler/simulationiohandler.hpp
3
 *
4
 * This file is part of the traintastic source code.
5
 *
6
 * Copyright (C) 2022-2024 Reinder Feenstra
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
 */
22

23
#ifndef TRAINTASTIC_SERVER_HARDWARE_PROTOCOL_XPRESSNET_IOHANDLER_SIMULATIONIOHANDLER_HPP
24
#define TRAINTASTIC_SERVER_HARDWARE_PROTOCOL_XPRESSNET_IOHANDLER_SIMULATIONIOHANDLER_HPP
25

26
#include "iohandler.hpp"
27
#include "../messages.hpp"
28
#include <unordered_map>
29
#include <array>
30
#include <cstddef>
31

32
namespace XpressNet {
33

34
class SimulationIOHandler final : public IOHandler
35
{
36
  private:
37
    struct Locomotive
38
    {
39
      LocomotiveInfo info;
40
      FunctionInfoF13F28 func13;
41
      FunctionInfoF29F68 func29;
42

NEW
43
      Locomotive()
×
NEW
44
      {
×
NEW
45
        info.setSpeedSteps(126);
×
NEW
46
        info.setEmergencyStop();
×
NEW
47
        info.setDirection(Direction::Forward);
×
NEW
48
        info.setBusy(true);
×
NEW
49
        info.updateChecksum();
×
NEW
50
        func13.updateChecksum();
×
NEW
51
        func29.updateChecksum();
×
NEW
52
      }
×
53
    };
54

55
    std::unordered_map<uint16_t, Locomotive> m_locomotives;
56

57
    void reply(const Message& message);
58
    void reply(const Message& message, size_t count);
59

60
    void speedAndDirectionInstruction(const SpeedAndDirectionInstruction& message);
61

62
  public:
63
    SimulationIOHandler(Kernel& kernel);
64

65
    void start() final;
66
    void stop() final {}
×
67

68
    bool send(const Message& message) final;
69
};
70

71
template<>
72
constexpr bool isSimulation<SimulationIOHandler>()
×
73
{
74
  return true;
×
75
}
76

77
}
78

79
#endif
80

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc