• 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/input/input.cpp
1
/**
2
 * This file is part of Traintastic,
3
 * see <https://github.com/traintastic/traintastic>.
4
 *
5
 * Copyright (C) 2019-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 "input.hpp"
23
#include "inputcontroller.hpp"
24
#include "list/inputlist.hpp"
25
#include "list/inputlisttablemodel.hpp"
26
#include "../../world/getworld.hpp"
27
#include "../../world/world.hpp"
28
#include "../../core/attributes.hpp"
29
#include "../../core/objectproperty.tpp"
30
#include "../../log/log.hpp"
31
#include "../../utils/displayname.hpp"
32

NEW
33
Input::Input(std::shared_ptr<InputController> inputController, InputChannel channel_, std::optional<uint32_t> node_, uint32_t address_)
×
34
  : interface{this, "interface", std::move(inputController), PropertyFlags::Constant | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}
×
35
  , channel{this, "channel", channel_, PropertyFlags::Constant | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}
×
36
  , address{this, "address", address_, PropertyFlags::Constant | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}
×
NEW
37
  , node{this, "node", node_ ? *node_ : 0, PropertyFlags::Constant | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}
×
38
  , value{this, "value", TriState::Undefined, PropertyFlags::ReadOnly | PropertyFlags::NoStore | PropertyFlags::ScriptReadOnly}
×
39
  , onValueChanged{*this, "on_value_changed", EventFlags::Scriptable}
×
40
{
41
  m_interfaceItems.add(interface);
×
42

43
  Attributes::addValues(channel, inputChannelValues);
×
44
  m_interfaceItems.add(channel);
×
45

46
  m_interfaceItems.add(address);
×
47

NEW
48
  if(node_)
×
49
  {
NEW
50
    m_interfaceItems.add(node);
×
51
  }
52

53
  Attributes::addValues(value, TriStateValues);
×
54
  m_interfaceItems.add(value);
×
55

56
  m_interfaceItems.add(onValueChanged);
×
57
}
×
58

59
void Input::simulateChange(SimulateInputAction action)
×
60
{
61
  assert(interface);
×
62
  assert(getWorld(dynamic_cast<Object*>(interface.value().get())).simulation.value()); // should only be called in simulation mode
×
NEW
63
  interface->inputSimulateChange(channel, inputLocation(channel, node, address), action);
×
64
}
×
65

66
void Input::updateValue(TriState _value)
×
67
{
68
  value.setValueInternal(_value);
×
69
  if(value != TriState::Undefined)
×
70
    fireEvent<bool, const std::shared_ptr<Input>&>(onValueChanged, value == TriState::True, shared_ptr<Input>());
×
71
}
×
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