2013-08-15 21:11:02 +02:00
|
|
|
|
|
|
|
// Local-Hyperion includes
|
2016-03-23 11:12:34 +01:00
|
|
|
#include "LedDeviceFile.h"
|
2013-08-15 21:11:02 +02:00
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
LedDeviceFile::LedDeviceFile(const Json::Value &deviceConfig)
|
2016-08-14 10:46:44 +02:00
|
|
|
: LedDevice()
|
2013-08-15 21:11:02 +02:00
|
|
|
{
|
2016-08-23 20:07:12 +02:00
|
|
|
setConfig(deviceConfig);
|
2013-08-15 21:11:02 +02:00
|
|
|
}
|
|
|
|
|
2016-03-23 11:12:34 +01:00
|
|
|
LedDeviceFile::~LedDeviceFile()
|
2013-08-15 21:11:02 +02:00
|
|
|
{
|
2016-08-23 20:07:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LedDevice* LedDeviceFile::construct(const Json::Value &deviceConfig)
|
|
|
|
{
|
|
|
|
return new LedDeviceFile(deviceConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LedDeviceFile::setConfig(const Json::Value &deviceConfig)
|
|
|
|
{
|
|
|
|
if ( _ofs.is_open() )
|
|
|
|
{
|
|
|
|
_ofs.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string fileName = deviceConfig.get("output","/dev/null").asString();
|
|
|
|
_ofs.open( fileName.c_str() );
|
|
|
|
|
|
|
|
return true;
|
2013-08-15 21:11:02 +02:00
|
|
|
}
|
|
|
|
|
2016-03-23 11:12:34 +01:00
|
|
|
int LedDeviceFile::write(const std::vector<ColorRgb> & ledValues)
|
2013-08-15 21:11:02 +02:00
|
|
|
{
|
|
|
|
_ofs << "[";
|
2013-11-11 10:00:37 +01:00
|
|
|
for (const ColorRgb& color : ledValues)
|
2013-08-15 21:11:02 +02:00
|
|
|
{
|
|
|
|
_ofs << color;
|
|
|
|
}
|
|
|
|
_ofs << "]" << std::endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-10-27 18:04:37 +01:00
|
|
|
|
2016-03-23 11:12:34 +01:00
|
|
|
int LedDeviceFile::switchOff()
|
2013-10-27 18:04:37 +01:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|