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

OpenLightingProject / ola / 16911433572

12 Aug 2025 02:08PM UTC coverage: 45.869% (-0.04%) from 45.909%
16911433572

Pull #1739

github

web-flow
Merge 02faeaa2d into 3566c28d9
Pull Request #1739: New web UI, store highest channel number used

7157 of 16316 branches covered (43.86%)

20915 of 45597 relevant lines covered (45.87%)

52.03 hits per line

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

74.36
/plugins/kinet/KiNetPlugin.cpp
1
/*
2
 * This program is free software; you can redistribute it and/or modify
3
 * it under the terms of the GNU General Public License as published by
4
 * the Free Software Foundation; either version 2 of the License, or
5
 * (at your option) any later version.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU Library General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15
 *
16
 * KiNetPlugin.cpp
17
 * The KiNet plugin for ola
18
 * Copyright (C) 2013 Simon Newton
19
 */
20

21
#include <string>
22
#include <vector>
23

24
#include "ola/Logging.h"
25
#include "ola/network/IPV4Address.h"
26
#include "olad/PluginAdaptor.h"
27
#include "olad/Preferences.h"
28
#include "plugins/kinet/KiNetDevice.h"
29
#include "plugins/kinet/KiNetPlugin.h"
30

31

32
namespace ola {
33
namespace plugin {
34
namespace kinet {
35

36
using ola::network::IPV4Address;
37
using std::string;
38
using std::vector;
39

40
const char KiNetPlugin::POWER_SUPPLY_KEY[] = "power_supply";
41
const char KiNetPlugin::PLUGIN_NAME[] = "KiNET";
42
const char KiNetPlugin::PLUGIN_PREFIX[] = "kinet";
43

44
KiNetPlugin::KiNetPlugin(PluginAdaptor *plugin_adaptor)
1✔
45
    : Plugin(plugin_adaptor) {
1✔
46
}
1✔
47

48
KiNetPlugin::~KiNetPlugin() {}
2✔
49

50
/*
51
 * Start the plugin.
52
 */
53
bool KiNetPlugin::StartHook() {
1✔
54
  vector<string> power_supplies_strings = m_preferences->GetMultipleValue(
1✔
55
      POWER_SUPPLY_KEY);
1✔
56
  vector<string>::const_iterator iter = power_supplies_strings.begin();
1✔
57
  vector<IPV4Address> power_supplies;
1✔
58

59
  for (; iter != power_supplies_strings.end(); ++iter) {
2✔
60
    if (iter->empty()) {
1✔
61
      continue;
1✔
62
    }
63
    IPV4Address target;
×
64
    if (IPV4Address::FromString(*iter, &target)) {
×
65
      power_supplies.push_back(target);
×
66
    } else {
67
      OLA_WARN << "Invalid power supply IP address : " << *iter;
×
68
    }
69
  }
70
  m_device.reset(new KiNetDevice(this, power_supplies, m_plugin_adaptor));
1✔
71

72
  if (!m_device->Start()) {
1✔
73
    m_device.reset();
×
74
    return false;
×
75
  }
76
  m_plugin_adaptor->RegisterDevice(m_device.get());
1✔
77
  return true;
78
}
1✔
79

80

81
/*
82
 * Stop the plugin
83
 * @return true on success, false on failure
84
 */
85
bool KiNetPlugin::StopHook() {
1✔
86
  if (m_device.get()) {
1✔
87
    // stop the device
88
    m_plugin_adaptor->UnregisterDevice(m_device.get());
1✔
89
    bool ret = m_device->Stop();
1✔
90
    m_device.reset();
1✔
91
    return ret;
1✔
92
  }
93
  return true;
94
}
95

96

97
/*
98
 * Return the description for this plugin.
99
 * @return a string description of the plugin
100
 */
101
string KiNetPlugin::Description() const {
×
102
    return
×
103
"KiNET Plugin\n"
×
104
"----------------------------\n"
105
"\n"
106
"This plugin creates a single device with multiple output ports. Each port\n"
107
"represents a power supply. This plugin uses the V1 DMX-Out version of the\n"
108
"KiNET protocol\n"
109
"\n"
110
"--- Config file : ola-kinet.conf ---\n"
111
"\n"
112
"power_supply = <ip>\n"
113
"The IP of the power supply to send to. You can communicate with more than\n"
114
"one power supply by adding multiple power_supply = lines\n"
115
"\n";
×
116
}
117

118

119
/*
120
 * Set default preferences.
121
 */
122
bool KiNetPlugin::SetDefaultPreferences() {
1✔
123
  bool save = false;
1✔
124

125
  if (!m_preferences) {
1✔
126
    return false;
127
  }
128

129
  save |= m_preferences->SetDefaultValue(POWER_SUPPLY_KEY,
1✔
130
                                         StringValidator(true), "");
1✔
131

132
  if (save) {
1✔
133
    m_preferences->Save();
1✔
134
  }
135
  return true;
136
}
137
}  // namespace kinet
138
}  // namespace plugin
139
}  // namespace ola
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

© 2025 Coveralls, Inc