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

traintastic / traintastic / 23516101412

24 Mar 2026 10:53PM UTC coverage: 26.176% (-0.06%) from 26.237%
23516101412

push

github

reinder
[cbus] improved timing of reading node parameters and added firmware version to node list

0 of 71 new or added lines in 5 files covered. (0.0%)

5 existing lines in 2 files now uncovered.

8246 of 31502 relevant lines covered (26.18%)

182.45 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 <format>
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 columnFirmwareVersion = 4;
32

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

39
  setColumnHeaders({
×
40
    std::string_view{"cbus_node_list:can_id"},
41
    std::string_view{"cbus_node_list:node_number"},
42
    std::string_view{"cbus_node_list:manufacturer"},
43
    std::string_view{"cbus_node_list:module"},
44
    std::string_view{"cbus_node_list:firmware_version"}
45
  });
46

47
  setRowCount(m_list->m_nodes.size());
×
48
}
×
49

50
CBUSNodeListTableModel::~CBUSNodeListTableModel()
×
51
{
52
  auto it = std::find(m_list->m_models.begin(), m_list->m_models.end(), this);
×
53
  assert(it != m_list->m_models.end());
×
54
  m_list->m_models.erase(it);
×
55
}
×
56

57
std::string CBUSNodeListTableModel::getText(uint32_t column, uint32_t row) const
×
58
{
59
  if(row < m_list->m_nodes.size())
×
60
  {
61
    const auto& node = m_list->m_nodes[row];
×
62

63
    switch(column)
×
64
    {
65
      case columnCANID:
×
66
        return std::to_string(node.canId);
×
67

68
      case columnNodeNumber:
×
69
        return std::to_string(node.nodeNumber);
×
70

71
      case columnManufacturer:
×
72
        if(auto sv = CBUS::manufacturerName(node.manufacturerId); !sv.empty())
×
73
        {
74
          return std::string(sv);
×
75
        }
76
        return std::to_string(node.manufacturerId);
×
77

78
      case columnModule:
×
79
        if(auto sv = CBUS::moduleName(node.manufacturerId, node.moduleId); !sv.empty())
×
80
        {
81
          return std::string(sv);
×
82
        }
83
        return std::to_string(node.moduleId);
×
84

NEW
85
      case columnFirmwareVersion:
×
NEW
86
        if(node.parameters.versionMajor && node.parameters.versionMinor && node.parameters.betaReleaseCode)
×
87
        {
NEW
88
          auto s = std::to_string(*node.parameters.versionMajor);
×
NEW
89
          s += static_cast<char>(*node.parameters.versionMinor);
×
NEW
90
          if(*node.parameters.betaReleaseCode > 0)
×
91
          {
NEW
92
            s += std::format(" Beta {}", *node.parameters.betaReleaseCode);
×
93
          }
NEW
94
          return s;
×
NEW
95
        }
×
NEW
96
        break;
×
97
    }
98
  }
99
  return {};
×
100
}
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