Transfert vers nouvel ordi + nouveau GIT + ajout Chalet
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#include "AvReceiver.h"
|
||||
#include "AvReceiverNetworkCtrlInterface.h"
|
||||
|
||||
CAvReceiver::CAvReceiver(CAvReceiverGui *ReceiverGui)
|
||||
{
|
||||
mReceiverGui = ReceiverGui;
|
||||
ReceiverGui->mProgramHandle = this;
|
||||
mNetworkInterface = new CAvReceiverNetworkCtrlInterface(this);
|
||||
|
||||
mReceiverPollTimer = new QTimer();
|
||||
mReceiverPollTimer->setSingleShot(false);
|
||||
mReceiverPollTimer->setInterval(1000);
|
||||
connect(mReceiverPollTimer,SIGNAL(timeout()),this,SLOT(PollTimerExpired()));
|
||||
}
|
||||
|
||||
CAvReceiver::~CAvReceiver()
|
||||
{
|
||||
delete mNetworkInterface;
|
||||
delete mReceiverPollTimer;
|
||||
}
|
||||
|
||||
int CAvReceiver::Start()
|
||||
{
|
||||
mNetworkInterface->ConnectToMasterCtrl();
|
||||
mReceiverPollTimer->start();
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
||||
int CAvReceiver::SpeakerBToggleSwitchPressed(bool state)
|
||||
{
|
||||
|
||||
QByteArray SpkrState;
|
||||
SpkrState.clear();
|
||||
|
||||
if(state)
|
||||
{
|
||||
SpkrState.append((char)0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpkrState.append((char)0x00);
|
||||
}
|
||||
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_SPEAKERB_REQUEST,SpkrState);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int CAvReceiver::SpeakerAToggleSwitchPressed(bool state)
|
||||
{
|
||||
|
||||
QByteArray SpkrState;
|
||||
SpkrState.clear();
|
||||
|
||||
if(state)
|
||||
{
|
||||
SpkrState.append((char)0x01);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpkrState.append((char)0x00);
|
||||
}
|
||||
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_SPEAKERA_REQUEST,SpkrState);
|
||||
|
||||
}
|
||||
|
||||
void CAvReceiver::PollTimerExpired()
|
||||
{
|
||||
mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_GENERAL_STATUS_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CAvReceiver::ReceiverGeneralStatusReceived(QByteArray StatusData)
|
||||
{
|
||||
mReceiverStatus.FromByteArray(StatusData);
|
||||
mReceiverGui->UpdateReceiverStatus(mReceiverStatus);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef AVRECEIVER_H
|
||||
#define AVRECEIVER_H
|
||||
|
||||
#include <QTimer>
|
||||
#include "AvReceiverData.h"
|
||||
|
||||
class CAvReceiverNetworkCtrlInterface;
|
||||
|
||||
#include "AvReceiverGui.h"
|
||||
|
||||
class CAvReceiver : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CAvReceiver(CAvReceiverGui *ReceiverGui);
|
||||
virtual ~CAvReceiver();
|
||||
|
||||
int Start();
|
||||
|
||||
int SpeakerBToggleSwitchPressed(bool state);
|
||||
int SpeakerAToggleSwitchPressed(bool state);
|
||||
int ReceiverGeneralStatusReceived(QByteArray StatusData);
|
||||
|
||||
CAvReceiverNetworkCtrlInterface *mNetworkInterface;
|
||||
CAvReceiverGui *mReceiverGui;
|
||||
QTimer *mReceiverPollTimer;
|
||||
|
||||
private:
|
||||
CAvReceiverMainStatus mReceiverStatus;
|
||||
|
||||
public slots:
|
||||
void PollTimerExpired();
|
||||
|
||||
};
|
||||
|
||||
#endif // AVRECEIVER_H
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "AvReceiverData.h"
|
||||
#include <QDataStream>
|
||||
|
||||
CAvReceiverMainStatus::CAvReceiverMainStatus()
|
||||
{
|
||||
mDataValid = false;
|
||||
mReceiverOnline = false;
|
||||
}
|
||||
|
||||
QByteArray CAvReceiverMainStatus::ToByteArray()
|
||||
{
|
||||
|
||||
QByteArray Output;
|
||||
Output.clear();
|
||||
QDataStream Strm(&Output,QIODevice::WriteOnly);
|
||||
|
||||
Strm << mMainPwrStatus;
|
||||
Strm << mMainSleepStatus;
|
||||
Strm << mMainVolume;
|
||||
Strm << mIsMute;
|
||||
Strm << mInput;
|
||||
Strm << mProgram;
|
||||
Strm << mSpeakerAState;
|
||||
Strm << mSpeakerBState;
|
||||
|
||||
Strm << mDataValid;
|
||||
Strm << mReceiverOnline;
|
||||
|
||||
return Output;
|
||||
|
||||
}
|
||||
|
||||
int CAvReceiverMainStatus::FromByteArray(QByteArray Data)
|
||||
{
|
||||
QDataStream Strm(Data);
|
||||
Strm.device()->seek(0);
|
||||
|
||||
Strm >> mMainPwrStatus;
|
||||
Strm >> mMainSleepStatus;
|
||||
Strm >> mMainVolume;
|
||||
Strm >> mIsMute;
|
||||
Strm >> mInput;
|
||||
Strm >> mProgram;
|
||||
Strm >> mSpeakerAState;
|
||||
Strm >> mSpeakerBState;
|
||||
|
||||
Strm >> mDataValid;
|
||||
Strm >> mReceiverOnline;
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef AVRECEIVERDATA_H
|
||||
#define AVRECEIVERDATA_H
|
||||
#include <QString>
|
||||
#include "GlobalDefine.h"
|
||||
|
||||
|
||||
class CAvReceiverMainStatus
|
||||
{
|
||||
public:
|
||||
|
||||
QByteArray ToByteArray();
|
||||
int FromByteArray(QByteArray Data);
|
||||
|
||||
CAvReceiverMainStatus();
|
||||
|
||||
bool mMainPwrStatus;
|
||||
bool mMainSleepStatus;
|
||||
float mMainVolume;
|
||||
bool mIsMute;
|
||||
QString mInput;
|
||||
QString mProgram;
|
||||
bool mSpeakerAState;
|
||||
bool mSpeakerBState;
|
||||
|
||||
bool mDataValid;
|
||||
bool mReceiverOnline;
|
||||
|
||||
};
|
||||
|
||||
#endif // AVRECEIVERDATA_H
|
||||
@@ -0,0 +1,104 @@
|
||||
#include "AvReceiverGui.h"
|
||||
#include "ui_AvReceiverGui.h"
|
||||
|
||||
#include "AvReceiver.h"
|
||||
|
||||
CAvReceiverGui::CAvReceiverGui(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::CAvReceiverGui)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->mSpkBCheckBox,SIGNAL(toggled(bool)),this,SLOT(SpeakerBRadioClicked(bool)));
|
||||
connect(ui->mSpkACheckBox,SIGNAL(toggled(bool)),this,SLOT(SpeakerARadioClicked(bool)));
|
||||
}
|
||||
|
||||
CAvReceiverGui::~CAvReceiverGui()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CAvReceiverGui::SpeakerBRadioClicked(bool checked)
|
||||
{
|
||||
mProgramHandle->SpeakerBToggleSwitchPressed(checked);
|
||||
}
|
||||
|
||||
void CAvReceiverGui::SpeakerARadioClicked(bool checked)
|
||||
{
|
||||
mProgramHandle->SpeakerAToggleSwitchPressed(checked);
|
||||
}
|
||||
|
||||
int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status)
|
||||
{
|
||||
QString StatusText;
|
||||
|
||||
StatusText.clear();
|
||||
StatusText += "Receiver Status:\n\n";
|
||||
|
||||
StatusText += "Power: ";
|
||||
if(Status.mMainPwrStatus == true)
|
||||
{
|
||||
StatusText += "ON\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText += "OFF\n";
|
||||
}
|
||||
|
||||
StatusText += "Mute: ";
|
||||
if(Status.mIsMute == true)
|
||||
{
|
||||
StatusText += "ON\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText += "OFF\n";
|
||||
}
|
||||
|
||||
StatusText += "Main sleep: ";
|
||||
if(Status.mMainSleepStatus == true)
|
||||
{
|
||||
StatusText += "ON\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText += "OFF\n";
|
||||
}
|
||||
|
||||
StatusText += "Volume: ";
|
||||
StatusText += QString("%1").arg(Status.mMainVolume);
|
||||
StatusText +="\n";
|
||||
StatusText += "Input: ";
|
||||
StatusText +=Status.mInput;
|
||||
StatusText += "\n";
|
||||
StatusText += "Program: ";
|
||||
StatusText +=Status.mProgram;
|
||||
StatusText += "\n";
|
||||
|
||||
StatusText += "Zone A: ";
|
||||
if(Status.mSpeakerAState == true)
|
||||
{
|
||||
StatusText += "ON\n";
|
||||
ui->mSpkACheckBox->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText += "OFF\n";
|
||||
ui->mSpkACheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
StatusText += "Zone B: ";
|
||||
if(Status.mSpeakerBState == true)
|
||||
{
|
||||
StatusText += "ON\n";
|
||||
ui->mSpkBCheckBox->setChecked(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
StatusText += "OFF\n";
|
||||
ui->mSpkBCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
ui->mRcvrStatusLabel->setText(StatusText);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef AVRECEIVERGUI_H
|
||||
#define AVRECEIVERGUI_H
|
||||
|
||||
#include <QWidget>
|
||||
class CAvReceiver;
|
||||
#include "AvReceiverData.h"
|
||||
|
||||
namespace Ui {
|
||||
class CAvReceiverGui;
|
||||
}
|
||||
|
||||
class CAvReceiverGui : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CAvReceiverGui(QWidget *parent = 0);
|
||||
~CAvReceiverGui();
|
||||
|
||||
CAvReceiver *mProgramHandle;
|
||||
|
||||
int UpdateReceiverStatus(CAvReceiverMainStatus Status);
|
||||
|
||||
private:
|
||||
Ui::CAvReceiverGui *ui;
|
||||
|
||||
public slots:
|
||||
void SpeakerBRadioClicked(bool checked);
|
||||
void SpeakerARadioClicked(bool checked);
|
||||
};
|
||||
|
||||
#endif // AVRECEIVERGUI_H
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CAvReceiverGui</class>
|
||||
<widget class="QWidget" name="CAvReceiverGui">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<height>447</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>30</y>
|
||||
<width>201</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>AvReceiver</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mRcvrStatusLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>110</y>
|
||||
<width>181</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mSpkBCheckBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>570</x>
|
||||
<y>130</y>
|
||||
<width>70</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Speaker B</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mSpkACheckBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>570</x>
|
||||
<y>160</y>
|
||||
<width>70</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Speaker A</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,79 @@
|
||||
#include "AvReceiverNetworkCtrlInterface.h"
|
||||
#include "AvReceiver.h"
|
||||
|
||||
CAvReceiverNetworkCtrlInterface::CAvReceiverNetworkCtrlInterface(CAvReceiver *ProgramHandle)
|
||||
{
|
||||
mMyDeviceID = ID_AVRECEIVER_INTERFACE;
|
||||
mNetworkPort = 2182;
|
||||
mMasterCtrlIPAddress = "127.0.0.1";
|
||||
mNetworkCommSocket = 0;
|
||||
mDeviceAddress = 1;
|
||||
|
||||
mProgramHandle = ProgramHandle;
|
||||
}
|
||||
int CAvReceiverNetworkCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data)
|
||||
{
|
||||
Q_UNUSED(DataSize)
|
||||
|
||||
|
||||
if(TargetDeviceID == mMyDeviceID && (TargetDeviceAddress == BROADCAST_VALUE || TargetDeviceAddress == mDeviceAddress))
|
||||
{
|
||||
switch(MessageID)
|
||||
{
|
||||
|
||||
case AV_RECEIVER_INTERFACE_ACK:
|
||||
{
|
||||
qDebug("Av Receiver Interface ACK received :)");
|
||||
break;
|
||||
}
|
||||
|
||||
case AV_RECEIVER_INTERFACE_GENERAL_STATUS_RESPONSE:
|
||||
{
|
||||
// qDebug("Av Receiver General Status received :)");
|
||||
mProgramHandle->ReceiverGeneralStatusReceived(Data);
|
||||
break;
|
||||
}
|
||||
|
||||
case AV_RECEIVER_INTERFACE_SET_MAIN_POWER_RESPONSE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case AV_RECEIVER_INTERFACE_SET_SPEAKERB_RESPONSE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_RESPONSE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case AV_RECEIVER_INTERFACE_GENERAL_STATUS_REQUEST:
|
||||
case AV_RECEIVER_INTERFACE_SET_MAIN_POWER_REQUEST:
|
||||
case AV_RECEIVER_INTERFACE_SET_SPEAKERB_REQUEST:
|
||||
case AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_REQUEST:
|
||||
default:
|
||||
{
|
||||
qDebug("AV Receiver: Invalid Ethernet Msg received: %d",MessageID);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CAvReceiverNetworkCtrlInterface::DeviceConnectedToMaster(bool Connected)
|
||||
{
|
||||
|
||||
if(Connected)
|
||||
{
|
||||
qDebug("Av Receiver Interface connected to Master.");
|
||||
return SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_GENERAL_STATUS_REQUEST,QByteArray());
|
||||
}
|
||||
else
|
||||
return RET_ERROR;
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef AVRECEIVERNETWORKCTRLINTERFACE_H
|
||||
#define AVRECEIVERNETWORKCTRLINTERFACE_H
|
||||
|
||||
#include "MasterCtrlInterface.h"
|
||||
class CAvReceiver;
|
||||
|
||||
class CAvReceiverNetworkCtrlInterface: public CMasterCtrlInterface
|
||||
{
|
||||
public:
|
||||
CAvReceiverNetworkCtrlInterface(CAvReceiver *ProgramHandle);
|
||||
|
||||
int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
|
||||
int DeviceConnectedToMaster(bool Connected = true);
|
||||
|
||||
private:
|
||||
CAvReceiver *mProgramHandle;
|
||||
};
|
||||
|
||||
#endif // AVRECEIVERNETWORKCTRLINTERFACE_H
|
||||
Reference in New Issue
Block a user