• 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

83.33
/plugins/pathport/PathportPlugin.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
 * PathportPlugin.cpp
17
 * The Pathport plugin for ola
18
 * Copyright (C) 2005 Simon Newton
19
 */
20

21
#include <limits.h>
22
#include <string>
23
#include "ola/Logging.h"
24
#include "ola/StringUtils.h"
25
#include "ola/math/Random.h"
26
#include "olad/PluginAdaptor.h"
27
#include "olad/Preferences.h"
28
#include "plugins/pathport/PathportDevice.h"
29
#include "plugins/pathport/PathportPlugin.h"
30

31

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

36
using std::string;
37

38
const char PathportPlugin::PLUGIN_NAME[] = "Pathport";
39
const char PathportPlugin::PLUGIN_PREFIX[] = "pathport";
40
const unsigned int PathportPlugin::DEFAULT_DSCP_VALUE = 0;
41

42

43
/*
44
 * Start the plugin
45
 * For now we just have one device.
46
 */
47
bool PathportPlugin::StartHook() {
1✔
48
  m_device = new PathportDevice(this,
2✔
49
                                m_preferences,
50
                                m_plugin_adaptor);
1✔
51

52
  if (!m_device) {
1✔
53
    return false;
54
  }
55

56
  if (!m_device->Start()) {
1✔
57
    delete m_device;
×
58
    return false;
×
59
  }
60
  m_plugin_adaptor->RegisterDevice(m_device);
1✔
61
  return true;
1✔
62
}
63

64

65
/*
66
 * Stop the plugin
67
 * @return true on success, false on failure
68
 */
69
bool PathportPlugin::StopHook() {
1✔
70
  if (m_device) {
1✔
71
    m_plugin_adaptor->UnregisterDevice(m_device);
1✔
72
    bool ret = m_device->Stop();
1✔
73
    delete m_device;
1✔
74
    return ret;
1✔
75
  }
76
  return true;
77
}
78

79

80
/*
81
 * Return the description for this plugin
82
 */
83
string PathportPlugin::Description() const {
×
84
  return
×
85
"Pathway Pathport Plugin\n"
×
86
"----------------------------\n"
87
"\n"
88
"This plugin creates a single device with 5 input and 5 output ports.\n"
89
"\n"
90
"The universe the port is patched to corresponds with the DMX channels used \n"
91
"in the PathPort protocol. For example universe 0 is xDMX channels 0 - 511, \n"
92
"universe 1 is xDMX channels 512 - 1023.\n"
93
"\n"
94
"--- Config file : ola-pathport.conf ---\n"
95
"\n"
96
"dscp = <int>\n"
97
"Set the DSCP value for the packets. Range is 0-63.\n"
98
"\n"
99
"ip = [a.b.c.d|<interface_name>]\n"
100
"The ip address or interface name to bind to. If not specified it will\n"
101
"use the first non-loopback interface.\n"
102
"\n"
103
"name = ola-Pathport\n"
104
"The name of the node.\n"
105
"\n"
106
"node-id = <int>\n"
107
"The pathport id of the node.\n"
108
"\n";
×
109
}
110

111

112
/*
113
 * Load the plugin prefs and default to sensible values
114
 */
115
bool PathportPlugin::SetDefaultPreferences() {
1✔
116
  bool save = false;
1✔
117

118
  if (!m_preferences) {
1✔
119
    return false;
120
  }
121

122
  save |= m_preferences->SetDefaultValue(PathportDevice::K_DSCP_KEY,
1✔
123
                                         UIntValidator(0, 63),
1✔
124
                                         DEFAULT_DSCP_VALUE);
125
  save |= m_preferences->SetDefaultValue(PathportDevice::K_NODE_IP_KEY,
1✔
126
                                         StringValidator(true), "");
1✔
127
  save |= m_preferences->SetDefaultValue(PathportDevice::K_NODE_NAME_KEY,
1✔
128
                                         StringValidator(),
1✔
129
                                         PathportDevice::K_DEFAULT_NODE_NAME);
130

131
  // Generate a new node id in case we need it
132
  uint32_t product_id = ((OLA_MANUFACTURER_CODE << 24) +
2✔
133
                         ola::math::Random(0, (1 << 24) - 1));
1✔
134

135
  save |= m_preferences->SetDefaultValue(PathportDevice::K_NODE_ID_KEY,
1✔
136
                                         UIntValidator(0, UINT_MAX),
1✔
137
                                         product_id);
138

139
  if (save) {
1✔
140
    m_preferences->Save();
1✔
141
  }
142

143
  if (m_preferences->GetValue(PathportDevice::K_NODE_NAME_KEY).empty() ||
3✔
144
      m_preferences->GetValue(PathportDevice::K_NODE_ID_KEY).empty()) {
3✔
145
    return false;
146
  }
147

148
  return true;
149
}
150
}  // namespace pathport
151
}  // namespace plugin
152
}  // 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

© 2026 Coveralls, Inc