129 lines
3.2 KiB
C++
Executable File
129 lines
3.2 KiB
C++
Executable File
/**
|
|
* AES Function Topic Client test executable
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "aes_test_gas_pipe.h"
|
|
#include <QCoreApplication>
|
|
#include <QTest>
|
|
#include <QTimer>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
|
|
TestGasPipe::TestGasPipe(QObject *parent)
|
|
: TestBase("Test.GasPipe", parent)
|
|
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
|
|
{}
|
|
|
|
bool TestGasPipe::init(int domainId, int exerciseId, int testId)
|
|
{
|
|
if (!TestBase::init(domainId, exerciseId, testId))
|
|
return false;
|
|
|
|
tryCreateGasPipe();
|
|
|
|
m_dtc->waitForHistoricalDataGasPipe();
|
|
m_esData.id(-1);
|
|
|
|
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::gasPipeChanged,
|
|
this, &TestGasPipe::gasPipeChanged);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool TestGasPipe::checkBaseData(const AreaEffectSimulation::GasPipe &a,
|
|
const AreaEffectSimulation::GasPipe &b) const
|
|
{
|
|
if (!checkAesItem(a, b))
|
|
return false;
|
|
|
|
/*if (a.impactPosition() != b.impactPosition())
|
|
{
|
|
WARNING_LOG(m_logger) << "impactPosition does not match: " << a.impactPosition() << " - " << b.impactPosition();
|
|
return false;
|
|
}*/
|
|
return true;
|
|
}
|
|
|
|
static inline void setPos(std::vector<Core::GeoPosition2D> &cont, const QPointF &pos)
|
|
{
|
|
cont.emplace_back(Core::GeoPosition2D(pos.x(), pos.y()));
|
|
}
|
|
|
|
//
|
|
// GasPipe
|
|
//
|
|
void TestGasPipe::tryCreateGasPipe()
|
|
{
|
|
AreaEffectSimulation::GasPipeModifyRequest gp;
|
|
//AreaEffectSimulation::GasPipe gp;
|
|
gp.id(0);
|
|
gp.name("GasPipe");
|
|
gp.partyId(1);
|
|
|
|
setPos(gp.segments(), m_refPos.geographic(3, 3));
|
|
setPos(gp.segments(), m_refPos.geographic(4, 4));
|
|
setPos(gp.segments(), m_refPos.geographic(5, 3));
|
|
|
|
DEBUG_LOG(m_logger) << LOGFUNCTION << " GasPipe created. id: " << gp.id();
|
|
DEBUG_LOG(m_logger) << "request GasPipe";
|
|
if (!m_ftc->gasPipeModifyRequest( gp, this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during explosionSingleCreateRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
}
|
|
|
|
void TestGasPipe::tryModifyGasPipe()
|
|
{
|
|
INFO_LOG(m_logger) << "tryModifyGasPipe successful";
|
|
}
|
|
|
|
void TestGasPipe::waitExpireGasPipe()
|
|
{
|
|
INFO_LOG(m_logger) << "waiting until explosion single expires";
|
|
|
|
if (!waitForData([this]() { return m_esData.effectStateId() == AreaEffectSimulation::AesEffectState::EsExpired;}))
|
|
{
|
|
ERROR_LOG(m_logger) << "Timeout waiting for expiry of explosion single with id " << m_esData.id();
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
INFO_LOG(m_logger) << "waitExpireGasPipe successful";
|
|
}
|
|
|
|
void TestGasPipe::gasPipeChanged(const AreaEffectSimulation::GasPipe &data, DataModification modType)
|
|
{
|
|
if (m_esData.id() == -1)
|
|
return;
|
|
onAesChanged(data, modType, m_esData);
|
|
}
|
|
|
|
void TestGasPipe::onGasPipeModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (m_bIsCreatedRequest)
|
|
onAesCreateReply(replyObject);
|
|
else
|
|
onAesModifyReply(replyObject);
|
|
}
|
|
|
|
void TestGasPipe::onGasPipeRemoveReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
onAesRemoveReply(replyObject);
|
|
}
|
|
|
|
} // namespace AreaEffectSimulation
|
|
|
|
// ------------------------------------------------------------------
|
|
int main(int argc, char **argv)
|
|
{
|
|
return AreaEffectSimulation::mainBase(argc, argv, []() { return new AreaEffectSimulation::TestGasPipe; });
|
|
}
|
|
|