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

mcallegari / qlcplus / 42371974533

07 Nov 2026 12:19PM UTC coverage: 36.826% (-0.1%) from 36.925%
42371974533

push

github

mcallegari
Back to 5.4.0 debug

19248 of 52268 relevant lines covered (36.83%)

41917.74 hits per line

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

93.41
/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)
3 ✔
30
    : m_doc(doc)
3 ✔
31
    , m_outputEnabled(false)
3 ✔
32
    , m_clearRequest(false)
3 ✔
33
    , m_changed(false)
3 ✔
34
{
35
    Q_ASSERT(m_doc != NULL);
3 ✔
36
    m_doc->masterTimer()->registerDMXSource(this);
3 ✔
37
}
3 ✔
38

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

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

51
void GenericDMXSource::set(quint32 fxi, quint32 ch, uchar value)
8 ✔
52
{
53
    QMutexLocker locker(&m_mutex);
8 ✔
54
    m_values[QPair<quint32,quint32>(fxi, ch)] = value;
8 ✔
55
    m_changed = true;
8 ✔
56
}
8 ✔
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)
3 ✔
74
{
75
    m_outputEnabled = enable;
3 ✔
76
}
3 ✔
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)
3 ✔
105
{
106
    Q_UNUSED(timer);
107

108
    QMutexLocker locker(&m_mutex);
3 ✔
109

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

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

121
            quint32 channelIndex = it.key().second;
8 ✔
122
            quint32 absAddress = fixture->channelAddress(channelIndex);
8 ✔
123
            if (absAddress == QLCChannel::invalid())
8 ✔
124
                continue;
×
125

126
            int universeIndex = absAddress >> 9;
8 ✔
127

128
            if (universeIndex >= ua.count())
8 ✔
129
                continue;
×
130

131
            Universe *universe = ua[universeIndex];
8 ✔
132

133
            QSharedPointer<GenericFader> fader = m_fadersMap.value(universe->id(), QSharedPointer<GenericFader>());
8 ✔
134
            if (fader.isNull())
8 ✔
135
            {
136
                fader = universe->requestFader();
5 ✔
137
                m_fadersMap[universe->id()] = fader;
5 ✔
138
            }
139

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

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