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-08-28 07:12:48 +02:00
|
|
|
/// The ProviderUdp implements an abstract base-class for LedDevices using the SPI-device.
|
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-08-23 20:07:12 +02:00
|
|
|
/// Constructs specific LedDevice
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
2016-08-23 20:07:12 +02:00
|
|
|
/// @param deviceConfig json device config
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
2016-08-28 07:12:48 +02:00
|
|
|
ProviderUdp(const Json::Value &deviceConfig);
|
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
|
|
|
|
bool setConfig(const Json::Value &deviceConfig);
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|