Added more inline documentation.

Simplified joinedMulticastgroup.
Removed non-required functions and includes.
This commit is contained in:
RickDB 2016-03-15 11:10:04 +01:00
parent af8a6df876
commit 829b5c6f89
2 changed files with 29 additions and 31 deletions

View File

@ -6,9 +6,7 @@
#include <QEventLoop>
#include <QtNetwork>
#include <QNetworkReply>
#include <QTime>
//#include <iostream>
#include <stdexcept>
#include <string>
#include <set>
@ -27,14 +25,7 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb(const std::string& output, bool switchOffOnBl
udpSocket = new QUdpSocket(this);
udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
if (!udpSocket->joinMulticastGroup(groupAddress))
{
joinedMulticastgroup = false;
}
else
{
joinedMulticastgroup = true;
}
joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress);
}
int LedDeviceAtmoOrb::write(const std::vector<ColorRgb> & ledValues) {
@ -113,8 +104,6 @@ void LedDeviceAtmoOrb::sendCommand(const QByteArray & bytes) {
}
int LedDeviceAtmoOrb::switchOff() {
// Default send color
for (unsigned int i = 0; i < orbIds.size(); i++) {
QByteArray bytes;
bytes.resize(5 + numLeds * 3);
@ -139,9 +128,6 @@ int LedDeviceAtmoOrb::switchOff() {
}
return 0;
}
void LedDeviceAtmoOrb::switchOn(unsigned int nLights) {
// Not implemented
}
LedDeviceAtmoOrb::~LedDeviceAtmoOrb() {
delete manager;

View File

@ -8,7 +8,6 @@
#include <QString>
#include <QNetworkAccessManager>
#include <QHostAddress>
#include <QTime>
// Leddevice includes
#include <leddevice/LedDevice.h>
@ -41,9 +40,6 @@ public:
int lastGreen;
int lastBlue;
// Last command sent timer
QTime timer;
// Multicast status
bool joinedMulticastgroup;
@ -60,7 +56,7 @@ public:
///
/// @param numLeds is the total amount of leds per Orb
///
/// @param orb ids to control
/// @param array containing orb ids
///
LedDeviceAtmoOrb(const std::string& output, bool switchOffOnBlack =
false, int transitiontime = 0, int port = 49692, int numLeds = 24, std::vector<unsigned int> orbIds = std::vector<unsigned int>());
@ -79,33 +75,49 @@ public:
virtual int write(const std::vector<ColorRgb> & ledValues);
virtual int switchOff();
private:
/// Array to save the lamps.
std::vector<AtmoOrbLight> lights;
/// QNetworkAccessManager object for sending requests.
QNetworkAccessManager* manager;
/// String containing multicast group IP address
QString multicastGroup;
/// Switch off when detecting black
bool switchOffOnBlack;
/// Transition time between colors (not implemented)
int transitiontime;
/// Multicast port to send data to
int multiCastGroupPort;
/// Number of leds in Orb, used to determine buffer size
int numLeds;
/// QHostAddress object of multicast group IP address
QHostAddress groupAddress;
/// QUdpSocket object used to send data over
QUdpSocket *udpSocket;
/// Array of the light ids.
/// Array of the orb ids.
std::vector<unsigned int> orbIds;
///
/// Switches the leds on.
/// Set Orbcolor
///
/// @param nLights the number of lights
/// @param orbId the orb id
///
/// @param color which color to set
///
///
/// @param commandType which type of command to send (off / smoothing / etc..)
///
void switchOn(unsigned int nLights);
// Set color
void setColor(unsigned int orbId, const ColorRgb& color, int commandType);
// Send color command
///
/// Send Orb command
///
/// @param bytes the byte array containing command to send over multicast
///
void sendCommand(const QByteArray & bytes);
};