Skip to content

Commit

Permalink
Merge branch 'Feature_#175' into 2.2-dev
Browse files Browse the repository at this point in the history
Resolves docsteer#175 Misleading display with 0xdd running at priority 0
  • Loading branch information
marcusbirkin committed Apr 18, 2021
2 parents d1b5b5d + c702925 commit 6faf2fb
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 26 deletions.
14 changes: 14 additions & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ void Preferences::SetDisplayDDOnly(bool bDDOnly)
return;
}

void Preferences::SetIgnoreDD(bool bIgnoreDD)
{
Q_ASSERT(bIgnoreDD == 0 || bIgnoreDD == 1);
m_bIgnoreDD = bIgnoreDD;
return;
}

void Preferences::SetDefaultTransmitName (const QString &sDefaultTransmitName)
{
m_sDefaultTransmitName = sDefaultTransmitName.trimmed();
Expand Down Expand Up @@ -199,6 +206,11 @@ bool Preferences::GetDisplayDDOnly() const
return m_bDisplayDDOnly;
}

bool Preferences::GetIgnoreDD() const
{
return m_bIgnoreDD;
}

QString Preferences::GetDefaultTransmitName() const
{
return m_sDefaultTransmitName;
Expand Down Expand Up @@ -279,6 +291,7 @@ void Preferences::savePreferences()
settings.setValue(S_DISPLAY_FORMAT, QVariant(m_nDisplayFormat));
settings.setValue(S_BLIND_VISUALIZER, QVariant(m_bBlindVisualizer));
settings.setValue(S_DDONLY, QVariant(m_bDisplayDDOnly));
settings.setValue(S_IGNOREDD, QVariant(m_bIgnoreDD));
settings.setValue(S_DEFAULT_SOURCENAME, m_sDefaultTransmitName);
settings.setValue(S_TIMEOUT, QVariant(m_nNumSecondsOfSacn));
settings.setValue(S_FLICKERFINDERSHOWINFO, QVariant(m_flickerFinderShowInfo));
Expand Down Expand Up @@ -337,6 +350,7 @@ void Preferences::loadPreferences()
m_nDisplayFormat = settings.value(S_DISPLAY_FORMAT, QVariant(DECIMAL)).toInt();
m_bBlindVisualizer = settings.value(S_BLIND_VISUALIZER, QVariant(true)).toBool();
m_bDisplayDDOnly = settings.value(S_DDONLY, QVariant(true)).toBool();
m_bIgnoreDD = settings.value(S_IGNOREDD, QVariant(false)).toBool();
m_sDefaultTransmitName = settings.value(S_DEFAULT_SOURCENAME, DEFAULT_SOURCE_NAME).toString();
m_nNumSecondsOfSacn = settings.value(S_TIMEOUT, QVariant(0)).toInt();
m_flickerFinderShowInfo = settings.value(S_FLICKERFINDERSHOWINFO, QVariant(true)).toBool();
Expand Down
4 changes: 4 additions & 0 deletions src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static const QString S_INTERFACE_NAME("InterfaceName");
static const QString S_DISPLAY_FORMAT("Display Format");
static const QString S_BLIND_VISUALIZER("Show Blind");
static const QString S_DDONLY("Show DDOnly");
static const QString S_IGNOREDD("Ignore DD");
static const QString S_DEFAULT_SOURCENAME("Default Transmit Source Name");
static const QString S_TIMEOUT("Timeout");
static const QString S_FLICKERFINDERSHOWINFO("Flicker Finder Info");
Expand Down Expand Up @@ -114,6 +115,7 @@ class Preferences
void SetDisplayFormat(unsigned int nDisplayFormat);
void SetBlindVisualizer (bool bBlindVisualizer);
void SetDisplayDDOnly (bool bDDOnly);
void SetIgnoreDD(bool bIgnoreDD);
void SetDefaultTransmitName (const QString &sDefaultTransmitName);
void SetNumSecondsOfSacn (int nNumSecondsOfSacn);
void setFlickerFinderShowInfo(bool showIt);
Expand All @@ -133,6 +135,7 @@ class Preferences
unsigned int GetMaxLevel() const;
bool GetBlindVisualizer() const;
bool GetDisplayDDOnly() const;
bool GetIgnoreDD() const;
QString GetDefaultTransmitName() const;
unsigned int GetNumSecondsOfSacn() const;
bool getFlickerFinderShowInfo() const;
Expand Down Expand Up @@ -165,6 +168,7 @@ public slots:
unsigned int m_nDisplayFormat;
bool m_bBlindVisualizer;
bool m_bDisplayDDOnly;
bool m_bIgnoreDD;
QString m_sDefaultTransmitName;
unsigned int m_nNumSecondsOfSacn;
bool m_flickerFinderShowInfo;
Expand Down
9 changes: 8 additions & 1 deletion src/sacn/sacnlistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,12 @@ void sACNListener::processDatagram(QByteArray data, QHostAddress destination, QH
memcpy(ps->last_priority_array, ps->priority_array, DMX_SLOT_MAX);
// Fill in the new array
memset(ps->priority_array, 0, DMX_SLOT_MAX);
memcpy(ps->priority_array, pdata, slot_count);
if (Preferences::getInstance()->GetIgnoreDD())
{ // DD is ignored, fill with universe priority
std::fill(std::begin(ps->priority_array), std::end(ps->priority_array), ps->priority);
} else {
memcpy(ps->priority_array, pdata, slot_count);
}
// Compare the two
for(int i=0; i<DMX_SLOT_MAX; i++)
{
Expand Down Expand Up @@ -741,6 +746,7 @@ void sACNListener::performMerge()
m_merged_levels[address].level = -1;
m_merged_levels[address].winningSource = NULL;
m_merged_levels[address].otherSources.clear();
m_merged_levels[address].winningPriority = priorities[address];
}
for (auto s : sourceList)
{
Expand All @@ -750,6 +756,7 @@ void sACNListener::performMerge()
m_merged_levels[address].changedSinceLastMerge = (m_merged_levels[address].level != levels[address]);
m_merged_levels[address].level = levels[address];
m_merged_levels[address].winningSource = s;
m_merged_levels[address].winningPriority = priorities[address];
}
}
// Remove the winning source from the list of others
Expand Down
2 changes: 2 additions & 0 deletions src/sacn/sacnlistener.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ struct sACNMergedAddress
level = -1;
winningSource = NULL;
changedSinceLastMerge = false;
winningPriority = 0;
}
int level;
sACNSource *winningSource;
QSet<sACNSource *> otherSources;
bool changedSinceLastMerge;
int winningPriority;
};

typedef QVector<sACNMergedAddress> sACNMergedSourceList;
Expand Down
7 changes: 6 additions & 1 deletion src/ui/preferencesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) :

ui->cbDisplayBlind->setChecked(Preferences::getInstance()->GetBlindVisualizer());
ui->cbDisplayDDOnlys->setChecked(Preferences::getInstance()->GetDisplayDDOnly());
ui->cbIgnoreDD->setChecked(Preferences::getInstance()->GetIgnoreDD());
ui->cbRestoreWindows->setChecked(Preferences::getInstance()->GetSaveWindowLayout());

ui->leDefaultSourceName->setText(Preferences::getInstance()->GetDefaultTransmitName());
Expand Down Expand Up @@ -121,10 +122,14 @@ void PreferencesDialog::on_buttonBox_accepted()
// Display Blind
p->SetBlindVisualizer(ui->cbDisplayBlind->isChecked());

// Display DD
// Display sources with only DD
if (ui->cbDisplayDDOnlys->isChecked() != p->GetDisplayDDOnly() ) {requiresRestart = true;}
p->SetDisplayDDOnly(ui->cbDisplayDDOnlys->isChecked());

// Ignore DD
//if (ui->cbIgnoreDD->isChecked() != p->GetIgnoreDD() );
p->SetIgnoreDD(ui->cbIgnoreDD->isChecked());

// Save layout
p->SetSaveWindowLayout(ui->cbRestoreWindows->isChecked());

Expand Down
55 changes: 34 additions & 21 deletions src/ui/universeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ void UniverseView::sourceChanged(sACNSource *source)
}

ui->twSources->item(row,COL_VER)->setText(protocolVerToString(source->protocol_version));
ui->twSources->item(row,COL_DD)->setText(source->doing_per_channel ? tr("Yes") : tr("No"));
ui->twSources->item(row,COL_DD)->setText(
source->doing_per_channel ?
(Preferences::getInstance()->GetIgnoreDD() ? "Ignored" : "Yes")
: tr("No"));
ui->twSources->item(row,COL_SLOTS)->setText(QString::number(source->slot_count));
}

Expand Down Expand Up @@ -241,7 +244,7 @@ void UniverseView::sourceOnline(sACNSource *source)
pLayout->addWidget(btn_seq);

// Connect button
connect(btn_seq, &QPushButton::clicked, [=]() {
connect(btn_seq, &QPushButton::clicked, this, [=]() {
source->resetSeqErr();
this->sourceChanged(source);
});
Expand Down Expand Up @@ -270,7 +273,7 @@ void UniverseView::sourceOnline(sACNSource *source)
pLayout->addWidget(btn_jumps);

// Connect button
connect(btn_jumps, &QPushButton::clicked, [=]() {
connect(btn_jumps, &QPushButton::clicked, this, [=]() {
source->resetJumps();
this->sourceChanged(source);
});
Expand Down Expand Up @@ -341,6 +344,20 @@ void UniverseView::resizeColumns()
ui->twSources->setColumnWidth(COL_NAME, width-used-5);
}

QString UniverseView::prioText(sACNSource *source, quint8 address)
{
if (source == nullptr)
return "Unknown";

if(source->doing_per_channel)
if (source->priority_array[address] > 0)
return QString::number(source->priority_array[address]);
else
return tr("Unpatched");
else
return QString::number(source->priority);
}

void UniverseView::selectedAddressChanged(int address)
{
ui->teInfo->clear();
Expand All @@ -358,32 +375,28 @@ void UniverseView::selectedAddressChanged(int address)

if(list[address].winningSource)
{
int prio;
if(list[address].winningSource->doing_per_channel)
prio = list[address].winningSource->priority_array[address];
else
prio = list[address].winningSource->priority;
info.append(tr("Winning Source : %1 @ %2 (Priority %3)").arg(
list[address].winningSource->name,
Preferences::getInstance()->GetFormattedValue(list[address].level),
prioText(list[address].winningSource, address)));

info.append(tr("Winning Source : %1 @ %2 (Priority %3)")
.arg(list[address].winningSource->name)
.arg(Preferences::getInstance()->GetFormattedValue(list[address].level))
.arg(prio));
if(list[address].otherSources.count()>0)
{
foreach(sACNSource *source, list[address].otherSources)
{
if(source->doing_per_channel)
prio = source->priority_array[address];
else
prio = source->priority;
info.append(tr("\nOther Source : %1 @ %2 (Priority %3)")
.arg(source->name)
.arg(Preferences::getInstance()->GetFormattedValue(source->level_array[address]))
.arg(prio));
info.append(tr("\nOther Source : %1 @ %2 (Priority %3)").arg(
source->name,
Preferences::getInstance()->GetFormattedValue(source->level_array[address]),
prioText(source, address)));
}
}
} else {
info.append(tr("No Sources"));
if (list[address].winningPriority <= 0)
{
info.append(tr("Unpatched"));
} else {
info.append(tr("No Sources"));
}
}

ui->teInfo->setPlainText(info);
Expand Down
2 changes: 2 additions & 0 deletions src/ui/universeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ protected slots:
bool m_bindWarningShown = false;
void checkBind();

QString prioText(sACNSource *source, quint8 address);

Ui::UniverseView *ui = nullptr;
QHash<sACNSource *, int> m_sourceToTableRow;
int m_selectedAddress = -1;
Expand Down
13 changes: 10 additions & 3 deletions ui/preferencesdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>653</width>
<height>491</height>
<width>772</width>
<height>511</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -196,7 +196,7 @@
<property name="title">
<string>Recieve Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,1">
<item>
<widget class="QCheckBox" name="cbDisplayBlind">
<property name="sizePolicy">
Expand Down Expand Up @@ -229,6 +229,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbIgnoreDD">
<property name="text">
<string>Ignore Per-Address priority (0xdd)</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
Expand Down

0 comments on commit 6faf2fb

Please sign in to comment.