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

traintastic / traintastic / 23088148108

14 Mar 2026 12:40PM UTC coverage: 26.661% (-0.2%) from 26.84%
23088148108

push

github

reinder
[cbus] added input support for short/long events

0 of 133 new or added lines in 4 files covered. (0.0%)

587 existing lines in 20 files now uncovered.

8246 of 30929 relevant lines covered (26.66%)

185.83 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

UNCOV
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}
×
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

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

UNCOV
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);
×
UNCOV
62
  assert(getWorld(dynamic_cast<Object*>(interface.value().get())).simulation.value()); // should only be called in simulation mode
×
63
  interface->inputSimulateChange(channel, inputLocation(channel, node, address), action);
×
64
}
×
65

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