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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

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

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

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

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

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

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

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

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

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

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

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

108
    QMutexLocker locker(&m_mutex);
×
109

110
    if (m_outputEnabled && m_changed)
×
111
    {
112

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

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

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

127
            Universe *universe = ua[universeIndex];
×
128

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

136
            FadeChannel *fc = fader->getChannelFader(m_doc, universe, fixture->id(), channelIndex);
×
137
            fc->setCurrent(it.value());
×
138
            fc->setTarget(it.value());
×
139
        }
140
    }
141
    if (m_clearRequest)
×
142
    {
143
        m_clearRequest = false;
×
144
        m_values.clear();
×
145

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