refactor: Address (Windows) compile warnings (#840)

* Windows compile errors and (Qt 5.15 deprecation) warnings

* Usability - Enable/Disable Instance button

Co-authored-by: brindosch <edeltraud70@gmx.de>
This commit is contained in:
LordGrey
2020-06-28 23:05:32 +02:00
committed by GitHub
parent e365a2839d
commit bfb50b8d91
61 changed files with 530 additions and 365 deletions

View File

@@ -1,74 +1,84 @@
#pragma once
#ifndef LEDEVICEFILE_H
#define LEDEVICEFILE_H
// STL includes
#include <fstream>
#include <chrono>
// Leddevice includes
// LedDevice includes
#include <leddevice/LedDevice.h>
// Qt includes
#include <QFile>
#include <QDateTime>
///
/// Implementation of the LedDevice that write the led-colors to an
/// ASCII-textfile('/home/pi/LedDevice.out')
/// Implementation of the LedDevice that write the LED-colors to an
/// ASCII-textfile primarily for testing purposes
///
class LedDeviceFile : public LedDevice
{
public:
///
/// Constructs specific LedDevice
/// @brief Constructs a file output LED-device
///
/// @param deviceConfig json device config
/// @param deviceConfig Device's configuration as JSON-Object
///
explicit LedDeviceFile(const QJsonObject &deviceConfig);
///
/// Destructor of this test-device
/// @brief Destructor of the LedDevice
///
virtual ~LedDeviceFile() override;
/// constructs leddevice
///
/// @brief Constructs the LED-device
///
/// @param[in] deviceConfig Device's configuration as JSON-Object
/// @return LedDevice constructed
static LedDevice* construct(const QJsonObject &deviceConfig);
public slots:
///
/// Sets configuration
/// @brief Closes the output device.
///
/// @param deviceConfig the json device config
/// @return true if success
virtual bool init(const QJsonObject &deviceConfig) override;
public slots:
///
/// Closes the output device.
/// Includes switching-off the device and stopping refreshes
/// @return Zero on success (i.e. device is closed), else negative
///
virtual void close() override;
protected:
///
/// Opens and initiatialises the output device
/// @brief Initialise the device's configuration
///
/// @return Zero on succes (i.e. device is ready and enabled) else negative
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
///
/// Writes the given led-color values to the output stream
/// @brief Writes the RGB-Color values to the LEDs.
///
/// @param ledValues The color-value per led
///
/// @return Zero on success else negative
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
/// The outputstream
std::ofstream _ofs;
QFile* _file;
private:
void initFile(const QString &filename);
QString _fileName;
/// Timestamp for the output record
bool _printTimeStamp;
/// Last write/output timestamp
std::chrono::system_clock::time_point lastWriteTime = std::chrono::system_clock::now();
};
#endif // LEDEVICEFILE_H