69 lines
1.5 KiB
C++
Executable File
69 lines
1.5 KiB
C++
Executable File
/**
|
|
* Handler for the HMI language
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "object_xxx_xxx.h"
|
|
|
|
#include "dds_handler.h"
|
|
#include "db_handler.h"
|
|
#include "logger.h"
|
|
|
|
namespace YyyYyyYyy
|
|
{
|
|
|
|
ObjectXxx::ObjectXxx(const std::shared_ptr<DdsHandler> &ddsHandler,
|
|
const std::shared_ptr<DbHandler> &dbHandler,
|
|
QObject *parent)
|
|
: QObject(parent)
|
|
, m_ddsHandler(ddsHandler)
|
|
, m_dbHandler(dbHandler)
|
|
, m_logger(getLogger("ObjectXxx"))
|
|
{
|
|
}
|
|
|
|
ObjectXxx::~ObjectXxx()
|
|
{
|
|
}
|
|
|
|
Core::FunctionReplyObject ObjectXxx::createObject(const Database::YyyXxx &data)
|
|
{
|
|
m_data = data;
|
|
if(m_data.id <= 0)
|
|
return Core::FunctionReplyObject(m_data.id, "It is not intended to insert data this way...");
|
|
|
|
// Publish Data via DTS
|
|
onPublishData();
|
|
|
|
return Core::FunctionReplyObject(m_data.id);
|
|
}
|
|
|
|
Core::FunctionReplyObject ObjectXxx::updateObject(const Database::YyyXxx &data)
|
|
{
|
|
return Core::FunctionReplyObject(m_data.id, "You are not allowed to change this datum.");
|
|
}
|
|
|
|
Core::FunctionReplyObject ObjectXxx::removeObject()
|
|
{
|
|
return Core::FunctionReplyObject(m_data.id, "Data removal denied.");
|
|
}
|
|
|
|
void ObjectXxx::onPublishData()
|
|
{
|
|
|
|
YyyYyyYyy::Xxx ddsData;
|
|
|
|
ddsData.id(m_data.id);
|
|
// Todo: Copy as above
|
|
INFO_LOG(m_logger) << "Publish YyyXxx-data to dds (" << m_data.id << ") ...";
|
|
|
|
if (!m_ddsHandler->dts()->publish(ddsData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error publishing YyyXxx-data to dds";
|
|
}
|
|
}
|
|
|
|
} // Namespace YyyYyyYyy
|