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

mcallegari / qlcplus / 27867971263

20 Jun 2026 10:09AM UTC coverage: 35.268% (-0.1%) from 35.377%
27867971263

push

github

mcallegari
Back to 5.3.0 debug

18433 of 52265 relevant lines covered (35.27%)

41250.48 hits per line

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

92.05
/engine/src/genericdmxsource.cpp
1
/*
2
  Q Light Controller
3
  genericdmxsource.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
#include "genericdmxsource.h"
21
#include "genericfader.h"
22
#include "mastertimer.h"
23
#include "fadechannel.h"
24
#include "universe.h"
25
#include "doc.h"
26

27
#include <cmath>
28

29
GenericDMXSource::GenericDMXSource(Doc* doc)
2✔
30
    : m_doc(doc)
2✔
31
    , m_outputEnabled(false)
2✔
32
    , m_clearRequest(false)
2✔
33
    , m_changed(false)
2✔
34
{
35
    Q_ASSERT(m_doc != NULL);
2✔
36
    m_doc->masterTimer()->registerDMXSource(this);
2✔
37
}
2✔
38

39
GenericDMXSource::~GenericDMXSource()
2✔
40
{
41
    foreach (QSharedPointer<GenericFader> fader, m_fadersMap)
2✔
42
    {
43
        if (!fader.isNull())
×
44
            fader->requestDelete();
×
45
    }
2✔
46
    m_fadersMap.clear();
2✔
47

48
    m_doc->masterTimer()->unregisterDMXSource(this);
2✔
49
}
2✔
50

51
void GenericDMXSource::set(quint32 fxi, quint32 ch, uchar value)
2✔
52
{
53
    QMutexLocker locker(&m_mutex);
2✔
54
    m_values[QPair<quint32,quint32>(fxi, ch)] = value;
2✔
55
    m_changed = true;
2✔
56
}
2✔
57

58
void GenericDMXSource::unset(quint32 fxi, quint32 ch)
1✔
59
{
60
    QMutexLocker locker(&m_mutex);
1✔
61
    m_values.remove(QPair<quint32,quint32>(fxi, ch));
1✔
62
    m_changed = true;
1✔
63
}
1✔
64

65
void GenericDMXSource::unsetAll()
1✔
66
{
67
    QMutexLocker locker(&m_mutex);
1✔
68
    // will be processed at the next writeDMX
69
    m_clearRequest = true;
1✔
70
    m_changed = true;
1✔
71
}
1✔
72

73
void GenericDMXSource::setOutputEnabled(bool enable)
2✔
74
{
75
    m_outputEnabled = enable;
2✔
76
}
2✔
77

78
bool GenericDMXSource::isOutputEnabled() const
×
79
{
80
    return m_outputEnabled;
×
81
}
82

83
quint32 GenericDMXSource::channelsCount() const
4✔
84
{
85
    return m_values.count();
4✔
86
}
87

88
QList<SceneValue> GenericDMXSource::channels()
1✔
89
{
90
    QList<SceneValue> chList;
1✔
91
    QMutableMapIterator <QPair<quint32,quint32>,uchar> it(m_values);
1✔
92
    while (it.hasNext() == true)
2✔
93
    {
94
        it.next();
1✔
95
        SceneValue sv;
1✔
96
        sv.fxi = it.key().first;
1✔
97
        sv.channel = it.key().second;
1✔
98
        sv.value = it.value();
1✔
99
        chList.append(sv);
1✔
100
    }
1✔
101
    return chList;
2✔
102
}
×
103

104
void GenericDMXSource::writeDMX(MasterTimer* timer, QList<Universe *> ua)
2✔
105
{
106
    Q_UNUSED(timer);
107

108
    QMutexLocker locker(&m_mutex);
2✔
109

110
    if (m_outputEnabled && m_changed)
2✔
111
    {
112

113
        QMutableMapIterator <QPair<quint32,quint32>,uchar> it(m_values);
2✔
114
        while (it.hasNext())
4✔
115
        {
116
            it.next();
2✔
117
            Fixture *fixture = m_doc->fixture(it.key().first);
2✔
118
            if (fixture == NULL)
2✔
119
                continue;
×
120

121
            quint32 channelIndex = it.key().second;
2✔
122
            int universeIndex = floor((fixture->universeAddress() + channelIndex) / 512);
2✔
123

124
            if (universeIndex >= ua.count())
2✔
125
                continue;
×
126

127
            Universe *universe = ua[universeIndex];
2✔
128

129
            QSharedPointer<GenericFader> fader = m_fadersMap.value(universe->id(), QSharedPointer<GenericFader>());
2✔
130
            if (fader.isNull())
2✔
131
            {
132
                fader = universe->requestFader();
1✔
133
                m_fadersMap[universe->id()] = fader;
1✔
134
            }
135

136
            const uchar value = it.value();
2✔
137
            fader->updateChannel(m_doc, universe, fixture->id(), channelIndex, [value](FadeChannel &fc)
2✔
138
            {
139
                fc.setCurrent(value);
2✔
140
                fc.setTarget(value);
2✔
141
            });
2✔
142
        }
2✔
143
    }
144
    if (m_clearRequest)
2✔
145
    {
146
        m_clearRequest = false;
1✔
147
        m_values.clear();
1✔
148

149
        QMapIterator <quint32, QSharedPointer<GenericFader> > it(m_fadersMap);
1✔
150
        while (it.hasNext() == true)
2✔
151
        {
152
            it.next();
1✔
153
            quint32 universe = it.key();
1✔
154
            QSharedPointer<GenericFader> fader = it.value();
1✔
155
            ua[universe]->dismissFader(fader);
1✔
156
        }
1✔
157
        m_fadersMap.clear();
1✔
158
    }
1✔
159
}
2✔
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