Compare commits

...
11 Commits
Author SHA1 Message Date
jfmartel 5b9c6cc111 Chalet LTE + dev 2025-07-10 18:13:04 -04:00
jfmartel 2dfd185494 Transert de la gestion du Z2 lock au MasterCtrl 2024-02-04 14:25:04 -05:00
jfmartel ac8490b5ee Ajout de la gestion de roulette de volume du clavier 2024-02-04 06:48:18 -05:00
jfmartel 59b07d5db3 Ajout interface LoraModuleInterface 2023-03-26 15:27:55 -04:00
jfmartel 635d754d27 Modif du contrôle du volume de AvReceiverGui
Fuck-up de Windows
2023-03-06 14:57:38 -05:00
jfmartel 52841786a9 Nouvel ampli 2022-12-20 12:58:37 -05:00
jfmartel 17e753c365 Del (a lot!) 2022-12-11 13:50:51 -05:00
jfmartel a69e88c091 Ajout interface ISpindel 2021-12-12 12:19:50 -05:00
jfmartel 75b487a862 Dev pour retour du LoRa au chalet 2021-10-12 11:28:53 -04:00
jfmartel 512bc280e7 Ajout du de l'interface avec le bootloader PIC32 2021-09-27 18:15:47 -04:00
jfmartel f7eeb9ecf4 Début firmware uploader 2021-05-22 22:20:06 -04:00
69 changed files with 15478 additions and 767 deletions
File diff suppressed because it is too large Load Diff
View File
+100 -14
View File
@@ -11,6 +11,9 @@ CAvReceiver::CAvReceiver(CAvReceiverGui *ReceiverGui)
mReceiverPollTimer->setSingleShot(false);
mReceiverPollTimer->setInterval(1000);
connect(mReceiverPollTimer,SIGNAL(timeout()),this,SLOT(PollTimerExpired()));
connect(&mVolumeController,&CVolumeController::ExternalVolumeChanged,this,&CAvReceiver::ExternalVolumeChanged);
mTempReceiverVolume = 0;
}
CAvReceiver::~CAvReceiver()
@@ -23,44 +26,45 @@ int CAvReceiver::Start()
{
mNetworkInterface->ConnectToMasterCtrl();
mReceiverPollTimer->start();
mVolumeController.Init(this);
return RET_OK;
}
int CAvReceiver::SpeakerBToggleSwitchPressed(bool state)
int CAvReceiver::Zone2ToggleSwitchPressed(bool state)
{
QByteArray SpkrState;
SpkrState.clear();
QByteArray ZoneState;
ZoneState.clear();
if(state)
{
SpkrState.append((char)0x01);
ZoneState.append((char)0x01);
}
else
{
SpkrState.append((char)0x00);
ZoneState.append((char)0x00);
}
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_SPEAKERB_REQUEST,SpkrState);
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_ZONE2_REQUEST,ZoneState);
}
int CAvReceiver::SpeakerAToggleSwitchPressed(bool state)
int CAvReceiver::MainUnitToggleSwitchPressed(bool state)
{
QByteArray SpkrState;
SpkrState.clear();
QByteArray ZoneState;
ZoneState.clear();
if(state)
{
SpkrState.append((char)0x01);
ZoneState.append((char)0x01);
}
else
{
SpkrState.append((char)0x00);
ZoneState.append((char)0x00);
}
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_SPEAKERA_REQUEST,SpkrState);
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_MAIN_ZONE_REQUEST,ZoneState);
}
@@ -71,6 +75,88 @@ void CAvReceiver::PollTimerExpired()
int CAvReceiver::ReceiverGeneralStatusReceived(QByteArray StatusData)
{
mReceiverStatus.FromByteArray(StatusData);
mReceiverGui->UpdateReceiverStatus(mReceiverStatus);
QDataStream Strm(&StatusData,QIODevice::ReadOnly | QIODevice::Unbuffered);
Strm.device()->seek(0);
Strm >> mReceiverStatus;
Strm >> mZone2Status;
mReceiverGui->UpdateReceiverStatus(mReceiverStatus, mZone2Status);
mTempReceiverVolume = mReceiverStatus.mMainVolume;
return RET_OK;
}
int CAvReceiver::SelectScenePressed(char Zone, char Scene)
{
QByteArray SceneData;
SceneData.append(Zone).append(Scene);
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SELECT_SCENE_REQUEST,SceneData);
}
int CAvReceiver::MainZoneVolumeChanged(float Value)
{
// qDebug("MainZoneVolumeChanged : %f",Value);
QByteArray VolumeData;
QDataStream Strm(&VolumeData,QIODevice::WriteOnly);
Strm << Value;
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_REQUEST,VolumeData);
}
int CAvReceiver::Zone2VolumeChanged(float Value)
{
QByteArray VolumeData;
QDataStream Strm(&VolumeData,QIODevice::WriteOnly);
Strm << Value;
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_REQUEST,VolumeData);
}
int CAvReceiver::SyncZonesVolumesChanged(bool Sync)
{
QByteArray SyncData;
QDataStream Strm(&SyncData,QIODevice::WriteOnly);
Strm << Sync;
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_SYNC_Z2_WITH_Z1_REQUEST,SyncData);
}
int CAvReceiver::Zone2InputSrcChanged(QString InputSrc)
{
QByteArray SourceData;
QDataStream Strm(&SourceData,QIODevice::WriteOnly);
Strm << InputSrc;
return mNetworkInterface->SendMasterCtrlCommand(AV_RECEIVER_INTERFACE_SET_ZONE2_INPUT_REQUEST,SourceData);
}
//We need to implement this in a slot because the Windows API runs in a differen Thread and it crashes the MasterCtrl socket.
void CAvReceiver::ExternalVolumeChanged(float Value)
{
float ValueInPercent;
float Ret;
if(Value > 0)
{
mTempReceiverVolume += Value;
MainZoneVolumeChanged(mTempReceiverVolume);
Ret = 0.04;
}
else
{
if(mTempReceiverVolume == -80.5)
{
Ret = 0;
}
else
{
mTempReceiverVolume += Value;
if(mTempReceiverVolume == -80.5)
{
MainZoneVolumeChanged(mTempReceiverVolume);
Ret = 0;
}
else
{
MainZoneVolumeChanged(mTempReceiverVolume);
Ret = 0.04;
}
}
}
mVolumeController.SetMasterVolume(Ret);
}
+14 -3
View File
@@ -3,6 +3,7 @@
#include <QTimer>
#include "AvReceiverData.h"
#include "VolumeController.h"
class CAvReceiverNetworkCtrlInterface;
@@ -17,20 +18,30 @@ public:
int Start();
int SpeakerBToggleSwitchPressed(bool state);
int SpeakerAToggleSwitchPressed(bool state);
int Zone2ToggleSwitchPressed(bool state);
int MainUnitToggleSwitchPressed(bool state);
int ReceiverGeneralStatusReceived(QByteArray StatusData);
int SelectScenePressed(char Zone, char Scene);
int MainZoneVolumeChanged(float Value);
int Zone2VolumeChanged(float Value);
int Zone2InputSrcChanged(QString InputSrc);
int SyncZonesVolumesChanged(bool Sync);
CAvReceiverNetworkCtrlInterface *mNetworkInterface;
CAvReceiverGui *mReceiverGui;
QTimer *mReceiverPollTimer;
CVolumeController mVolumeController;
private:
CAvReceiverMainStatus mReceiverStatus;
CAvReceiverMainStatus mZone2Status;
float mTempReceiverVolume;
public slots:
void PollTimerExpired();
void ExternalVolumeChanged(float Value);
};
#endif // AVRECEIVER_H
+138 -20
View File
@@ -14,17 +14,56 @@ QByteArray CAvReceiverMainStatus::ToByteArray()
Output.clear();
QDataStream Strm(&Output,QIODevice::WriteOnly);
Strm << mMainPwrStatus;
Strm << mMainSleepStatus;
Strm << mMainVolume;
Strm << mIsMute;
Strm << mInput;
Strm << mProgram;
Strm << mSpeakerAState;
Strm << mSpeakerBState;
// Strm << mMainPwrStatus;
// Strm << mMainSleepStatus;
// Strm << mMainVolume;
// Strm << mIsMute;
// Strm << mInput;
// Strm << mProgram;
Strm << mDataValid;
Strm << mReceiverOnline;
// Strm << mDataValid;
// Strm << mReceiverOnline;
// Strm << mSyncZonesVolumes;
if(mMainPwrStatus == true)
Output.append(0x01);
else
Output.append((char)0x00);
if(mMainSleepStatus == true)
Output.append(0x01);
else
Output.append((char)0x00);
char VolArray[4];
memcpy(VolArray,&mMainVolume,4);
Output.append(VolArray);
if(mIsMute == true)
Output.append(0x01);
else
Output.append((char)0x00);
char String[50];
strcpy(String,mInput.toUtf8().data());
Output.append(String,50);
strcpy(String,mProgram.toUtf8().data());
Output.append(String,50);
if(mDataValid == true)
Output.append(0x01);
else
Output.append((char)0x00);
if(mReceiverOnline == true)
Output.append(0x01);
else
Output.append((char)0x00);
if(mSyncZonesVolumes == true)
Output.append(0x01);
else
Output.append((char)0x00);
return Output;
@@ -35,18 +74,97 @@ 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 >> mMainPwrStatus;
// Strm >> mMainSleepStatus;
// Strm >> mMainVolume;
// Strm >> mIsMute;
// Strm >> mInput;
// Strm >> mProgram;
Strm >> mDataValid;
Strm >> mReceiverOnline;
// Strm >> mDataValid;
// Strm >> mReceiverOnline;
// Strm >> mSyncZonesVolumes;
if(Data.at(0) == 1)
mMainPwrStatus = true;
else
mMainPwrStatus = false;
if(Data.at(1) == 1)
mMainSleepStatus = true;
else
mMainSleepStatus = false;
char VolArray[4];
VolArray[0] = Data[2];
VolArray[1] = Data[3];
VolArray[2] = Data[4];
VolArray[3] = Data[5];
memcpy(&mMainVolume,VolArray,4);
if(Data.at(6) == 1)
mIsMute = true;
else
mIsMute = false;
char String[50];
for(int i= 0; i < 50; i++)
{
String[i] = Data[i+6];
}
mInput.clear();
mInput.append(String);
for(int i= 0; i < 50; i++)
{
String[i] = Data[i+56];
}
mProgram.clear();
mProgram.append(String);
if(Data.at(107) == 1)
mDataValid = true;
else
mDataValid = false;
if(Data.at(108) == 1)
mReceiverOnline = true;
else
mReceiverOnline = false;
if(Data.at(109) == 1)
mSyncZonesVolumes = true;
else
mSyncZonesVolumes = false;
return RET_OK;
}
QDataStream &operator<<(QDataStream &out, const CAvReceiverMainStatus &source)
{
out << source.mMainPwrStatus
<< source.mMainSleepStatus
<< source.mMainVolume
<< source.mIsMute
<< source.mInput
<< source.mProgram
<< source.mDataValid
<< source.mReceiverOnline
<< source.mSyncZonesVolumes;
return out;
}
QDataStream &operator>>(QDataStream &in, CAvReceiverMainStatus &dest)
{
in >> dest.mMainPwrStatus
>> dest.mMainSleepStatus
>> dest.mMainVolume
>> dest.mIsMute
>> dest.mInput
>> dest.mProgram
>> dest.mDataValid
>> dest.mReceiverOnline
>> dest.mSyncZonesVolumes;
return in;
}
+13 -2
View File
@@ -3,6 +3,16 @@
#include <QString>
#include "GlobalDefine.h"
#define MAIN_ZONE_MIN_VOLUME (float)-80.5
#define MAIN_ZONE_MAX_VOLUME (float)16.5
enum eAVReceiverZones
{
AV_RECEIVER_MAIN_ZONE = 1,
AV_RECEIVER_ZONE_2,
AV_RECEIVER_MAX_ZONE
};
class CAvReceiverMainStatus
{
@@ -19,12 +29,13 @@ public:
bool mIsMute;
QString mInput;
QString mProgram;
bool mSpeakerAState;
bool mSpeakerBState;
bool mSyncZonesVolumes;
bool mDataValid;
bool mReceiverOnline;
};
QDataStream &operator<<(QDataStream &out, const CAvReceiverMainStatus &source);
QDataStream &operator>>(QDataStream &in, CAvReceiverMainStatus &dest);
#endif // AVRECEIVERDATA_H
+196 -18
View File
@@ -1,5 +1,6 @@
#include "AvReceiverGui.h"
#include "ui_AvReceiverGui.h"
#include "TrayVolumeCtrl.h"
#include "AvReceiver.h"
@@ -8,41 +9,63 @@ CAvReceiverGui::CAvReceiverGui(QWidget *parent) :
ui(new Ui::CAvReceiverGui)
{
ui->setupUi(this);
mVolumeBarMovementTimer = new QTimer();
mVolumeBarMovementTimer->setInterval(500);
mVolumeBarMovementTimer->setSingleShot(true);
mLockZone2VolumeWithZone1 = false;
connect(ui->mSpkBCheckBox,SIGNAL(toggled(bool)),this,SLOT(SpeakerBRadioClicked(bool)));
connect(ui->mSpkACheckBox,SIGNAL(toggled(bool)),this,SLOT(SpeakerARadioClicked(bool)));
mTrayVolumeCtrlGuiHandle = 0;
ui->mZone2InputComboBx->addItems(QStringList() << "AUDIO1" << "AUDIO2" << "AUDIO3" << "AUDIO4" << "AUDIO5" << "PHONO" << "TUNER" << "SERVER" << "Main Zone Sync");
ui->mZone2InputComboBx->setEditable(false);
connect(mVolumeBarMovementTimer,SIGNAL(timeout()),this,SLOT(VolumeBarMovementTimerExpired()));
connect(ui->mSpkBCheckBox,SIGNAL(clicked(bool)),this,SLOT(SpeakerBRadioClicked(bool)));
connect(ui->mSpkACheckBox,SIGNAL(clicked(bool)),this,SLOT(SpeakerARadioClicked(bool)));
connect(ui->MainZoneScene1Btn,SIGNAL(clicked(bool)),this,SLOT(MainZoneScene1BtnClicked(bool)));
connect(ui->MainZoneScene2Btn,SIGNAL(clicked(bool)),this,SLOT(MainZoneScene2BtnClicked(bool)));
connect(ui->MainZoneScene3Btn,SIGNAL(clicked(bool)),this,SLOT(MainZoneScene3BtnClicked(bool)));
connect(ui->MainZoneScene4Btn,SIGNAL(clicked(bool)),this,SLOT(MainZoneScene4BtnClicked(bool)));
connect(ui->mMainZoneVolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(MainZoneVolumeSetChanged(int)));
connect(ui->mZone2VolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(Zone2VolumeSetChanged(int)));
connect(ui->mZone2InputComboBx,&QComboBox::currentTextChanged,this,&CAvReceiverGui::Zone2InputSelectionChanged);
connect(ui->mZone2SyncVolumeChkBx,&QCheckBox::clicked,this,&CAvReceiverGui::Zone2LockVolumeChanged);
}
CAvReceiverGui::~CAvReceiverGui()
{
delete ui;
delete mVolumeBarMovementTimer;
}
void CAvReceiverGui::SpeakerBRadioClicked(bool checked)
{
mProgramHandle->SpeakerBToggleSwitchPressed(checked);
mProgramHandle->Zone2ToggleSwitchPressed(checked);
}
void CAvReceiverGui::SpeakerARadioClicked(bool checked)
{
mProgramHandle->SpeakerAToggleSwitchPressed(checked);
mProgramHandle->MainUnitToggleSwitchPressed(checked);
}
int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status)
int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status, CAvReceiverMainStatus Zone2Status)
{
QString StatusText;
StatusText.clear();
StatusText += "Receiver Status:\n\n";
StatusText += "Main Receiver Status:\n\n";
StatusText += "Power: ";
if(Status.mMainPwrStatus == true)
{
StatusText += "ON\n";
ui->mSpkACheckBox->setChecked(true);
}
else
{
StatusText += "OFF\n";
ui->mSpkACheckBox->setChecked(false);
}
StatusText += "Mute: ";
@@ -75,20 +98,26 @@ int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status)
StatusText +=Status.mProgram;
StatusText += "\n";
StatusText += "Zone A: ";
if(Status.mSpeakerAState == true)
ui->mRcvrStatusLabel->setText(StatusText);
if(/*ui->mMainZoneVolumeSldBar->isSliderDown() == false && */mVolumeBarMovementTimer->isActive() == false)
{
StatusText += "ON\n";
ui->mSpkACheckBox->setChecked(true);
}
else
{
StatusText += "OFF\n";
ui->mSpkACheckBox->setChecked(false);
int SliderValue = ConvertVolumeToBarPosition(Status.mMainVolume);
disconnect(ui->mMainZoneVolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(MainZoneVolumeSetChanged(int)));
ui->mMainZoneVolumeSldBar->setValue(SliderValue);
connect(ui->mMainZoneVolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(MainZoneVolumeSetChanged(int)));
ui->mMainZoneSliderValueLbl->setText("");
mTrayVolumeCtrlGuiHandle->SetMainZoneVolume(SliderValue,Status.mMainVolume);
}
StatusText += "Zone B: ";
if(Status.mSpeakerBState == true)
StatusText = "Zone2 Status\n\n";
StatusText += "Power: ";
if(Zone2Status.mMainPwrStatus == true)
{
StatusText += "ON\n";
ui->mSpkBCheckBox->setChecked(true);
@@ -99,6 +128,155 @@ int CAvReceiverGui::UpdateReceiverStatus(CAvReceiverMainStatus Status)
ui->mSpkBCheckBox->setChecked(false);
}
StatusText += "Mute: ";
if(Zone2Status.mIsMute == true)
{
StatusText += "ON\n";
}
else
{
StatusText += "OFF\n";
}
ui->mRcvrStatusLabel->setText(StatusText);
StatusText += "Main sleep: ";
if(Zone2Status.mMainSleepStatus == true)
{
StatusText += "ON\n";
}
else
{
StatusText += "OFF\n";
}
StatusText += "Volume: ";
StatusText += QString("%1").arg(Zone2Status.mMainVolume);
StatusText +="\n";
StatusText += "Input: ";
StatusText +=Zone2Status.mInput;
StatusText += "\n";
StatusText += "Program: ";
StatusText +=Zone2Status.mProgram;
StatusText += "\n";
ui->mZone2StatusLabel->setText(StatusText);
ui->mZone2InputComboBx->setCurrentText(Zone2Status.mInput);
if(/*ui->mZone2VolumeSldBar->isSliderDown() == false && */mVolumeBarMovementTimer->isActive() == false)
{
int SliderValue = ConvertVolumeToBarPosition(Zone2Status.mMainVolume);
disconnect(ui->mZone2VolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(Zone2VolumeSetChanged(int)));
ui->mZone2VolumeSldBar->setValue(SliderValue);
connect(ui->mZone2VolumeSldBar,SIGNAL(valueChanged(int)),this,SLOT(Zone2VolumeSetChanged(int)));
ui->mZone2SliderValueLbl->setText("");
mTrayVolumeCtrlGuiHandle->SetZone2Volume(SliderValue,Zone2Status.mMainVolume);
}
if(Status.mSyncZonesVolumes)
ui->mZone2SyncVolumeChkBx->setCheckState(Qt::Checked);
else
ui->mZone2SyncVolumeChkBx->setCheckState(Qt::Unchecked);
return RET_OK;
}
void CAvReceiverGui::MainZoneScene1BtnClicked(bool)
{
mProgramHandle->SelectScenePressed(AV_RECEIVER_MAIN_ZONE,1);
}
void CAvReceiverGui::MainZoneScene2BtnClicked(bool)
{
mProgramHandle->SelectScenePressed(AV_RECEIVER_MAIN_ZONE,2);
}
void CAvReceiverGui::MainZoneScene3BtnClicked(bool)
{
mProgramHandle->SelectScenePressed(AV_RECEIVER_MAIN_ZONE,3);
}
void CAvReceiverGui::MainZoneScene4BtnClicked(bool)
{
mProgramHandle->SelectScenePressed(AV_RECEIVER_MAIN_ZONE,4);
}
int CAvReceiverGui::ConvertVolumeToBarPosition(float Volume)
{
int Pos;
Pos = (int)((Volume + 80.5) *2);
return Pos;
}
float CAvReceiverGui::ConvertBarPositionToVolume(int position)
{
float Volume;
Volume = (float)position;
Volume = ((Volume/2) - 80.5);
return Volume;
}
void CAvReceiverGui::MainZoneVolumeSetChanged(int value)
{
// int BarPosition = ui->mMainZoneVolumeSldBar->value();
int BarPosition = value;
float Volume = ConvertBarPositionToVolume(BarPosition);
ui->mMainZoneSliderValueLbl->setText(QString("%1").arg(Volume));
mProgramHandle->MainZoneVolumeChanged(Volume);
// if(mLockZone2VolumeWithZone1 == true)
if(ui->mZone2SyncVolumeChkBx->checkState() == Qt::Checked)
{
ui->mZone2VolumeSldBar->setValue(BarPosition);
// mVolumeBarMovementTimer->start();
// //mProgramHandle->Zone2VolumeChanged(Volume);
}
}
void CAvReceiverGui::Zone2VolumeSetChanged(int value)
{
// int BarPosition = ui->mZone2VolumeSldBar->value();
int BarPosition = value;
float Volume = ConvertBarPositionToVolume(BarPosition);
ui->mZone2SliderValueLbl->setText(QString("%1").arg(Volume));
mProgramHandle->Zone2VolumeChanged(Volume);
// mVolumeBarMovementTimer->start();
}
void CAvReceiverGui::VolumeBarMovementTimerExpired()
{
int BarPosition = ui->mMainZoneVolumeSldBar->value();
float Volume = ConvertBarPositionToVolume(BarPosition);
mProgramHandle->Zone2VolumeChanged(Volume);
}
void CAvReceiverGui::Zone2LockVolumeChanged(bool checked)
{
mLockZone2VolumeWithZone1 = checked;
if(checked)
{
// //Set Zone 2 volume to main zone value
// int BarPosition = ui->mMainZoneVolumeSldBar->value();
// float Volume = ConvertBarPositionToVolume(BarPosition);
// mProgramHandle->Zone2VolumeChanged(Volume);
ui->mZone2VolumeSldBar->setEnabled(false);
mProgramHandle->SyncZonesVolumesChanged(true);
}
else
{
ui->mZone2VolumeSldBar->setEnabled(true);
mProgramHandle->SyncZonesVolumesChanged(false);
}
}
void CAvReceiverGui::Zone2InputSelectionChanged()
{
QString Src = ui->mZone2InputComboBx->currentText();
mProgramHandle->Zone2InputSrcChanged(Src);
}
+18 -1
View File
@@ -4,6 +4,9 @@
#include <QWidget>
class CAvReceiver;
#include "AvReceiverData.h"
#include <QTimer>
class CTrayVolumeCtrl;
namespace Ui {
class CAvReceiverGui;
@@ -19,7 +22,12 @@ public:
CAvReceiver *mProgramHandle;
int UpdateReceiverStatus(CAvReceiverMainStatus Status);
int UpdateReceiverStatus(CAvReceiverMainStatus Status, CAvReceiverMainStatus Zone2Status);
int ConvertVolumeToBarPosition(float Volume);
float ConvertBarPositionToVolume(int position);
QTimer *mVolumeBarMovementTimer;
bool mLockZone2VolumeWithZone1;
CTrayVolumeCtrl *mTrayVolumeCtrlGuiHandle;
private:
Ui::CAvReceiverGui *ui;
@@ -27,6 +35,15 @@ private:
public slots:
void SpeakerBRadioClicked(bool checked);
void SpeakerARadioClicked(bool checked);
void MainZoneScene1BtnClicked(bool);
void MainZoneScene2BtnClicked(bool);
void MainZoneScene3BtnClicked(bool);
void MainZoneScene4BtnClicked(bool);
void MainZoneVolumeSetChanged(int);
void Zone2VolumeSetChanged(int);
void VolumeBarMovementTimerExpired();
void Zone2InputSelectionChanged();
void Zone2LockVolumeChanged(bool checked);
};
#endif // AVRECEIVERGUI_H
+182 -11
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>796</width>
<height>447</height>
<width>883</width>
<height>453</height>
</rect>
</property>
<property name="windowTitle">
@@ -29,10 +29,10 @@
<widget class="QLabel" name="mRcvrStatusLabel">
<property name="geometry">
<rect>
<x>100</x>
<y>110</y>
<x>50</x>
<y>130</y>
<width>181</width>
<height>231</height>
<height>181</height>
</rect>
</property>
<property name="text">
@@ -42,27 +42,198 @@
<widget class="QCheckBox" name="mSpkBCheckBox">
<property name="geometry">
<rect>
<x>570</x>
<y>130</y>
<x>350</x>
<y>110</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Speaker B</string>
<string>Zone 2</string>
</property>
</widget>
<widget class="QCheckBox" name="mSpkACheckBox">
<property name="geometry">
<rect>
<x>570</x>
<y>160</y>
<x>50</x>
<y>110</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Speaker A</string>
<string>Main Zone</string>
</property>
</widget>
<widget class="QLabel" name="mZone2StatusLabel">
<property name="geometry">
<rect>
<x>370</x>
<y>140</y>
<width>171</width>
<height>191</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QGroupBox" name="MainZoneSceneBox">
<property name="geometry">
<rect>
<x>40</x>
<y>320</y>
<width>101</width>
<height>81</height>
</rect>
</property>
<property name="title">
<string>Scene</string>
</property>
<widget class="QPushButton" name="MainZoneScene1Btn">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>31</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>1</string>
</property>
</widget>
<widget class="QPushButton" name="MainZoneScene2Btn">
<property name="geometry">
<rect>
<x>50</x>
<y>20</y>
<width>31</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>2</string>
</property>
</widget>
<widget class="QPushButton" name="MainZoneScene3Btn">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>31</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>3</string>
</property>
</widget>
<widget class="QPushButton" name="MainZoneScene4Btn">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>31</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>4</string>
</property>
</widget>
</widget>
<widget class="QSlider" name="mMainZoneVolumeSldBar">
<property name="geometry">
<rect>
<x>190</x>
<y>120</y>
<width>21</width>
<height>160</height>
</rect>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>194</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QSlider" name="mZone2VolumeSldBar">
<property name="geometry">
<rect>
<x>500</x>
<y>119</y>
<width>20</width>
<height>151</height>
</rect>
</property>
<property name="maximum">
<number>182</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<widget class="QLabel" name="mMainZoneSliderValueLbl">
<property name="geometry">
<rect>
<x>180</x>
<y>100</y>
<width>47</width>
<height>14</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="mZone2SliderValueLbl">
<property name="geometry">
<rect>
<x>490</x>
<y>100</y>
<width>51</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QComboBox" name="mZone2InputComboBx">
<property name="geometry">
<rect>
<x>580</x>
<y>180</y>
<width>121</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QCheckBox" name="mZone2SyncVolumeChkBx">
<property name="geometry">
<rect>
<x>590</x>
<y>120</y>
<width>171</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>Sync volume with Main zone</string>
</property>
</widget>
</widget>
@@ -39,7 +39,7 @@ int CAvReceiverNetworkCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int
break;
}
case AV_RECEIVER_INTERFACE_SET_SPEAKERB_RESPONSE:
case AV_RECEIVER_INTERFACE_SET_ZONE2_RESPONSE:
{
break;
}
@@ -48,10 +48,21 @@ int CAvReceiverNetworkCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int
{
break;
}
case AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_RESPONSE:
{
break;
}
case AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_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_SET_ZONE2_REQUEST:
case AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_REQUEST:
case AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_REQUEST:
case AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_REQUEST:
default:
{
qDebug("AV Receiver: Invalid Ethernet Msg received: %d",MessageID);
+138
View File
@@ -0,0 +1,138 @@
#include "VolumeController.h"
#include <windows.h>
#include <combaseapi.h>
#include <AvReceiver.h>
#include <initguid.h>
#include <Functiondiscoverykeys_devpkey.h>
CVolumeController::CVolumeController(QObject *parent) : QObject(parent)
{
mDeviceEnumerator = NULL;
mAudioDevice = NULL;
mEndpointVolume = 0;
mProgramPtr = 0;
mVolumeControllerActive = false;
}
CVolumeController::~CVolumeController()
{
if(mVolumeControllerActive == true)
{
if(mEndpointVolume != NULL)
{
mEndpointVolume->UnregisterControlChangeNotify(this);
mEndpointVolume->Release();
}
if(mAudioDevice != NULL)
mAudioDevice->Release();
if(mDeviceEnumerator != NULL)
mDeviceEnumerator->Release();
CoUninitialize();
}
}
int CVolumeController::Init(CAvReceiver *ProgramPtr)
{
mProgramPtr = ProgramPtr;
IPropertyStore *pProps = NULL;
IMMDeviceCollection *pCollection = NULL;
CoInitialize(NULL);
CoCreateGuid(&mMyGUID);
const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL,CLSCTX_ALL, IID_IMMDeviceEnumerator,(void**)&mDeviceEnumerator);
hr = mDeviceEnumerator->EnumAudioEndpoints(eRender,DEVICE_STATE_ACTIVE,&pCollection);
unsigned int count;
hr = pCollection->GetCount(&count);
// mDeviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &mAudioDevice); // Get the default audio output device
bool InterfaceFound = false;
for(unsigned int i = 0; i < count; i++)
{
hr = pCollection->Item(i,&mAudioDevice);
mAudioDevice->OpenPropertyStore(STGM_READ,&pProps);
PROPVARIANT DevName;
// Initialize container for property value.
PropVariantInit(&DevName);
hr = pProps->GetValue(PKEY_Device_FriendlyName, &DevName); //Get the friendly name
QString FriendlyName = QString("%1").arg(DevName.pwszVal);
PropVariantClear(&DevName);
qDebug("%s",qPrintable(FriendlyName));
if(FriendlyName.contains("SPDIF"))
{
//We found our interface.
InterfaceFound = true;
qDebug("Audio interface found... binding callback.");
break;
}
}
if(pProps != NULL)
pProps->Release();
if(InterfaceFound == false)
{
qDebug("Audio interface not found");
if(mAudioDevice != NULL)
mAudioDevice->Release();
if(mDeviceEnumerator != NULL)
mDeviceEnumerator->Release();
CoUninitialize();
return RET_ERROR;
}
mAudioDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, (void**)&mEndpointVolume); // Activate the endpoint volume interface
mEndpointVolume->RegisterControlChangeNotify(this);// Set up the volume change callback
mEndpointVolume->SetMasterVolumeLevelScalar(0.02,&mMyGUID);
mEndpointVolume->GetMasterVolumeLevelScalar(&mMasterVolume);
return RET_OK;
}
int CVolumeController::SetMasterVolume(float Volume)
{
mEndpointVolume->SetMasterVolumeLevelScalar(Volume,&mMyGUID);
return RET_OK;
}
STDMETHODIMP CVolumeController:: OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify)
{
if (pNotify)
{
if(pNotify->guidEventContext != mMyGUID)
{
// qDebug("Volume changed. Current %f, Requested: %f",mMasterVolume,pNotify->fMasterVolume);
// float NewVolume;
if(mMasterVolume > pNotify->fMasterVolume) //Volume decrease
{
// qDebug("Volume Decrease");
emit ExternalVolumeChanged(-EXTERNAL_VOLUME_INCREMENT);
}
else if(mMasterVolume < pNotify->fMasterVolume) //Volume increase
{
// qDebug("Volume increase");
emit ExternalVolumeChanged(EXTERNAL_VOLUME_INCREMENT);
}
// qDebug("Setting interface volume to %f",NewVolume);
// mEndpointVolume->SetMasterVolumeLevelScalar(NewVolume,&mMyGUID);
}
else
{
mEndpointVolume->GetMasterVolumeLevelScalar(&mMasterVolume);
// qDebug("Setting internal master volume: %f",mMasterVolume);
}
}
return RET_OK;
}
+57
View File
@@ -0,0 +1,57 @@
#ifndef VOLUMECONTROLLER_H
#define VOLUMECONTROLLER_H
#include "GlobalDefine.h"
#include <QObject>
#include <endpointvolume.h>
#include <Mmdeviceapi.h>
#define EXTERNAL_VOLUME_INCREMENT 1
class CAvReceiver;
class CVolumeController : public QObject, public IAudioEndpointVolumeCallback
{
Q_OBJECT
public:
explicit CVolumeController(QObject *parent = 0);
~CVolumeController();
int Init(CAvReceiver *ProgramPtr);
bool mVolumeControllerActive;
int SetMasterVolume(float Volume);
CAvReceiver *mProgramPtr;
private:
IMMDeviceEnumerator *mDeviceEnumerator ;
IMMDevice *mAudioDevice ;
IAudioEndpointVolume *mEndpointVolume;
GUID mMyGUID;
float mMasterVolume;
// CAudioNotificationCallback *mAudioNotificationObject;
public:
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) {
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) AddRef() {return 2;}
STDMETHODIMP_(ULONG) Release() {return 1;}
STDMETHODIMP OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
public:
signals:
void ExternalVolumeChanged(float);
public slots:
};
#endif // VOLUMECONTROLLER_H
@@ -0,0 +1,53 @@
#ifndef VOLUMECONTROLLER_H
#define VOLUMECONTROLLER_H
#include "GlobalDefine.h"
#include <QObject>
#include <endpointvolume.h>
#include <Mmdeviceapi.h>
class CAvReceiver;
class CVolumeController : public QObject, public IAudioEndpointVolumeCallback
{
Q_OBJECT
public:
explicit CVolumeController(QObject *parent = 0);
~CVolumeController();
int Init();
CAvReceiver *mProgramPtr;
private:
IMMDeviceEnumerator *mDeviceEnumerator ;
IMMDevice *mAudioDevice ;
IAudioEndpointVolume *mEndpointVolume;
// CAudioNotificationCallback *mAudioNotificationObject;
public:
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) {
return E_NOINTERFACE;
}
STDMETHODIMP_(ULONG) AddRef() {return 2;}
STDMETHODIMP_(ULONG) Release() {return 1;}
STDMETHODIMP OnNotify(PAUDIO_VOLUME_NOTIFICATION_DATA pNotify);
public:
signals:
public slots:
};
#endif // VOLUMECONTROLLER_H
+75
View File
@@ -0,0 +1,75 @@
#include "CRC32.h"
CCRC32::CCRC32()
{
InitTable();
}
void CCRC32::InitTable()
{
quint32 i;
quint32 j;
quint32 crc;
for (i=0; i<256; i++)
{
crc = i;
for (j=0; j<8; j++) {
if ( crc & 0x00000001L ) crc = ( crc >> 1 ) ^ CRC_POLY_32;
else crc = crc >> 1;
}
mCRC32Table[i] = crc;
}
}
quint32 CCRC32::ComputeCRC32(QByteArray Buffer)
{
return ComputeCRC32((const unsigned char *)Buffer.data(),Buffer.size());
}
quint32 CCRC32::ComputeCRC32( const unsigned char *input_str, qulonglong num_bytes )
{
quint32 crc;
quint32 tmp;
quint32 long_c;
const unsigned char *ptr;
qulonglong a;
crc = CRC_START_32;
ptr = input_str;
if ( ptr != NULL ) for (a=0; a<num_bytes; a++) {
long_c = 0x000000FFL & (quint32) *ptr;
tmp = crc ^ long_c;
crc = (crc >> 8) ^ mCRC32Table[ tmp & 0xff ];
ptr++;
}
crc ^= 0xffffffffL;
return crc & 0xffffffffL;
}
quint32 CCRC32::UpdateCRC32(quint32 crc, unsigned char c)
{
quint32 tmp;
quint32 long_c;
long_c = 0x000000ffL & (quint32) c;
tmp = crc ^ long_c;
crc = (crc >> 8) ^ mCRC32Table[ tmp & 0xff ];
return crc & 0xffffffffL;;
}
+55
View File
@@ -0,0 +1,55 @@
#ifndef CRC32_H
#define CRC32_H
#include <stdbool.h>
#include <stdlib.h>
#include <QtGlobal>
#include <QByteArray>
/*
* #define CRC_POLY_xxxx
*
* The constants of the form CRC_POLY_xxxx define the polynomials for some well
* known CRC calculations.
*/
#define CRC_POLY_16 0xA001
#define CRC_POLY_32 0xEDB88320L
#define CRC_POLY_CCITT 0x1021
#define CRC_POLY_DNP 0xA6BC
#define CRC_POLY_KERMIT 0x8408
#define CRC_POLY_SICK 0x8005
/*
* #define CRC_START_xxxx
*
* The constants of the form CRC_START_xxxx define the values that are used for
* initialization of a CRC value for common used calculation methods.
*/
#define CRC_START_8 0x00
#define CRC_START_16 0x0000
#define CRC_START_MODBUS 0xFFFF
#define CRC_START_XMODEM 0x0000
#define CRC_START_CCITT_1D0F 0x1D0F
#define CRC_START_CCITT_FFFF 0xFFFF
#define CRC_START_KERMIT 0x0000
#define CRC_START_SICK 0x0000
#define CRC_START_DNP 0x0000
#define CRC_START_32 0xFFFFFFFFL
class CCRC32
{
public:
CCRC32();
void InitTable();
quint32 ComputeCRC32( const unsigned char *input_str, qulonglong num_bytes );
quint32 ComputeCRC32( QByteArray Buffer);
quint32 UpdateCRC32( quint32 crc, unsigned char c );
private:
quint32 mCRC32Table[256];
};
#endif // CRC32_H
+179
View File
@@ -124,3 +124,182 @@ int CChalet::RequestChaletLogs(QDate StartDate)
return mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_GET_DATA_LOG_REQUEST,StartDateData);
}
int CChalet::RequestDeviceWifiParams()
{
mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_WIFI_GET_DEVICE_PARAMS_REQUEST,QByteArray());
return RET_OK;
}
int CChalet::RequestFirmwareVersion()
{
mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_GET_FIRMWARE_VERSION_REQUEST,QByteArray());
return RET_OK;
}
int CChalet::RequestClearCommStats()
{
mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_CLEAR_COMMS_STATS_REQUEST,QByteArray());
return RET_OK;
}
int CChalet::RequestWifiStatus()
{
mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_GET_WIFI_STATUS_REQUEST,QByteArray());
return RET_OK;
}
int CChalet::WifiStatusReceived(QByteArray Data)
{
quint32 Add = 0;
char byte;
byte = Data.at(1);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data.at(2);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data.at(3);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data.at(4);
Add += (quint32)(byte & 0x000000FF);
QHostAddress IP = QHostAddress(Add);
mChaletGui->UpdateDeviceWifiStatus(Data[0],IP);
return RET_OK;
}
int CChalet::DeviceWiFiParamsReceived(QByteArray *Data)
{
quint32 Add = 0;
char byte;
byte = Data->at(0);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data->at(1);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data->at(2);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data->at(3);
Add += (quint32)(byte & 0x000000FF);
QHostAddress IP = QHostAddress(Add);
Add = 0;
byte = Data->at(4);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data->at(5);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data->at(6);
Add += (quint32)(byte & 0x000000FF);
Add <<= 8;
byte = Data->at(7);
Add += (quint32)(byte & 0x000000FF);
QHostAddress Gateway = QHostAddress(Add);
QString APName, APPassword;
quint8 APNameLenght, APPasswordLenght;
bool UseDHCP = false;
if(Data->size() > 9)
{
if(Data->at(8) == 1)
UseDHCP = true;
APNameLenght = Data->at(9);
APPasswordLenght = Data->at(10);
APName = QString(Data->mid(11,APNameLenght));
APPassword = QString(Data->mid(11+APNameLenght,APPasswordLenght));
}
mChaletGui->UpdateDeviceWiFiParameters(IP, Gateway,APName,APPassword,UseDHCP);
return RET_OK;
}
int CChalet::DeviceFirmwareVersionReceived(QByteArray Data)
{
mChaletGui->UpdateFirmwareVersion(Data);
}
int CChalet::SetDeviceWifiParams(QString IP, QString Gateway, bool UseDHCP, QString APName, QString APPwd)
{
QHostAddress DeviceIP;
QHostAddress DeviceGateway;
quint8 APNameLength, APPwdLength;
if(APName.length() > 64)
return RET_ERROR;
if(APPwd.length() > 64)
return RET_ERROR;
if(DeviceIP.setAddress(IP) == false)
{
return RET_ERROR;
}
if(DeviceGateway.setAddress(Gateway) == false)
{
return RET_ERROR;
}
QByteArray Buffer;
Buffer.resize(8);
quint32 Address = DeviceIP.toIPv4Address();
char byte = (char)(Address & 0x000000FF);
Buffer[3] = byte;
Address >>= 8;
byte = (char)(Address & 0x000000FF);
Buffer[2] = byte;
Address >>= 8;
byte = (char)(Address & 0x000000FF);
Buffer[1] = byte;
Address >>= 8;
byte = (char)(Address & 0x000000FF);
Buffer[0] = byte;
Address >>= 8;
Address = DeviceGateway.toIPv4Address();
byte = (char)(Address & 0x000000FF);
Buffer[7] = byte;
Address >>= 8;
byte = (char)(Address & 0x000000FF);
Buffer[6] = byte;
Address >>= 8;
byte = (char)(Address & 0x000000FF);
Buffer[5] = byte;
Address >>= 8;
byte = (char)(Address & 0x000000FF);
Buffer[4] = byte;
Address >>= 8;
if(UseDHCP)
{
Buffer[8] = 1;
}
else
{
Buffer[8] = 0;
}
Buffer.append(APName.length());
Buffer.append(APPwd.length());
Buffer.append(APName);
Buffer.append(APPwd);
mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_WIFI_SET_DEVICE_PARAMS_REQUEST,Buffer);
return RET_OK;
}
+8
View File
@@ -32,6 +32,14 @@ public:
int DoHarakiriButtonClicked(bool Verified);
int RebootCPUButtonPressed();
int RequestChaletLogs(QDate StartDate);
int RequestDeviceWifiParams();
int DeviceWiFiParamsReceived(QByteArray *Data);
int SetDeviceWifiParams(QString IP, QString Gateway, bool UseDHCP, QString APName, QString APPwd);
int RequestFirmwareVersion();
int DeviceFirmwareVersionReceived(QByteArray Data);
int RequestClearCommStats();
int RequestWifiStatus();
int WifiStatusReceived(QByteArray Data);
signals:
+6 -1
View File
@@ -12,6 +12,7 @@ CChaletMainStatus::CChaletMainStatus()
mBatteryVoltage = 0;
mIsOnline = false;
mLostRequestPercentage = 0;
mChaletTemperature = -100;
}
@@ -46,7 +47,11 @@ QDataStream &operator>>(QDataStream &in, CChaletMainStatus &dest)
>> dest.mLostRequestPercentage
>> dest.mThisStatusDateTime
>> dest.mLastLoraStatus
>> dest.mStatusToggleBit;
>> dest.mStatusToggleBit
>> dest.mChaletTemperature
>> dest.mTotalNbChaletRxCmds
>> dest.mTotalMasterTxCmds
>> dest.mMasterLostRequestCount;
return in;
}
+5
View File
@@ -43,6 +43,7 @@ public:
qint8 mCurrentSensorStatus;
float mBatteryVoltage;
float mChaletTemperature;
qint16 mBatteryCurrent;
qint16 mBatterySOC;
@@ -57,6 +58,10 @@ public:
float mLostRequestPercentage;
int mTotalNbChaletRxCmds;
int mTotalMasterTxCmds;
int mMasterLostRequestCount;
};
QDataStream &operator>>(QDataStream &in, CChaletMainStatus &dest);
+252 -9
View File
@@ -1,8 +1,10 @@
#include "ChaletGui.h"
#include "ui_ChaletGui.h"
#include "CChalet.h"
#include "LoraModuleInterface.h"
#include <QWidget>
#include <QDate>
#include "LoraModuleInterfaceData.h"
CChaletGui::CChaletGui(QWidget *parent) :
QWidget(parent),
@@ -15,6 +17,15 @@ CChaletGui::CChaletGui(QWidget *parent) :
ui->mDoHarakiriButton->setEnabled(false);
ui->mLogStartDateEdit->setDate(QDate::currentDate());
mGetFimwVersionButtonColorTimer = new QTimer;
mGetFimwVersionButtonColorTimer->setSingleShot(true);
mGetFimwVersionButtonColorTimer->setInterval(500);
mGetWifiParamsButtonColorTimer = new QTimer;
mGetWifiParamsButtonColorTimer->setSingleShot(true);
mGetWifiParamsButtonColorTimer->setInterval(500);
connect(ui->mWiFiModuleONBtn,SIGNAL(clicked()),this,SLOT(WiFiONButtonClicked()));
connect(ui->mWiFiModuleOFFBtn,SIGNAL(clicked(bool)),this,SLOT(WiFiOFFButtonClicked()));
connect(ui->mInverterRelayOFFBtn,SIGNAL(clicked()),this,SLOT(InverterPowerOFFButtonClicked()));
@@ -23,17 +34,29 @@ CChaletGui::CChaletGui(QWidget *parent) :
connect(ui->mDoHarakiriButton,SIGNAL(clicked(bool)),this,SLOT(DoHarakiriButtonClicked()));
connect(ui->mEnableHarakiriChkBx,SIGNAL(clicked(bool)),this,SLOT(EnableHarakiriClicked(bool)));
connect(ui->mGetChaletLogButton,SIGNAL(clicked(bool)),this,SLOT(GetChaletLogsBtnClicked()));
connect(ui->mWiFiGetRemoteSettingsBtn,SIGNAL(clicked(bool)),this,SLOT(GetDeviceWiFiParamsButtonClicked(bool)));
connect(ui->mWiFiSetRemoteSettingsBtn,SIGNAL(clicked(bool)),this,SLOT(SetDeviceWiFiParamsButtonClicked(bool)));
connect(ui->mGetFirmwareVersionBtn,SIGNAL(clicked(bool)),this,SLOT(GetFirmwareVersionBtnClicked()));
connect(ui->mStartSyslogShellBtn,SIGNAL(clicked(bool)),this,SLOT(StartSyslogShellBtnClicked()));
connect(ui->mStartTerminalShellBtn,SIGNAL(clicked(bool)),this,SLOT(StartTerminalShellBtnClicked()));
connect(mGetFimwVersionButtonColorTimer,SIGNAL(timeout()),this,SLOT(GetFirmwVersionBtnColorTimerExpired()));
connect(mGetWifiParamsButtonColorTimer,SIGNAL(timeout()),this,SLOT(GetWifiParamsBtnColorTimerExpired()));
connect(ui->mResetCommStatsBtn,SIGNAL(clicked(bool)),this,SLOT(ResetCommStatsBtnClicked()));
connect(ui->mGetWifiStatusBtn,SIGNAL(clicked(bool)),this,SLOT(GetModuleWifiStatusBtnClicked()));
mBatteryPlotWidget = new QCustomPlot(ui->mPlotWidget);
mBatteryPlotWidget->resize(ui->mPlotWidget->size());
// create graph and assign data to it:
mBatteryPlotWidget->addGraph();
mBatteryPlotWidget->addGraph(mBatteryPlotWidget->xAxis,mBatteryPlotWidget->yAxis2);
// give the axes some labels:
mBatteryPlotWidget->xAxis->setLabel("time");
mBatteryPlotWidget->yAxis->setLabel("Volts");
mBatteryPlotWidget->yAxis2->setLabel("RSSI (dBm)");
mBatteryPlotWidget->yAxis2->setVisible(true);
double now = QDateTime::currentDateTime().toSecsSinceEpoch();
QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
@@ -53,16 +76,47 @@ CChaletGui::CChaletGui(QWidget *parent) :
mBatteryPlotWidget->xAxis->setRange(midnight.toSecsSinceEpoch(), eod.toSecsSinceEpoch());
mBatteryPlotWidget->yAxis->setRange(12,15);
mBatteryPlotWidget->yAxis2->setRange(-255,0.0);
QList<QCPAxis*> xAxis, yAxis;
xAxis.append(mBatteryPlotWidget->xAxis);
yAxis.append(mBatteryPlotWidget->yAxis);
yAxis.append(mBatteryPlotWidget->yAxis2);
mBatteryPlotWidget->axisRect()->setRangeDragAxes(xAxis,yAxis);
mBatteryPlotWidget->axisRect()->setRangeZoomAxes(xAxis,yAxis);
mBatteryPlotWidget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
mBatteryPlotWidget->graph(0)->addData(now,13.5);
mBatteryPlotWidget->replot();
mFirmVersionDefaultBtnPal = ui->mGetFirmwareVersionBtn->palette();
mWifiDefaultBtnPal = ui->mGetFirmwareVersionBtn->palette();
mChaletLastLostReqCount = 0;
ui->mWiFiModuleStatusLabel->setText("Unknown");
ui->mInverterRlyStatusLabel->setText("Unknown");
ui->mCurrentSensorStateLbl->setText("Current Sensor: Unknown state");
ui->mBatteryVoltageLabel->setText("Battery Voltage: Unknown");
ui->mBatterySOCLabel->setText("Battery SOC: Unknown");
ui->mSolarPanelCurrentLabel->setText("Raw Solar Panel Current: Unknown");
ui->mSolarPanelCurrentCnvLbl->setText("Solar Panel Current (A): Unknown");
ui->mLostReqPercentLbl->setText("N/A");
ui->mTotalRxTxRequestsLbl->setText("Chalet Rx req: ??");
ui->mChaletTemperatureLbl->setText("Temperature: -100)");
ui->mChaletWifiSelectionRadioBtn->setChecked(true);
}
CChaletGui::~CChaletGui()
{
delete ui;
delete mBatteryPlotWidget;
delete mGetFimwVersionButtonColorTimer;
delete mGetWifiParamsButtonColorTimer;
}
int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
@@ -80,13 +134,16 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
pal.setColor(QPalette::WindowText,QColor(Qt::red));
ui->mChaletOnlineStatusLbl->setPalette(pal);
ui->mWiFiModuleStatusLabel->setText("Unknown");
ui->mInverterRlyStatusLabel->setText("Unknown");
ui->mCurrentSensorStateLbl->setText("Current Sensor: Unknown state");
ui->mBatteryVoltageLabel->setText("Battery Voltage: Unknown");
ui->mBatterySOCLabel->setText("Battery SOC: Unknown");
ui->mSolarPanelCurrentLabel->setText("Solar Panel Current: Unknown");
ui->mLostReqPercentLbl->setText("N/A");
// ui->mWiFiModuleStatusLabel->setText("Unknown");
// ui->mInverterRlyStatusLabel->setText("Unknown");
// ui->mCurrentSensorStateLbl->setText("Current Sensor: Unknown state");
// ui->mBatteryVoltageLabel->setText("Battery Voltage: Unknown");
// ui->mBatterySOCLabel->setText("Battery SOC: Unknown");
// ui->mSolarPanelCurrentLabel->setText("Raw Solar Panel Current: Unknown");
// ui->mSolarPanelCurrentCnvLbl->setText("Solar Panel Current (A): Unknown");
// ui->mLostReqPercentLbl->setText("N/A");
// ui->mTotalRxTxRequestsLbl->setText("Chalet Rx req: ??");
// ui->mChaletTemperatureLbl->setText("Temperature: -100)");
return RET_OK;
@@ -182,11 +239,17 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
QString Voltage = QString("Battery Voltage: %1").arg(Status.mBatteryVoltage);
ui->mBatteryVoltageLabel->setText(Voltage);
ui->mVoltageLCD->display(Voltage);
QString Current = QString("Solar Panel Current: %1").arg(Status.mBatteryCurrent);
QString Current = QString("Raw Solar Panel Current: %1").arg(Status.mBatteryCurrent - 2);
ui->mSolarPanelCurrentLabel->setText(Current);
float ConvertedCurrent = (float)(Status.mBatteryCurrent - 2) * (3.3/1023); //*0.080645; // 3.3/(1023*0.04) = 0.080645;
ConvertedCurrent /= 0.08;
QString CnvCurrent = QString("Solar Panel Current (A): %1").arg(ConvertedCurrent);
ui->mSolarPanelCurrentCnvLbl->setText(CnvCurrent);
QString SOC = QString("Battery SOC: %1").arg(Status.mBatterySOC);
ui->mBatterySOCLabel->setText(SOC);
@@ -194,6 +257,16 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
ui->mLostReqPercentLbl->setText(Percent);
QString ChaletRxCnt = QString("Chalet Rx req: %1, Master Tx cmds: %2, Master lost reqs: %3").arg(Status.mTotalNbChaletRxCmds).arg(Status.mTotalMasterTxCmds).arg(Status.mMasterLostRequestCount);
ui->mTotalRxTxRequestsLbl->setText(ChaletRxCnt);
if(mChaletLastLostReqCount != Status.mMasterLostRequestCount)
{
QString ChaletLostReqStats = QString("Master --> Chalet: %1\nChalet --> Master: %2").arg((Status.mTotalMasterTxCmds-Status.mTotalNbChaletRxCmds)).arg(Status.mMasterLostRequestCount-(Status.mTotalMasterTxCmds-Status.mTotalNbChaletRxCmds));
ui->mLostReqsStatsLbl->setText(ChaletLostReqStats);
}
mChaletLastLostReqCount = Status.mMasterLostRequestCount;
if(Status.mStatusToggleBit != LastToggle)
{
LastToggle = Status.mStatusToggleBit;
@@ -212,6 +285,49 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
mBatteryPlotWidget->replot();
}
QString Temperature = QString("Temperature: %1").arg(Status.mChaletTemperature);
ui->mChaletTemperatureLbl->setText(Temperature);
return RET_OK;
}
int CChaletGui::UpdateLoraModuleStatus(CLoraModuleInterfaceStatus Status)
{
if(ui->mLoraModuleCommActivityLbl->isEnabled())
{
ui->mLoraModuleCommActivityLbl->setEnabled(false);
}
else
{
ui->mLoraModuleCommActivityLbl->setEnabled(true);
}
QString ModuleStatusTxt = QString("Ambient RSSI: %1 [%3dBm]\nLast Rx RSSI: %2 [%4dBm]").arg(Status.mModuleAmbientRSSI).arg(Status.mModuleLastRxRSSI).arg(-1*(255-Status.mModuleAmbientRSSI)).arg(-1*(255-Status.mModuleLastRxRSSI));
ui->mLoraIFModuleStatus->setText(ModuleStatusTxt);
quint32 Add = 0;
Add += (quint32)(Status.mIPAddress1 & 0x000000FF);
Add <<= 8;
Add += (quint32)(Status.mIPAddress2 & 0x000000FF);
Add <<= 8;
Add += (quint32)(Status.mIPAddress3 & 0x000000FF);
Add <<= 8;
Add += (quint32)(Status.mIPAddress4 & 0x000000FF);
QHostAddress IP = QHostAddress(Add);
QString IPString = QString("Lora Module IP Address:").append(IP.toString());
ui->mLoraModuleIPAddressLbl->setText(IPString);
if(Status.mModuleLastRxRSSI > 10) //filter glitches
{
double CurTime = QDateTime::currentDateTime().toSecsSinceEpoch();
mBatteryPlotWidget->graph(1)->addData(CurTime,-1*(255-Status.mModuleLastRxRSSI));
mBatteryPlotWidget->replot();
}
return RET_OK;
}
@@ -235,6 +351,9 @@ int CChaletGui::UpdateChaletLogPlot(QByteArray *Log)
}
}
if(x.size() == 0 || y.size() == 0)
return RET_ERROR;
mBatteryPlotWidget->graph(0)->data().clear();
mBatteryPlotWidget->graph(0)->setData(x,y);
mBatteryPlotWidget->xAxis->setRange(x.first(),x.last());
@@ -304,3 +423,127 @@ void CChaletGui::RebootCPUButtonClicked()
}
mProgramHandle->RequestChaletLogs(StartDate);
}
void CChaletGui::GetDeviceWiFiParamsButtonClicked(bool state)
{
mProgramHandle->RequestDeviceWifiParams();
}
void CChaletGui::SetDeviceWiFiParamsButtonClicked(bool state)
{
bool UseDHCP = ui->mDHCPEnableChkBx->isChecked();
if(mProgramHandle->SetDeviceWifiParams(ui->mWiFiIPAddressEditBx->text(),ui->mWiFiGatewayAddressEditBx->text(),UseDHCP,ui->mWifiAccessPtNameEditBx->text(),ui->mWifiPasswordEditBx->text()) == RET_ERROR)
{
QMessageBox::critical(this,"IP error","Invalid IP address");
}
}
void CChaletGui::UpdateDeviceWiFiParameters(QHostAddress IP, QHostAddress Gateway, QString APName, QString APPassword, bool UseDHCP)
{
ui->mWiFiIPAddressEditBx->setText(IP.toString());
ui->mWiFiGatewayAddressEditBx->setText(Gateway.toString());
ui->mWifiAccessPtNameEditBx->setText(APName);
ui->mWifiPasswordEditBx->setText(APPassword);
ui->mDHCPEnableChkBx->setChecked(UseDHCP);
QPalette pal = ui->mWiFiGetRemoteSettingsBtn->palette();
pal.setColor(QPalette::Button, QColor(Qt::green));
ui->mWiFiGetRemoteSettingsBtn->setAutoFillBackground(true);
ui->mWiFiGetRemoteSettingsBtn->setPalette(pal);
ui->mWiFiGetRemoteSettingsBtn->update();
mGetWifiParamsButtonColorTimer->start();
}
void CChaletGui::GetFirmwareVersionBtnClicked()
{
mProgramHandle->RequestFirmwareVersion();
}
void CChaletGui::ResetCommStatsBtnClicked()
{
mChaletLastLostReqCount = 0;
QString ChaletLostReqStats = QString("Master --> Chalet: 0\nChalet --> Master: 0");
ui->mLostReqsStatsLbl->setText(ChaletLostReqStats);
mProgramHandle->RequestClearCommStats();
}
void CChaletGui::UpdateFirmwareVersion(QByteArray Version)
{
QString VersionString(Version);
VersionString.prepend("Firmware version: ");
ui->mFirmwareVersionLabel->setText(VersionString);
QPalette pal = ui->mGetFirmwareVersionBtn->palette();
pal.setColor(QPalette::Button, QColor(Qt::green));
ui->mGetFirmwareVersionBtn->setAutoFillBackground(true);
ui->mGetFirmwareVersionBtn->setPalette(pal);
ui->mGetFirmwareVersionBtn->update();
mGetFimwVersionButtonColorTimer->start();
}
void CChaletGui::UpdateDeviceWifiStatus(char WifiState, QHostAddress IP)
{
QString Txt = QString("Module IP Address: %1").arg(IP.toString());
ui->mModuleIPAddressLbl->setText(Txt);
mModuleIPAddress = IP;
}
void CChaletGui::StartSyslogShellBtnClicked()
{
//system("c:\\progra~1\\putty\\putty.exe -load \"0-ChaletDuino_Syslog\"");
// QProcess Putty;
//QProcess::startDetached("c:\\progra~1\\putty\\putty.exe -load \"0-ChaletDuino_Syslog\"");
if(mModuleIPAddress.isNull() || mModuleIPAddress.isBroadcast())
{
QProcess::startDetached("c:\\progra~1\\putty\\putty.exe -load \"0-ChaletDuino_Syslog\"");
}
else
{
QString Proc = QString("c:\\progra~1\\putty\\putty.exe -raw -P 87 %1").arg(mModuleIPAddress.toString());
QProcess::startDetached(Proc);
}
}
void CChaletGui::StartTerminalShellBtnClicked()
{
// system("c:\\program files\\putty\\putty.exe -load \"0-ChaletDuino_Terminal\"");
// QProcess::startDetached("c:\\progra~1\\putty\\putty.exe -load \"0-ChaletDuino_Terminal\"");
if(mModuleIPAddress.isNull() || mModuleIPAddress.isBroadcast())
{
QProcess::startDetached("c:\\progra~1\\putty\\putty.exe -load \"0-ChaletDuino_Terminal\"");
}
else
{
QString Proc = QString("c:\\progra~1\\putty\\putty.exe -raw -P 85 %1").arg(mModuleIPAddress.toString());
QProcess::startDetached(Proc);
}
}
void CChaletGui::GetFirmwVersionBtnColorTimerExpired()
{
ui->mGetFirmwareVersionBtn->setAutoFillBackground(true);
ui->mGetFirmwareVersionBtn->setPalette(mFirmVersionDefaultBtnPal);
ui->mGetFirmwareVersionBtn->update();
}
void CChaletGui::GetWifiParamsBtnColorTimerExpired()
{
ui->mWiFiGetRemoteSettingsBtn->setAutoFillBackground(true);
ui->mWiFiGetRemoteSettingsBtn->setPalette(mFirmVersionDefaultBtnPal);
ui->mWiFiGetRemoteSettingsBtn->update();
}
void CChaletGui::GetModuleWifiStatusBtnClicked()
{
ui->mModuleIPAddressLbl->setText("Module IP Address: ");
mProgramHandle->RequestWifiStatus();
}
void CChaletGui::WiFiSettingsSelectionChanged()
{
}
+25
View File
@@ -4,8 +4,12 @@
#include <QWidget>
#include "ChaletData.h"
#include "QCustomPlot/qcustomplot.h"
#include <QHostAddress>
class CChalet;
class CLoraModuleInterface;
class CLoraModuleInterfaceStatus;
namespace Ui {
class CChaletGui;
@@ -20,11 +24,17 @@ public:
~CChaletGui();
CChalet *mProgramHandle;
CLoraModuleInterface *mLoraModuleIFProgramHandle;
QCustomPlot *mBatteryPlotWidget;
int UpdateChaletStatus(CChaletMainStatus Status);
int UpdateLoraModuleStatus(CLoraModuleInterfaceStatus Status);
int UpdateChaletLogPlot(QByteArray* Log);
int ChaletCommActivity();
QTimer *mGetWifiParamsButtonColorTimer, *mGetFimwVersionButtonColorTimer;
QPalette mFirmVersionDefaultBtnPal, mWifiDefaultBtnPal;
int mChaletLastLostReqCount;
QHostAddress mModuleIPAddress;
private:
Ui::CChaletGui *ui;
@@ -38,6 +48,21 @@ public slots:
void DoHarakiriButtonClicked();
void EnableHarakiriClicked(bool);
void GetChaletLogsBtnClicked();
void GetDeviceWiFiParamsButtonClicked(bool);
void SetDeviceWiFiParamsButtonClicked(bool);
void UpdateDeviceWiFiParameters(QHostAddress IP,QHostAddress Gateway,QString APName, QString APPassword, bool UseDHCP);
void GetFirmwareVersionBtnClicked();
void UpdateFirmwareVersion(QByteArray Version);
void StartSyslogShellBtnClicked();
void StartTerminalShellBtnClicked();
void GetWifiParamsBtnColorTimerExpired();
void GetFirmwVersionBtnColorTimerExpired();
void ResetCommStatsBtnClicked();
void UpdateDeviceWifiStatus(char WifiState, QHostAddress IP);
void GetModuleWifiStatusBtnClicked();
void WiFiSettingsSelectionChanged();
};
#endif // CHALETGUI_H
+560 -58
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1205</width>
<height>598</height>
<width>1443</width>
<height>662</height>
</rect>
</property>
<property name="windowTitle">
@@ -36,8 +36,8 @@
<widget class="QLabel" name="mInverterRlyStatusLabel">
<property name="geometry">
<rect>
<x>198</x>
<y>50</y>
<x>238</x>
<y>120</y>
<width>210</width>
<height>16</height>
</rect>
@@ -49,8 +49,8 @@
<widget class="QLabel" name="mWiFiModuleStatusLabel">
<property name="geometry">
<rect>
<x>198</x>
<y>90</y>
<x>238</x>
<y>160</y>
<width>130</width>
<height>16</height>
</rect>
@@ -62,8 +62,8 @@
<widget class="QLabel" name="mWiFiSectionLabel">
<property name="geometry">
<rect>
<x>26</x>
<y>90</y>
<x>66</x>
<y>160</y>
<width>31</width>
<height>16</height>
</rect>
@@ -75,8 +75,8 @@
<widget class="QPushButton" name="mInverterRelayOFFBtn">
<property name="geometry">
<rect>
<x>126</x>
<y>50</y>
<x>166</x>
<y>120</y>
<width>61</width>
<height>22</height>
</rect>
@@ -88,8 +88,8 @@
<widget class="QPushButton" name="mWiFiModuleOFFBtn">
<property name="geometry">
<rect>
<x>126</x>
<y>90</y>
<x>166</x>
<y>160</y>
<width>61</width>
<height>23</height>
</rect>
@@ -101,8 +101,8 @@
<widget class="QPushButton" name="mInverterRelayONBtn">
<property name="geometry">
<rect>
<x>70</x>
<y>50</y>
<x>110</x>
<y>120</y>
<width>51</width>
<height>23</height>
</rect>
@@ -114,8 +114,8 @@
<widget class="QPushButton" name="mWiFiModuleONBtn">
<property name="geometry">
<rect>
<x>70</x>
<y>90</y>
<x>110</x>
<y>160</y>
<width>51</width>
<height>23</height>
</rect>
@@ -127,8 +127,8 @@
<widget class="QLabel" name="mWiFiSectionLabel_2">
<property name="geometry">
<rect>
<x>16</x>
<y>50</y>
<x>56</x>
<y>120</y>
<width>51</width>
<height>20</height>
</rect>
@@ -140,8 +140,8 @@
<widget class="QPushButton" name="mRebootCPUBtn">
<property name="geometry">
<rect>
<x>66</x>
<y>130</y>
<x>106</x>
<y>200</y>
<width>75</width>
<height>23</height>
</rect>
@@ -152,12 +152,12 @@
</widget>
<widget class="QCheckBox" name="mEnableHarakiriChkBx">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>850</x>
<y>80</y>
<x>680</x>
<y>70</y>
<width>111</width>
<height>17</height>
</rect>
@@ -169,8 +169,8 @@
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>830</x>
<y>50</y>
<x>660</x>
<y>40</y>
<width>151</width>
<height>81</height>
</rect>
@@ -195,8 +195,8 @@
<widget class="QLabel" name="mBatteryVoltageLabel">
<property name="geometry">
<rect>
<x>147</x>
<y>170</y>
<x>187</x>
<y>240</y>
<width>241</width>
<height>16</height>
</rect>
@@ -229,21 +229,21 @@
<widget class="QLabel" name="mSolarPanelCurrentLabel">
<property name="geometry">
<rect>
<x>147</x>
<y>190</y>
<x>187</x>
<y>260</y>
<width>241</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Solar Panel Current: </string>
<string>Raw Solar Panel Current: </string>
</property>
</widget>
<widget class="QLabel" name="mBatterySOCLabel">
<property name="geometry">
<rect>
<x>147</x>
<y>210</y>
<x>190</x>
<y>300</y>
<width>241</width>
<height>16</height>
</rect>
@@ -255,8 +255,8 @@
<widget class="QLabel" name="mCurrentSensorStateLbl">
<property name="geometry">
<rect>
<x>147</x>
<y>230</y>
<x>190</x>
<y>320</y>
<width>241</width>
<height>16</height>
</rect>
@@ -268,8 +268,8 @@
<widget class="QLabel" name="mLostReqPercentLbl">
<property name="geometry">
<rect>
<x>770</x>
<y>200</y>
<x>430</x>
<y>160</y>
<width>241</width>
<height>16</height>
</rect>
@@ -281,28 +281,18 @@
<widget class="QWidget" name="mPlotWidget" native="true">
<property name="geometry">
<rect>
<x>590</x>
<y>250</y>
<width>571</width>
<x>420</x>
<y>260</y>
<width>1021</width>
<height>321</height>
</rect>
</property>
</widget>
<widget class="QLCDNumber" name="mVoltageLCD">
<property name="geometry">
<rect>
<x>30</x>
<y>170</y>
<width>111</width>
<height>23</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="mChaletCommActivityLbl">
<property name="geometry">
<rect>
<x>770</x>
<y>180</y>
<x>430</x>
<y>140</y>
<width>47</width>
<height>16</height>
</rect>
@@ -314,8 +304,8 @@
<widget class="QLabel" name="mLasCommRequestReceivedLbl">
<property name="geometry">
<rect>
<x>770</x>
<y>160</y>
<x>430</x>
<y>120</y>
<width>301</width>
<height>16</height>
</rect>
@@ -327,8 +317,8 @@
<widget class="QDateEdit" name="mLogStartDateEdit">
<property name="geometry">
<rect>
<x>950</x>
<y>220</y>
<x>520</x>
<y>210</y>
<width>110</width>
<height>22</height>
</rect>
@@ -337,8 +327,8 @@
<widget class="QPushButton" name="mGetChaletLogButton">
<property name="geometry">
<rect>
<x>1070</x>
<y>220</y>
<x>640</x>
<y>210</y>
<width>75</width>
<height>23</height>
</rect>
@@ -347,6 +337,504 @@
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="mChaletTemperatureLbl">
<property name="geometry">
<rect>
<x>190</x>
<y>340</y>
<width>241</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Temperature:</string>
</property>
</widget>
<widget class="QGroupBox" name="WifiSettingGroupBox">
<property name="geometry">
<rect>
<x>60</x>
<y>380</y>
<width>321</width>
<height>251</height>
</rect>
</property>
<property name="title">
<string>Wifi parameters stored in flash</string>
</property>
<widget class="QLineEdit" name="mWifiAccessPtNameEditBx">
<property name="geometry">
<rect>
<x>80</x>
<y>150</y>
<width>221</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>?</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="mAccessPtNameLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Access Pt:</string>
</property>
</widget>
<widget class="QLabel" name="mAccessPtPassLbl">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Password:</string>
</property>
</widget>
<widget class="QLineEdit" name="mWifiPasswordEditBx">
<property name="geometry">
<rect>
<x>80</x>
<y>180</y>
<width>221</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>?</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>90</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>IP Address:</string>
</property>
</widget>
<widget class="QLineEdit" name="mWiFiIPAddressEditBx">
<property name="geometry">
<rect>
<x>80</x>
<y>90</y>
<width>221</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>?</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>71</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Gatweway:</string>
</property>
</widget>
<widget class="QLineEdit" name="mWiFiGatewayAddressEditBx">
<property name="geometry">
<rect>
<x>80</x>
<y>120</y>
<width>221</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>?</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QCheckBox" name="mDHCPEnableChkBx">
<property name="geometry">
<rect>
<x>20</x>
<y>60</y>
<width>70</width>
<height>17</height>
</rect>
</property>
<property name="text">
<string>DHCP</string>
</property>
</widget>
<widget class="QPushButton" name="mWiFiGetRemoteSettingsBtn">
<property name="geometry">
<rect>
<x>70</x>
<y>220</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>GET</string>
</property>
</widget>
<widget class="QPushButton" name="mWiFiSetRemoteSettingsBtn">
<property name="geometry">
<rect>
<x>170</x>
<y>220</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>SET</string>
</property>
</widget>
<widget class="QRadioButton" name="mChaletWifiSelectionRadioBtn">
<property name="geometry">
<rect>
<x>40</x>
<y>20</y>
<width>85</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Chalet</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
<widget class="QRadioButton" name="mLoraIFWifiSelectionRadioBtn">
<property name="geometry">
<rect>
<x>140</x>
<y>20</y>
<width>101</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Lora Module IF</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</widget>
<widget class="QLabel" name="mSolarPanelCurrentCnvLbl">
<property name="geometry">
<rect>
<x>190</x>
<y>280</y>
<width>201</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Solar Panel Current (A):</string>
</property>
</widget>
<widget class="QLabel" name="mFirmwareVersionLabel">
<property name="geometry">
<rect>
<x>510</x>
<y>590</y>
<width>231</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Firmware Version: ?</string>
</property>
</widget>
<widget class="QPushButton" name="mGetFirmwareVersionBtn">
<property name="geometry">
<rect>
<x>420</x>
<y>590</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>GET</string>
</property>
</widget>
<widget class="QPushButton" name="mStartTerminalShellBtn">
<property name="geometry">
<rect>
<x>420</x>
<y>620</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Terminal</string>
</property>
</widget>
<widget class="QPushButton" name="mStartSyslogShellBtn">
<property name="geometry">
<rect>
<x>510</x>
<y>620</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Syslog</string>
</property>
</widget>
<widget class="QLabel" name="mTotalRxTxRequestsLbl">
<property name="geometry">
<rect>
<x>430</x>
<y>180</y>
<width>521</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Chalet Rx Req :</string>
</property>
</widget>
<widget class="QPushButton" name="mResetCommStatsBtn">
<property name="geometry">
<rect>
<x>420</x>
<y>100</y>
<width>101</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Reset Comm Stats</string>
</property>
</widget>
<widget class="QLabel" name="mLostReqsStatsLbl">
<property name="geometry">
<rect>
<x>700</x>
<y>140</y>
<width>241</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Master --&gt; Chalet: ??
Chalet --&gt; Master: ??</string>
</property>
</widget>
<widget class="QPushButton" name="mGetWifiStatusBtn">
<property name="geometry">
<rect>
<x>820</x>
<y>590</y>
<width>61</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>GET</string>
</property>
</widget>
<widget class="QLabel" name="mModuleIPAddressLbl">
<property name="geometry">
<rect>
<x>890</x>
<y>590</y>
<width>341</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Module IP Address:</string>
</property>
</widget>
<widget class="QGroupBox" name="mLoraIFGroupBox">
<property name="geometry">
<rect>
<x>890</x>
<y>20</y>
<width>541</width>
<height>201</height>
</rect>
</property>
<property name="title">
<string>Lora module Interface</string>
</property>
<widget class="QLabel" name="mLoraIFModuleStatus">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>231</width>
<height>141</height>
</rect>
</property>
<property name="text">
<string>Module Type: ???
Module state: ??</string>
</property>
</widget>
<widget class="QSpinBox" name="mLoraChannelSpinBox">
<property name="geometry">
<rect>
<x>470</x>
<y>30</y>
<width>51</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QSpinBox" name="mLoraAddressSpinBox">
<property name="geometry">
<rect>
<x>470</x>
<y>50</y>
<width>51</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>378</x>
<y>30</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Module Channel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>380</x>
<y>51</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Module Address</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="mLoraModuleCommActivityLbl">
<property name="geometry">
<rect>
<x>390</x>
<y>80</y>
<width>47</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Activity!!!</string>
</property>
</widget>
<widget class="QPushButton" name="mGetLoraWifiStatusBtn">
<property name="geometry">
<rect>
<x>170</x>
<y>130</y>
<width>61</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>GET</string>
</property>
</widget>
<widget class="QLabel" name="mLoraModuleIPAddressLbl">
<property name="geometry">
<rect>
<x>240</x>
<y>130</y>
<width>291</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Module IP Address:</string>
</property>
</widget>
</widget>
<zorder>WifiSettingGroupBox</zorder>
<zorder>groupBox</zorder>
<zorder>MainPageLabel</zorder>
<zorder>mInverterRlyStatusLabel</zorder>
@@ -366,12 +854,26 @@
<zorder>mCurrentSensorStateLbl</zorder>
<zorder>mLostReqPercentLbl</zorder>
<zorder>mPlotWidget</zorder>
<zorder>mVoltageLCD</zorder>
<zorder>mChaletCommActivityLbl</zorder>
<zorder>mLasCommRequestReceivedLbl</zorder>
<zorder>mLogStartDateEdit</zorder>
<zorder>mGetChaletLogButton</zorder>
<zorder>mChaletTemperatureLbl</zorder>
<zorder>mSolarPanelCurrentCnvLbl</zorder>
<zorder>mFirmwareVersionLabel</zorder>
<zorder>mGetFirmwareVersionBtn</zorder>
<zorder>mStartTerminalShellBtn</zorder>
<zorder>mStartSyslogShellBtn</zorder>
<zorder>mTotalRxTxRequestsLbl</zorder>
<zorder>mResetCommStatsBtn</zorder>
<zorder>mLostReqsStatsLbl</zorder>
<zorder>mGetWifiStatusBtn</zorder>
<zorder>mModuleIPAddressLbl</zorder>
<zorder>mLoraIFGroupBox</zorder>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>
@@ -84,11 +84,33 @@ int CChaletMasterCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int Targ
mProgramHandle->ChaletLogReceived(&Data);
break;
}
case CHALET_INTERFACE_WIFI_GET_DEVICE_PARAMS_RESPONSE:
{
mProgramHandle->DeviceWiFiParamsReceived(&Data);
break;
}
case CHALET_INTERFACE_WIFI_SET_DEVICE_PARAMS_RESPONSE:
{
break;
}
case CHALET_INTERFACE_GET_FIRMWARE_VERSION_RESPONSE:
{
mProgramHandle->DeviceFirmwareVersionReceived(Data);
break;
}
case CHALET_INTERFACE_GET_WIFI_STATUS_RESPONSE:
{
mProgramHandle->WifiStatusReceived(Data);
break;
}
case CHALET_INTERFACE_GENERAL_STATUS_REQUEST:
case CHALET_INTERFACE_AC_POWER_STATE_STATUS_REQUEST:
case CHALET_INTERFACE_AC_POWER_SET_STATE_REQUEST:
case CHALET_INTERFACE_BATTERY_VOLTAGE_REQUEST:
case CHALET_INTERFACE_GET_TODAYS_DATA_LOG_REQUEST:
case CHALET_INTERFACE_WIFI_GET_DEVICE_PARAMS_REQUEST:
case CHALET_INTERFACE_WIFI_SET_DEVICE_PARAMS_REQUEST:
default:
{
qDebug("Chalet: Invalid Ethernet Msg received from MasterCtrl: %d",MessageID);
+7 -1
View File
@@ -9,15 +9,21 @@ CGuiMain::CGuiMain(QWidget *parent)
mAvReceiverGui = new CAvReceiverGui(this);
mMainTabWidget = new QTabWidget(this);
mChaletGui = new CChaletGui(this);
mChaletGuiLTE = new CChaletGui(this);
mIspindelGui = new CIspindelGUI(this);
mTowerLightShowGui = new CTowerLightShowGui;
mPICUploaderGui = new CPICUploaderGui;
setCentralWidget(mMainTabWidget);
mMainTabWidget->addTab(mSMSGui,"SMS");
mMainTabWidget->addTab(mSprinklerGui,"Sprinkler");
mMainTabWidget->addTab(mAvReceiverGui,"AV Receiver");
mMainTabWidget->addTab(mChaletGui,"Chalet");
mMainTabWidget->addTab(mTowerLightShowGui,"Lightshow");
mMainTabWidget->addTab(mPICUploaderGui,"Firmware Upload");
mMainTabWidget->addTab(mIspindelGui,"ISpindel");
mMainTabWidget->addTab(mChaletGuiLTE,"Chalet LTE");
resize(1500,768);
resize(1700,768);
}
CGuiMain::~CGuiMain()
+5
View File
@@ -9,6 +9,8 @@
#include "AvReceiverGui.h"
#include "ChaletGui.h"
#include "TowerLightShowGui.h"
#include "PICUploaderGui.h"
#include "IspindelGUI.h"
class CGuiMain : public QMainWindow
{
@@ -22,8 +24,11 @@ public:
CSprinklerGui *mSprinklerGui;
CAvReceiverGui *mAvReceiverGui;
CChaletGui *mChaletGui;
CChaletGui *mChaletGuiLTE;
QTabWidget *mMainTabWidget;
CTowerLightShowGui *mTowerLightShowGui;
CPICUploaderGui *mPICUploaderGui;
CIspindelGUI *mIspindelGui;
int RespawnMainWindow();
int HideMainWindow();
+154
View File
@@ -0,0 +1,154 @@
#include "Ispindel.h"
#include <QDataStream>
#include "IspindelInterface.h"
CIspindel::CIspindel(CIspindelGUI *IspindelGui)
{
mIspindelGui = IspindelGui;
IspindelGui->mProgramHandle = this;
mNetworkInterface = new CIspindelInterface(this);
mOG = 0.0;
}
CIspindel::~CIspindel()
{
delete mNetworkInterface;
}
void CIspindel::Start()
{
mNetworkInterface->ConnectToMasterCtrl();
}
void CIspindel::IspindelFullBufferReceived(QByteArray *Data)
{
int NbItems;
QDataStream Strm(Data,QIODevice::ReadOnly | QIODevice::Unbuffered);
Strm >> NbItems;
if(NbItems == 0)
{
qDebug("Received empty Ispindel buffer...");
return;
}
ClearIspindleDataList();
for(int i = 0; i < NbItems; i++)
{
CIspindelData *NewFrame = new CIspindelData;
Strm >> *NewFrame;
mIspindelDataList.append(NewFrame);
}
mOG = mIspindelDataList.first()->mGravity;
SetLasFrameTextInGUI(*mIspindelDataList.last());
mIspindelGui->UpdateIspindelPlot(&mIspindelDataList);
}
void CIspindel::IspindelLastFrameReceived(QByteArray Data)
{
int DataSize;
QDataStream Strm(&Data,QIODevice::ReadOnly | QIODevice::Unbuffered);
if(Data.size() == 0)
return;
CIspindelData *NewData = new CIspindelData();
Strm >> *NewData;
mIspindelDataList.append(NewData);
SetLasFrameTextInGUI(*NewData);
mIspindelGui->NewIspindelFrameReceived(NewData);
// qDebug("Latest Ispindel data received");
}
int CIspindel::DeleteSampleResponseReceived(QByteArray Data)
{
bool Success;
QDataStream Strm(&Data,QIODevice::ReadOnly | QIODevice::Unbuffered);
Strm >> Success;
if(Success)
{
mNetworkInterface->SendMasterCtrlCommand(ISPINDEL_GET_FULL_DATA_BUFFER_REQUEST,QByteArray());
return RET_OK;
}
return RET_ERROR;
}
void CIspindel::ClearIspindleDataList()
{
for(int i = 0; i < mIspindelDataList.size(); i++)
{
delete mIspindelDataList[i];
}
mIspindelDataList.clear();
}
void CIspindel::ConnectedToMaster(bool connected)
{
if(connected)
{
mNetworkInterface->SendMasterCtrlCommand(ISPINDEL_GET_FULL_DATA_BUFFER_REQUEST,QByteArray());
}
}
void CIspindel::SetLasFrameTextInGUI(CIspindelData Frame)
{
QString FrameText;
QString ABVText;
FrameText = QString("\nLast Frame:\n------------------------------\nAngle: %1\nBattery Voltage: %2\nGravity: %3\nSample Interval: %4\nIspindel ID: %5\nIspindel Name: %6\nRSSI: %7\nTemperature: %8%9 (%11F)\nSample date time: %10\n------------------------------")\
.arg(Frame.mAngle)\
.arg(Frame.mBattery)\
.arg(Frame.mGravity)\
.arg(Frame.mInterval)\
.arg(Frame.mIspindelID)\
.arg(Frame.mIspindelName)\
.arg(Frame.mRSSI)\
.arg(Frame.mTemperature).arg(Frame.mTemperatureUnits)\
.arg(Frame.mSampleDateTime.toString("yyyy-MM-dd - hh:mm:ss"))\
.arg(((Frame.mTemperature*9/5)+32));
if(mIspindelDataList.size() > 1)
{
float ABV = ((mOG - Frame.mGravity) * 131.25);
ABVText = QString("ABV : %1\%").arg(ABV);
}
else
{
ABVText = QString("ABV : ?\%");
}
mIspindelGui->SetLastIspindelFrameData(FrameText,ABVText);
}
int CIspindel::SetOGFromItem(int ItemIndex)
{
if(ItemIndex >= mIspindelDataList.size())
return RET_ERROR;
mOG = mIspindelDataList.at(ItemIndex)->mGravity;
SetLasFrameTextInGUI(*mIspindelDataList.last());
return RET_OK;
}
int CIspindel::DeleteSample(int ItemIndex)
{
if(ItemIndex >= mIspindelDataList.size())
return RET_ERROR;
QByteArray Data;
QDataStream Strm(&Data,QIODevice::WriteOnly | QIODevice::Unbuffered);
Strm << ItemIndex;
mNetworkInterface->SendMasterCtrlCommand(ISPINDEL_DELETE_SAMPLE_REQUEST,Data);
}
+43
View File
@@ -0,0 +1,43 @@
#ifndef ISPINDEL_H
#define ISPINDEL_H
#include <QObject>
#include "IspindelGUI.h"
#include "IspindelData.h"
#include <QList>
#include "QCustomPlot/qcustomplot.h"
class CIspindelInterface;
class CIspindel : public QObject
{
Q_OBJECT
public:
explicit CIspindel(CIspindelGUI *IspindelGui);
~CIspindel();
CIspindelGUI *mIspindelGui;
void Start();
void IspindelFullBufferReceived(QByteArray *Data);
void IspindelLastFrameReceived(QByteArray Data);
void ClearIspindleDataList();
void ConnectedToMaster(bool connected);
void SetLasFrameTextInGUI(CIspindelData Frame);
int SetOGFromItem(int ItemIndex);
int DeleteSample(int ItemIndex);
int DeleteSampleResponseReceived(QByteArray Data);
QList<CIspindelData*> mIspindelDataList;
CIspindelInterface *mNetworkInterface;
double mOG;
signals:
public slots:
};
#endif // ISPINDEL_H
+54
View File
@@ -0,0 +1,54 @@
#include "IspindelData.h"
CIspindelData::CIspindelData()
{
mIspindelID = mRSSI = mInterval = 0;
mIspindelName = mTemperatureUnits = "";
mAngle = mBattery = mGravity = mTemperature = 0.0;
mSampleDateTime = QDateTime::currentDateTime();
}
QDataStream &operator<<(QDataStream &out, const CIspindelData &source)
{
out << source.mAngle
<< source.mBattery
<< source.mGravity
<< source.mInterval
<< source.mIspindelID
<< source.mIspindelName
<< source.mRSSI
<< source.mTemperature
<< source.mTemperatureUnits
<< source.mSampleDateTime;
return out;
}
QDataStream &operator>>(QDataStream &in, CIspindelData &dest)
{
in >> dest.mAngle
>> dest.mBattery
>> dest.mGravity
>> dest.mInterval
>> dest.mIspindelID
>> dest.mIspindelName
>> dest.mRSSI
>> dest.mTemperature
>> dest.mTemperatureUnits
>> dest.mSampleDateTime;
return in;
}
QByteArray CIspindelData::ToByteArray()
{
QByteArray Array;
QDataStream Strm(&Array,QIODevice::WriteOnly | QIODevice::Unbuffered);
Strm << *this;
return Array;
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef CISPINDELDATA_H
#define CISPINDELDATA_H
#include <QString>
#include <QDataStream>
#include <QDateTime>
class CIspindelData
{
public:
CIspindelData();
int mIspindelID, mRSSI, mInterval;
QString mIspindelName, mTemperatureUnits;
double mAngle, mBattery, mGravity, mTemperature;
QDateTime mSampleDateTime;
QByteArray ToByteArray();
};
QDataStream &operator<<(QDataStream &out, const CIspindelData &source);
QDataStream &operator>>(QDataStream &in, CIspindelData &dest);
#endif // CISPINDELDATA_H
+176
View File
@@ -0,0 +1,176 @@
#include "IspindelGUI.h"
#include "ui_IspindelGUI.h"
#include "Ispindel.h"
#include "IspindelData.h"
#include "GlobalDefine.h"
CIspindelGUI::CIspindelGUI(QWidget *parent) :
QDialog(parent),
ui(new Ui::CIspindelGUI)
{
ui->setupUi(this);
mIspindelPlot = new QCustomPlot(ui->mIspindelPlot);
mIspindelPlot->resize(ui->mIspindelPlot->size());
// create graph and assign data to it:
mIspindelPlot->addGraph();
mIspindelPlot->addGraph(mIspindelPlot->xAxis,mIspindelPlot->yAxis2);
// give the axes some labels:
mIspindelPlot->xAxis->setLabel("Time");
mIspindelPlot->yAxis->setLabel("Gravity");
mIspindelPlot->yAxis2->setLabel("Temprature (C)");
mIspindelPlot->yAxis2->setVisible(true);
double now = QDateTime::currentDateTime().toSecsSinceEpoch();
QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
dateTicker->setDateTimeFormat("hh:mm:ss\ndd MMM");
mIspindelPlot->xAxis->setTicker(dateTicker);
mIspindelPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
QList<QCPAxis*> xAxis, yAxis;
xAxis.append(mIspindelPlot->xAxis);
yAxis.append(mIspindelPlot->yAxis);
yAxis.append(mIspindelPlot->yAxis2);
mIspindelPlot->axisRect()->setRangeDragAxes(xAxis,yAxis);
mIspindelPlot->axisRect()->setRangeZoomAxes(xAxis,yAxis);
// mIspindelPlot->yAxis2->axisRect()->setRangeZoomAxes(0,mIspindelPlot->yAxis2);
QDateTime Now = QDateTime::currentDateTime().toLocalTime();
QDateTime midnight = Now;
midnight.setTime(QTime(0,0,0));
QDateTime eod = Now;
eod.setTime(QTime(23,59,0));
//mIspindelPlot->xAxis->setRange(0/*QCPAxisTickerDateTime::dateTimeToKey(midnight)*/,QCPAxisTickerDateTime::dateTimeToKey(eod));
// mIspindelPlot->xAxis->setRange(now, now+(2*3600));
mIspindelPlot->xAxis->setRange(midnight.toSecsSinceEpoch(), eod.toSecsSinceEpoch());
mIspindelPlot->yAxis->setRange(1.000,1.01);
mIspindelPlot->yAxis2->setRange(15,25);
// mIspindelPlot->graph(0)->addData(now,1.005);
// mIspindelPlot->graph(1)->addData(now,20);
mIspindelPlot->replot();
ui->mSamplesTable->setColumnCount(4);
ui->mSamplesTable->setHorizontalHeaderLabels(QStringList() << "Sample" << "Date" << "Gravity" << "Temperature");
connect(ui->mSetOGBtn,SIGNAL(clicked(bool)),this,SLOT(SetOGButtonClicked(bool)));
connect(ui->mDelSelectedSampleBtn,SIGNAL(clicked(bool)),this,SLOT(DeleteSampleBtnClicked(bool)));
}
CIspindelGUI::~CIspindelGUI()
{
delete ui;
}
void CIspindelGUI::SetLastIspindelFrameData(QString Data, QString ABVText)
{
ui->mLastFrameDataLbl->setText(Data);
ui->mABVLabel->setText(ABVText);
}
int CIspindelGUI::UpdateIspindelPlot(QList<CIspindelData *> *Data)
{
if(Data->size() == 0)
return RET_ERROR;
QVector<double> x,y,ty;
for(int i = 0; i < Data->size(); i++)
{
x.append(Data->at(i)->mSampleDateTime.toSecsSinceEpoch());
y.append(Data->at(i)->mGravity);
ty.append(Data->at(i)->mTemperature);
}
if(x.size() == 0 || y.size() == 0)
return RET_ERROR;
mIspindelPlot->graph(0)->data().clear();
mIspindelPlot->graph(0)->setData(x,y);
mIspindelPlot->xAxis->setRange(x.first(),x.last());
mIspindelPlot->yAxis->setRange(y.first(),y.last());
mIspindelPlot->graph(1)->setPen(QColor(Qt::red));
mIspindelPlot->graph(1)->setName("Température");
mIspindelPlot->graph(1)->setData(x,ty);
mIspindelPlot->yAxis2->setRange(10,30);
mIspindelPlot->replot();
ui->mSamplesTable->setRowCount(Data->size());
QTableWidgetItem *TableItem;
for(int i= 0; i < Data->size(); i++)
{
TableItem = new QTableWidgetItem(QString("%1").arg(i));
ui->mSamplesTable->setItem(i,0,TableItem);
TableItem = new QTableWidgetItem(Data->at(i)->mSampleDateTime.toString("yyyy-MM-dd - hh:mm:ss"));
ui->mSamplesTable->setItem(i,1,TableItem);
TableItem = new QTableWidgetItem(QString("%1").arg(Data->at(i)->mGravity));
ui->mSamplesTable->setItem(i,2,TableItem);
TableItem = new QTableWidgetItem(QString("%1").arg(Data->at(i)->mTemperature));
ui->mSamplesTable->setItem(i,3,TableItem);
}
ui->mSamplesTable->resizeColumnsToContents();
return RET_OK;
}
int CIspindelGUI::NewIspindelFrameReceived(CIspindelData *Data)
{
mIspindelPlot->graph(0)->addData(Data->mSampleDateTime.toSecsSinceEpoch(),Data->mGravity);
mIspindelPlot->graph(1)->addData(Data->mSampleDateTime.toSecsSinceEpoch(),Data->mTemperature);
QTableWidgetItem *TableItem;
int RowIndex = ui->mSamplesTable->rowCount();
ui->mSamplesTable->insertRow(RowIndex);
TableItem = new QTableWidgetItem(QString("%1").arg(RowIndex));
ui->mSamplesTable->setItem(RowIndex,0,TableItem);
TableItem = new QTableWidgetItem(Data->mSampleDateTime.toString("yyyy-MM-dd - hh:mm:ss"));
ui->mSamplesTable->setItem(RowIndex,1,TableItem);
TableItem = new QTableWidgetItem(QString("%1").arg(Data->mGravity));
ui->mSamplesTable->setItem(RowIndex,2,TableItem);
TableItem = new QTableWidgetItem(QString("%1").arg(Data->mTemperature));
ui->mSamplesTable->setItem(RowIndex,3,TableItem);
mIspindelPlot->replot();
return RET_OK;
}
void CIspindelGUI::SetOGButtonClicked(bool)
{
QList<QTableWidgetItem*> SelectedItemsList;
SelectedItemsList = ui->mSamplesTable->selectedItems();
if(SelectedItemsList.size() == 0)
return;
int SampleIndex = SelectedItemsList.at(0)->row();
mProgramHandle->SetOGFromItem(SampleIndex);
}
void CIspindelGUI::DeleteSampleBtnClicked(bool)
{
QList<QTableWidgetItem*> SelectedItemsList;
SelectedItemsList = ui->mSamplesTable->selectedItems();
if(SelectedItemsList.size() == 0)
return;
int SampleIndex = SelectedItemsList.at(0)->row();
mProgramHandle->DeleteSample(SampleIndex);
}
+40
View File
@@ -0,0 +1,40 @@
#ifndef ISPINDELGUI_H
#define ISPINDELGUI_H
#include <QDialog>
#include "QCustomPlot/qcustomplot.h"
#include <QList>
namespace Ui {
class CIspindelGUI;
}
class CIspindel;
class CIspindelData;
class CIspindelGUI : public QDialog
{
Q_OBJECT
public:
explicit CIspindelGUI(QWidget *parent = 0);
~CIspindelGUI();
CIspindel *mProgramHandle;
void SetLastIspindelFrameData(QString Data, QString ABVText);
int UpdateIspindelPlot(QList<CIspindelData*> *Data);
int NewIspindelFrameReceived(CIspindelData *Data);
QCustomPlot *mIspindelPlot;
public slots:
void SetOGButtonClicked(bool );
void DeleteSampleBtnClicked(bool);
private:
Ui::CIspindelGUI *ui;
};
#endif // ISPINDELGUI_H
+127
View File
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CIspindelGUI</class>
<widget class="QDialog" name="CIspindelGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1123</width>
<height>629</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>520</x>
<y>0</y>
<width>91</width>
<height>41</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>ISpindel</string>
</property>
</widget>
<widget class="QWidget" name="mIspindelPlot" native="true">
<property name="geometry">
<rect>
<x>520</x>
<y>100</y>
<width>661</width>
<height>461</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="mLastFrameDataLbl">
<property name="geometry">
<rect>
<x>60</x>
<y>10</y>
<width>381</width>
<height>241</height>
</rect>
</property>
<property name="font">
<font>
<family>Tahoma</family>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>No data...</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QTableWidget" name="mSamplesTable">
<property name="geometry">
<rect>
<x>10</x>
<y>290</y>
<width>461</width>
<height>331</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="mABVLabel">
<property name="geometry">
<rect>
<x>660</x>
<y>50</y>
<width>231</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>ABV : ?</string>
</property>
</widget>
<widget class="QPushButton" name="mSetOGBtn">
<property name="geometry">
<rect>
<x>650</x>
<y>10</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Set OG</string>
</property>
</widget>
<widget class="QPushButton" name="mDelSelectedSampleBtn">
<property name="geometry">
<rect>
<x>520</x>
<y>590</y>
<width>81</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Delete Sample</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
+70
View File
@@ -0,0 +1,70 @@
#include "IspindelInterface.h"
#include "IspindelData.h"
#include "Ispindel.h"
#include "ProtocolDefs.h"
CIspindelInterface::CIspindelInterface(CIspindel *ProgramHandle)
{
mMyDeviceID = ID_ISPINDEL_INTERFACE;
mNetworkPort = 2182;
mMasterCtrlIPAddress = "127.0.0.1";
mNetworkCommSocket = 0;
mDeviceAddress = 1;
mProgramHandle = ProgramHandle;
}
int CIspindelInterface::DeviceConnectedToMaster(bool Connected)
{
if(Connected)
{
qDebug("Ispindel Interface connected to Master.");
mProgramHandle->ConnectedToMaster(Connected);
}
else
return RET_ERROR;
return RET_OK;
}
int CIspindelInterface::DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data)
{
Q_UNUSED(DataSize)
Q_UNUSED(SenderID)
Q_UNUSED(SenderAddress)
if(TargetDeviceID == mMyDeviceID && (TargetDeviceAddress == BROADCAST_VALUE || TargetDeviceAddress == mDeviceAddress))
{
switch(MessageID)
{
case ISPINDEL_GET_FULL_DATA_BUFFER_RESPONSE:
{
mProgramHandle->IspindelFullBufferReceived(&Data);
break;
}
case ISPINDLE_LATEST_DATA_RESPONSE:
{
mProgramHandle->IspindelLastFrameReceived(Data);
break;
}
case ISPINDEL_DELETE_SAMPLE_RESPONSE:
{
mProgramHandle->DeleteSampleResponseReceived(Data);
break;
}
case ISPINDEL_GET_FULL_DATA_BUFFER_REQUEST:
case ISPINDLE_LATEST_DATA_REQUEST:
case ISPINDEL_DELETE_SAMPLE_REQUEST:
default:
{
qDebug("Ispindel: Invalid Ethernet Msg received from MasterCtrl: %d",MessageID);
break;
}
}
}
return RET_OK;
}
+20
View File
@@ -0,0 +1,20 @@
#ifndef ISPINDELINTERFACE_H
#define ISPINDELINTERFACE_H
#include "MasterCtrlInterface.h"
class CIspindel;
class CIspindelInterface : public CMasterCtrlInterface
{
public:
CIspindelInterface(CIspindel *ProgramHandle);
int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
int DeviceConnectedToMaster(bool Connected);
private:
CIspindel *mProgramHandle;
};
#endif // ISPINDELINTERFACE_H
@@ -0,0 +1,68 @@
#include "LoraModuleIFMasterCtrlInterface.h"
#include "LoraModuleInterface.h"
#include "LoraModuleInterfaceData.h"
CLoraModuleIFMasterCtrlInterface::CLoraModuleIFMasterCtrlInterface(CLoraModuleInterface *ProgramHandle)
{
mMyDeviceID = ID_LORA_INTERFACE_INTERFACE;
mNetworkPort = 2182;
mMasterCtrlIPAddress = "127.0.0.1";
mNetworkCommSocket = 0;
mDeviceAddress = 1;
mProgramHandle = ProgramHandle;
}
int CLoraModuleIFMasterCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data)
{
Q_UNUSED(DataSize)
Q_UNUSED(SenderID)
Q_UNUSED(SenderAddress)
if(TargetDeviceID == mMyDeviceID && (TargetDeviceAddress == BROADCAST_VALUE || TargetDeviceAddress == mDeviceAddress))
{
switch(MessageID)
{
case LORA_MODULE_IF_INTERFACE_ACK:
{
qDebug("Chalet Interface ACK received");
break;
}
case LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_RESPONSE:
{
// qDebug("Rx Lora Module IF status");
CLoraModuleInterfaceStatus Status;
QDataStream Strm(Data);
Strm >> Status;
mProgramHandle->NewLoraModuleStatusData(Status);
break;
}
case LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST:
default:
{
qDebug("CLoraModuleIFMasterCtrlInterface: invalid command received");
break;
}
}
}
return RET_OK;
}
int CLoraModuleIFMasterCtrlInterface::DeviceConnectedToMaster(bool Connected)
{
if(Connected)
{
qDebug("LoraModuleIF Interface connected to Master.");
mProgramHandle->ConnectedToMaster(Connected);
}
else
return RET_ERROR;
return RET_OK;
}
@@ -0,0 +1,19 @@
#ifndef LORAMODULEIFMASTERCTRLINTERFACE_H
#define LORAMODULEIFMASTERCTRLINTERFACE_H
#include "MasterCtrlInterface.h"
class CLoraModuleInterface;
class CLoraModuleIFMasterCtrlInterface: public CMasterCtrlInterface
{
public:
CLoraModuleIFMasterCtrlInterface(CLoraModuleInterface *ProgramHandle);
int DeviceFrameReceived(int TargetDeviceID, int TargetDeviceAddress, int SenderID, int SenderAddress, int MessageID, int DataSize, QByteArray Data);
int DeviceConnectedToMaster(bool Connected = true);
private:
CLoraModuleInterface *mProgramHandle;
};
#endif // LORAMODULEIFMASTERCTRLINTERFACE_H
@@ -0,0 +1,44 @@
#include "LoraModuleInterface.h"
#include "LoraModuleIFMasterCtrlInterface.h"
CLoraModuleInterface::CLoraModuleInterface(CChaletGui *ChaletGuiPtr)
{
mChaletGui = ChaletGuiPtr;
mChaletGui->mLoraModuleIFProgramHandle = this;
mNetworkInterface = new CLoraModuleIFMasterCtrlInterface(this);
mLoraModulePollTimer = new QTimer();
mLoraModulePollTimer->setInterval(1000);
mLoraModulePollTimer->setSingleShot(false);
connect(mLoraModulePollTimer,&QTimer::timeout,this,&CLoraModuleInterface::LoraModulePollTimerExpired);
}
int CLoraModuleInterface::ConnectedToMaster(bool connected)
{
if(connected)
{
mLoraModulePollTimer->start();
}
else
{
mLoraModulePollTimer->stop();
}
return RET_OK;
}
int CLoraModuleInterface::Start()
{
mNetworkInterface->ConnectToMasterCtrl();
return RET_OK;
}
void CLoraModuleInterface::LoraModulePollTimerExpired()
{
mNetworkInterface->SendMasterCtrlCommand(LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST,QByteArray());
}
int CLoraModuleInterface::NewLoraModuleStatusData(CLoraModuleInterfaceStatus Data)
{
mChaletGui->UpdateLoraModuleStatus(Data);
}
@@ -0,0 +1,29 @@
#ifndef LORAMODULEINTERFACE_H
#define LORAMODULEINTERFACE_H
#include "ChaletGui.h"
#include <QTimer>
#include "LoraModuleInterfaceData.h"
class CLoraModuleIFMasterCtrlInterface;
class CLoraModuleInterface : public QObject
{
Q_OBJECT
public:
CLoraModuleInterface(CChaletGui *ChaletGuiPtr);
int Start();
int ConnectedToMaster(bool connected);
int NewLoraModuleStatusData(CLoraModuleInterfaceStatus Data);
CLoraModuleIFMasterCtrlInterface *mNetworkInterface;
CChaletGui *mChaletGui;
QTimer *mLoraModulePollTimer;
public slots:
void LoraModulePollTimerExpired();
};
#endif // LORAMODULEINTERFACE_H
@@ -0,0 +1,90 @@
#include "LoraModuleInterfaceData.h"
CLoraModuleInterfaceStatus::CLoraModuleInterfaceStatus()
{
}
CLoraModuleInterfaceStatus& CLoraModuleInterfaceStatus::operator = (const CLoraModuleInterfaceStatus &rhs)
{
if(this == &rhs)
return *this;
mModuleModel = rhs.mModuleModel;
mModuleInternalAddress = rhs.mModuleInternalAddress;
mModuleUARTParity = rhs.mModuleUARTParity;
mModuleUARTRate = rhs.mModuleUARTRate;
mModuleAirRate = rhs.mModuleAirRate;
mModuleSubPacket = rhs.mModuleSubPacket;
mModuleRSSIEnabled = rhs.mModuleRSSIEnabled;
mModuleTxPower = rhs.mModuleTxPower;
mModuleInternalChannel = rhs.mModuleInternalChannel;
mModuleRSSIByteEnabled = rhs.mModuleRSSIByteEnabled;
mModuleTxMethod = rhs.mModuleTxMethod;
mModuleLBTEnabled = rhs.mModuleLBTEnabled;
mModuleWORCycle = rhs.mModuleWORCycle;
mModuleAmbientRSSI = rhs.mModuleAmbientRSSI;
mModuleLastRxRSSI = rhs.mModuleLastRxRSSI;
mIPAddress1 = rhs.mIPAddress1;
mIPAddress2 = rhs.mIPAddress2;
mIPAddress3 = rhs.mIPAddress3;
mIPAddress4 = rhs.mIPAddress4;
return *this;
}
QDataStream &operator<<(QDataStream &out, const CLoraModuleInterfaceStatus &source)
{
out << source.mModuleModel
<< source.mModuleInternalAddress
<< source.mModuleUARTParity
<< source.mModuleUARTRate
<< source.mModuleAirRate
<< source.mModuleSubPacket
<< source.mModuleRSSIEnabled
<< source.mModuleTxPower
<< source.mModuleInternalChannel
<< source.mModuleRSSIByteEnabled
<< source.mModuleTxMethod
<< source.mModuleLBTEnabled
<< source.mModuleWORCycle
<< source.mModuleAmbientRSSI
<< source.mModuleLastRxRSSI
<< source.mIPAddress1
<< source.mIPAddress2
<< source.mIPAddress3
<< source.mIPAddress4;
return out;
}
QDataStream &operator>>(QDataStream &in, CLoraModuleInterfaceStatus &dest)
{
in >> dest.mModuleModel
>> dest.mModuleInternalAddress
>> dest.mModuleUARTParity
>> dest.mModuleUARTRate
>> dest.mModuleAirRate
>> dest.mModuleSubPacket
>> dest.mModuleRSSIEnabled
>> dest.mModuleTxPower
>> dest.mModuleInternalChannel
>> dest.mModuleRSSIByteEnabled
>> dest.mModuleTxMethod
>> dest.mModuleLBTEnabled
>> dest.mModuleWORCycle
>> dest.mModuleAmbientRSSI
>> dest.mModuleLastRxRSSI
>> dest.mIPAddress1
>> dest.mIPAddress2
>> dest.mIPAddress3
>> dest.mIPAddress4;
return in;
}
@@ -0,0 +1,110 @@
#ifndef LORAMODULEINTERFACEDATA_H
#define LORAMODULEINTERFACEDATA_H
#include <QtGlobal>
#include <QDataStream>
class CLoraModuleInterfaceStatus
{
public:
enum eE220UartRates
{
E220_UART_1200 = 0,
E220_UART_2400,
E220_UART_4800,
E220_UART_9600,
E220_UART_19200,
E220_UART_38400,
E220_UART_57600,
E220_UART_115200
};
enum eE220ParityBit
{
E220_UART_8N1=0,
E220_UART_8O1,
E220_UART_8E1,
E220_UART_8N1_bis
};
enum e220AirDataRates
{
E220_AIR_RATE_24K = 0,
E220_AIR_RATE_24K_1,
E220_AIR_RATE_24K_2,
E220_AIR_RATE_48K,
E220_AIR_RATE_96K,
E220_AIR_RATE_192K,
E220_AIR_RATE_384K,
E220_AIR_RATE_625K
};
enum e220PacketSizes
{
E220_PACKET_200,
E220_PACKET_128,
E220_PACKET_64,
E220_PACKET_32
};
enum e220TransmitPower
{
E220_TX_PWR_30,
E220_TX_PWR_27,
E220_TX_PWR_24,
E220_TX_PWR_21
};
enum e220WORCycles
{
E220_WOR_500MS,
E220_WOR_1000MS,
E220_WOR_1500MS,
E220_WOR_2000MS,
E220_WOR_2500MS,
E220_WOR_3000MS,
E220_WOR_3500MS,
E220_WOR_4000MS
};
CLoraModuleInterfaceStatus();
quint8 mModuleModel;
quint16 mModuleInternalAddress;
quint8 mModuleUARTParity;
quint8 mModuleUARTRate;
quint8 mModuleAirRate;
quint8 mModuleSubPacket;
quint8 mModuleRSSIEnabled;
quint8 mModuleTxPower;
quint8 mModuleInternalChannel;
quint8 mModuleRSSIByteEnabled;
quint8 mModuleTxMethod;
quint8 mModuleLBTEnabled;
quint8 mModuleWORCycle;
quint8 mModuleAmbientRSSI;
quint8 mModuleLastRxRSSI;
quint8 mIPAddress1;
quint8 mIPAddress2;
quint8 mIPAddress3;
quint8 mIPAddress4;
CLoraModuleInterfaceStatus& operator=(const CLoraModuleInterfaceStatus &rhs);
};
QDataStream &operator<<(QDataStream &out, const CLoraModuleInterfaceStatus &source);
QDataStream &operator>>(QDataStream &in, CLoraModuleInterfaceStatus &dest);
#endif // LORAMODULEINTERFACEDATA_H
+7 -6
View File
@@ -10,10 +10,10 @@ CMasterCtrlInterface::CMasterCtrlInterface()
connect(mNetworkCommSocket,SIGNAL(disconnected()),this,SLOT(NetworkSocketDisconnected()));
connect(mNetworkCommSocket,SIGNAL(readyRead()),this,SLOT(NetworkSocketDataAvailable()));
// mMasterReconnectTimer.setInterval(500);
// mMasterReconnectTimer.stop();
// mMasterReconnectTimer.setSingleShot(false);
// connect(&mMasterReconnectTimer,SIGNAL(timeout()),this,SLOT(NetworkReconnectTimerExpired()));
mMasterReconnectTimer.setInterval(1000);
mMasterReconnectTimer.stop();
mMasterReconnectTimer.setSingleShot(false);
connect(&mMasterReconnectTimer,SIGNAL(timeout()),this,SLOT(NetworkReconnectTimerExpired()));
}
@@ -27,7 +27,8 @@ int CMasterCtrlInterface::ConnectToMasterCtrl()
connect(mNetworkCommSocket,SIGNAL(disconnected()),this,SLOT(NetworkSocketDisconnected()));
connect(mNetworkCommSocket,SIGNAL(readyRead()),this,SLOT(NetworkSocketDataAvailable()));
}
mNetworkCommSocket->connectToHost(mMasterCtrlIPAddress,mNetworkPort);
if(mNetworkCommSocket->state() == QAbstractSocket::UnconnectedState)
mNetworkCommSocket->connectToHost(mMasterCtrlIPAddress,mNetworkPort);
return RET_OK;
}
@@ -62,7 +63,7 @@ int CMasterCtrlInterface::NewFrameReceived(int TargetDeviceID, int TargetDeviceA
}
case ETH_NETWK_CONNECTION_REFUSED:
{
qDebug("MasterCtrl connection refused");
qDebug("MasterCtrl connection refused for device ID: %d, address: %d",TargetDeviceID,TargetDeviceAddress);
mNetworkCommSocket->close();
delete mNetworkCommSocket;
mNetworkCommSocket = 0;
+292
View File
@@ -0,0 +1,292 @@
#include "BootloaderProtocol.h"
#include "PICUploader.h"
CBootloaderProtocol::CBootloaderProtocol(QObject *parent) : QObject(parent)
{
mCRCEngine.InitTable();
}
CBootloaderProtocol::~CBootloaderProtocol()
{
}
int CBootloaderProtocol::BootloaderProtocolInit()
{
BootloaderProtocolResetStateMachine();
}
int CBootloaderProtocol::BootloaderProtocolResetStateMachine()
{
mBootloaderDataSize = 0;
mBootloaderHeader = 0;
mBootloaderBufPtr = 0;
mBootloaderDataBuffer.clear();
mBootloaderCommand = 0;
mBootloaderCRC = 0;
mBootloaderComputedCRC = CRC_START_32;
mBootloaderState = RxHeader1;
mBootloaderDataCtr = 0;
}
int CBootloaderProtocol::BooloaderProtocolRxFrame(QByteArray Frame)
{
for(int i = 0; i < Frame.size(); i++)
{
BootloaderProtocolStateMachine(Frame.at(i));
}
}
void CBootloaderProtocol::BootloaderProtocolStateMachine(unsigned char Data)
{
switch(mBootloaderState)
{
case Initialization: //Reset all pointers and data...
{
mBootloaderDataSize = 0;
mBootloaderBufPtr = 0;
mBootloaderDataBuffer.clear();
mBootloaderCommand = 0;
mBootloaderCRC = 0;
mBootloaderComputedCRC = CRC_START_32;
mBootloaderState = RxHeader1;
break;
}
case RxHeader1: //Wait for data header...
{
mBootloaderHeader += Data; //0xDE
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
if(Data == BOOTLOADER_FRAME_HEADER_1)
{
mBootloaderState = RxHeader2;
}
else
{
BootloaderProtocolResetStateMachine();
}
break;
}
case RxHeader2: //Wait for data header...
{
mBootloaderHeader <<= 8;
mBootloaderHeader += Data; //0xAD
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
if(Data == BOOTLOADER_FRAME_HEADER_2)
{
mBootloaderState = RxHeader3;
}
else
{
BootloaderProtocolResetStateMachine();
}
break;
}
case RxHeader3: //Wait for data header...
{
mBootloaderHeader <<= 8;
mBootloaderHeader += Data; //0xBE
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
if(Data == BOOTLOADER_FRAME_HEADER_3)
{
mBootloaderState = RxHeader4;
}
else
{
BootloaderProtocolResetStateMachine();
}
break;
}
case RxHeader4: //Wait for data header...
{
mBootloaderHeader <<= 8;
mBootloaderHeader += Data; //0xEF
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
if(mBootloaderHeader != BOOTLOADER_FRAME_HEADER)
{
//TODO, send NACK?
BootloaderProtocolResetStateMachine();
break;
}
else
{
mBootloaderState = RxCmd;
}
break;
}
case RxCmd:
{
mBootloaderCommand = Data;
mBootloaderState = RxPayloadSize1;
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
break;
}
case RxPayloadSize1:
{
mBootloaderDataSize = Data;
mBootloaderState = RxPayloadSize2;
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
break;
}
case RxPayloadSize2:
{
mBootloaderDataSize <<= 8;
mBootloaderDataSize += Data;
mBootloaderState = RxPayloadSize3;
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
break;
}
case RxPayloadSize3:
{
mBootloaderDataSize <<= 8;
mBootloaderDataSize += Data;
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
mBootloaderState = RxPayloadSize4;
break;
}
case RxPayloadSize4:
{
mBootloaderDataSize <<= 8;
mBootloaderDataSize += Data;
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
if(mBootloaderDataSize > MAX_BOOTLOADER_PAYLOAD_SIZE)
{
//TODO, send NACK?
BootloaderProtocolResetStateMachine();
break;
}
mBootloaderState = RxPayload;
break;
}
case RxPayload: //Data size
{
mBootloaderDataBuffer.append(Data);
mBootloaderDataCtr++;
mBootloaderComputedCRC = mCRCEngine.UpdateCRC32(mBootloaderComputedCRC,Data);
if(mBootloaderDataCtr == mBootloaderDataSize)
{
mBootloaderState = RxCRC1;
break;
}
break;
}
case RxCRC1: //Data size
{
mBootloaderCRC = Data;
mBootloaderState = RxCRC2;
break;
}
case RxCRC2: //Data size
{
mBootloaderCRC <<= 8;
mBootloaderCRC += Data;
mBootloaderState = RxCRC3;
break;
}
case RxCRC3: //Data size
{
mBootloaderCRC <<= 8;
mBootloaderCRC += Data;
mBootloaderState = RxCRC4;
break;
}
case RxCRC4: //Data size
{
mBootloaderCRC <<= 8;
mBootloaderCRC += Data;
mBootloaderComputedCRC ^= 0xffffffffL;
//if(mBootloaderCRC == 0xBAADCAFE)
if(mBootloaderCRC == mBootloaderComputedCRC)
{
mProgramHandle->BootloaderRxCmd(mBootloaderCommand,mBootloaderDataBuffer);
}
else
{
qDebug("Bootloader Protocol bad CRC...");
}
BootloaderProtocolResetStateMachine();
break;
}
default:
{
BootloaderProtocolResetStateMachine();
break;
}
}
}
QByteArray CBootloaderProtocol::BootloaderProtocolGetFrame(char Cmd, QByteArray Data)
{
QByteArray Frame;
Frame.clear();
// Header
Frame.append(BOOTLOADER_FRAME_HEADER_1);
Frame.append(BOOTLOADER_FRAME_HEADER_2);
Frame.append(BOOTLOADER_FRAME_HEADER_3);
Frame.append(BOOTLOADER_FRAME_HEADER_4);
//Cmd
Frame.append(Cmd);
//Size
unsigned int Size = Data.size();
char nibble = (char)((Size >> 24) &0x000000FF);
Frame.append(nibble);
nibble = (char)((Size >> 16) &0x000000FF);
Frame.append(nibble);
nibble = (char)((Size >> 8) &0x000000FF);
Frame.append(nibble);
nibble = (char)(Size &0x000000FF);
Frame.append(nibble);
//Payload
Frame.append(Data);
//CRC
unsigned int CRC = mCRCEngine.ComputeCRC32(Frame);
nibble = (char)((CRC >> 24) &0x000000FF);
Frame.append(nibble);
nibble = (char)((CRC >> 16) &0x000000FF);
Frame.append(nibble);
nibble = (char)((CRC >> 8) &0x000000FF);
Frame.append(nibble);
nibble = (char)(CRC &0x000000FF);
Frame.append(nibble);
/* Frame.append(0xBA);
Frame.append(0xAD);
Frame.append(0xCA);
Frame.append(0xFE);*/
//Send
return Frame;
}
+77
View File
@@ -0,0 +1,77 @@
#ifndef BOOTLOADERPROTOCOL_H
#define BOOTLOADERPROTOCOL_H
#include <QObject>
#include "ProtocolDefs.h"
#include "CRC32.h"
class CPICUploader;
#define BOOTLOADER_FRAME_HEADER 0xDEADBEEF
#define BOOTLOADER_FRAME_HEADER_1 0xDE
#define BOOTLOADER_FRAME_HEADER_2 0xAD
#define BOOTLOADER_FRAME_HEADER_3 0xBE
#define BOOTLOADER_FRAME_HEADER_4 0xEF
#define MAX_BOOTLOADER_PAYLOAD_SIZE 200
enum eProtocolBootloaderStates
{
Initialization,
RxHeader1,
RxHeader2,
RxHeader3,
RxHeader4,
RxCmd,
RxPayloadSize1,
RxPayloadSize2,
RxPayloadSize3,
RxPayloadSize4,
RxPayload,
RxCRC1,
RxCRC2,
RxCRC3,
RxCRC4
};
class CBootloaderProtocol : public QObject
{
Q_OBJECT
public:
explicit CBootloaderProtocol(QObject *parent = 0);
~CBootloaderProtocol();
int BootloaderProtocolInit();
int BootloaderProtocolResetStateMachine();
int BooloaderProtocolRxFrame(QByteArray Frame);
void BootloaderProtocolStateMachine(unsigned char data);
QByteArray BootloaderProtocolGetFrame(char Cmd, QByteArray Data);
CPICUploader *mProgramHandle;
private:
unsigned int mBootloaderHeader;
unsigned int mBootloaderDataSize;
unsigned int mBootloaderDataCtr;
unsigned int mBootloaderBufPtr;
unsigned int mBootloaderCRC;
unsigned int mBootloaderComputedCRC;
QByteArray mBootloaderDataBuffer;
unsigned char mBootloaderCommand;
unsigned char mBootloaderState;
CCRC32 mCRCEngine;
signals:
public slots:
};
#endif // BOOTLOADERPROTOCOL_H
+380
View File
@@ -0,0 +1,380 @@
#include "HexFile.h"
#include <QTextStream>
#include <QMessageBox>
#include "CRC32.h"
#define USE_BIG_RECORDS
#define MAX_RECORDS_IN_BIG_RECORDS 512 //16 bytes by record, 512 bytes by row --> 16 rows / big record
CHexFile::CHexFile(void)
{
mFileOpened = false;
mFileParsed = false;
mRecordsListValid = false;
mHighAddress = 0;
mDiscardedRecords = 0;
mTotalParsedRecords = 0;
mFirmwareCRC = 0;
}
CHexFile::~CHexFile(void)
{
for(int i = 0; i < mRecordsList.size(); i++)
delete mRecordsList.at(i);
}
int CHexFile::CloseOpenedHexFile()
{
for(int i = 0; i < mRecordsList.size(); i++)
delete mRecordsList.at(i);
mRecordsList.clear();
mFileOpened = false;
mFileParsed = false;
mHexfileHandle = 0;
mRecordsListValid = false;
mHighAddress = 0;
mDiscardedRecords = 0;
mTotalParsedRecords = 0;
return 1;
}
int CHexFile::OpenDataFile(QString FilePath, bool CloseIfAlreadyParsed)
{
//Check if file exists
if(QFile::exists(FilePath) == false)
return 0;
if(mFileParsed == true)
{
if(CloseIfAlreadyParsed == false)
{
return 0;
}
else
{
CloseOpenedHexFile();
}
}
mHexfileHandle = new QFile(FilePath);
if(mHexfileHandle->open(QIODevice::ReadOnly|QIODevice::Text|QIODevice::Unbuffered) == false)
{
delete mHexfileHandle;
mHexfileHandle = 0;
qDebug("Cannot open specified HEX file...");
return 0;
}
mHexFileSize = mHexfileHandle->size();
mFileOpened = true;
mRecordsTableSize = 0;
mFirmwareDataSize = 0;
return ParseData();
mHexfileHandle->close();
}
int CHexFile::ParseData(void)
{
if(!mFileOpened)
return 0;
int Ret;
bool Finished = false;
unsigned int CurAddress;
// CArray<CHexRecord*,CHexRecord*> TempArray;
QList<CHexRecord*> TempList;
QString RecordString;
QTextStream RecordFileStream(mHexfileHandle);
// CArchive ar(&mHexfileHandle,CArchive::load);
while(!Finished)
{
CHexRecord *NewRecord = new CHexRecord;
RecordString.clear();
// ar.ReadString(mRecordString);
RecordString = RecordFileStream.readLine();
// Ret = NewRecord.DecodeRawRecord(&mRecordString,mHighAddress);
Ret = NewRecord->DecodeRawRecord(&RecordString,mHighAddress);
mTotalParsedRecords++;
switch(Ret)
{
case CHexRecord::RET_DATA_RECORD:
{
#ifdef USE_BIG_RECORDS
TempList.append(NewRecord);
// mRecordsTable[mRecordsTableSize] = NewRecord;
// mRecordsTableSize++;
#else
mRecordsList.append(NewRecord);
mRecordsTable[mRecordsTableSize] = NewRecord;
mRecordsTableSize++;
#endif
break;
}
case CHexRecord::RET_EOF_RECORD:
{
mHexfileHandle->close();
mFileOpened = false;
delete mHexfileHandle;
mRecordsListValid = true;
Finished = true;
delete NewRecord;
break;
}
case CHexRecord::RET_EXTENDED_LINEAR_ADDRESS:
{
// mHighAddress = NewRecord.GetExtenedAddress();
mHighAddress = NewRecord->GetExtenedAddress();
CurAddress = mHighAddress;
delete NewRecord;
break;
}
case CHexRecord::RET_IGNORED_ALL_FF_RECORD:
{
delete NewRecord;
mDiscardedRecords++;
break;
}
case CHexRecord::RET_EXTENDED_ADDRESS:
case CHexRecord::RET_START_SEGMENT_ADDRESS:
case CHexRecord::RET_START_LINEAR_ADDRESS:
case CHexRecord::RET_UNKNOWN_RECORD_TYPE:
case CHexRecord::RET_INVALID_RECORD:
case CHexRecord::RET_BAD_RECORD_CHECKSUM:
case CHexRecord::RET_UNMANAGED_RECORD_TYPE:
{
mHexfileHandle->close();
mFileOpened = false;
delete mHexfileHandle;
Finished = true;
//MessageBox(NULL,"Parsing Error", "Cannot Parse Hex File",MB_OK);
QMessageBox::warning(0,"Parsing Error","Cannot parse HEX file",QMessageBox::Ok);
delete NewRecord;
return 0;
break;
}
}
}
#ifdef USE_BIG_RECORDS
int i;
int RecordCount;
CHexRecord *TempRecordPtr;
CHexRecord *BigRecord = new CHexRecord;
CCRC32 Crc32Engine;
TempRecordPtr = TempList.at(0);
CurAddress = TempRecordPtr->GetStartAddress();
*BigRecord = *TempRecordPtr;
RecordCount = 1;
for(i = 1; i < TempList.size(); i++)
{
// if(CurAddress == 0x1d0097F0)
// {
// CurAddress = CurAddress;
// }
CurAddress += (TempRecordPtr->GetRecordSizeInBytes());
TempRecordPtr = TempList.at(i);
if(CurAddress == TempRecordPtr->GetStartAddress() && RecordCount<MAX_RECORDS_IN_BIG_RECORDS && (i != (TempList.size()-1)))
{
BigRecord->AppendRecord(TempRecordPtr);
RecordCount++;
}
else
{
RecordCount = 1; //Init to 1 because we load the record right below...
mRecordsList.append(BigRecord);
BigRecord = new CHexRecord;
if(i == TempList.size()-1) //Manage the last record.
{
*BigRecord = *TempRecordPtr;
mRecordsList.append(BigRecord);
BigRecord->mRecordSize += TempRecordPtr->mRecordSize;
}
else
{
*BigRecord = *TempRecordPtr;
CurAddress = TempRecordPtr->GetStartAddress();
}
}
}
#endif
for(i = 0; i < TempList.size(); i++)
{
delete TempList[i];
}
// for(i = 0; i < mRecordsList.size(); i++)
// {
// mFirmwareDataSize += mRecordsList.at(i)->GetRecordSizeInBytes();
// }
FilterRecords(0x1D004000,0x1D07FFFF);
QByteArray RawShit = GetRawData(false);
mFirmwareDataSize = RawShit.size();
unsigned int testcrc = CRC_START_32;
for(unsigned int i = 0; i < mFirmwareDataSize; i++)
{
testcrc = Crc32Engine.UpdateCRC32(testcrc,RawShit[i]);
}
testcrc ^= 0xffffffffL;
mFirmwareCRC = Crc32Engine.ComputeCRC32((const unsigned char *)RawShit.data(),RawShit.size());
mFileParsed = true;
return 1;
}
int CHexFile::FilterRecords(unsigned int StartAddress, unsigned int EndAddress)
{
if(mRecordsList.isEmpty() == true)
{
return 0;
}
bool done = false;
int i = 0;
while(done == false)
{
if(mRecordsList.at(i)->GetStartAddress() < StartAddress ||
mRecordsList.at(i)->GetStartAddress() > EndAddress)
{
//Record is outside filter area, delete it...
delete mRecordsList.at(i);
mRecordsList.removeAt(i);
}
else
{
i++;
}
if(i == mRecordsList.size())
{
done = true;
break;
}
}
return 1;
}
unsigned int CHexFile::GetNBRecords(void)
{
// return mRecordsTableSize;
return mRecordsList.size();
}
unsigned long CHexFile::GetFileSize(void)
{
return mHexFileSize;
}
unsigned int CHexFile::GetDataCRC32()
{
return mFirmwareCRC;
}
CHexRecord * CHexFile::GetRecord(int RecordIndex, int &Status)
{
if(RecordIndex > mRecordsList.size())
// if(RecordIndex > mRecordsTableSize)
{
Status = ERR_INDEX_OUT_OF_BOUND;
return 0;
}
//CHexRecord *mRecordPtr = (CHexRecord*)&mRecordsList.GetAt(RecordIndex);
CHexRecord *mRecordPtr = mRecordsList.at(RecordIndex);
// CHexRecord *mRecordPtr = mRecordsTable[RecordIndex];
return mRecordPtr;
}
QByteArray CHexFile::GetRawData(bool IncludeHeader)
{
QByteArray Data;
Data.clear();
if(IncludeHeader)
{
QDataStream Strm(&Data,QIODevice::WriteOnly);
//Header
Strm << HEX_FILE_HEADER_CODE;
//Flags
Strm << (int)0x0000; //TODO: Manage that
//Nb Records
Strm << GetNBRecords();
//Firmware size
Strm << GetFirmwareSize();
//Version
Strm << (int)0x00; //TODO: Manage that
//CRC32
Strm << GetDataCRC32();
}
for(int i = 0; i < mRecordsList.size(); i++)
{
Data.append(mRecordsList.at(i)->GetRecord());
}
return Data;
}
QString CHexFile::GetHexFileInfoString()
{
QString string;
string.clear();
if(HexDataValid() == false)
return QString("No file loaded\n");
for(int i = 0; i < mRecordsList.size(); i++)
{
CHexRecord *rec = mRecordsList.at(i);
unsigned int StartAddress = rec->GetStartAddress();
unsigned int Size = rec->GetRecordSizeInBytes();
unsigned int EndAddress = StartAddress + Size;
string.append(QString("Record %1: Start = [0x%2], Length = [%3], End = 0x%4\n").arg(i).arg(StartAddress,0,16).arg(Size).arg(EndAddress,0,16));
}
string.prepend("-------------------------------------------------------------\n");
string.append("-------------------------------------------------------------\n");
return string;
}
+63
View File
@@ -0,0 +1,63 @@
#pragma once
#include "HexRecord.h"
#include <QString>
#include <QList>
#include <QFile>
#define HEX_FILE_HEADER_CODE (int)0xBAADBEEF
class CHexFile
{
enum eHexFileStatus
{
STATUS_OK,
STATUS_OK_LAST_INDEX,
ERR_INDEX_OUT_OF_BOUND
};
public:
CHexFile(void);
~CHexFile(void);
int OpenDataFile(QString FilePath, bool CloseIfAlreadyParsed = true);
int CloseDataFile();
int CloseOpenedHexFile();
int ParseData(void);
unsigned int GetNBRecords(void);
unsigned long GetFileSize(void);
unsigned int GetFirmwareSize(void){return mFirmwareDataSize;}
unsigned int GetDataCRC32(void);
bool HexFileLoaded(void){return mFileOpened;}
bool HexDataValid(void){return mFileParsed;}
unsigned long GetTotalParsedRecords(void){return mTotalParsedRecords;}
QByteArray GetRawData(bool IncludeHeader = true);
int FilterRecords(unsigned int StartAddress, unsigned int EndAddress);
CHexRecord * GetRecord(int RecordIndex, int &Status);
unsigned long mDiscardedRecords;
unsigned long mTotalParsedRecords;
QString GetHexFileInfoString();
private:
QFile *mHexfileHandle;
bool mFileOpened;
bool mFileParsed;
bool mRecordsListValid;
//CArray<CHexRecord*,CHexRecord*> mRecordsList;
QList<CHexRecord*> mRecordsList;
// CHexRecord* mRecordsTable[0x3000];
unsigned int mRecordsTableSize;
unsigned int mHighAddress;
unsigned long mHexFileSize;
unsigned int mFirmwareDataSize;
unsigned int mFirmwareCRC;
};
+198
View File
@@ -0,0 +1,198 @@
#include "HexRecord.h"
#include <QByteArray>
#include <QDataStream>
CHexRecord::CHexRecord(void)
{
mRecordData = NULL;
}
CHexRecord::~CHexRecord(void)
{
mStartAddress = 0;
mRecordSize = 0;
mRecordType = 0;
mExtendedAddress = 0;
// delete[] mRecordData;
}
int CHexRecord::DecodeRawRecord(QString *RawRecordData, unsigned int HighAddress)
{
bool OK;
// CString RecordString;
QString RecordString;
bool IsAllFF = true;
int StartIndex = RawRecordData->indexOf(QChar(':'));
if(StartIndex == -1)
return -1;
RecordString = RawRecordData->right(RawRecordData->length()-1); //Remove all that is left of ':'
QString RecordSizeString;
RecordSizeString = RecordString.mid(0,2);
//sscanf_s(RecordSizeString.GetBuffer(),"%x",&mRecordSize);
mRecordSize = RecordSizeString.toUInt(&OK,16);
QString RecordAddress;
RecordAddress = RecordString.mid(2,4);
//sscanf_s(RecordAddress.GetBuffer(),"%x",&mStartAddress);
mStartAddress = RecordAddress.toUInt(&OK,16);
mStartAddress |= (HighAddress & 0xFFFF0000);
if(mStartAddress == 0x1d0097F0)
{
mStartAddress = mStartAddress;
}
QString RecordTypeString;
RecordTypeString = RecordString.mid(6,2);
//sscanf_s(RecordTypeString.GetBuffer(),"%x",&mRecordType);
mRecordType = RecordTypeString.toUInt(&OK,16);
RecordString = RecordString.right(RecordString.length()- 8);
if(mRecordType >= MAX_RECORD_TYPE)
return RET_UNKNOWN_RECORD_TYPE;
if(mRecordSize %2 != 0)
{
mRecordSize++;//Pad the last word if we do not have an even number of bytes in the record.
}
switch(mRecordType)
{
case DATA_RECORD_TYPE: //0x00
{
char *DataPtr;
QString DataString;
// mRecordData = new char[mRecordSize/*+10*/]; //I have no clue why I have to allocate more space but if I don't delete[] crashes. I think it's a scanf bug...
// DataPtr = mRecordData.data();
for(unsigned int i = 0; i < mRecordSize; i++)
{
DataString = RecordString.mid(2*i,2);
char DataByte = (char)DataString.toUShort(&OK,16);
//sscanf_s(DataString.GetBuffer(),"%x",&mRecordData[i],sizeof(char)/*DataPtr*/);
//mRecordData[i] = (char)DataString.toUShort(&OK,16);
mRecordData.append(DataByte);
if((unsigned char)DataByte != 0xFF)
IsAllFF = false;
//DataPtr++;
}
if(mRecordSize %2 != 0) //Is this really needed?
{
//*DataPtr++ = 0xFF; //Pad the last word if we do not have an even number of bytes in the record.
mRecordData.append(0xFF);
}
mRecordSize /= 4; //Transfom the size in WORD size...
//#ifdef IGNORE_ALL_FF_RECORDS
if(IsAllFF)
{
return RET_IGNORED_ALL_FF_RECORD;
}
else
return RET_DATA_RECORD;
//#else
// return RET_DATA_RECORD;
//#endif
break;
}
case EOF_RECORD_TYPE: //0x01
{
return RET_EOF_RECORD;
break;
}
case EXTENDED_ADDRESS_TYPE: //0x02
{
return RET_UNMANAGED_RECORD_TYPE;
break;
}
case START_SEGMENT_ADDRESS_TYPE: //0x03
{
return RET_UNMANAGED_RECORD_TYPE;
break;
}
case EXTENDED_LINEAR_ADDRESS_TYPE: //0x04
{
QString ExtendedAddressString;
ExtendedAddressString = RecordString.mid(0,4);
//sscanf_s(ExtendedAddressString.GetBuffer(),"%x",&mExtendedAddress);
mExtendedAddress = ExtendedAddressString.toUInt(&OK,16);
mExtendedAddress <<= 16;
return RET_EXTENDED_LINEAR_ADDRESS;
break;
}
case START_LINEAR_ADDRESS_TYPE: //0x05
{
return RET_UNMANAGED_RECORD_TYPE;
break;
}
default:
{
return RET_UNKNOWN_RECORD_TYPE;
}
}
}
unsigned int CHexRecord::AppendRecord(CHexRecord *NewRecord)
{
unsigned int NewSize;
NewSize = GetRecordSizeInBytes() + NewRecord->GetRecordSizeInBytes();
// char *NewBuff = new char[NewSize];
// memcpy(NewBuff,mRecordData,GetRecordSizeInBytes());
// memcpy(&NewBuff[GetRecordSizeInBytes()],NewRecord->GetDataBuffer(),NewRecord->GetRecordSizeInBytes());
//delete[] mRecordData;
//mRecordData = NewBuff;
mRecordData.append(NewRecord->GetData());
mRecordSize = NewSize/4;
return 1;
}
CHexRecord& CHexRecord::operator = (const CHexRecord &rhs)
{
if(this == &rhs)
return *this;
mExtendedAddress = rhs.mExtendedAddress;
mRecordSize = rhs.mRecordSize;
mStartAddress = rhs.mStartAddress;
mRecordType = rhs.mRecordType;
mRecordData = rhs.mRecordData;
// mRecordData = new char[mRecordSize*4];
// memcpy(mRecordData,rhs.mRecordData,mRecordSize*4);
return *this;
}
QByteArray CHexRecord::GetRecord()
{
QByteArray Record;
Record.clear();
QDataStream Strm(&Record,QIODevice::WriteOnly);
//Header
Strm << HEX_RECORD_HEADER;
//Size
Strm << GetRecordSizeInBytes();
//Address
Strm << GetStartAddress();
//Data
Record.append(mRecordData);
return Record;
}
+65
View File
@@ -0,0 +1,65 @@
#pragma once
#include <QString>
#include <QByteArray>
#define IGNORE_ALL_FF_RECORDS
#define HEX_RECORD_HEADER (int)0xDEADBEEF
class CHexRecord
{
public:
enum eRecordTypes
{
DATA_RECORD_TYPE, //0x00
EOF_RECORD_TYPE, //0x01
EXTENDED_ADDRESS_TYPE, //0x02
START_SEGMENT_ADDRESS_TYPE, //0x03
EXTENDED_LINEAR_ADDRESS_TYPE, //0x04
START_LINEAR_ADDRESS_TYPE, //0x05
MAX_RECORD_TYPE
};
enum eRetValues
{
RET_DATA_RECORD,
RET_EOF_RECORD,
RET_EXTENDED_ADDRESS,
RET_START_SEGMENT_ADDRESS,
RET_EXTENDED_LINEAR_ADDRESS,
RET_IGNORED_ALL_FF_RECORD,
RET_START_LINEAR_ADDRESS,
RET_UNKNOWN_RECORD_TYPE,
RET_INVALID_RECORD,
RET_BAD_RECORD_CHECKSUM,
RET_UNMANAGED_RECORD_TYPE
};
//char *mRecordData;
QByteArray mRecordData;
unsigned int mStartAddress;
unsigned int mRecordSize;
unsigned int mRecordType;
unsigned int mExtendedAddress;
CHexRecord(void);
~CHexRecord(void);
int SetRecordStartAddress(unsigned int Address);
int SetRecordSize(unsigned int size);
int DecodeRawRecord(QString *RawRecordData, unsigned int HighAddress);
unsigned int GetExtenedAddress(void){return mExtendedAddress;}
unsigned int GetStartAddress(void){return mStartAddress;}
char *GetDataBuffer(void){return mRecordData.data();}
QByteArray GetData(void){return mRecordData;}
unsigned int GetRecordSize(void){return mRecordData.size()/4;}
unsigned int GetRecordSizeInBytes(void){return mRecordData.size();}
unsigned int GetRecordType(void){return mRecordType;}
unsigned int AppendRecord(CHexRecord *RecordToAppend);
QByteArray GetRecord();
CHexRecord& operator=(const CHexRecord &rhs);
};
+916
View File
@@ -0,0 +1,916 @@
#include "PICUploader.h"
#include "GlobalDefine.h"
#include <QHostAddress>
#include <QtEndian>
CPICUploader::CPICUploader(CPICUploaderGui *Gui)
{
mPICUploaderGui = Gui;
mPICUploaderGui->mProgramHandle = this;
connect(&mBootloaderSocket,SIGNAL(connected()),this,SLOT(BootloaderSocketConnected()));
connect(&mBootloaderSocket,SIGNAL(disconnected()),this,SLOT(BootloaderSocketDisconnected()));
connect(&mBootloaderSocket,SIGNAL(readyRead()),this,SLOT(BootloaderDataAvailable()));
connect(&mBootloaderSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(BootloaderSocketError(QAbstractSocket::SocketError)));
mBootloaderProtocol.mProgramHandle = this;
}
int CPICUploader::Start()
{
mBootloaderProtocol.BootloaderProtocolInit();
ResetBooloaderInterfaceStateMachine();
return RET_OK;
}
int CPICUploader::OpenHexFileRequest(QString FilePath)
{
if(mHexFile.HexFileLoaded() == true)
{
mHexFile.CloseOpenedHexFile();
}
int ret = mHexFile.OpenDataFile(FilePath);
if(ret == 0)
return 0;
QString HexFileStats = QString("HexFileSize: %1\nFirmware Size: %4\nNb analyzed Records: %2\nNb Big Records: %3\nData CRC32: 0x%5").arg(mHexFile.GetFileSize()).arg(mHexFile.GetTotalParsedRecords()).arg(mHexFile.GetNBRecords()).arg(mHexFile.GetFirmwareSize()).arg(mHexFile.GetDataCRC32(),0,16);
mPICUploaderGui->SetHexFileStats(HexFileStats);
//HexFileStats << "HexFileSize: " << mHexFile.GetFileSize() << "\n";
// HexFileStats <<
}
int CPICUploader::ShowHexFileInfoRequest()
{
mPICUploaderGui->AddTextToLogScreen(mHexFile.GetHexFileInfoString());
}
int CPICUploader::ConnectToBootloader(QString IP)
{
mBootloaderSocket.connectToHost(IP,99);
return RET_OK;
}
int CPICUploader::DisconnectFromBootloader()
{
mBootloaderSocket.disconnectFromHost();
return true;
}
void CPICUploader::BootloaderSocketConnected()
{
mPICUploaderGui->UploaderSocketConnected();
mPICUploaderGui->AddTextToLogScreen("Socket Connected");
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_BOOTLOADER_CONNECTED_CMD);
}
void CPICUploader::BootloaderSocketDisconnected()
{
mPICUploaderGui->UploaderSocketDisconnected();
mPICUploaderGui->AddTextToLogScreen("Socket Disconnected");
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_BOOTLOADER_DISCONNECTED_CMD);
}
void CPICUploader::BootloaderDataAvailable()
{
QByteArray Data = mBootloaderSocket.readAll();
mPICUploaderGui->AddTextToLogScreen(QString("Recevied %1 bytes from bootloader").arg(Data.size()));
mBootloaderProtocol.BooloaderProtocolRxFrame(Data);
}
void CPICUploader::BootloaderSocketError(QAbstractSocket::SocketError Error)
{
mPICUploaderGui->AddTextToLogScreen(QString("Socket error %1 in PICUploader").arg(Error));
}
int CPICUploader::SendSingleCmdRequest(int CmdID)
{
QByteArray Frame = mBootloaderProtocol.BootloaderProtocolGetFrame(CmdID,QByteArray());
mBootloaderSocket.write(Frame);
return RET_OK;
}
int CPICUploader::SendCmdRequest(int CmdID, QByteArray Data)
{
QByteArray Frame = mBootloaderProtocol.BootloaderProtocolGetFrame(CmdID,Data);
mBootloaderSocket.write(Frame);
return RET_OK;
}
int CPICUploader::GuiEvent(int EventID, void *Data)
{
switch(EventID)
{
case CPICUploaderGui::UPLOADER_GUI_HEARTBEAT_BTN_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_HEARTBEAT_REQUEST);
break;
}
case CPICUploaderGui::UPLOADER_GUI_FLASH_ERASE_BTN_CLICK_EVENT:
{
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_ERASE_FLASH_GUI_CMD);
break;
}
case CPICUploaderGui::UPLOADER_GUI_INIT_UPLOAD_BTN_CLICK_EVENT:
{
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_START_UPLOAD_GUI_CMD);
break;
}
case CPICUploaderGui::UPLOADER_GUI_SEND_DATA_CHUNK_BTN_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_SEND_DATA_CHUNK_REQUEST);
break;
}
case CPICUploaderGui::UPLOADER_GUI_UPLOAD_FINISHED_BTN_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_UPLOAD_FINISHED_REQUEST);
break;
}
case CPICUploaderGui::UPLOADER_GUI_EXECUTE_UPGRADE_BTN_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_EXECUTE_UPGRAGE_REQUEST);
break;
}
case CPICUploaderGui::UPLOADER_GUI_ABORT_BTN_CLICK_EVENT:
{
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_ABORT_GUI_CMD);
break;
}
case CPICUploaderGui::UPLOADER_GUI_AUTOMATIC_UPDATE_START_BTN_CLICK_EVENT:
{
break;
}
case CPICUploaderGui::UPLOADER_GUI_GET_STATE_BTN_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_GET_STATE_REQUEST);
break;
}
case CPICUploaderGui::UPLOADER_GUI_CHECK_FLASH_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_REQUEST);
break;
}
case CPICUploaderGui::UPLOADER_GUI_GET_STORED_FIRMWARE_INFO_CLICK_EVENT:
{
SendSingleCmdRequest(BOOTLOADER_GET_STORED_FIRMWARE_INFO_REQUEST);
break;
}
}
return RET_OK;
}
int CPICUploader::BootloaderRxCmd(int CmdID, QByteArray Data)
{
switch(CmdID)
{
case BOOTLOADER_HEARTBEAT_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Heartbeat device response: %1").arg((int)Data.at(0)));
break;
}
case BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Erase flash device response: %1").arg((int)Data.at(0)));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_ERASE_BOOTLOADER_FLASH_ACK_HOST_CMD,Data.at(0));
break;
}
case BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESULT_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Erase flash result device response: %1").arg((int)Data.at(0)));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_ERASE_BOOTLOADER_FLASH_RESULT_HOST_CMD,Data.at(0));
break;
}
case BOOTLOADER_INIT_UPLOAD_RESPONSE:
{
int ChunkSize;
quint32 temp = *(int*)Data.mid(1,4).data();
qToBigEndian(temp,&ChunkSize);
mPICUploaderGui->AddTextToLogScreen(QString("Init Upload device response: %1, Chunk Size: %2").arg((int)Data.at(0)).arg(ChunkSize));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_INIT_UPLOAD_HOST_CMD,(int)Data.at(0),(void*)&ChunkSize);
break;
}
case BOOTLOADER_GET_STATE_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Get State device Response: %1").arg((int)Data.at(0)));
break;
}
case BOOTLOADER_READY_FOR_DATA_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Ready for data device response: %1").arg((int)Data.at(0)));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_READY_FOR_DATA_HOST_CMD,(int)Data.at(0));
break;
}
case BOOTLOADER_SEND_DATA_CHUNK_RESPONSE:
{
quint32 temp = *(int*)Data.mid(1,4).data();
int Index;
qToBigEndian(temp,&Index);
mPICUploaderGui->AddTextToLogScreen(QString("Send Chunk device response: %1, Index: %2").arg((int)Data.at(0)).arg(Index));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_SEND_DATA_CHUNK_HOST_CMD,(int)Data.at(0),(void*)&Index);
break;
}
case BOOTLOADER_UPLOAD_FINISHED_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Upload finished device response: %1").arg((int)Data.at(0)));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_UPLOAD_FINISHED_HOST_CMD,(int)Data.at(0));
break;
}
case BOOTLOADER_EXECUTE_UPGRADE_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Execute upgrade device response: %1").arg((int)Data.at(0)));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_EXECUTE_UPGRADE_HOST_CMD,(int)Data.at(0));
break;
}
case BOOTLOADER_ABORT_OPERATION_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Abort Operation device response: %1").arg((int)Data.at(0)));
BootloaderInterfaceStateMachine(BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,BOOTLOADER_UPLOAD_ABORT_OPERATION_HOST_CMD,(int)Data.at(0));
break;
}
case BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_RESPONSE:
{
mPICUploaderGui->AddTextToLogScreen(QString("Flash integrity check response: %1").arg((int)Data.at(0)));
break;
}
case BOOTLOADER_GET_STORED_FIRMWARE_INFO_RESPONSE:
{
QString FirmwareInfo;
FirmwareInfo.clear();
if(Data.at(0) == 0)
{
FirmwareInfo = "--------------------------------\nNo firmware stored in SPI flash\n--------------------------------";
}
else
{
quint32 FirmwareFlags, NbRecords, FirmwareSize, VersionCode, DataCRC32;
quint32 temp = *(int*)Data.mid(1,4).data();
qToBigEndian(temp,&FirmwareFlags);
temp = *(int*)Data.mid(5,4).data();
qToBigEndian(temp,&NbRecords);
temp = *(int*)Data.mid(9,4).data();
qToBigEndian(temp,&FirmwareSize);
temp = *(int*)Data.mid(13,4).data();
qToBigEndian(temp,&VersionCode);
temp = *(int*)Data.mid(17,4).data();
qToBigEndian(temp,&DataCRC32);
FirmwareInfo = QString("\n----------------------------------\nStored firmware info:\nFirmware flags: 0x%1\nNb Records: %2\nFirmware Size: %3\nVersion: %4\nData CRC32: 0x%5\n----------------------------------\n")\
.arg(FirmwareFlags,0,16).arg(NbRecords).arg(FirmwareSize).arg(VersionCode).arg(DataCRC32,0,16);
}
mPICUploaderGui->AddTextToLogScreen(FirmwareInfo);
break;
}
}
}
int CPICUploader::BootloaderInterfaceStateMachine(int Event, int Cmd, int CmdParam, void* Data)
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_BOOTLOADER_DISCONNECTED_CMD:
{
ResetBooloaderInterfaceStateMachine();
return RET_OK;
break;
}
}
break;
}
}
// State machine implementation starts here...
switch (mBootloaderInterfaceSMState)
{
case BOOTLOADER_INTERFACE_SM_STANDBY_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_BOOTLOADER_CONNECTED_CMD:
{
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_BOOTLDR_CONNECTED_STATE;
mPICUploaderGui->AddTextToLogScreen("[BootloaderSM] Going into CONNECTED state\n");
break;
}
}
break;
}
}
break;
}
case BOOTLOADER_INTERFACE_SM_BOOTLDR_CONNECTED_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_ERASE_FLASH_GUI_CMD:
{
SendSingleCmdRequest(BOOTLOADER_ERASE_BOOTLOADER_FLASH_REQUEST);
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_ERASE_FLASH_STATE;
mPICUploaderGui->AddTextToLogScreen("[BootloaderSM] Going into ERASE_FLASH state\n");
break;
}
case BOOTLOADER_UPLOAD_START_FULL_UPDATE_GUI_CMD:
{
break;
}
case BOOTLOADER_UPLOAD_START_UPLOAD_GUI_CMD:
{
SendSingleCmdRequest(BOOTLOADER_INIT_UPLOAD_REQUEST);
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_INIT_UPLOAD_STATE;
mPICUploaderGui->AddTextToLogScreen("[BootloaderSM] Going into INIT_UPLOAD state\n");
break;
}
}
break;
}
}
break;
}
case BOOTLOADER_INTERFACE_SM_ERASE_FLASH_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_ERASE_BOOTLOADER_FLASH_ACK_HOST_CMD:
{
if(CmdParam != BOOTLOADER_FLASH_ERASE_OK)
{
mPICUploaderGui->AddTextToLogScreen("Flash erase refused from host. Going back to CONNECTED state\n");
}
else
{
mPICUploaderGui->AddTextToLogScreen("Device confirmed erasing flash in progress... \n");
}
break;
}
case BOOTLOADER_UPLOAD_ERASE_BOOTLOADER_FLASH_RESULT_HOST_CMD:
{
if(CmdParam != BOOTLOADER_FLASH_ERASE_OK)
{
mPICUploaderGui->AddTextToLogScreen("Flash erase failed. Going back to CONNECTED state\n");
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_BOOTLDR_CONNECTED_STATE;
}
else
{
mPICUploaderGui->AddTextToLogScreen("Flash erase success. \n");
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_BOOTLDR_CONNECTED_STATE;
mPICUploaderGui->AddTextToLogScreen("[BootloaderSM] Going into CONNECTED state\n");
}
break;
}
default:
{
}
}
break;
}
}
break;
}
case BOOTLOADER_INTERFACE_SM_INIT_UPLOAD_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_INIT_UPLOAD_HOST_CMD:
{
if(CmdParam == BOOTLOADER_INIT_UPLOAD_SUCCESS)
{
//Host is in update mode. Load the buffer size and wait for "Ready for data" CMD (stay in the same state)
mFirmwareUploadBufferSize = *(int*)Data;
mPICUploaderGui->AddTextToLogScreen(QString("Init upload accepted by host. Frame size: %1\n").arg(mFirmwareUploadBufferSize));
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_WAIT_READY_FOR_DATA_FROM_HOST_STATE;
mPICUploaderGui->AddTextToLogScreen("[BootloaderSM] Going into READY_FOR_DATA state\n");
}
else
{
//Something's wrong with the host. Abort upload...
//TODO: Make the GUI aware of this.
mPICUploaderGui->AddTextToLogScreen(QString("Init upload refused. Error code: %1. Going back to STANDBY state\n").arg(CmdParam));
ResetBooloaderInterfaceStateMachine();
}
break;
}
}
break;
}
}
break;
}
case BOOTLOADER_INTERFACE_SM_WAIT_READY_FOR_DATA_FROM_HOST_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_READY_FOR_DATA_HOST_CMD:
{
//Host is ready for data. Start the upload state machine
mPICUploaderGui->AddTextToLogScreen("Host ready for data. Starting upload\n");
BootloaderFirmwareUploadStateMachine(BOOTLOADER_FIRM_UPLD_CMD_EVENT,BOOTLOADER_FIRM_UPLD_INIT_UPLOAD_CMD);
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_SEND_DATA_STATE;
break;
}
default:
{
mPICUploaderGui->AddTextToLogScreen(QString("Invalid response from host received int <WAIT READY FOR DATA> state. Response Cmd received: %1. Going back to STANDBY state\n").arg(Cmd));
ResetBooloaderInterfaceStateMachine();
break;
}
}
break;
}
}
break;
}
case BOOTLOADER_INTERFACE_SM_SEND_DATA_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_SEND_DATA_CHUNK_HOST_CMD:
{
int Res = BootloaderFirmwareUploadStateMachine(BOOTLOADER_FIRM_UPLD_CMD_EVENT,BOOTLOADER_FIRM_UPLD_CHUNK_RX_RESPONSE_CMD,CmdParam,*(int*)Data);
switch(Res)
{
case BOOTLOADER_FIRM_UPLD_SENDING_RES:
{
//All is going well.
break;
}
case BOOTLOADER_FIRM_UPLD_FINISHED_RES:
{
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_DATA_FINISHED_STATE;
mPICUploaderGui->AddTextToLogScreen("Bootloader upload state machine uploaded all firmware\n");
break;
}
case BOOTLOADER_FIRM_UPLD_ERROR_RES:
{
break;
}
case BOOTLOADER_FIRM_UPLD_TIMEOUT_RES:
{
break;
}
case BOOTLOADER_FIRM_UPLD_ABORT_RES:
{
break;
}
case BOOTLOADER_FIRM_UPLD_OK_RES:
{
break;
}
}
break;
}
}
break;
}
}
break;
}
case BOOTLOADER_INTERFACE_SM_DATA_FINISHED_STATE:
{
switch(Event)
{
case BOOTLOADER_UPLOAD_SM_TICK_EVENT:
{
break;
}
case BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_UPLOAD_BOOTLOADER_CONNECTED_CMD:
{
break;
}
case BOOTLOADER_UPLOAD_UPLOAD_FINISHED_HOST_CMD:
{
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_BOOTLDR_CONNECTED_STATE;
break;
}
}
break;
}
}
break;
}
}
return RET_OK;
}
//State machine managing firmware packets upload and errors
int CPICUploader::BootloaderFirmwareUploadStateMachine(int Event, int Cmd, int CmdResult, int CmdParam)
{
switch(mBootloaderFirmwareUpldState)
{
case BOOTLOADER_FIRM_UPLD_STANDBY_STATE:
{
switch(Event)
{
case BOOTLOADER_FIRM_UPLD_TICK_EVENT:
{
break;
}
case BOOTLOADER_FIRM_UPLD_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_FIRM_UPLD_INIT_UPLOAD_CMD:
{
//TODO: Send First chunk
bool Finished;
mFirmwareData = mHexFile.GetRawData();
SendCmdRequest(BOOTLOADER_SEND_DATA_CHUNK_REQUEST, GetCurDataChunk(Finished));
mPICUploaderGui->AddTextToLogScreen(QString("Upload SM: Sending first frame (%1)\n").arg(mFirmwareUploadCurFrame));
int NbChunks = mFirmwareData.size() / mFirmwareUploadBufferSize;
mPICUploaderGui->SetUploadProgressSettings(NbChunks);
mPICUploaderGui->ResetProgressBar();
if(Finished)
{
mPICUploaderGui->AddTextToLogScreen(QString("That was the last chunk. Going into UPLOAD_FINISHED state\n"));
mBootloaderFirmwareUpldState = BOOTLOADER_FIRM_UPLD_FINISHED_STATE;
}
else
{
mBootloaderFirmwareUpldState = BOOTLOADER_FIRM_UPLD_SEND_CHUNK_STATE;
}
return BOOTLOADER_FIRM_UPLD_SENDING_RES;
break;
}
case BOOTLOADER_FIRM_UPLD_ABORT_UPLOAD_CMD:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ABORT_RES;
break;
}
default:
{
//TODO: Find out what to do with that...
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
}
break;
}
}
break;
}
// case BOOTLOADER_FIRM_UPLD_WAIT_FOR_HOST_READY_STATE:
// {
// switch(Event)
// {
// case BOOTLOADER_FIRM_UPLD_TICK_EVENT:
// {
// return BOOTLOADER_FIRM_UPLD_WAITING_FOR_HOST_RES;
// break;
// }
// case BOOTLOADER_FIRM_UPLD_CMD_EVENT:
// {
// switch(Cmd)
// {
// case BOOTLOADER_FIRM_UPLD_INIT_UPLOAD_ACK_CMD:
// {
// if(CmdResult == BOOTLOADER_INIT_UPLOAD_SUCCESS)
// {
// //Host is in update mode. Load the buffer size and wait for "Ready for data" CMD (stay in the same state)
// mFirmwareUploadBufferSize = CmdParam;
// return BOOTLOADER_FIRM_UPLD_WAITING_FOR_HOST_RES;
// }
// else
// {
// ResetFirmwareUploadStateMachine();
// return BOOTLOADER_FIRM_UPLD_ERROR_RES;
// }
// break;
// }
// case BOOTLOADER_FIRM_UPLD_HOST_READY_FOR_DATA_CMD:
// {
// //Host is ready for data. Send the first chunk and go into next state (send chunk)
// //TODO: Send first data chunk
// mBootloaderFirmwareUpldState = BOOTLOADER_FIRM_UPLD_SEND_CHUNK_STATE;
// return BOOTLOADER_FIRM_UPLD_SENDING_RES;
// break;
// }
// default:
// {
// return BOOTLOADER_FIRM_UPLD_ERROR_RES;
// break;
// }
// }
// break;
// }
// }
// break;
// }
case BOOTLOADER_FIRM_UPLD_SEND_CHUNK_STATE:
{
switch(Event)
{
case BOOTLOADER_FIRM_UPLD_TICK_EVENT:
{
break;
}
case BOOTLOADER_FIRM_UPLD_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_FIRM_UPLD_CHUNK_RX_RESPONSE_CMD:
{
switch(CmdResult)
{
case BOOTLOADER_CHUNK_TRANSFER_SUCCESS:
{
if(mFirmwareUploadCurFrame == 700 || mFirmwareUploadCurFrame == 800 || mFirmwareUploadCurFrame == 900)
{
int toto = 5;
}
bool Finished = false;
mPICUploaderGui->AddTextToLogScreen(QString("Upload SM: Sending frame Nb: %1\n").arg(mFirmwareUploadCurFrame));
mFirmwareUploadCurFrame++;
SendCmdRequest(BOOTLOADER_SEND_DATA_CHUNK_REQUEST, GetCurDataChunk(Finished));
mPICUploaderGui->TickProgressBar();
if(Finished)
{
mPICUploaderGui->AddTextToLogScreen(QString("That was the last chunk. Going into UPLOAD_FINISHED state\n"));
mBootloaderFirmwareUpldState = BOOTLOADER_FIRM_UPLD_FINISHED_STATE;
}
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_RESEND:
{
//TODO: Resend current frame
if(mFirmwareUploadCurFrame != CmdParam)
{
mPICUploaderGui->AddTextToLogScreen(QString("Upload of frame %1 failed. and frame index desynchronized (Curframe = %2). Aborting and going to STANDBY mode\n").arg(CmdParam).arg(mFirmwareUploadCurFrame));
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
}
bool Finished;
mPICUploaderGui->AddTextToLogScreen(QString("Upload of frame %1 failed. Trying to resend\n").arg(CmdParam));
SendCmdRequest(BOOTLOADER_SEND_DATA_CHUNK_REQUEST, GetCurDataChunk(Finished));
//TODO: Manage the number of failed attempts.
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_FAILURE:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_INVALID_CHUNK_INDEX:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_ERROR:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
}
return BOOTLOADER_FIRM_UPLD_SENDING_RES;
break;
}
case BOOTLOADER_FIRM_UPLD_ABORT_UPLOAD_CMD:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ABORT_RES;
break;
}
default:
{
ResetFirmwareUploadStateMachine();
break;
}
}
break;
}
}
break;
}
case BOOTLOADER_FIRM_UPLD_FINISHED_STATE:
{
switch(Event)
{
case BOOTLOADER_FIRM_UPLD_TICK_EVENT:
{
break;
}
case BOOTLOADER_FIRM_UPLD_CMD_EVENT:
{
switch(Cmd)
{
case BOOTLOADER_FIRM_UPLD_CHUNK_RX_RESPONSE_CMD:
{switch(CmdResult)
{
case BOOTLOADER_CHUNK_TRANSFER_SUCCESS:
{
//TODO: Send upload finished CMD to host
mPICUploaderGui->AddTextToLogScreen(QString("Upload of last frame success. Frame Nb %1\n").arg(CmdParam));
mPICUploaderGui->TickProgressBar();
return BOOTLOADER_FIRM_UPLD_FINISHED_RES;
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_RESEND:
{
//TODO: Resend current frame
if(mFirmwareUploadCurFrame != CmdParam)
{
//TODO: Manage this error... (Abort)
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
}
bool Finished;
mPICUploaderGui->AddTextToLogScreen(QString("Upload of frame %1 failed. Trying to resend\n").arg(CmdParam));
SendCmdRequest(BOOTLOADER_SEND_DATA_CHUNK_REQUEST, GetCurDataChunk(Finished));
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_FAILURE:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_INVALID_CHUNK_INDEX:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
case BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_ERROR:
{
ResetFirmwareUploadStateMachine();
return BOOTLOADER_FIRM_UPLD_ERROR_RES;
break;
}
}
ResetFirmwareUploadStateMachine();
break;
}
default:
{
ResetFirmwareUploadStateMachine();
break;
}
}
break;
}
}
break;
}
}
return BOOTLOADER_FIRM_UPLD_OK_RES;
}
int CPICUploader::ResetBooloaderInterfaceStateMachine()
{
mBootloaderInterfaceSMState = BOOTLOADER_INTERFACE_SM_STANDBY_STATE;
mFirmwareUploadBufferSize = 0;
mFirmwareUploadCurFrame = 0;
ResetFirmwareUploadStateMachine();
return RET_OK;
}
int CPICUploader::ResetFirmwareUploadStateMachine()
{
mBootloaderFirmwareUpldState = BOOTLOADER_FIRM_UPLD_STANDBY_STATE;
mFirmwareData.clear();
return RET_OK;
}
//Sends current data chunk based on mFirmwareUploadCurFrame and mFirmwareUploadBufferSize.
QByteArray CPICUploader::GetCurDataChunk(bool &IsLastChunk)
{
QByteArray Chunk;
QByteArray Payload;
Chunk.clear();
unsigned int index = mFirmwareUploadCurFrame * mFirmwareUploadBufferSize;
if((index + mFirmwareUploadBufferSize) >= mFirmwareData.size())
{
IsLastChunk = true;
}
Payload = mFirmwareData.mid(index,mFirmwareUploadBufferSize);
Chunk.append(IntToByteArray(mFirmwareUploadCurFrame));
Chunk.append(IntToByteArray(Payload.size()));
Chunk.append(Payload);
return Chunk;
}
QByteArray CPICUploader::IntToByteArray(int data)
{
QByteArray Array;
unsigned char nibble = (char)((data >> 24) &0x000000FF);
Array.append(nibble);
nibble = (char)((data >> 16) &0x000000FF);
Array.append(nibble);
nibble = (char)((data >> 8) &0x000000FF);
Array.append(nibble);
nibble = (char)(data &0x000000FF);
Array.append(nibble);
return Array;
}
+176
View File
@@ -0,0 +1,176 @@
#ifndef PICUPLOADER_H
#define PICUPLOADER_H
#include <QObject>
#include "PICUploaderGui.h"
#include "HexFile.h"
#include <QTcpSocket>
#include "BootloaderProtocol.h"
enum eBootloaderUploadSMEvents
{
BOOTLOADER_UPLOAD_SM_TICK_EVENT,
BOOTLOADER_UPLOAD_SM_NEW_CMD_EVENT,
BOOTLOADER_UPLOAD_SM_MAX_EVENT
};
enum eBootloaderSMCmdEvents
{
BOOTLOADER_UPLOAD_ERASE_FLASH_GUI_CMD,
BOOTLOADER_UPLOAD_START_UPLOAD_GUI_CMD,
BOOTLOADER_UPLOAD_START_FULL_UPDATE_GUI_CMD,
BOOTLOADER_UPLOAD_ABORT_GUI_CMD,
BOOTLOADER_UPLOAD_BOOTLOADER_CONNECTED_CMD,
BOOTLOADER_UPLOAD_BOOTLOADER_DISCONNECTED_CMD,
BOOTLOADER_UPLOAD_HEARTBEAT_HOST_CMD,
BOOTLOADER_UPLOAD_ERASE_BOOTLOADER_FLASH_ACK_HOST_CMD,
BOOTLOADER_UPLOAD_ERASE_BOOTLOADER_FLASH_RESULT_HOST_CMD,
BOOTLOADER_UPLOAD_INIT_UPLOAD_HOST_CMD,
BOOTLOADER_UPLOAD_GET_STATE_HOST_CMD,
BOOTLOADER_UPLOAD_READY_FOR_DATA_HOST_CMD,
BOOTLOADER_UPLOAD_SEND_DATA_CHUNK_HOST_CMD,
BOOTLOADER_UPLOAD_UPLOAD_FINISHED_HOST_CMD,
BOOTLOADER_UPLOAD_EXECUTE_UPGRADE_HOST_CMD,
BOOTLOADER_UPLOAD_ABORT_OPERATION_HOST_CMD,
BOOTLOADER_UPLOAD_MAX_CMD
};
typedef enum eBootloaderInterfaceSMStates
{
BOOTLOADER_INTERFACE_SM_STANDBY_STATE,
BOOTLOADER_INTERFACE_SM_BOOTLDR_CONNECTED_STATE,
BOOTLOADER_INTERFACE_SM_ERASE_FLASH_STATE,
BOOTLOADER_INTERFACE_SM_WAIT_READY_FOR_DATA_FROM_HOST_STATE,
BOOTLOADER_INTERFACE_SM_INIT_UPLOAD_STATE,
BOOTLOADER_INTERFACE_SM_SEND_DATA_STATE,
BOOTLOADER_INTERFACE_SM_DATA_FINISHED_STATE,
BOOTLOADER_UPLOAD_MAX_STATE
}BootloaderInterfaceSMStates;
typedef enum eBootloaderFirmwareUploadSMStates
{
BOOTLOADER_FIRM_UPLD_STANDBY_STATE,
// BOOTLOADER_FIRM_UPLD_WAIT_FOR_HOST_READY_STATE,
BOOTLOADER_FIRM_UPLD_SEND_CHUNK_STATE,
BOOTLOADER_FIRM_UPLD_FINISHED_STATE,
BOOTLOADER_FIRM_UPLD_MAX_STATE
}BootloaderFirmwareUpldState;
enum eBootloaderFirmwareUploadEvents
{
BOOTLOADER_FIRM_UPLD_TICK_EVENT,
BOOTLOADER_FIRM_UPLD_CMD_EVENT,
BOOTLOADER_FIRM_UPLD_MAX_EVENT
};
enum eBootloaderFirmwareUploadSMCmd
{
BOOTLOADER_FIRM_UPLD_INIT_UPLOAD_CMD,
BOOTLOADER_FIRM_UPLD_CHUNK_RX_RESPONSE_CMD,
BOOTLOADER_FIRM_UPLD_ABORT_UPLOAD_CMD,
BOOTLOADER_FIRM_UPLD_MAX_CMD
};
enum eBootloaderProtocolDataTransferError
{
BOOTLOADER_CHUNK_TRANSFER_SUCCESS = 1,
BOOTLOADER_CHUNK_TRANSFER_ERROR_RESEND = 2,
BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_FAILURE = 3,
BOOTLOADER_CHUNK_TRANSFER_ERROR_INVALID_CHUNK_INDEX = 4,
BOOTLOADER_CHUNK_TRANSFER_ERROR_FLASH_ERROR = 5,
BOOTLOADER_CHUNK_TRANSFER_MAX_ERROR
};
enum eBootloaderProtocolInitUploadError
{
BOOTLOADER_INIT_UPLOAD_FAILED = 0,
BOOTLOADER_INIT_UPLOAD_SUCCESS = 1,
BOOTLOADER_INIT_UPLOAD_ERROR_FLASH_NOT_ERASED = 2,
BOOTLOADER_INIT_UPLOAD_MAX_ERROR
};
enum eBootloaderFirmwareUploadRes
{
BOOTLOADER_FIRM_UPLD_STANDBY_RES,
BOOTLOADER_FIRM_UPLD_SENDING_RES,
BOOTLOADER_FIRM_UPLD_FINISHED_RES,
BOOTLOADER_FIRM_UPLD_ERROR_RES,
BOOTLOADER_FIRM_UPLD_TIMEOUT_RES,
BOOTLOADER_FIRM_UPLD_ABORT_RES,
BOOTLOADER_FIRM_UPLD_OK_RES,
BOOTLOADER_FIRM_UPLD_MAX_RES
};
//Used for both ACK and erase operation result
enum eBootloaderFlashEraseResult
{
BOOTLOADER_FLASH_ERASE_ERROR = 0,
BOOTLOADER_FLASH_ERASE_OK = 1,
BOOTLOADER_FLASH_ERASE_MAX_RESULT
};
class CPICUploader : public QObject
{
Q_OBJECT
public:
explicit CPICUploader(CPICUploaderGui *Gui);
int OpenHexFileRequest(QString FilePath);
int Start();
CPICUploaderGui *mPICUploaderGui;
CHexFile mHexFile;
QTcpSocket mBootloaderSocket;
CBootloaderProtocol mBootloaderProtocol;
int ConnectToBootloader(QString IP);
int DisconnectFromBootloader();
int SendSingleCmdRequest(int CmdID);
int SendCmdRequest(int CmdID, QByteArray Data);
int GuiEvent(int EventID, void* Data=0);
int ShowHexFileInfoRequest();
int BootloaderRxCmd(int CmdID, QByteArray Data);
int BootloaderFirmwareUploadStateMachine(int Event, int Cmd, int CmdResult = 1, int CmdParam = 0xBAADCAFE);
int BootloaderInterfaceStateMachine(int Event, int Cmd, int CmdParam = 0, void *Data = 0);
private:
BootloaderInterfaceSMStates mBootloaderInterfaceSMState;
int ResetBooloaderInterfaceStateMachine();
BootloaderFirmwareUpldState mBootloaderFirmwareUpldState;
int ResetFirmwareUploadStateMachine();
unsigned int mFirmwareUploadBufferSize;
unsigned int mFirmwareUploadCurFrame;
QByteArray mFirmwareData;
QByteArray GetCurDataChunk(bool &IsLastChunk);
QByteArray IntToByteArray(int);
signals:
public slots:
void BootloaderSocketConnected();
void BootloaderSocketDisconnected();
void BootloaderDataAvailable();
void BootloaderSocketError(QAbstractSocket::SocketError);
};
#endif // PICUPLOADER_H
+165
View File
@@ -0,0 +1,165 @@
#include "PICUploaderGui.h"
#include "ui_PICUploaderGui.h"
#include <QFileDialog>
#include "PICUploader.h"
#include "ProtocolDefs.h"
CPICUploaderGui::CPICUploaderGui(QWidget *parent) :
QDialog(parent),
ui(new Ui::CPICUploaderGui)
{
ui->setupUi(this);
connect(ui->mHexFileSelectBtn,SIGNAL(clicked(bool)),this,SLOT(OpenHexFileBtnClicked(bool)));
connect(ui->mConnectBtn,SIGNAL(clicked(bool)),this,SLOT(ConnectBtnClicked(bool)));
connect(ui->mSendCmdBtn,SIGNAL(clicked(bool)),this,SLOT(SendSingleCmdCliked(bool)));
connect(ui->mClearLogginWndwBtn,SIGNAL(clicked(bool)),SLOT(ClearLogScreen(bool)));
connect(ui->mShowHexFileInfoBtn,SIGNAL(clicked(bool)),this,SLOT(ShowHexFileInfoClicked(bool)));
ui->mUploadProgressBar->reset();
}
CPICUploaderGui::~CPICUploaderGui()
{
delete ui;
}
void CPICUploaderGui::OpenHexFileBtnClicked(bool checked)
{
QString FileName = QFileDialog::getOpenFileName(0,"Select Firmware Hex File",QString(),"Hex files (*.hex)");
if(mProgramHandle->OpenHexFileRequest(FileName) != 1)
{
ui->mOpenedHexFilePathLbl->setText(FileName);
}
}
void CPICUploaderGui::SetHexFileStats(QString Stats)
{
ui->mHexFileStatsLbl->setText(Stats);
}
void CPICUploaderGui::ConnectBtnClicked(bool)
{
if(ui->mConnectBtn->text() == "Connect")
{
QString IP = ui->mIPAddressEdit->text();
if(IP.isEmpty())
{
return;
}
// ui->mConnectBtn->setText("Disconnect");
// ui->mConnectBtn->setEnabled(false);
mProgramHandle->ConnectToBootloader(IP);
}
else
{
// ui->mConnectBtn->setText("Connect");
mProgramHandle->DisconnectFromBootloader();
}
}
void CPICUploaderGui::UploaderSocketConnected()
{
ui->mConnectBtn->setEnabled(true);
ui->mConnectBtn->setText("Disconnect");
}
void CPICUploaderGui::UploaderSocketDisconnected()
{
ui->mConnectBtn->setEnabled(true);
ui->mConnectBtn->setText("Connect");
}
void CPICUploaderGui::SendSingleCmdCliked(bool)
{
QString CmdSelection = ui->mCmdSelectCombo->currentText();
if(CmdSelection == "Heartbeat")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_HEARTBEAT_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_HEARTBEAT_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Flash Erase")
{
//mProgramHandle->SendSingleCmdRequest(BOOTLOADER_ERASE_BOOTLOADER_FLASH_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_FLASH_ERASE_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Init Upload")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_INIT_UPLOAD_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_INIT_UPLOAD_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Get State")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_GET_STATE_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_GET_STATE_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Send Data Chunk")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_SEND_DATA_CHUNK_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_SEND_DATA_CHUNK_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Upload Finished")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_UPLOAD_FINISHED_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_UPLOAD_FINISHED_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Execute Upgrade")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_EXECUTE_UPGRAGE_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_EXECUTE_UPGRADE_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Abort")
{
// mProgramHandle->SendSingleCmdRequest(BOOTLOADER_ABORT_OPERATION_REQUEST);
mProgramHandle->GuiEvent(UPLOADER_GUI_ABORT_BTN_CLICK_EVENT);
}
else if(CmdSelection == "Check Flash")
{
mProgramHandle->GuiEvent(UPLOADER_GUI_CHECK_FLASH_CLICK_EVENT);
}
else if(CmdSelection == "Get Stored Firmware Info")
{
mProgramHandle->GuiEvent(UPLOADER_GUI_GET_STORED_FIRMWARE_INFO_CLICK_EVENT);
}
else
{
qDebug("Unknown selection???!!!");
}
}
void CPICUploaderGui::AddTextToLogScreen(QString Text)
{
Text.append("\n");
mLogScreenText.prepend(Text);
ui->mLoggingWindowTextEdit->setPlainText(mLogScreenText);
}
void CPICUploaderGui::ClearLogScreen(bool dummy)
{
mLogScreenText.clear();
ui->mLoggingWindowTextEdit->setPlainText(mLogScreenText);
}
void CPICUploaderGui::ShowHexFileInfoClicked(bool)
{
mProgramHandle->ShowHexFileInfoRequest();
}
void CPICUploaderGui::SetUploadProgressSettings(int max)
{
ui->mUploadProgressBar->setRange(0,max);
}
void CPICUploaderGui::TickProgressBar()
{
ui->mUploadProgressBar->setValue(ui->mUploadProgressBar->value()+1);
}
void CPICUploaderGui::ResetProgressBar()
{
ui->mUploadProgressBar->reset();
}
+62
View File
@@ -0,0 +1,62 @@
#ifndef PICUPLOADERGUI_H
#define PICUPLOADERGUI_H
#include <QDialog>
class CPICUploader;
namespace Ui {
class CPICUploaderGui;
}
class CPICUploaderGui : public QDialog
{
Q_OBJECT
public:
enum eUploaderGuiEvents
{
UPLOADER_GUI_HEARTBEAT_BTN_CLICK_EVENT,
UPLOADER_GUI_FLASH_ERASE_BTN_CLICK_EVENT,
UPLOADER_GUI_INIT_UPLOAD_BTN_CLICK_EVENT,
UPLOADER_GUI_GET_STATE_BTN_CLICK_EVENT,
UPLOADER_GUI_SEND_DATA_CHUNK_BTN_CLICK_EVENT,
UPLOADER_GUI_UPLOAD_FINISHED_BTN_CLICK_EVENT,
UPLOADER_GUI_EXECUTE_UPGRADE_BTN_CLICK_EVENT,
UPLOADER_GUI_ABORT_BTN_CLICK_EVENT,
UPLOADER_GUI_AUTOMATIC_UPDATE_START_BTN_CLICK_EVENT,
UPLOADER_GUI_CHECK_FLASH_CLICK_EVENT,
UPLOADER_GUI_GET_STORED_FIRMWARE_INFO_CLICK_EVENT,
UPLOADER_GUI_MAX_EVENT
};
public:
explicit CPICUploaderGui(QWidget *parent = nullptr);
~CPICUploaderGui();
void SetHexFileStats(QString Stats);
void UploaderSocketConnected();
void UploaderSocketDisconnected();
void AddTextToLogScreen(QString Text);
void SetUploadProgressSettings(int max);
void TickProgressBar();
void ResetProgressBar();
CPICUploader *mProgramHandle;
private:
Ui::CPICUploaderGui *ui;
QString mLogScreenText;
public slots:
void OpenHexFileBtnClicked(bool);
void ConnectBtnClicked(bool);
void SendSingleCmdCliked(bool);
void ClearLogScreen(bool);
void ShowHexFileInfoClicked(bool);
};
#endif // PICUPLOADERGUI_H
+324
View File
@@ -0,0 +1,324 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CPICUploaderGui</class>
<widget class="QDialog" name="CPICUploaderGui">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1024</width>
<height>768</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>260</x>
<y>20</y>
<width>191</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Firmware Uploader</string>
</property>
</widget>
<widget class="QPushButton" name="mHexFileSelectBtn">
<property name="geometry">
<rect>
<x>70</x>
<y>110</y>
<width>81</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Open Hex File</string>
</property>
</widget>
<widget class="QLineEdit" name="mIPAddressEdit">
<property name="geometry">
<rect>
<x>690</x>
<y>120</y>
<width>181</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>192.168.30.125</string>
</property>
</widget>
<widget class="QLabel" name="mOpenedHexFilePathLbl">
<property name="geometry">
<rect>
<x>70</x>
<y>140</y>
<width>521</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>No File Opened</string>
</property>
</widget>
<widget class="QLabel" name="mHexFileStatsLbl">
<property name="geometry">
<rect>
<x>70</x>
<y>170</y>
<width>471</width>
<height>131</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="mConnectBtn">
<property name="geometry">
<rect>
<x>890</x>
<y>120</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
<widget class="QPushButton" name="mSendCmdBtn">
<property name="geometry">
<rect>
<x>890</x>
<y>170</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Send Cmd</string>
</property>
</widget>
<widget class="QComboBox" name="mCmdSelectCombo">
<property name="geometry">
<rect>
<x>710</x>
<y>170</y>
<width>151</width>
<height>22</height>
</rect>
</property>
<item>
<property name="text">
<string>Heartbeat</string>
</property>
</item>
<item>
<property name="text">
<string>Get Stored Firmware Info</string>
</property>
</item>
<item>
<property name="text">
<string>Flash Erase</string>
</property>
</item>
<item>
<property name="text">
<string>Init Upload</string>
</property>
</item>
<item>
<property name="text">
<string>Get State</string>
</property>
</item>
<item>
<property name="text">
<string>Send Data Chunk</string>
</property>
</item>
<item>
<property name="text">
<string>Upload Finished</string>
</property>
</item>
<item>
<property name="text">
<string>Execute Upgrade</string>
</property>
</item>
<item>
<property name="text">
<string>Check Flash</string>
</property>
</item>
<item>
<property name="text">
<string>Abort</string>
</property>
</item>
</widget>
<widget class="QPlainTextEdit" name="mLoggingWindowTextEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>310</y>
<width>651</width>
<height>341</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton" name="mClearLogginWndwBtn">
<property name="geometry">
<rect>
<x>10</x>
<y>660</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Clear</string>
</property>
</widget>
<widget class="QPushButton" name="mShowHexFileInfoBtn">
<property name="geometry">
<rect>
<x>170</x>
<y>110</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Show Info</string>
</property>
</widget>
<widget class="QLabel" name="mFilterParamsLbl">
<property name="geometry">
<rect>
<x>680</x>
<y>320</y>
<width>231</width>
<height>81</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLineEdit" name="mFilterStartAddressTxtEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>760</x>
<y>330</y>
<width>113</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>0x1D004000</string>
</property>
</widget>
<widget class="QLineEdit" name="mFilterEndAddressTxtEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>760</x>
<y>370</y>
<width>113</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>0x1D07FFFF</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>690</x>
<y>330</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Start Address</string>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>690</x>
<y>370</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>End Address</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>680</x>
<y>300</y>
<width>71</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Code area</string>
</property>
</widget>
<widget class="QProgressBar" name="mUploadProgressBar">
<property name="geometry">
<rect>
<x>680</x>
<y>420</y>
<width>231</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
+138 -4
View File
@@ -59,6 +59,10 @@ enum DEVICES_IDS
ID_DEADBOLT_INTERFACE,
ID_AVRECEIVER_INTERFACE,
ID_CHALET_INTERFACE,
ID_CHALET_DEVICE,
ID_ISPINDEL_INTERFACE,
ID_LORA_INTERFACE_DEVICE,
ID_LORA_INTERFACE_INTERFACE,
ID_NB_DEVICE_ID
};
@@ -234,14 +238,24 @@ enum AV_RECEIVER_INTERFACE_CMDS
AV_RECEIVER_INTERFACE_GENERAL_STATUS_RESPONSE,
AV_RECEIVER_INTERFACE_SET_MAIN_POWER_REQUEST,
AV_RECEIVER_INTERFACE_SET_MAIN_POWER_RESPONSE,
AV_RECEIVER_INTERFACE_SET_SPEAKERB_REQUEST,
AV_RECEIVER_INTERFACE_SET_SPEAKERB_RESPONSE,
AV_RECEIVER_INTERFACE_SET_SPEAKERA_REQUEST,
AV_RECEIVER_INTERFACE_SET_SPEAKERA_RESPONSE,
AV_RECEIVER_INTERFACE_SET_ZONE2_REQUEST,
AV_RECEIVER_INTERFACE_SET_ZONE2_RESPONSE,
AV_RECEIVER_INTERFACE_SET_MAIN_ZONE_REQUEST,
AV_RECEIVER_INTERFACE_SET_MAIN_ZONE_RESPONSE,
AV_RECEIVER_INTERFACE_SET_SPEAKERS_REQUEST,
AV_RECEIVER_INTERFACE_SET_SPEAKERS_RESPONSE,
AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_REQUEST,
AV_RECEIVER_INTERFACE_SEND_DIRECT_CMD_RESPONSE,
AV_RECEIVER_INTERFACE_SELECT_SCENE_REQUEST,
AV_RECEIVER_INTERFACE_SELECT_SCENE_RESPONSE,
AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_REQUEST,
AV_RECEIVER_INTERFACE_SET_MAIN_VOLUME_RESPONSE,
AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_REQUEST,
AV_RECEIVER_INTERFACE_SET_ZONE2_VOLUME_RESPONSE,
AV_RECEIVER_INTERFACE_SET_ZONE2_INPUT_REQUEST,
AV_RECEIVER_INTERFACE_SET_ZONE2_INPUT_RESPONSE,
AV_RECEIVER_INTERFACE_SET_SYNC_Z2_WITH_Z1_REQUEST,
AV_RECEIVER_INTERFACE_SET_SYNC_Z2_WITH_Z1_RESPONSE,
MAX_AV_RECEIVER_INTERFACE_CMD
@@ -269,9 +283,129 @@ enum CHALET_INTERFACE_CMDS
CHALET_INTERFACE_CHALET_ACTIVITY_RESPONSE,
CHALET_INTERFACE_GET_DATA_LOG_REQUEST,
CHALET_INTERFACE_GET_DATA_LOG_RESPONSE,
CHALET_INTERFACE_WIFI_GET_DEVICE_PARAMS_REQUEST,
CHALET_INTERFACE_WIFI_GET_DEVICE_PARAMS_RESPONSE,
CHALET_INTERFACE_WIFI_SET_DEVICE_PARAMS_REQUEST,
CHALET_INTERFACE_WIFI_SET_DEVICE_PARAMS_RESPONSE,
CHALET_INTERFACE_GET_FIRMWARE_VERSION_REQUEST,
CHALET_INTERFACE_GET_FIRMWARE_VERSION_RESPONSE,
CHALET_INTERFACE_CLEAR_COMMS_STATS_REQUEST,
CHALET_INTERFACE_CLEAR_COMMS_STATS_RESPONSE,
CHALET_INTERFACE_GET_WIFI_STATUS_REQUEST,
CHALET_INTERFACE_GET_WIFI_STATUS_RESPONSE,
MAX_CHALET_INTERFACE_CMD
};
enum CHALET_CMDS
{
CHALET_ACK = 1,
CHALET_GENERAL_STATUS_REQUEST, //2
CHALET_GENERAL_STATUS_RESPONSE, //3
CHALET_AC_POWER_STATE_STATUS_REQUEST,
CHALET_AC_POWER_STATE_STATUS_RESPONSE,
CHALET_AC_POWER_SET_STATE_REQUEST,
CHALET_AC_POWER_SET_STATE_RESPONSE,
CHALET_BATTERY_VOLTAGE_REQUEST,
CHALET_BATTERY_VOLTAGE_RESPONSE, //9
CHALET_BATTERY_CURRENT_REQUEST,
CHALET_BATTERY_CURRENT_RESPONSE,
CHALET_WIFI_STATUS_REQUEST,
CHALET_WIFI_STATUS_RESPONSE, //D
CHALET_WIFI_SET_STATE_REQUEST,
CHALET_WIFI_SET_STATE_RESPONSE, //F
CHALET_DO_HARAKIRI_REQUEST,
CHALET_DO_HARAKIRI_CONFIRMATION,
CHALET_REBOOT_CPU_REQUEST, //12
CHALET_REBOOT_CPU_RESPONSE,
CHALET_GET_STORED_WIFI_SETTINGS_REQUEST, //14
CHALET_GET_STORED_WIFI_SETTINGS_RESPONSE,
CHALET_SET_STORED_WIFI_SETTINGS_REQUEST, //
CHALET_SET_STORED_WIFI_SETTINGS_RESPONSE,
CHALET_GET_FIRMWARE_VERSION_REQUEST,
CHALET_GET_FIRMWARE_VERSION_RESPONSE,
CHALET_CLEAR_COMMS_STATISTICS_REQUEST,
CHALET_CLEAR_COMMS_STATISTICS_RESPONSE,
MAX_CHALET_CMD
};
enum BOOTLOADER_CMDS
{
BOOTLOADER_ACK = 1,
BOOTLOADER_HEARTBEAT_REQUEST,
BOOTLOADER_HEARTBEAT_RESPONSE,
BOOTLOADER_ERASE_BOOTLOADER_FLASH_REQUEST,
BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESPONSE,
BOOTLOADER_ERASE_BOOTLOADER_FLASH_RESULT_RESPONSE,
BOOTLOADER_INIT_UPLOAD_REQUEST,
BOOTLOADER_INIT_UPLOAD_RESPONSE,
BOOTLOADER_GET_STATE_REQUEST,
BOOTLOADER_GET_STATE_RESPONSE,
BOOTLOADER_READY_FOR_DATA_RESPONSE,
BOOTLOADER_SEND_DATA_CHUNK_REQUEST,
BOOTLOADER_SEND_DATA_CHUNK_RESPONSE,
BOOTLOADER_UPLOAD_FINISHED_REQUEST,
BOOTLOADER_UPLOAD_FINISHED_RESPONSE,
BOOTLOADER_EXECUTE_UPGRAGE_REQUEST,
BOOTLOADER_EXECUTE_UPGRADE_RESPONSE,
BOOTLOADER_ABORT_OPERATION_REQUEST,
BOOTLOADER_ABORT_OPERATION_RESPONSE,
BOOTLOADER_SEND_FLASH_DATA_REQUEST,
BOOTLOADER_SEND_FLASH_DATA_RESPONSE,
BOOTLOADER_SEND_FLASH_DATA_CHUNK,
BOOTLOADER_SEND_FLASH_DATA_CHUNK_RESPONSE,
BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_REQUEST,
BOOTLOADER_CHECK_FLASH_FIRMW_INTEGRITY_RESPONSE,
BOOTLOADER_GET_STORED_FIRMWARE_INFO_REQUEST,
BOOTLOADER_GET_STORED_FIRMWARE_INFO_RESPONSE,
MAX_BOOTLOADER_CMD
};
enum ISPINDLE_CMDS
{
ISPINDLE_ACK = 1,
ISPINDLE_LATEST_DATA_REQUEST,
ISPINDLE_LATEST_DATA_RESPONSE,
ISPINDEL_GET_FULL_DATA_BUFFER_REQUEST,
ISPINDEL_GET_FULL_DATA_BUFFER_RESPONSE,
ISPINDEL_DELETE_SAMPLE_REQUEST,
ISPINDEL_DELETE_SAMPLE_RESPONSE,
MAX_ISPINDLE_CMDS
};
enum LORA_INTERFACE_CMDS
{
LORA_IF_ACK = 1,
LORA_IF_GET_STATUS_REQUEST,
LORA_IF_GET_STATUS_RESPONSE,
LORA_IF_SEND_FRAME_REQUEST,
LORA_IF_SEND_FRAME_RESPONSE,
LORA_IF_NEW_FRAME_RESPONSE,
LORA_IF_GET_MODULE_CONFIG_REQUEST,
LORA_IF_GET_MODULE_CONFIG_RESPONSE,
LORA_IF_GET_RSSI_REQUEST,
LORA_IF_GET_RSSI_RESPONSE,
LORA_IF_SET_MODULE_CONFIG_REQUEST,
LORA_IF_SET_MODULE_CONFIG_RESPONSE,
MAX_LORA_IF_CMD
};
enum LORA_MODULE_IF_INTERFACE_CMDS
{
LORA_MODULE_IF_INTERFACE_ACK = 1,
LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_REQUEST,
LORA_MODULE_IF_INTERFACE_GENERAL_STATUS_RESPONSE,
MAX_LORA_MODULE_IF_INTERFACE_CMD
};
#endif
+17 -1
View File
@@ -9,11 +9,18 @@ CSystemGui::CSystemGui(QObject *parent) : QObject(parent)
mSprinklers = new CSprinkler(mGui->mSprinklerGui);
mAvReceiver = new CAvReceiver(mGui->mAvReceiverGui);
mChalet = new CChalet(mGui->mChaletGui);
mPICUploader = new CPICUploader(mGui->mPICUploaderGui);
mIspindel = new CIspindel(mGui->mIspindelGui);
mLoraModuleIF = new CLoraModuleInterface(mGui->mChaletGui);
mTrayVolumeCtrl = new CTrayVolumeCtrl(mGui->mAvReceiverGui);
mGui->mAvReceiverGui->mTrayVolumeCtrlGuiHandle = mTrayVolumeCtrl;
mSysTrayMgr = new CSystemTrayManager();
mSysTrayMgr = new CSystemTrayManager(mTrayVolumeCtrl);
mSysTrayMgr->mProgramHandle=this;
mSMSClient->mTrayIconMgr = mSysTrayMgr;
}
CSystemGui::~CSystemGui()
@@ -24,6 +31,10 @@ CSystemGui::~CSystemGui()
delete mSysTrayMgr;
delete mAvReceiver;
delete mChalet;
delete mPICUploader;
delete mIspindel;
delete mLoraModuleIF;
delete mTrayVolumeCtrl;
}
@@ -34,6 +45,9 @@ void CSystemGui::Start()
mSMSClient->Start();
mAvReceiver->Start();
mChalet->Start();
mPICUploader->Start();
mIspindel->Start();
// mLoraModuleIF->Start();
}
@@ -59,6 +73,8 @@ int CSystemGui::TrayIconLeftClick()
if(mGui->isVisible())
{
mGui->hide();
}
else
{
+8
View File
@@ -10,6 +10,10 @@
#include "AvReceiverGui.h"
#include "AvReceiver.h"
#include "CChalet.h"
#include "PICUploader.h"
#include "Ispindel.h"
#include "LoraModuleInterface.h"
#include "TrayVolumeCtrl.h"
class CSystemGui : public QObject
@@ -35,6 +39,10 @@ private:
CSprinkler *mSprinklers;
CAvReceiver *mAvReceiver;
CChalet *mChalet;
CPICUploader *mPICUploader;
CIspindel *mIspindel;
CLoraModuleInterface *mLoraModuleIF;
CTrayVolumeCtrl *mTrayVolumeCtrl;
signals:
+25 -3
View File
@@ -2,7 +2,7 @@
#include "SystemGui.h"
#include <QCursor>
CSystemTrayManager::CSystemTrayManager()
CSystemTrayManager::CSystemTrayManager(CTrayVolumeCtrl *VolumeCtrlWidget)
{
mProgramHandle = 0;
@@ -13,8 +13,20 @@ CSystemTrayManager::CSystemTrayManager()
connect(&mSystemTrayIcon,SIGNAL(messageClicked()),this,SLOT(TrayBaloonMessageClicked()));
connect(mTrayMenu,SIGNAL(triggered(QAction*)),this,SLOT(TrayMenuClicked(QAction*)));
mShowSettingsGUIAction = mTrayMenu->addAction("Settings");
QWidgetAction *test = new QWidgetAction(0);
test->setDefaultWidget(VolumeCtrlWidget);
// mTrayVolumeAction = new CTrayVolumeMenuAction("Volume");
// mShowSettingsGUIAction = mTrayMenu->addAction("Settings");
mQuitAction = mTrayMenu->addAction("Quit SMS Client");
mTrayMenu->addSection("Display");
mCloneDisplaysAction = mTrayMenu->addAction("Clone");
mExtendDisplaysAction = mTrayMenu->addAction("Extend");
mTrayMenu->addSeparator();
mTrayMenu->addAction(test);
//mTrayMenu->setMinimumWidth(300);
mSystemTrayIcon.setIcon(QIcon("./Ico/sms.png"));
mSystemTrayIcon.setToolTip("SMS Client :)");
mSystemTrayIcon.show();
@@ -44,7 +56,8 @@ void CSystemTrayManager::TrayIconActivated(QSystemTrayIcon::ActivationReason Rea
}
case QSystemTrayIcon::Context:
{
//qDebug("Context");
// mTrayVolumeCtrl->show();
qDebug("Context");
break;
}
case QSystemTrayIcon::DoubleClick:
@@ -56,6 +69,7 @@ void CSystemTrayManager::TrayIconActivated(QSystemTrayIcon::ActivationReason Rea
//qDebug("Trigger");
//mTrayMenu->popup(QCursor::pos());
//mProgramHandle->RespawnMainWindowRequest();
// mTrayVolumeCtrl->show();
mProgramHandle->TrayIconLeftClick();
break;
}
@@ -78,6 +92,14 @@ void CSystemTrayManager::TrayMenuClicked(QAction *Menu)
qDebug("Settings");
mProgramHandle->ShowSettingsWindowRequest();
}
else if(Menu == mCloneDisplaysAction)
{
system("C:\\Windows\\System32\\DisplaySwitch.exe /clone");
}
else if(Menu == mExtendDisplaysAction)
{
system("C:\\Windows\\System32\\DisplaySwitch.exe /extend");
}
}
+5 -2
View File
@@ -5,6 +5,8 @@
#include <QSystemTrayIcon>
#include <QMenu>
#include <QAction>
#include "TrayVolumeCtrl.h"
class CSystemGui;
@@ -12,7 +14,7 @@ class CSystemTrayManager: public QObject
{
Q_OBJECT
public:
CSystemTrayManager();
CSystemTrayManager(CTrayVolumeCtrl *VolumeCtrlWidget);
virtual ~CSystemTrayManager();
CSystemGui *mProgramHandle;
int NewSMSMessagesPendingCount(int count);
@@ -21,7 +23,8 @@ public:
private:
QSystemTrayIcon mSystemTrayIcon;
QMenu *mTrayMenu;
QAction *mQuitAction, *mShowSettingsGUIAction;
// CTrayVolumeMenuAction *mTrayVolumeAction;
QAction *mQuitAction, *mShowSettingsGUIAction, *mTrayVolumeMenuAction, *mCloneDisplaysAction, *mExtendDisplaysAction;
public slots:
void TrayIconActivated(QSystemTrayIcon::ActivationReason);
+3
View File
@@ -50,6 +50,9 @@ CLightShowWidget::CLightShowWidget(QWidget *parent)
setSceneRect(-100,-100,parentWidget()->geometry().width(),parentWidget()->geometry().height());
setMinimumSize(parentWidget()->geometry().width(),parentWidget()->geometry().height());
mScene->views().at(0)->setBackgroundBrush(QBrush(QColor(Qt::black)));
}
+89
View File
@@ -0,0 +1,89 @@
#include "TrayVolumeCtrl.h"
#include "AvReceiverGui.h"
CTrayVolumeCtrl::CTrayVolumeCtrl(CAvReceiverGui *AvReceiverGuiPtr, QWidget *parent) :
QWidget(parent)
{
mAvReceiverGuiHandle = AvReceiverGuiPtr;
mMainZoneSlider = new QSlider();
mZone2Slider = new QSlider();
mMainZoneLabel = new QLabel("Main\n0");
mMainZoneLabel->setAlignment(Qt::AlignCenter);
mZone2Label = new QLabel("Zone 2\n0");
mZone2Label->setAlignment(Qt::AlignCenter);
mLayout = new QGridLayout(this);
mButton1 = new QPushButton("1");
mButton2 = new QPushButton("2");
mButton3 = new QPushButton("3");
mButton4 = new QPushButton("4");
mLayout->addWidget(mMainZoneLabel,0,0);
mLayout->addWidget(mZone2Label,0,1);
mLayout->addWidget(mMainZoneSlider,1,0,4,1);
mLayout->addWidget(mZone2Slider,1,1,4,1);
mLayout->addWidget(mButton1,1,2);
mLayout->addWidget(mButton2,2,2);
mLayout->addWidget(mButton3,3,2);
mLayout->addWidget(mButton4,4,2);
mButton1->setMaximumWidth(25);
mButton2->setMaximumWidth(25);
mButton3->setMaximumWidth(25);
mButton4->setMaximumWidth(25);
mMainZoneSlider->setMaximum(182);
mZone2Slider->setMaximum(182);
connect(mMainZoneSlider,&QSlider::valueChanged,this,&CTrayVolumeCtrl::MainZoneSliderValueChanged);
connect(mZone2Slider,&QSlider::valueChanged,this,&CTrayVolumeCtrl::Zone2SliderValueChanged);
connect(mButton1,&QPushButton::clicked,mAvReceiverGuiHandle,&CAvReceiverGui::MainZoneScene1BtnClicked);
connect(mButton2,&QPushButton::clicked,mAvReceiverGuiHandle,&CAvReceiverGui::MainZoneScene2BtnClicked);
connect(mButton3,&QPushButton::clicked,mAvReceiverGuiHandle,&CAvReceiverGui::MainZoneScene3BtnClicked);
connect(mButton4,&QPushButton::clicked,mAvReceiverGuiHandle,&CAvReceiverGui::MainZoneScene4BtnClicked);
}
CTrayVolumeCtrl::~CTrayVolumeCtrl()
{
delete mLayout;
delete mMainZoneSlider;
delete mZone2Slider;
delete mZone2Label;
delete mMainZoneLabel;
}
void CTrayVolumeCtrl::MainZoneSliderValueChanged()
{
float SetVolume = mAvReceiverGuiHandle->ConvertBarPositionToVolume(mMainZoneSlider->value());
mMainZoneLabel->setText(QString("Main\n%1").arg(SetVolume));
mAvReceiverGuiHandle->MainZoneVolumeSetChanged(mMainZoneSlider->value());
}
void CTrayVolumeCtrl::Zone2SliderValueChanged()
{
float SetVolume = mAvReceiverGuiHandle->ConvertBarPositionToVolume(mZone2Slider->value());
mZone2Label->setText(QString("Main\n%1").arg(SetVolume));
mAvReceiverGuiHandle->Zone2VolumeSetChanged(mZone2Slider->value());
}
int CTrayVolumeCtrl::SetMainZoneVolume(int SliderValue, float Volume)
{
mMainZoneSlider->blockSignals(true);
mMainZoneLabel->setText(QString("Main\n%1").arg(Volume));
mMainZoneSlider->setValue(SliderValue);
mMainZoneSlider->blockSignals(false);
mMainZoneCurVolume = Volume;
}
int CTrayVolumeCtrl::SetZone2Volume(int SliderValue, float Volume)
{
mZone2Slider->blockSignals(true);
mZone2Label->setText(QString("Zone 2\n%1").arg(Volume));
mZone2Slider->setValue(SliderValue);
mZone2Slider->blockSignals(false);
mZone2CurVolume = Volume;
}
+42
View File
@@ -0,0 +1,42 @@
#ifndef TRAYVOLUMECTRL_H
#define TRAYVOLUMECTRL_H
#include <QWidget>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QSlider>
#include <QLabel>
#include <QPushButton>
class CAvReceiverGui;
class CTrayVolumeCtrl : public QWidget
{
Q_OBJECT
public:
explicit CTrayVolumeCtrl(CAvReceiverGui *AvReceiverGuiPtr,QWidget *parent = 0);
~CTrayVolumeCtrl();
//QHBoxLayout *mLayout;
QGridLayout *mLayout;
QSlider *mMainZoneSlider, *mZone2Slider;
QLabel *mMainZoneLabel, *mZone2Label;
QPushButton *mButton1, *mButton2, *mButton3, *mButton4;
CAvReceiverGui *mAvReceiverGuiHandle;
int SetMainZoneVolume(int SliderValue, float Volume);
int SetZone2Volume(int SliderValue, float Volume);
float mMainZoneCurVolume, mZone2CurVolume;
private:
public slots:
void MainZoneSliderValueChanged();
void Zone2SliderValueChanged();
};
#endif // TRAYVOLUMECTRL_H
+42 -3
View File
@@ -28,6 +28,9 @@ INCLUDEPATH += Sources\
Sources/AvReceiver\
Sources/Chalet\
Sources/Tower\
Sources/PICUploader\
Sources/Ispindel \
Sources/LoRaModuleInterface
SOURCES += \
Sources/Chalet/CChalet.cpp \
@@ -36,6 +39,7 @@ SOURCES += \
Sources/Chalet/ChaletMasterCtrlInterface.cpp \
Sources/GuiMain.cpp \
Sources/NetworkProtocol.cpp \
Sources/PICUploader/PICUploaderGui.cpp \
Sources/ProgramSettings.cpp \
Sources/SystemGui.cpp \
Sources/SMSClient/SMSConversation.cpp \
@@ -64,7 +68,21 @@ SOURCES += \
Sources/Tower/LedStringWidget.cpp \
Sources/Tower/LEDAnimator.cpp \
Sources/Tower/LEDAnimation.cpp \
Sources/main.cpp
Sources/main.cpp \
Sources/PICUploader/PICUploader.cpp \
Sources/PICUploader/HexFile.cpp \
Sources/PICUploader/HexRecord.cpp \
Sources/PICUploader/BootloaderProtocol.cpp \
Sources/CRC32.cpp \
Sources/Ispindel/IspindelGUI.cpp \
Sources/Ispindel/Ispindel.cpp \
Sources/Ispindel/IspindelInterface.cpp \
Sources/Ispindel/IspindelData.cpp \
Sources/LoRaModuleInterface/LoraModuleInterface.cpp \
Sources/LoRaModuleInterface/LoraModuleIFMasterCtrlInterface.cpp \
Sources/LoRaModuleInterface/LoraModuleInterfaceData.cpp \
Sources/TrayVolumeCtrl.cpp \
Sources/AvReceiver/VolumeController.cpp
HEADERS += Sources/AbstractNetworkInterface.h \
Sources/Chalet/CChalet.h \
@@ -73,6 +91,7 @@ HEADERS += Sources/AbstractNetworkInterface.h \
Sources/Chalet/ChaletMasterCtrlInterface.h \
Sources/GuiMain.h \
Sources/NetworkProtocol.h \
Sources/PICUploader/PICUploaderGui.h \
Sources/ProgramSettings.h \
Sources/ProtocolDefs.h \
Sources/SystemGui.h \
@@ -102,12 +121,32 @@ HEADERS += Sources/AbstractNetworkInterface.h \
Sources/Tower/RGBLedWidget.h \
Sources/Tower/LedStringWidget.h \
Sources/Tower/LEDAnimator.h \
Sources/Tower/LEDAnimation.h
Sources/Tower/LEDAnimation.h \
Sources/PICUploader/PICUploader.h \
Sources/PICUploader/HexFile.h \
Sources/PICUploader/HexRecord.h \
Sources/PICUploader/BootloaderProtocol.h \
Sources/CRC32.h \
Sources/Ispindel/IspindelGUI.h \
Sources/Ispindel/Ispindel.h \
Sources/Ispindel/IspindelInterface.h \
Sources/Ispindel/IspindelData.h \
Sources/LoRaModuleInterface/LoraModuleInterface.h \
Sources/LoRaModuleInterface/LoraModuleIFMasterCtrlInterface.h \
Sources/LoRaModuleInterface/LoraModuleInterfaceData.h \
Sources/TrayVolumeCtrl.h \
Sources/AvReceiver/VolumeController.h
FORMS += \
SMSGui.ui \
Sources/Chalet/ChaletGui.ui \
Sources/PICUploader/PICUploaderGui.ui \
Sources/Sprinkler/SprinklerGui.ui \
Sources/Sprinkler/SprinklerDeviceGuiItem.ui \
Sources/AvReceiver/AvReceiverGui.ui \
Sources/Tower/TowerLightShowGui.ui
Sources/Tower/TowerLightShowGui.ui \
Sources/Ispindel/IspindelGUI.ui
#win32: LIBS += -luuid
win32: LIBS += -lole32
+264
View File
@@ -0,0 +1,264 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.1, 2023-01-15T12:49:24. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{5a351af6-dc3b-4afc-af92-7da5e3a5cd12}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 5.14.2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Qt 5.14.2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{dc2b548b-27bc-4e25-8500-cc36640735d8}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Main/PicDev/Projets/MasterCtrl/SystemGui</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Main/PicDev/Projets/MasterCtrl/SystemGui</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">SystemGui</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Main/PicDev/Projets/MasterCtrl/SystemGui/SystemGui.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">SystemGui.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/Main/PicDev/Projets/MasterCtrl/SystemGui</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>
-68
View File
@@ -1,68 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'AvReceiverGui.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_AVRECEIVERGUI_H
#define UI_AVRECEIVERGUI_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CAvReceiverGui
{
public:
QLabel *label;
QLabel *mRcvrStatusLabel;
QCheckBox *mSpkBCheckBox;
QCheckBox *mSpkACheckBox;
void setupUi(QWidget *CAvReceiverGui)
{
if (CAvReceiverGui->objectName().isEmpty())
CAvReceiverGui->setObjectName(QString::fromUtf8("CAvReceiverGui"));
CAvReceiverGui->resize(796, 447);
label = new QLabel(CAvReceiverGui);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(230, 30, 201, 16));
mRcvrStatusLabel = new QLabel(CAvReceiverGui);
mRcvrStatusLabel->setObjectName(QString::fromUtf8("mRcvrStatusLabel"));
mRcvrStatusLabel->setGeometry(QRect(100, 110, 181, 231));
mSpkBCheckBox = new QCheckBox(CAvReceiverGui);
mSpkBCheckBox->setObjectName(QString::fromUtf8("mSpkBCheckBox"));
mSpkBCheckBox->setGeometry(QRect(570, 130, 70, 17));
mSpkACheckBox = new QCheckBox(CAvReceiverGui);
mSpkACheckBox->setObjectName(QString::fromUtf8("mSpkACheckBox"));
mSpkACheckBox->setGeometry(QRect(570, 160, 70, 17));
retranslateUi(CAvReceiverGui);
QMetaObject::connectSlotsByName(CAvReceiverGui);
} // setupUi
void retranslateUi(QWidget *CAvReceiverGui)
{
CAvReceiverGui->setWindowTitle(QCoreApplication::translate("CAvReceiverGui", "Form", nullptr));
label->setText(QCoreApplication::translate("CAvReceiverGui", "AvReceiver", nullptr));
mRcvrStatusLabel->setText(QCoreApplication::translate("CAvReceiverGui", "TextLabel", nullptr));
mSpkBCheckBox->setText(QCoreApplication::translate("CAvReceiverGui", "Speaker B", nullptr));
mSpkACheckBox->setText(QCoreApplication::translate("CAvReceiverGui", "Speaker A", nullptr));
} // retranslateUi
};
namespace Ui {
class CAvReceiverGui: public Ui_CAvReceiverGui {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_AVRECEIVERGUI_H
-210
View File
@@ -1,210 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'ChaletGui.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_CHALETGUI_H
#define UI_CHALETGUI_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QDateEdit>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QLCDNumber>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CChaletGui
{
public:
QLabel *MainPageLabel;
QLabel *mInverterRlyStatusLabel;
QLabel *mWiFiModuleStatusLabel;
QLabel *mWiFiSectionLabel;
QPushButton *mInverterRelayOFFBtn;
QPushButton *mWiFiModuleOFFBtn;
QPushButton *mInverterRelayONBtn;
QPushButton *mWiFiModuleONBtn;
QLabel *mWiFiSectionLabel_2;
QPushButton *mRebootCPUBtn;
QCheckBox *mEnableHarakiriChkBx;
QGroupBox *groupBox;
QPushButton *mDoHarakiriButton;
QLabel *mBatteryVoltageLabel;
QLabel *mChaletOnlineStatusLbl;
QLabel *mSolarPanelCurrentLabel;
QLabel *mBatterySOCLabel;
QLabel *mCurrentSensorStateLbl;
QLabel *mLostReqPercentLbl;
QWidget *mPlotWidget;
QLCDNumber *mVoltageLCD;
QLabel *mChaletCommActivityLbl;
QLabel *mLasCommRequestReceivedLbl;
QDateEdit *mLogStartDateEdit;
QPushButton *mGetChaletLogButton;
void setupUi(QWidget *CChaletGui)
{
if (CChaletGui->objectName().isEmpty())
CChaletGui->setObjectName(QString::fromUtf8("CChaletGui"));
CChaletGui->resize(1205, 598);
MainPageLabel = new QLabel(CChaletGui);
MainPageLabel->setObjectName(QString::fromUtf8("MainPageLabel"));
MainPageLabel->setGeometry(QRect(460, 10, 71, 31));
QFont font;
font.setPointSize(12);
font.setBold(true);
font.setWeight(75);
MainPageLabel->setFont(font);
mInverterRlyStatusLabel = new QLabel(CChaletGui);
mInverterRlyStatusLabel->setObjectName(QString::fromUtf8("mInverterRlyStatusLabel"));
mInverterRlyStatusLabel->setGeometry(QRect(198, 50, 210, 16));
mWiFiModuleStatusLabel = new QLabel(CChaletGui);
mWiFiModuleStatusLabel->setObjectName(QString::fromUtf8("mWiFiModuleStatusLabel"));
mWiFiModuleStatusLabel->setGeometry(QRect(198, 90, 130, 16));
mWiFiSectionLabel = new QLabel(CChaletGui);
mWiFiSectionLabel->setObjectName(QString::fromUtf8("mWiFiSectionLabel"));
mWiFiSectionLabel->setGeometry(QRect(26, 90, 31, 16));
mInverterRelayOFFBtn = new QPushButton(CChaletGui);
mInverterRelayOFFBtn->setObjectName(QString::fromUtf8("mInverterRelayOFFBtn"));
mInverterRelayOFFBtn->setGeometry(QRect(126, 50, 61, 22));
mWiFiModuleOFFBtn = new QPushButton(CChaletGui);
mWiFiModuleOFFBtn->setObjectName(QString::fromUtf8("mWiFiModuleOFFBtn"));
mWiFiModuleOFFBtn->setGeometry(QRect(126, 90, 61, 23));
mInverterRelayONBtn = new QPushButton(CChaletGui);
mInverterRelayONBtn->setObjectName(QString::fromUtf8("mInverterRelayONBtn"));
mInverterRelayONBtn->setGeometry(QRect(70, 50, 51, 23));
mWiFiModuleONBtn = new QPushButton(CChaletGui);
mWiFiModuleONBtn->setObjectName(QString::fromUtf8("mWiFiModuleONBtn"));
mWiFiModuleONBtn->setGeometry(QRect(70, 90, 51, 23));
mWiFiSectionLabel_2 = new QLabel(CChaletGui);
mWiFiSectionLabel_2->setObjectName(QString::fromUtf8("mWiFiSectionLabel_2"));
mWiFiSectionLabel_2->setGeometry(QRect(16, 50, 51, 20));
mRebootCPUBtn = new QPushButton(CChaletGui);
mRebootCPUBtn->setObjectName(QString::fromUtf8("mRebootCPUBtn"));
mRebootCPUBtn->setGeometry(QRect(66, 130, 75, 23));
mEnableHarakiriChkBx = new QCheckBox(CChaletGui);
mEnableHarakiriChkBx->setObjectName(QString::fromUtf8("mEnableHarakiriChkBx"));
mEnableHarakiriChkBx->setEnabled(false);
mEnableHarakiriChkBx->setGeometry(QRect(850, 80, 111, 17));
groupBox = new QGroupBox(CChaletGui);
groupBox->setObjectName(QString::fromUtf8("groupBox"));
groupBox->setGeometry(QRect(830, 50, 151, 81));
mDoHarakiriButton = new QPushButton(groupBox);
mDoHarakiriButton->setObjectName(QString::fromUtf8("mDoHarakiriButton"));
mDoHarakiriButton->setGeometry(QRect(20, 50, 101, 23));
mBatteryVoltageLabel = new QLabel(CChaletGui);
mBatteryVoltageLabel->setObjectName(QString::fromUtf8("mBatteryVoltageLabel"));
mBatteryVoltageLabel->setGeometry(QRect(147, 170, 241, 16));
mChaletOnlineStatusLbl = new QLabel(CChaletGui);
mChaletOnlineStatusLbl->setObjectName(QString::fromUtf8("mChaletOnlineStatusLbl"));
mChaletOnlineStatusLbl->setGeometry(QRect(450, 50, 91, 21));
QFont font1;
font1.setFamily(QString::fromUtf8("Terminal"));
font1.setPointSize(14);
font1.setBold(true);
font1.setWeight(75);
mChaletOnlineStatusLbl->setFont(font1);
mSolarPanelCurrentLabel = new QLabel(CChaletGui);
mSolarPanelCurrentLabel->setObjectName(QString::fromUtf8("mSolarPanelCurrentLabel"));
mSolarPanelCurrentLabel->setGeometry(QRect(147, 190, 241, 16));
mBatterySOCLabel = new QLabel(CChaletGui);
mBatterySOCLabel->setObjectName(QString::fromUtf8("mBatterySOCLabel"));
mBatterySOCLabel->setGeometry(QRect(147, 210, 241, 16));
mCurrentSensorStateLbl = new QLabel(CChaletGui);
mCurrentSensorStateLbl->setObjectName(QString::fromUtf8("mCurrentSensorStateLbl"));
mCurrentSensorStateLbl->setGeometry(QRect(147, 230, 241, 16));
mLostReqPercentLbl = new QLabel(CChaletGui);
mLostReqPercentLbl->setObjectName(QString::fromUtf8("mLostReqPercentLbl"));
mLostReqPercentLbl->setGeometry(QRect(770, 200, 241, 16));
mPlotWidget = new QWidget(CChaletGui);
mPlotWidget->setObjectName(QString::fromUtf8("mPlotWidget"));
mPlotWidget->setGeometry(QRect(590, 250, 571, 321));
mVoltageLCD = new QLCDNumber(CChaletGui);
mVoltageLCD->setObjectName(QString::fromUtf8("mVoltageLCD"));
mVoltageLCD->setGeometry(QRect(30, 170, 111, 23));
mChaletCommActivityLbl = new QLabel(CChaletGui);
mChaletCommActivityLbl->setObjectName(QString::fromUtf8("mChaletCommActivityLbl"));
mChaletCommActivityLbl->setGeometry(QRect(770, 180, 47, 16));
mLasCommRequestReceivedLbl = new QLabel(CChaletGui);
mLasCommRequestReceivedLbl->setObjectName(QString::fromUtf8("mLasCommRequestReceivedLbl"));
mLasCommRequestReceivedLbl->setGeometry(QRect(770, 160, 301, 16));
mLogStartDateEdit = new QDateEdit(CChaletGui);
mLogStartDateEdit->setObjectName(QString::fromUtf8("mLogStartDateEdit"));
mLogStartDateEdit->setGeometry(QRect(950, 220, 110, 22));
mGetChaletLogButton = new QPushButton(CChaletGui);
mGetChaletLogButton->setObjectName(QString::fromUtf8("mGetChaletLogButton"));
mGetChaletLogButton->setGeometry(QRect(1070, 220, 75, 23));
groupBox->raise();
MainPageLabel->raise();
mInverterRlyStatusLabel->raise();
mWiFiModuleStatusLabel->raise();
mWiFiSectionLabel->raise();
mInverterRelayOFFBtn->raise();
mWiFiModuleOFFBtn->raise();
mInverterRelayONBtn->raise();
mWiFiModuleONBtn->raise();
mWiFiSectionLabel_2->raise();
mRebootCPUBtn->raise();
mEnableHarakiriChkBx->raise();
mBatteryVoltageLabel->raise();
mChaletOnlineStatusLbl->raise();
mSolarPanelCurrentLabel->raise();
mBatterySOCLabel->raise();
mCurrentSensorStateLbl->raise();
mLostReqPercentLbl->raise();
mPlotWidget->raise();
mVoltageLCD->raise();
mChaletCommActivityLbl->raise();
mLasCommRequestReceivedLbl->raise();
mLogStartDateEdit->raise();
mGetChaletLogButton->raise();
retranslateUi(CChaletGui);
QMetaObject::connectSlotsByName(CChaletGui);
} // setupUi
void retranslateUi(QWidget *CChaletGui)
{
CChaletGui->setWindowTitle(QCoreApplication::translate("CChaletGui", "Form", nullptr));
MainPageLabel->setText(QCoreApplication::translate("CChaletGui", "Chalet", nullptr));
mInverterRlyStatusLabel->setText(QCoreApplication::translate("CChaletGui", "Inverter Relay : OFF", nullptr));
mWiFiModuleStatusLabel->setText(QCoreApplication::translate("CChaletGui", "ON", nullptr));
mWiFiSectionLabel->setText(QCoreApplication::translate("CChaletGui", "WiFi :", nullptr));
mInverterRelayOFFBtn->setText(QCoreApplication::translate("CChaletGui", "Turn OFF", nullptr));
mWiFiModuleOFFBtn->setText(QCoreApplication::translate("CChaletGui", "Turn OFF", nullptr));
mInverterRelayONBtn->setText(QCoreApplication::translate("CChaletGui", "Turn ON", nullptr));
mWiFiModuleONBtn->setText(QCoreApplication::translate("CChaletGui", "Turn ON", nullptr));
mWiFiSectionLabel_2->setText(QCoreApplication::translate("CChaletGui", "Inverter:", nullptr));
mRebootCPUBtn->setText(QCoreApplication::translate("CChaletGui", "Reboot CPU", nullptr));
mEnableHarakiriChkBx->setText(QCoreApplication::translate("CChaletGui", "Enable HARAKIRI", nullptr));
groupBox->setTitle(QCoreApplication::translate("CChaletGui", "HARAKIRI!!!", nullptr));
mDoHarakiriButton->setText(QCoreApplication::translate("CChaletGui", "DO HARAKIRI !!!", nullptr));
mBatteryVoltageLabel->setText(QCoreApplication::translate("CChaletGui", "Battery Voltage", nullptr));
mChaletOnlineStatusLbl->setText(QCoreApplication::translate("CChaletGui", "OFFLINE", nullptr));
mSolarPanelCurrentLabel->setText(QCoreApplication::translate("CChaletGui", "Solar Panel Current: ", nullptr));
mBatterySOCLabel->setText(QCoreApplication::translate("CChaletGui", "Battery SOC: ", nullptr));
mCurrentSensorStateLbl->setText(QCoreApplication::translate("CChaletGui", "Current Sensor:", nullptr));
mLostReqPercentLbl->setText(QCoreApplication::translate("CChaletGui", "Lost requests: ", nullptr));
mChaletCommActivityLbl->setText(QCoreApplication::translate("CChaletGui", "Activity!!!", nullptr));
mLasCommRequestReceivedLbl->setText(QCoreApplication::translate("CChaletGui", "Last Request: ", nullptr));
mGetChaletLogButton->setText(QCoreApplication::translate("CChaletGui", "PushButton", nullptr));
} // retranslateUi
};
namespace Ui {
class CChaletGui: public Ui_CChaletGui {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_CHALETGUI_H
-138
View File
@@ -1,138 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'SMSGui.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SMSGUI_H
#define UI_SMSGUI_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QFrame>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QTreeWidget>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CSMSGui
{
public:
QGridLayout *gridLayout_2;
QLabel *mContactPic;
QLabel *mContactName;
QTextBrowser *mConversationText;
QTreeWidget *mContactsTreeWidget;
QFrame *mSMSEditFrame;
QGridLayout *gridLayout;
QPushButton *mSMSSendBtn;
QTextEdit *mSMSEdit;
QSpacerItem *horizontalSpacer;
QLabel *mSMSMessageStatsLabel;
void setupUi(QWidget *CSMSGui)
{
if (CSMSGui->objectName().isEmpty())
CSMSGui->setObjectName(QString::fromUtf8("CSMSGui"));
CSMSGui->resize(803, 785);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(CSMSGui->sizePolicy().hasHeightForWidth());
CSMSGui->setSizePolicy(sizePolicy);
gridLayout_2 = new QGridLayout(CSMSGui);
gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2"));
mContactPic = new QLabel(CSMSGui);
mContactPic->setObjectName(QString::fromUtf8("mContactPic"));
QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Fixed);
sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(mContactPic->sizePolicy().hasHeightForWidth());
mContactPic->setSizePolicy(sizePolicy1);
mContactPic->setMinimumSize(QSize(100, 100));
mContactPic->setBaseSize(QSize(100, 100));
gridLayout_2->addWidget(mContactPic, 0, 0, 1, 1);
mContactName = new QLabel(CSMSGui);
mContactName->setObjectName(QString::fromUtf8("mContactName"));
gridLayout_2->addWidget(mContactName, 0, 1, 1, 2);
mConversationText = new QTextBrowser(CSMSGui);
mConversationText->setObjectName(QString::fromUtf8("mConversationText"));
gridLayout_2->addWidget(mConversationText, 1, 0, 1, 2);
mContactsTreeWidget = new QTreeWidget(CSMSGui);
QTreeWidgetItem *__qtreewidgetitem = new QTreeWidgetItem();
__qtreewidgetitem->setText(0, QString::fromUtf8("1"));
mContactsTreeWidget->setHeaderItem(__qtreewidgetitem);
mContactsTreeWidget->setObjectName(QString::fromUtf8("mContactsTreeWidget"));
mContactsTreeWidget->setIndentation(2);
mContactsTreeWidget->header()->setVisible(false);
gridLayout_2->addWidget(mContactsTreeWidget, 1, 2, 2, 1);
mSMSEditFrame = new QFrame(CSMSGui);
mSMSEditFrame->setObjectName(QString::fromUtf8("mSMSEditFrame"));
mSMSEditFrame->setFrameShape(QFrame::StyledPanel);
mSMSEditFrame->setFrameShadow(QFrame::Raised);
gridLayout = new QGridLayout(mSMSEditFrame);
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
mSMSSendBtn = new QPushButton(mSMSEditFrame);
mSMSSendBtn->setObjectName(QString::fromUtf8("mSMSSendBtn"));
gridLayout->addWidget(mSMSSendBtn, 3, 2, 1, 1);
mSMSEdit = new QTextEdit(mSMSEditFrame);
mSMSEdit->setObjectName(QString::fromUtf8("mSMSEdit"));
gridLayout->addWidget(mSMSEdit, 2, 0, 2, 1);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayout->addItem(horizontalSpacer, 3, 3, 1, 1);
mSMSMessageStatsLabel = new QLabel(mSMSEditFrame);
mSMSMessageStatsLabel->setObjectName(QString::fromUtf8("mSMSMessageStatsLabel"));
mSMSMessageStatsLabel->setMinimumSize(QSize(200, 75));
gridLayout->addWidget(mSMSMessageStatsLabel, 2, 2, 1, 2);
gridLayout_2->addWidget(mSMSEditFrame, 2, 0, 1, 2);
retranslateUi(CSMSGui);
QMetaObject::connectSlotsByName(CSMSGui);
} // setupUi
void retranslateUi(QWidget *CSMSGui)
{
CSMSGui->setWindowTitle(QCoreApplication::translate("CSMSGui", "Form", nullptr));
mContactPic->setText(QCoreApplication::translate("CSMSGui", "TextLabel", nullptr));
mContactName->setText(QCoreApplication::translate("CSMSGui", "TextLabel", nullptr));
mSMSSendBtn->setText(QCoreApplication::translate("CSMSGui", "Send", nullptr));
mSMSMessageStatsLabel->setText(QCoreApplication::translate("CSMSGui", "TextLabel", nullptr));
} // retranslateUi
};
namespace Ui {
class CSMSGui: public Ui_CSMSGui {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_SMSGUI_H
-69
View File
@@ -1,69 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'SprinklerDeviceGuiItem.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SPRINKLERDEVICEGUIITEM_H
#define UI_SPRINKLERDEVICEGUIITEM_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CSprinklerDeviceGuiItem
{
public:
QLabel *SprinklerAddress;
QLabel *SprinklerFlowSpeed;
QLabel *label;
QPushButton *pushButton;
void setupUi(QWidget *CSprinklerDeviceGuiItem)
{
if (CSprinklerDeviceGuiItem->objectName().isEmpty())
CSprinklerDeviceGuiItem->setObjectName(QString::fromUtf8("CSprinklerDeviceGuiItem"));
CSprinklerDeviceGuiItem->resize(540, 399);
SprinklerAddress = new QLabel(CSprinklerDeviceGuiItem);
SprinklerAddress->setObjectName(QString::fromUtf8("SprinklerAddress"));
SprinklerAddress->setGeometry(QRect(20, 10, 101, 41));
SprinklerFlowSpeed = new QLabel(CSprinklerDeviceGuiItem);
SprinklerFlowSpeed->setObjectName(QString::fromUtf8("SprinklerFlowSpeed"));
SprinklerFlowSpeed->setGeometry(QRect(20, 50, 131, 41));
label = new QLabel(CSprinklerDeviceGuiItem);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(30, 100, 54, 17));
pushButton = new QPushButton(CSprinklerDeviceGuiItem);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(220, 20, 80, 25));
pushButton->setCheckable(true);
retranslateUi(CSprinklerDeviceGuiItem);
QMetaObject::connectSlotsByName(CSprinklerDeviceGuiItem);
} // setupUi
void retranslateUi(QWidget *CSprinklerDeviceGuiItem)
{
CSprinklerDeviceGuiItem->setWindowTitle(QCoreApplication::translate("CSprinklerDeviceGuiItem", "Form", nullptr));
SprinklerAddress->setText(QCoreApplication::translate("CSprinklerDeviceGuiItem", "Address : ", nullptr));
SprinklerFlowSpeed->setText(QCoreApplication::translate("CSprinklerDeviceGuiItem", "Flow speed :", nullptr));
label->setText(QCoreApplication::translate("CSprinklerDeviceGuiItem", "State : ", nullptr));
pushButton->setText(QCoreApplication::translate("CSprinklerDeviceGuiItem", "PushButton", nullptr));
} // retranslateUi
};
namespace Ui {
class CSprinklerDeviceGuiItem: public Ui_CSprinklerDeviceGuiItem {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_SPRINKLERDEVICEGUIITEM_H
-57
View File
@@ -1,57 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'SprinklerGui.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_SPRINKLERGUI_H
#define UI_SPRINKLERGUI_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QLabel>
#include <QtWidgets/QWidget>
#include "ToggleSwitch.h"
QT_BEGIN_NAMESPACE
class Ui_CSprinklerGui
{
public:
QLabel *label;
CToggleSwitch *mValveSwitch;
void setupUi(QWidget *CSprinklerGui)
{
if (CSprinklerGui->objectName().isEmpty())
CSprinklerGui->setObjectName(QString::fromUtf8("CSprinklerGui"));
CSprinklerGui->resize(1047, 560);
label = new QLabel(CSprinklerGui);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(20, 10, 201, 51));
mValveSwitch = new CToggleSwitch(CSprinklerGui);
mValveSwitch->setObjectName(QString::fromUtf8("mValveSwitch"));
mValveSwitch->setGeometry(QRect(220, 90, 91, 81));
retranslateUi(CSprinklerGui);
QMetaObject::connectSlotsByName(CSprinklerGui);
} // setupUi
void retranslateUi(QWidget *CSprinklerGui)
{
CSprinklerGui->setWindowTitle(QCoreApplication::translate("CSprinklerGui", "Form", nullptr));
label->setText(QCoreApplication::translate("CSprinklerGui", "Sprinklers network", nullptr));
} // retranslateUi
};
namespace Ui {
class CSprinklerGui: public Ui_CSprinklerGui {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_SPRINKLERGUI_H
-66
View File
@@ -1,66 +0,0 @@
/********************************************************************************
** Form generated from reading UI file 'TowerLightShowGui.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_TOWERLIGHTSHOWGUI_H
#define UI_TOWERLIGHTSHOWGUI_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CTowerLightShowGui
{
public:
QLabel *label;
QWidget *mLightCtrlWidget;
QPushButton *pushButton;
void setupUi(QDialog *CTowerLightShowGui)
{
if (CTowerLightShowGui->objectName().isEmpty())
CTowerLightShowGui->setObjectName(QString::fromUtf8("CTowerLightShowGui"));
CTowerLightShowGui->resize(1694, 658);
label = new QLabel(CTowerLightShowGui);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(470, 20, 171, 31));
QFont font;
font.setPointSize(16);
label->setFont(font);
mLightCtrlWidget = new QWidget(CTowerLightShowGui);
mLightCtrlWidget->setObjectName(QString::fromUtf8("mLightCtrlWidget"));
mLightCtrlWidget->setGeometry(QRect(39, 119, 1621, 531));
pushButton = new QPushButton(CTowerLightShowGui);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(40, 100, 75, 23));
retranslateUi(CTowerLightShowGui);
QMetaObject::connectSlotsByName(CTowerLightShowGui);
} // setupUi
void retranslateUi(QDialog *CTowerLightShowGui)
{
CTowerLightShowGui->setWindowTitle(QCoreApplication::translate("CTowerLightShowGui", "Dialog", nullptr));
label->setText(QCoreApplication::translate("CTowerLightShowGui", "Tower Light Show", nullptr));
pushButton->setText(QCoreApplication::translate("CTowerLightShowGui", "PushButton", nullptr));
} // retranslateUi
};
namespace Ui {
class CTowerLightShowGui: public Ui_CTowerLightShowGui {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TOWERLIGHTSHOWGUI_H
+57
View File
@@ -0,0 +1,57 @@
/********************************************************************************
** Form generated from reading UI file 'TrayVolumeCtrl.ui'
**
** Created by: Qt User Interface Compiler version 5.14.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_TRAYVOLUMECTRL_H
#define UI_TRAYVOLUMECTRL_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QSlider>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_CTrayVolumeCtrl
{
public:
QSlider *horizontalSlider;
QSlider *horizontalSlider_2;
void setupUi(QWidget *CTrayVolumeCtrl)
{
if (CTrayVolumeCtrl->objectName().isEmpty())
CTrayVolumeCtrl->setObjectName(QString::fromUtf8("CTrayVolumeCtrl"));
CTrayVolumeCtrl->resize(441, 147);
horizontalSlider = new QSlider(CTrayVolumeCtrl);
horizontalSlider->setObjectName(QString::fromUtf8("horizontalSlider"));
horizontalSlider->setGeometry(QRect(70, 40, 160, 16));
horizontalSlider->setOrientation(Qt::Horizontal);
horizontalSlider_2 = new QSlider(CTrayVolumeCtrl);
horizontalSlider_2->setObjectName(QString::fromUtf8("horizontalSlider_2"));
horizontalSlider_2->setGeometry(QRect(70, 70, 160, 16));
horizontalSlider_2->setOrientation(Qt::Horizontal);
retranslateUi(CTrayVolumeCtrl);
QMetaObject::connectSlotsByName(CTrayVolumeCtrl);
} // setupUi
void retranslateUi(QWidget *CTrayVolumeCtrl)
{
CTrayVolumeCtrl->setWindowTitle(QCoreApplication::translate("CTrayVolumeCtrl", "Form", nullptr));
} // retranslateUi
};
namespace Ui {
class CTrayVolumeCtrl: public Ui_CTrayVolumeCtrl {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TRAYVOLUMECTRL_H