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

mcallegari / qlcplus / 19144422256

06 Nov 2025 05:33PM UTC coverage: 34.256% (-0.1%) from 34.358%
19144422256

push

github

mcallegari
Back to 5.1.0 debug

17718 of 51723 relevant lines covered (34.26%)

19528.23 hits per line

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

85.39
/engine/src/outputpatch.cpp
1
/*
2
  Q Light Controller
3
  outputpatch.cpp
4

5
  Copyright (c) Heikki Junnila
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#if defined(WIN32) || defined(Q_OS_WIN)
21
#   define WIN32_LEAN_AND_MEAN
22
#   include <Windows.h>
23
#else
24
#   include <unistd.h>
25
#endif
26

27
#include "qlcioplugin.h"
28
#include "outputpatch.h"
29

30
#define GRACE_MS 1
31

32
/*****************************************************************************
33
 * Initialization
34
 *****************************************************************************/
35

36
OutputPatch::OutputPatch(QObject* parent)
1✔
37
    : QObject(parent)
38
    , m_plugin(NULL)
1✔
39
    , m_pluginLine(QLCIOPlugin::invalidLine())
2✔
40
    , m_universe(UINT_MAX)
1✔
41
    , m_paused(false)
1✔
42
    , m_blackout(false)
1✔
43
{
44
}
1✔
45

46
OutputPatch::OutputPatch(quint32 universe, QObject* parent)
18✔
47
    : QObject(parent)
48
    , m_plugin(NULL)
18✔
49
    , m_pluginLine(QLCIOPlugin::invalidLine())
36✔
50
    , m_universe(universe)
18✔
51
    , m_paused(false)
18✔
52
    , m_blackout(false)
18✔
53
{
54
}
18✔
55

56
OutputPatch::~OutputPatch()
37✔
57
{
58
    if (m_plugin != NULL)
19✔
59
        m_plugin->closeOutput(m_pluginLine, m_universe);
18✔
60
}
37✔
61

62
/****************************************************************************
63
 * Plugin & Output
64
 ****************************************************************************/
65

66
bool OutputPatch::set(QLCIOPlugin* plugin, quint32 output)
19✔
67
{
68
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
19✔
69
        m_plugin->closeOutput(m_pluginLine, m_universe);
1✔
70

71
    m_plugin = plugin;
19✔
72
    m_pluginLine = output;
19✔
73

74
    if (m_plugin != NULL)
19✔
75
    {
76
        emit pluginNameChanged();
19✔
77
        if (m_pluginLine != QLCIOPlugin::invalidLine())
19✔
78
            emit outputNameChanged();
19✔
79
    }
80

81
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
19✔
82
        return m_plugin->openOutput(m_pluginLine, m_universe);
19✔
83

84
    return false;
×
85
}
86

87
bool OutputPatch::reconnect()
1✔
88
{
89
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
1✔
90
    {
91
        m_plugin->closeOutput(m_pluginLine, m_universe);
1✔
92
#if defined(WIN32) || defined(Q_OS_WIN)
93
        Sleep(GRACE_MS);
94
#else
95
        usleep(GRACE_MS * 1000);
1✔
96
#endif
97
        bool ret = m_plugin->openOutput(m_pluginLine, m_universe);
1✔
98
        if (ret == true)
1✔
99
        {
100
            QMap<QString, QVariant>::iterator it = m_parametersCache.begin();
1✔
101
            for (; it != m_parametersCache.end(); it++)
1✔
102
                m_plugin->setParameter(m_universe, m_pluginLine, QLCIOPlugin::Output, it.key(), it.value());
×
103
        }
104
        return ret;
1✔
105
    }
106
    return false;
×
107
}
108

109
QString OutputPatch::pluginName() const
12✔
110
{
111
    if (m_plugin != NULL)
12✔
112
        return m_plugin->name();
11✔
113
    else
114
        return KOutputNone;
1✔
115
}
116

117
QLCIOPlugin* OutputPatch::plugin() const
7✔
118
{
119
    return m_plugin;
7✔
120
}
121

122
QString OutputPatch::outputName() const
4✔
123
{
124
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine() &&
7✔
125
        m_pluginLine < quint32(m_plugin->outputs().size()))
7✔
126
    {
127
        return m_plugin->outputs()[m_pluginLine];
3✔
128
    }
129
    else
130
    {
131
        return KOutputNone;
1✔
132
    }
133
}
134

135
quint32 OutputPatch::output() const
11✔
136
{
137
    return m_pluginLine;
11✔
138
}
139

140
bool OutputPatch::isPatched() const
×
141
{
142
    return output() != QLCIOPlugin::invalidLine() && m_plugin != NULL;
×
143
}
144

145
void OutputPatch::setPluginParameter(QString prop, QVariant value)
4✔
146
{
147
    m_parametersCache[prop] = value;
4✔
148
    if (m_plugin != NULL)
4✔
149
        m_plugin->setParameter(m_universe, m_pluginLine, QLCIOPlugin::Output, prop, value);
4✔
150
}
4✔
151

152
QMap<QString, QVariant> OutputPatch::getPluginParameters()
×
153
{
154
    if (m_plugin != NULL)
×
155
        return m_plugin->getParameters(m_universe, m_pluginLine, QLCIOPlugin::Output);
×
156

157
    return QMap<QString, QVariant>();
×
158
}
159

160
/*****************************************************************************
161
 * Value dump
162
 *****************************************************************************/
163
bool OutputPatch::paused() const
×
164
{
165
    return m_paused;
×
166
}
167

168
void OutputPatch::setPaused(bool paused)
2✔
169
{
170
    if (m_paused == paused)
2✔
171
        return;
×
172

173
    m_paused = paused;
2✔
174

175
    if (m_pauseBuffer.length())
2✔
176
        m_pauseBuffer.clear();
1✔
177

178
    emit pausedChanged(m_paused);
2✔
179
}
180

181
bool OutputPatch::blackout() const
40✔
182
{
183
    return m_blackout;
40✔
184
}
185

186
void OutputPatch::setBlackout(bool blackout)
12✔
187
{
188
    if (m_blackout == blackout)
12✔
189
        return;
×
190

191
    m_blackout = blackout;
12✔
192
    emit blackoutChanged(m_blackout);
12✔
193
}
194

195
void OutputPatch::dump(quint32 universe, const QByteArray& data, bool dataChanged)
44✔
196
{
197
    /* Don't do anything if there is no plugin and/or output line. */
198
    if (m_plugin != NULL && m_pluginLine != QLCIOPlugin::invalidLine())
44✔
199
    {
200
        if (m_paused)
44✔
201
        {
202
            if (m_pauseBuffer.isNull())
2✔
203
                m_pauseBuffer.append(data);
1✔
204

205
            m_plugin->writeUniverse(universe, m_pluginLine, m_pauseBuffer, dataChanged);
2✔
206
        }
207
        else
208
        {
209
            m_plugin->writeUniverse(universe, m_pluginLine, data, dataChanged);
42✔
210
        }
211
    }
212
}
44✔
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