hyperion.ng/libsrc/leddevice/LedDeviceTemplate.cpp
LordGrey 7e370b3d8b
Fix typos (#1051)
* Fix typo in handlePriorityChangedLedDevice

* Typo

* Correct description

* Correct LedDeviceTemplate
2020-10-19 10:54:41 +02:00

90 lines
1.6 KiB
C++

#include "LedDeviceTemplate.h"
LedDeviceTemplate::LedDeviceTemplate(const QJsonObject &deviceConfig)
: LedDevice()
{
}
LedDevice* LedDeviceTemplate::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceTemplate(deviceConfig);
}
bool LedDeviceTemplate::init(const QJsonObject &deviceConfig)
{
bool isInitOK = false;
// Initialise sub-class
if ( LedDevice::init(deviceConfig) )
{
// Initialise LedDevice configuration and execution environment
// ...
if ( 0 /*Error during init*/)
{
//Build an errortext, illustrative
QString errortext = QString ("Error message: %1").arg("errno/text");
this->setInError(errortext);
isInitOK = false;
}
else
{
isInitOK = true;
}
}
return isInitOK;
}
int LedDeviceTemplate::open()
{
int retval = -1;
QString errortext;
_isDeviceReady = false;
// Try to open the LedDevice
//...
if ( false /*If opening failed*/ )
{
//Build an errortext, illustrative
errortext = QString ("Failed to xxx. Error message: %1").arg("errno/text");
}
else
{
// Everything is OK, device is ready
_isDeviceReady = true;
retval = 0;
}
// On error/exceptions, set LedDevice in error
if ( retval < 0 )
{
this->setInError( errortext );
}
return retval;
}
int LedDeviceTemplate::close()
{
// LedDevice specific closing activities
//...
int retval = 0;
_isDeviceReady = false;
// Test, if device requires closing
if ( true /*If device is still open*/ )
{
// Close device
// Everything is OK -> device is closed
}
return retval;
}
int LedDeviceTemplate::write(const std::vector<ColorRgb> & ledValues)
{
int retval = -1;
//...
return retval;
}