Files
T
torstenandCopilot 7a6be7474e Qt6 migration: Fix BUILD_RTI=OFF build errors in TrainingAreaBase
- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document

C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+

Build status: BUILD_RTI=OFF successful (0 errors, warnings only)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-23 20:49:23 +02:00

134 lines
3.2 KiB
C++
Executable File

#include "handeleffect.h"
#include <QtCore/QUrlQuery>
#include <QtCore/QTimer>
namespace BuildingControlUnit
{
HandelEffect::HandelEffect(QObject *parent, const QString &loggerchannel)
: QObject(parent)
, m_logger(getLogger(QStringLiteral("HandelSingleEffect.") + loggerchannel))
{
}
bool HandelEffect::init(const QVector<Action *> &actions, int repetitions = 1)
{
if (actions.isEmpty())
return false;
m_actions = actions;
m_currentAction = nullptr;
m_repeatCount = repetitions;
return true;
}
void HandelEffect::handleEffect()
{
if (!m_currentAction)
{
if (m_repeatCount != 0)
{
m_currentAction = m_actions.first();
--m_repeatCount;
}
else
{
emit effectReady();
deleteLater();
return;
}
}
else
{
int index = m_actions.indexOf(m_currentAction);
++index;
m_currentAction = m_actions.value(index, nullptr);
if (!m_currentAction)
{
QTimer::singleShot(0, this, &HandelEffect::handleEffect);
return;
}
}
switch (m_currentAction->aclass)
{
case AC_Unset:
DEBUG_LOG(m_logger) << "---- This is unset ----";
break;
case AC_Standard:
{
DEBUG_LOG(m_logger) << "---- This is a standard Action ----";
if (!m_currentAction->url.isEmpty())
{
DEBUG_LOG(m_logger) << "---- emit newHttpRequest(a->url):" << m_currentAction->url.toString();
emit newHttpRequest(m_currentAction->url);
}
break;
}
case AC_Repeat:
{
DEBUG_LOG(m_logger) << "---- This is a Repeat Action";
const RepeatAction *ra = static_cast<const RepeatAction *>(m_currentAction);
HandelEffect *he = new HandelEffect(this);
he->init(ra->actions, ra->count);
connect(he, &HandelEffect::effectReady, this, &HandelEffect::handleEffect);
connect(he, &HandelEffect::newHttpRequest, this, &HandelEffect::newHttpRequest);
connect(he, &HandelEffect::triggerAllFlashlights, this, &HandelEffect::triggerAllFlashlights);
QTimer::singleShot(0, he, &HandelEffect::handleEffect);
return;
}
case AC_Pause:
{
const PauseAction *pa = static_cast<const PauseAction *>(m_currentAction);
DEBUG_LOG(m_logger) << "---- This is a Pause Action Pause=" << pa->pause
<< " comment=" << pa->comment;
QTimer::singleShot(pa->pause, this, &HandelEffect::handleEffect);
return;
}
case AC_Bsm:
{
DEBUG_LOG(m_logger) << "---- This is a Bsm Action ";
const BsmAction *ba = static_cast<const BsmAction*>(m_currentAction);
if (!ba->isNull())
{
DEBUG_LOG(m_logger) << "emit triggerAllFlashlights ------ atype=" << m_currentAction->atype
<< " pause=" << ba->pause
<< " choplength=" << ba->choplength
<< " pulses=" << ba->pulses
<< " pulseduration=" << ba->pulseduration
<< " comment=" << ba->comment
<< " this: " << this;
emit triggerAllFlashlights(ba->pulses, ba->pause, ba->choplength, ba->pulseduration);
}
break;
}
default:
break;
}
DEBUG_LOG(m_logger) << "--- End Action ";
QTimer::singleShot(0, this, &HandelEffect::handleEffect);
}
}