Start implementation of AVReceiverDevice
This commit is contained in:
parent
1a7ca49b7d
commit
a71197282e
@ -11,7 +11,8 @@ HEADERS += \
|
|||||||
Sources/AbstractNetworkInterface.h \
|
Sources/AbstractNetworkInterface.h \
|
||||||
Sources/DeadboltDevice.h \
|
Sources/DeadboltDevice.h \
|
||||||
Sources/AbstractDevice.h \
|
Sources/AbstractDevice.h \
|
||||||
Sources/ProtocolDefs.h
|
Sources/ProtocolDefs.h \
|
||||||
|
Sources/AVReceiverDevice.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
Sources/main.cpp \
|
Sources/main.cpp \
|
||||||
@ -20,7 +21,8 @@ SOURCES += \
|
|||||||
Sources/232NetworkCommIF.cpp \
|
Sources/232NetworkCommIF.cpp \
|
||||||
Sources/EthernetNetworkCommIF.cpp \
|
Sources/EthernetNetworkCommIF.cpp \
|
||||||
Sources/NetworkProtocol.cpp \
|
Sources/NetworkProtocol.cpp \
|
||||||
Sources/DeadboltDevice.cpp
|
Sources/DeadboltDevice.cpp \
|
||||||
|
Sources/AVReceiverDevice.cpp
|
||||||
|
|
||||||
|
|
||||||
#win32:SOURCES += $$PWD/Source/qextserialport/win_qextserialport.cpp \
|
#win32:SOURCES += $$PWD/Source/qextserialport/win_qextserialport.cpp \
|
||||||
|
|||||||
222
Sources/AVReceiverDevice.cpp
Normal file
222
Sources/AVReceiverDevice.cpp
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
#include "AVReceiverDevice.h"
|
||||||
|
#include "GlobalDefine.h"
|
||||||
|
|
||||||
|
CAVReceiverDevice::CAVReceiverDevice()
|
||||||
|
{
|
||||||
|
mReceiverSocket = new QTcpSocket;
|
||||||
|
|
||||||
|
|
||||||
|
connect(mReceiverSocket,SIGNAL(connected()),this,SLOT(SocketConnected()));
|
||||||
|
connect(mReceiverSocket,SIGNAL(disconnected()),this,SLOT(SocketDisconnected()));
|
||||||
|
connect(mReceiverSocket,SIGNAL(readyRead()),this,SLOT(SocketRX()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CAVReceiverDevice::~CAVReceiverDevice()
|
||||||
|
{
|
||||||
|
mReceiverSocket->disconnectFromHost();
|
||||||
|
mReceiverSocket->waitForDisconnected();
|
||||||
|
delete mReceiverSocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAVReceiverDevice::ConnectToReceiver()
|
||||||
|
{
|
||||||
|
if(mReceiverSocket->state() != QAbstractSocket::ConnectedState)
|
||||||
|
{
|
||||||
|
mReceiverSocket->connectToHost(RECEIVER_IP_ADDRESS,RECEIVER_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAVReceiverDevice::DisconnectReceiver()
|
||||||
|
{
|
||||||
|
if(mReceiverSocket->state() != QAbstractSocket::ConnectedState)
|
||||||
|
return RET_ERROR;
|
||||||
|
|
||||||
|
mReceiverSocket->disconnectFromHost();
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CAVReceiverDevice::AnalyseRxData(QByteArray data)
|
||||||
|
{
|
||||||
|
QString Data(data);
|
||||||
|
if(data == "\r\n")
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: Heartbeat received");
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Commands = Data.split("\r\n",QString::SkipEmptyParts);
|
||||||
|
|
||||||
|
for(int i = 0; i < Commands.size(); i++)
|
||||||
|
{
|
||||||
|
QString CurCmd = Commands.at(i);
|
||||||
|
|
||||||
|
|
||||||
|
if(CurCmd.contains("PWR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: POWER status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("VOL"))
|
||||||
|
{
|
||||||
|
CurCmd.remove("VOL");
|
||||||
|
mReceiverVolume = CurCmd.toInt();
|
||||||
|
qDebug("AV Receiver: VOLUME status received %d",mReceiverVolume);
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("MUT"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: MUTE status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("FN"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: INPUT SRC status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("SR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: LISTENING MODE SET feedback received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("LM"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: LISTENING MODE status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("SPK"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: SPEAKERS status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("HO"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: HDMI OUTPUT SELECTION status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("EX"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: SBch PROCESSING status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("MC"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: MCACC MEMORY status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("IS"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: PHASE CONTROL status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("TO"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: TONE status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("BA"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: BASS status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("TR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: TREBLE status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("HA"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: HDMI AUDIO status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("PR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: TUNER PRESET status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("FR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: TUNER FREQUENCY status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("XM"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: XM CHANNEL status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("SIR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: SIRIUS CHANNEL status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("APR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 2 POWER status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("BPR"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 3 POWER status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("ZV"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 2 VOLUME status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("YV"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 3 VOLUME status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("Z2MUT"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 2 MUTE status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("Z3MUT"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 3 MUTE status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("Z2F"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 2 INPUT status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("Z3F"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: ZONE 3 INPUT status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("PQ"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: PQLS status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("CLV"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: CHANNEL LEVEL status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("VSB"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: VIRTUAL SB status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("VHT"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: VIRTUAL HEIGHT status received");
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("FL"))
|
||||||
|
{
|
||||||
|
CurCmd.remove("FL");
|
||||||
|
QString FlString = "";
|
||||||
|
for(int i = 0; i < CurCmd.size()/2; i++)
|
||||||
|
{
|
||||||
|
QString FlChar = CurCmd.left(2);
|
||||||
|
CurCmd.remove(0,2);
|
||||||
|
int CharIndex = FlChar.toInt(0,16);
|
||||||
|
FlString.append(QChar(CharIndex));
|
||||||
|
|
||||||
|
}
|
||||||
|
qDebug("AV Receiver: DISPLAY DATA received: %s",FlString.toUtf8().data());
|
||||||
|
}
|
||||||
|
else if(CurCmd.contains("RGB"))
|
||||||
|
{
|
||||||
|
qDebug("AV Receiver: INPUT NAME INFO received");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CAVReceiverDevice::SocketConnected()
|
||||||
|
{
|
||||||
|
qDebug("Receiver Connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAVReceiverDevice::SocketDisconnected()
|
||||||
|
{
|
||||||
|
qDebug("Receiver Disconnected");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAVReceiverDevice::SocketRX()
|
||||||
|
{
|
||||||
|
AnalyseRxData(mReceiverSocket->readAll());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
34
Sources/AVReceiverDevice.h
Normal file
34
Sources/AVReceiverDevice.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef AVRECEIVERDEVICE_H
|
||||||
|
#define AVRECEIVERDEVICE_H
|
||||||
|
|
||||||
|
#include <QTcpSocket>
|
||||||
|
|
||||||
|
#define RECEIVER_PORT 23
|
||||||
|
#define RECEIVER_IP_ADDRESS "192.168.0.104"
|
||||||
|
|
||||||
|
class CAVReceiverDevice : QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAVReceiverDevice();
|
||||||
|
~CAVReceiverDevice();
|
||||||
|
|
||||||
|
int ConnectToReceiver();
|
||||||
|
int DisconnectReceiver();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTcpSocket *mReceiverSocket;
|
||||||
|
int AnalyseRxData(QByteArray data);
|
||||||
|
|
||||||
|
int mReceiverVolume;
|
||||||
|
|
||||||
|
bool mIsConnected;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void SocketConnected();
|
||||||
|
void SocketDisconnected();
|
||||||
|
void SocketRX();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // AVRECEIVERDEVICE_H
|
||||||
@ -3,4 +3,7 @@
|
|||||||
|
|
||||||
#include "QDebug"
|
#include "QDebug"
|
||||||
|
|
||||||
|
#define RET_OK 1
|
||||||
|
#define RET_ERROR 0
|
||||||
|
|
||||||
#endif // GLOBALDEFINE_H
|
#endif // GLOBALDEFINE_H
|
||||||
|
|||||||
@ -4,13 +4,21 @@ CMasterCtrl::CMasterCtrl()
|
|||||||
{
|
{
|
||||||
qDebug("Creation...");
|
qDebug("Creation...");
|
||||||
mDeadBoltDevice = new CDeadboltDevice(1);
|
mDeadBoltDevice = new CDeadboltDevice(1);
|
||||||
|
mAVReceiverDevice = new CAVReceiverDevice;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CMasterCtrl::~CMasterCtrl()
|
CMasterCtrl::~CMasterCtrl()
|
||||||
{
|
{
|
||||||
|
mAVReceiverDevice->DisconnectReceiver();
|
||||||
|
|
||||||
delete mDeadBoltDevice;
|
delete mDeadBoltDevice;
|
||||||
|
delete mAVReceiverDevice;
|
||||||
}
|
}
|
||||||
void CMasterCtrl::Start()
|
void CMasterCtrl::Start()
|
||||||
{
|
{
|
||||||
qDebug("Started!");
|
qDebug("Started!");
|
||||||
|
|
||||||
|
mAVReceiverDevice->ConnectToReceiver();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "GlobalDefine.h"
|
#include "GlobalDefine.h"
|
||||||
#include "DeadboltDevice.h"
|
#include "DeadboltDevice.h"
|
||||||
|
#include "AVReceiverDevice.h"
|
||||||
|
|
||||||
class CMasterCtrl
|
class CMasterCtrl
|
||||||
{
|
{
|
||||||
@ -12,6 +13,7 @@ public:
|
|||||||
|
|
||||||
void Start(void);
|
void Start(void);
|
||||||
CDeadboltDevice *mDeadBoltDevice;
|
CDeadboltDevice *mDeadBoltDevice;
|
||||||
|
CAVReceiverDevice *mAVReceiverDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MASTERCTRL_H
|
#endif // MASTERCTRL_H
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user