2016-05-30 23:58:31 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QUdpSocket>
|
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <leddevice/LedDevice.h>
|
2016-06-24 17:46:23 +02:00
|
|
|
#include <utils/Logger.h>
|
2016-05-30 23:58:31 +02:00
|
|
|
|
|
|
|
///
|
2016-10-08 13:52:22 +02:00
|
|
|
/// The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
2016-08-28 07:12:48 +02:00
|
|
|
class ProviderUdp : public LedDevice
|
2016-05-30 23:58:31 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-09-22 00:18:46 +02:00
|
|
|
///
|
|
|
|
/// Constructs specific LedDevice
|
|
|
|
///
|
|
|
|
ProviderUdp();
|
2016-05-30 23:58:31 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// Destructor of the LedDevice; closes the output device if it is open
|
|
|
|
///
|
2016-08-28 07:12:48 +02:00
|
|
|
virtual ~ProviderUdp();
|
2016-05-30 23:58:31 +02:00
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
|
|
|
/// Sets configuration
|
|
|
|
///
|
|
|
|
/// @param deviceConfig the json device config
|
|
|
|
/// @return true if success
|
2016-10-13 21:59:58 +02:00
|
|
|
bool init(const QJsonObject &deviceConfig, std::string defaultHost="127.0.0.1");
|
2016-08-23 20:07:12 +02:00
|
|
|
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
|
|
|
/// Opens and configures the output device
|
|
|
|
///
|
|
|
|
/// @return Zero on succes else negative
|
|
|
|
///
|
|
|
|
int open();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
|
|
|
/// Writes the given bytes/bits to the SPI-device and sleeps the latch time to ensure that the
|
|
|
|
/// values are latched.
|
|
|
|
///
|
2016-08-14 10:46:44 +02:00
|
|
|
/// @param[in] size The length of the data
|
2016-05-30 23:58:31 +02:00
|
|
|
/// @param[in] data The data
|
|
|
|
///
|
|
|
|
/// @return Zero on succes else negative
|
|
|
|
///
|
|
|
|
int writeBytes(const unsigned size, const uint8_t *data);
|
|
|
|
|
|
|
|
/// The time which the device should be untouched after a write
|
2016-08-23 20:07:12 +02:00
|
|
|
int _LatchTime_ns;
|
2016-05-30 23:58:31 +02:00
|
|
|
|
|
|
|
///
|
2016-08-14 10:46:44 +02:00
|
|
|
QUdpSocket * _udpSocket;
|
2016-05-30 23:58:31 +02:00
|
|
|
QHostAddress _address;
|
2016-08-14 10:46:44 +02:00
|
|
|
quint16 _port;
|
2016-05-30 23:58:31 +02:00
|
|
|
};
|