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

mcallegari / qlcplus / 7307414152

23 Dec 2023 09:18AM CUT coverage: 32.067%. Remained the same
7307414152

push

github

web-flow
Merge pull request #1493 from yestalgia/readme

Update Readme

15169 of 47304 relevant lines covered (32.07%)

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

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

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

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

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

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

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

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

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

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

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

106
    QMutexLocker locker(&m_mutex);
×
107

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

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

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

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

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