Adds NmeaManagement tests, fixes codegen includes and Qt6 SerialPort CMake target.
134 lines
4.5 KiB
C++
Executable File
134 lines
4.5 KiB
C++
Executable File
/**
|
|
* Handler for the HMI language
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "object_video_receiver.h"
|
|
|
|
#include "dds_handler.h"
|
|
#include "logger.h"
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
ObjectVideoReceiver::ObjectVideoReceiver(Interface::Dts *dts,
|
|
DatabaseInterface *db)
|
|
: m_dts(dts)
|
|
, m_db(db)
|
|
, m_logger(getLogger("ObjectVideoReceiver"))
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
ObjectVideoReceiver::~ObjectVideoReceiver()
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectVideoReceiver::createObject(const VideoReceiver &data)
|
|
{
|
|
m_data = data;
|
|
if (m_data.id <= 0)
|
|
{
|
|
Database::AvmVideoReceiver dbData;
|
|
dbData = toDbData(data);
|
|
|
|
if (!m_db->insert(dbData))
|
|
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting AvmVideoReceiver-data into database"));
|
|
|
|
m_data.id = dbData.id;
|
|
DEBUG_LOG(m_logger) << "New Id: " << m_data.id;
|
|
}
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectVideoReceiver::updateObject(const VideoReceiver &data)
|
|
{
|
|
m_data = data;
|
|
DEBUG_LOG(m_logger) << "ObjectVideoReceiver::updateObject id=" << data.id
|
|
<< " isActive=" << data.isActive
|
|
<< " hostName=" << data.hostName
|
|
<< " isLocked=" << data.isLocked;
|
|
Database::AvmVideoReceiver dbData(toDbData(data));
|
|
|
|
|
|
if (!m_db->update(dbData))
|
|
return Core::FunctionReplyObject(data.id, tr_lts("dds", "Error updating VideoReceiver2 into database"));
|
|
|
|
|
|
DEBUG_LOG(m_logger) << "Data changed for VideoReceiver Id: " << data.id;
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(data.id);
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
Core::FunctionReplyObject ObjectVideoReceiver::removeObject()
|
|
{
|
|
if (!m_db->removeAvmVideoReceiver(m_data.id))
|
|
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Video Receiver with id %1 can not be removed from DB")).arg(m_data.id);
|
|
|
|
if (!m_dts->removeVideoReceiverByKey(m_data.id))
|
|
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Video Receiver with id %1 can not be removed from DDS")).arg(m_data.id);
|
|
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
void ObjectVideoReceiver::onPublishData()
|
|
{
|
|
INFO_LOG(m_logger) << "Publish MvsVideoReceiver-data to dds (" << m_data.id << ") ...";
|
|
|
|
if (!m_dts->publish(m_data))
|
|
ERROR_LOG(m_logger) << "Error publishing MvsVideoReceiver-data to dds";
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
Database::AvmVideoReceiver ObjectVideoReceiver::toDbData(const VideoReceiver &ddsData)
|
|
{
|
|
Database::AvmVideoReceiver dbData;
|
|
|
|
dbData.id = ddsData.id;
|
|
dbData.streamName = QString::fromStdString(ddsData.streamName);
|
|
dbData.mainStructureElementId = ddsData.mainStructureElementId;
|
|
dbData.teamId = ddsData.teamId;
|
|
dbData.isActive = ddsData.isActive;
|
|
dbData.info = QString::fromStdString(ddsData.info);
|
|
dbData.hostName = QString::fromStdString(ddsData.hostName);
|
|
dbData.frequency = ddsData.frequency;
|
|
dbData.isLocked = ddsData.isLocked;
|
|
|
|
return dbData;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
AudioVideoManagement::VideoReceiver ObjectVideoReceiver::toDdsData(const Database::AvmVideoReceiver &dbData)
|
|
{
|
|
AudioVideoManagement::VideoReceiver ddsData;
|
|
ddsData.id = dbData.id;
|
|
ddsData.streamName = dbData.streamName.toStdString();
|
|
ddsData.mainStructureElementId = dbData.mainStructureElementId;
|
|
ddsData.teamId = dbData.teamId;
|
|
ddsData.isActive = dbData.isActive;
|
|
ddsData.isLocked = dbData.isLocked;
|
|
ddsData.info = dbData.info.toStdString();
|
|
ddsData.hostName = dbData.hostName.toStdString();
|
|
ddsData.frequency = dbData.frequency;
|
|
|
|
// init data not in db
|
|
ddsData.dbm = 0;
|
|
ddsData.snr = 0;
|
|
|
|
return ddsData;
|
|
} // end of toDdsData()
|
|
} // Namespace AudioVideoManagement
|