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

ossia / score / 36213733900

26 Sep 2026 03:05AM UTC coverage: 42.353% (+0.1%) from 42.23%
36213733900

Pull #2310

github

web-flow
Merge 9f9d60cd9 into c0c64ec39
Pull Request #2310: bitfocus: host companion modules the way companion does

41 of 2024 new or added lines in 11 files covered. (2.03%)

210 existing lines in 15 files now uncovered.

126773 of 299323 relevant lines covered (42.35%)

118427.51 hits per line

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

0.0
/src/plugins/score-plugin-protocols/Protocols/Bitfocus/BitfocusDevice.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "BitfocusDevice.hpp"
4

5
#include <Device/Protocol/DeviceSettings.hpp>
6

7
#include <Explorer/DeviceList.hpp>
8
#include <Explorer/DeviceLogging.hpp>
9
#include <Explorer/DocumentPlugin/DeviceDocumentPlugin.hpp>
10

11
#include <Protocols/Bitfocus/BitfocusContext.hpp>
12
#include <Protocols/Bitfocus/BitfocusProtocol.hpp>
13
#include <Protocols/Bitfocus/BitfocusSpecificSettings.hpp>
14

15
#include <score/application/ApplicationContext.hpp>
16
#include <score/document/DocumentContext.hpp>
17

18
#include <ossia/network/context.hpp>
19
#include <ossia/network/generic/generic_device.hpp>
20
#include <ossia/network/generic/generic_parameter.hpp>
21
#include <ossia/network/rate_limiting_protocol.hpp>
22

23
#include <ossia-qt/js_utilities.hpp>
24

25
#include <memory>
26
namespace Protocols
27
{
28

29
BitfocusDevice::BitfocusDevice(
×
30
    const Device::DeviceSettings& settings, const ossia::net::network_context_ptr& ctx)
31
    : OwningDeviceInterface{settings}
×
32
    , m_ctx{ctx}
×
33
{
×
34
  m_capas.canRefreshTree = true;
×
35
  m_capas.canAddNode = false;
×
36
  m_capas.canRemoveNode = false;
×
37
  m_capas.canRenameNode = false;
×
38
  m_capas.canSetProperties = false;
×
39
  m_capas.canSerialize = true;
×
40
  m_capas.canLearn = false;
×
41
  m_capas.hasCallbacks = false;
×
42
}
×
43

44
bool BitfocusDevice::reconnect()
×
45
{
46
  disconnect();
×
47

48
  try
49
  {
50
    BitfocusSpecificSettings stgs
51
        = settings().deviceSpecificSettings.value<BitfocusSpecificSettings>();
×
52
    stgs.deduplicateConfiguration();
×
53

NEW
54
    const auto conf = stgs.moduleConfiguration();
×
NEW
55
    const auto label = settings().name;
×
56

57
    if(!stgs.handler)
×
58
    {
NEW
59
      stgs.handler = stgs.makeHandler(label);
×
60
      m_settings.deviceSpecificSettings = QVariant::fromValue(stgs);
×
61
    }
×
62
    else
63
    {
NEW
64
      stgs.handler->afterRegistration([label, conf, h = std::weak_ptr{stgs.handler}] {
×
NEW
65
        if(auto handler = h.lock())
×
NEW
66
          handler->updateConfigAndLabel(label, conf);
×
NEW
67
      });
×
68
    }
69

NEW
70
    QObject::disconnect(m_configurationSaved);
×
NEW
71
    m_configurationSaved = connect(
×
NEW
72
        stgs.handler.get(), &bitfocus::module_handler::configurationSaved, this,
×
NEW
73
        [this, h = std::weak_ptr{stgs.handler}] {
×
NEW
74
      auto handler = h.lock();
×
NEW
75
      if(!handler)
×
NEW
76
        return;
×
NEW
77
      auto cur = m_settings.deviceSpecificSettings.value<BitfocusSpecificSettings>();
×
NEW
78
      if(cur.handler != handler)
×
NEW
79
        return;
×
NEW
80
      cur.configuration.clear();
×
NEW
81
      for(auto& [k, v] : handler->model().config)
×
NEW
82
        if(k != "product" || v != cur.product)
×
NEW
83
          cur.configuration.emplace_back(k, ossia::qt::qt_to_ossia{}(v));
×
NEW
84
      cur.upgradeIndex = handler->model().upgradeIndex;
×
NEW
85
      if(auto keys = handler->secretKeys())
×
NEW
86
        cur.secretKeys = std::vector<QString>(keys->begin(), keys->end());
×
NEW
87
      m_settings.deviceSpecificSettings = QVariant::fromValue(cur);
×
UNCOV
88
    });
×
89

90
    const auto& name = settings().name.toStdString();
×
91
    if(auto proto = std::make_unique<ossia::net::bitfocus_protocol>(stgs.handler, m_ctx))
×
92
    {
93
      auto pproto = proto.get();
×
94
      m_dev = std::make_shared<ossia::net::generic_device>(std::move(proto), name);
×
95

NEW
96
      deviceChanged(nullptr, m_dev.get());
×
NEW
97
      setLogging_impl(Device::get_cur_logging(isLogging()));
×
98

99
      stgs.handler->afterRegistration([dev = std::weak_ptr{m_dev}, pproto] {
×
100
        if(auto d = dev.lock())
×
101
          pproto->init_device();
×
102
      });
×
103
    }
×
104
    else
105
    {
106
      qDebug() << "Could not create Bitfocus protocol";
×
107
    }
108
  }
×
109
  catch(std::exception& e)
110
  {
111
    qDebug() << "Bitfocus Protocol error: " << e.what();
×
112
  }
×
113
  catch(...)
114
  {
115
    SCORE_TODO;
×
116
  }
×
117
  return connected();
×
118
}
×
119

120
bool BitfocusDevice::isLearning() const
×
121
{
122
  /*
123
  auto& proto = static_cast<ossia::net::bitfocus5_protocol&>(m_dev->get_protocol());
124
  return proto.learning();
125
  */
126
  return false;
×
127
}
128

129
void BitfocusDevice::setLearning(bool b)
×
130
{
131
  /*
132
  if(!m_dev)
133
    return;
134
  auto& proto = static_cast<ossia::net::bitfocus5_protocol&>(m_dev->get_protocol());
135
  auto& dev = *m_dev;
136
  if(b)
137
  {
138
    dev.on_node_created.connect<&DeviceInterface::nodeCreated>((DeviceInterface*)this);
139
    dev.on_node_removing.connect<&DeviceInterface::nodeRemoving>((DeviceInterface*)this);
140
    dev.on_node_renamed.connect<&DeviceInterface::nodeRenamed>((DeviceInterface*)this);
141
    dev.on_parameter_created.connect<&DeviceInterface::addressCreated>(
142
        (DeviceInterface*)this);
143
    dev.on_attribute_modified.connect<&DeviceInterface::addressUpdated>(
144
        (DeviceInterface*)this);
145
  }
146
  else
147
  {
148
    dev.on_node_created.disconnect<&DeviceInterface::nodeCreated>(
149
        (DeviceInterface*)this);
150
    dev.on_node_removing.disconnect<&DeviceInterface::nodeRemoving>(
151
        (DeviceInterface*)this);
152
    dev.on_node_renamed.disconnect<&DeviceInterface::nodeRenamed>(
153
        (DeviceInterface*)this);
154
    dev.on_parameter_created.disconnect<&DeviceInterface::addressCreated>(
155
        (DeviceInterface*)this);
156
    dev.on_attribute_modified.disconnect<&DeviceInterface::addressUpdated>(
157
        (DeviceInterface*)this);
158
  }
159

160
  proto.set_learning(b);*/
161
}
×
162
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc