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

traintastic / traintastic / 24288605255

11 Apr 2026 06:17PM UTC coverage: 25.599% (-2.4%) from 27.99%
24288605255

push

github

web-flow
Merge pull request #222 from traintastic/cbus

Added CBUS/VLCB hardware support

169 of 3369 new or added lines in 99 files covered. (5.02%)

5 existing lines in 4 files now uncovered.

8300 of 32423 relevant lines covered (25.6%)

178.31 hits per line

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

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

22
#include "cbussimulationiohandler.hpp"
23
#include <boost/asio/post.hpp>
24
#include "../cbusconst.hpp"
25
#include "../cbuskernel.hpp"
26
#include "../simulator/cbussimulator.hpp"
27

28
namespace CBUS {
29

NEW
30
SimulationIOHandler::SimulationIOHandler(Kernel& kernel, Simulator& simulator)
×
31
  : IOHandler(kernel)
NEW
32
  , m_simulator{simulator}
×
33
{
NEW
34
  m_simulator.onSend =
×
NEW
35
    [this](const CAN::Message& canMessage)
×
36
    {
37
      // post the message, so it has some delay
NEW
38
      boost::asio::post(m_kernel.ioContext(),
×
NEW
39
        [this, canMessage]()
×
40
        {
NEW
41
          assert(onReceive);
×
NEW
42
          onReceive(canMessage);
×
NEW
43
        });
×
NEW
44
    };
×
NEW
45
}
×
46

NEW
47
SimulationIOHandler::~SimulationIOHandler() = default;
×
48

NEW
49
void SimulationIOHandler::start()
×
50
{
NEW
51
  m_kernel.started();
×
NEW
52
}
×
53

NEW
54
void SimulationIOHandler::stop()
×
55
{
NEW
56
}
×
57

NEW
58
std::error_code SimulationIOHandler::send(const CAN::Message& canMessage)
×
59
{
NEW
60
  m_simulator.receive(canMessage);
×
NEW
61
  return {};
×
62
}
63

64
}
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