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

mcallegari / qlcplus / 4393537972

pending completion
4393537972

push

github

Massimo Callegari
resources: 5 new fixtures (see changelog)

15282 of 54426 relevant lines covered (28.08%)

20192.05 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 "qlcchannel.h"
25
#include "universe.h"
26
#include "doc.h"
27

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

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

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

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

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

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

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

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

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

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

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

107
    QMutexLocker locker(&m_mutex);
×
108

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

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

120
            quint32 universe = fixture->universe();
×
121
            QSharedPointer<GenericFader> fader = m_fadersMap.value(universe, QSharedPointer<GenericFader>());
×
122
            if (fader.isNull())
×
123
            {
124
                fader = ua[universe]->requestFader();
×
125
                m_fadersMap[universe] = fader;
×
126
            }
127

128
            FadeChannel *fc = fader->getChannelFader(m_doc, ua[universe], fixture->id(), it.key().second);
×
129
            fc->setCurrent(it.value());
×
130
            fc->setTarget(it.value());
×
131
        }
132
    }
133
    if (m_clearRequest)
×
134
    {
135
        m_clearRequest = false;
×
136
        m_values.clear();
×
137

138
        QMapIterator <quint32, QSharedPointer<GenericFader> > it(m_fadersMap);
×
139
        while (it.hasNext() == true)
×
140
        {
141
            it.next();
×
142
            quint32 universe = it.key();
×
143
            QSharedPointer<GenericFader> fader = it.value();
×
144
            ua[universe]->dismissFader(fader);
×
145
        }
146
        m_fadersMap.clear();
×
147
    }
148
}
×
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