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

traintastic / traintastic / 23695207116

28 Mar 2026 09:57PM UTC coverage: 26.14% (-0.006%) from 26.146%
23695207116

push

github

reinder
[cbus] added mode and type to node list

0 of 7 new or added lines in 3 files covered. (0.0%)

4 existing lines in 1 file now uncovered.

8256 of 31584 relevant lines covered (26.14%)

182.15 hits per line

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

0.0
/server/src/hardware/interface/cbus/cbusnodelisttablemodel.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 "cbusnodelisttablemodel.hpp"
23
#include "cbusnodelist.hpp"
24
#include "../../../compat/stdformat.hpp"
25
#include "../../protocol/cbus/cbusmanufacturermodule.hpp"
26

27
constexpr uint32_t columnCANID = 0;
28
constexpr uint32_t columnNodeNumber = 1;
29
constexpr uint32_t columnManufacturer = 2;
30
constexpr uint32_t columnModule = 3;
31
constexpr uint32_t columnVersion = 4;
32
constexpr uint32_t columnMode = 5;
33
constexpr uint32_t columnType = 6;
34

35
CBUSNodeListTableModel::CBUSNodeListTableModel(CBUSNodeList& list)
×
36
  : m_list{list.shared_ptr<CBUSNodeList>()}
×
37
{
38
  assert(m_list);
×
39
  m_list->m_models.push_back(this);
×
40

41
  setColumnHeaders({
×
42
    std::string_view{"cbus_node_list:can_id"},
43
    std::string_view{"cbus_node_list:node_number"},
44
    std::string_view{"cbus_node_list:manufacturer"},
45
    std::string_view{"cbus_node_list:module"},
46
    std::string_view{"cbus_node_list:version"},
47
    std::string_view{"cbus_node_list:mode"},
48
    std::string_view{"cbus_node_list:type"}
49
  });
50

51
  setRowCount(m_list->m_nodes.size());
×
52
}
×
53

54
CBUSNodeListTableModel::~CBUSNodeListTableModel()
×
55
{
56
  auto it = std::find(m_list->m_models.begin(), m_list->m_models.end(), this);
×
57
  assert(it != m_list->m_models.end());
×
58
  m_list->m_models.erase(it);
×
59
}
×
60

61
std::string CBUSNodeListTableModel::getText(uint32_t column, uint32_t row) const
×
62
{
63
  if(row < m_list->m_nodes.size())
×
64
  {
65
    const auto& node = m_list->m_nodes[row];
×
66

67
    switch(column)
×
68
    {
69
      case columnCANID:
×
70
        return std::to_string(node.canId);
×
71

72
      case columnNodeNumber:
×
73
        return std::to_string(node.nodeNumber);
×
74

75
      case columnManufacturer:
×
76
        if(auto sv = CBUS::manufacturerName(node.manufacturerId); !sv.empty())
×
77
        {
78
          return std::string(sv);
×
79
        }
80
        return std::to_string(node.manufacturerId);
×
81

82
      case columnModule:
×
83
        if(auto sv = CBUS::moduleName(node.manufacturerId, node.moduleId); !sv.empty())
×
84
        {
85
          return std::string(sv);
×
86
        }
87
        return std::to_string(node.moduleId);
×
88

NEW
89
      case columnVersion:
×
90
        if(node.parameters.versionMajor && node.parameters.versionMinor && node.parameters.betaReleaseCode)
×
91
        {
92
          auto s = std::to_string(*node.parameters.versionMajor);
×
93
          s += static_cast<char>(*node.parameters.versionMinor);
×
94
          if(*node.parameters.betaReleaseCode > 0)
×
95
          {
96
            s += std::format(" Beta {}", *node.parameters.betaReleaseCode);
×
97
          }
98
          return s;
×
99
        }
×
100
        break;
×
101

NEW
102
      case columnMode:
×
NEW
103
        return node.flim ? "FLiM" : "SLiM";
×
104

NEW
105
      case columnType:
×
NEW
106
        return node.vlcb ? "VLCB" : "CBUS";
×
107
    }
108
  }
109
  return {};
×
110
}
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