79 lines
2.3 KiB
C++
Executable File
79 lines
2.3 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Definition des PAN-Telegramms PanErDirectFire
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Gerlinde Rudolphus, SLSA, 2013-03-05
|
|
*/
|
|
|
|
#include "bsm_telegrams_direct_fire.h"
|
|
#include "logger.h"
|
|
#include <QStringBuilder>
|
|
|
|
namespace BuildingControlUnit
|
|
{
|
|
namespace BSM
|
|
{
|
|
namespace Telegrams
|
|
{
|
|
|
|
QByteArray PanDirectFire::print() const
|
|
{
|
|
QByteArray ret = Telegram::print() ;
|
|
ret += "\n TimeofEvent = " + QByteArray::number(m_timeofEvent);
|
|
ret += "\n AmmunitionId = " + QByteArray::number(m_ammunitionId);
|
|
ret += "\n Deposition1 = " + QByteArray::number(m_deposition1);
|
|
ret += "\n Deposition2 = " + QByteArray::number(m_deposition2);
|
|
ret += "\n NumberOpticalPulses = " + QByteArray::number(m_numberOpticalPulses);
|
|
ret += "\n IDNumberOriginator = " + QByteArray::number(m_originatorId);
|
|
ret += "\n DetectorNo = " + QByteArray::number(m_detectorNo);
|
|
ret += "\n AmmunitionChildCode = " + QByteArray::number(m_ammunitionChildCode);
|
|
|
|
return ret;
|
|
}
|
|
|
|
QByteArray PanDirectFire::payload() const
|
|
{
|
|
Q_ASSERT(false);
|
|
return QByteArray();
|
|
}
|
|
|
|
Telegram *PanDirectFire::fromBytestream(const QByteArray &data)
|
|
{
|
|
NGL::INGLLogger &logger = getLogger("PanDirectFire");
|
|
DEBUG_LOG(logger) << "data.length=" << data.length();
|
|
if (data.length() < 9)
|
|
return nullptr;
|
|
|
|
bool bOk = true;
|
|
PanDirectFire rep;
|
|
rep.m_timeofEvent = decode_ushort_little(data, 0, bOk);
|
|
rep.m_ammunitionId = decode_ushort_little(data, 2, bOk);
|
|
if (data.length() == 9)
|
|
{
|
|
rep.m_deposition1 = static_cast<short>(data[3]);
|
|
rep.m_deposition2 = static_cast<short>(data[4]);
|
|
rep.m_numberOpticalPulses = static_cast<unsigned short>(data[5]);
|
|
rep.m_originatorId = decode_ushort_little(data, 6, bOk);
|
|
rep.m_detectorNo = static_cast<unsigned short>(data[8] & 0xFF);
|
|
}
|
|
else
|
|
{
|
|
rep.m_deposition1 = static_cast<short>(data[4]);
|
|
rep.m_deposition2 = static_cast<short>(data[5]);
|
|
rep.m_numberOpticalPulses = static_cast<unsigned short>(data[6]);
|
|
rep.m_originatorId = decode_ushort_little(data, 7, bOk);
|
|
rep.m_detectorNo = static_cast<unsigned short>(data[9] & 0xFF);
|
|
}
|
|
// optional
|
|
if (data.length() >= 12)
|
|
rep.m_ammunitionChildCode = decode_ushort_little(data, 10, bOk);
|
|
|
|
return bOk ? new PanDirectFire(rep) : nullptr;
|
|
}
|
|
|
|
} // namespace Telegrams
|
|
} // namespace BSM
|
|
} // namespace BuildingControlUnit
|