Création des brokers fonctionnelle
This commit is contained in:
@@ -96,23 +96,49 @@ CLoggingSettingsPage::CLoggingSettingsPage(QWidget *parent) :
|
||||
connect(ui->mDevicePresChangeParamsBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::DevicePresenceModifyParamsBtnPressed);
|
||||
connect(ui->mDevicePresCancelBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::DevicePresenceCancelBtnPressed);
|
||||
|
||||
connect(ui->mAddMQTTBrokerBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::AddMQTTBrokerBtnPressed);
|
||||
connect(ui->mDeleteMQTTBrokerBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::DeleteMQTTBrokerBtnPressed);
|
||||
connect(ui->mMQTTBrokersList,&QListWidget::itemSelectionChanged,this,&CLoggingSettingsPage::MQTTBrokerSelected);
|
||||
|
||||
}
|
||||
|
||||
CLoggingSettingsPage::~CLoggingSettingsPage()
|
||||
{
|
||||
while(mCloudParams.size() != 0)
|
||||
{
|
||||
delete mCloudParams.takeAt(0);
|
||||
}
|
||||
delete ui;
|
||||
}
|
||||
|
||||
int CLoggingSettingsPage::SetCloudParams(const CCloudParams *CloudParams)
|
||||
int CLoggingSettingsPage::SetCloudParams(QList<CCloudParams *> *CloudParams)
|
||||
{
|
||||
if(CloudParams == 0)
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCloudParams = *CloudParams;
|
||||
while(mCloudParams.size() != 0)
|
||||
{
|
||||
delete mCloudParams.takeAt(0);
|
||||
}
|
||||
|
||||
UpdateCloudConfig();
|
||||
for(int i = 0; i < CloudParams->size(); i++)
|
||||
{
|
||||
CCloudParams *NewBrokerParam = new CCloudParams;
|
||||
*NewBrokerParam = *CloudParams->at(i);
|
||||
mCloudParams.append(NewBrokerParam);
|
||||
}
|
||||
|
||||
if(mCloudParams.size() != 0)
|
||||
{
|
||||
for(int i = 0; i < mCloudParams.size(); i++)
|
||||
{
|
||||
ui->mMQTTBrokersList->insertItem(i,mCloudParams.at(i)->mMQTTBrokerHostName);
|
||||
ui->mMQTTBrokersList->setCurrentRow(0);
|
||||
}
|
||||
// UpdateCloudConfig();
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@@ -173,6 +199,7 @@ void CLoggingSettingsPage::ModifyParamsBtnPressed()
|
||||
ui->mCloudMQTTRefreshRateSpinBx->setEnabled(true);
|
||||
ui->mCloudMQTTClientID->setEnabled(true);
|
||||
ui->mChangeParamsBtn->setText("Appliquer");
|
||||
ui->mMQTTBrokersList->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,26 +213,41 @@ void CLoggingSettingsPage::ModifyParamsBtnPressed()
|
||||
ui->mCloudMQTTUserNameEdit->setEnabled(false);
|
||||
ui->mCloudMQTTRefreshRateSpinBx->setEnabled(false);
|
||||
ui->mCloudMQTTClientID->setEnabled(false);
|
||||
ui->mMQTTBrokersList->setEnabled(true);
|
||||
|
||||
|
||||
mCloudParams.mMQTTBrokerHostName = ui->mCloudMQTTHostNameEdit->text();
|
||||
mCloudParams.mMQTTBrokerPassword = ui->mCloudMQTTPasswordEdit->text();
|
||||
mCloudParams.mMQTTBrokerPort = (quint32)ui->mCloudMQTTPortSpinBx->value();
|
||||
mCloudParams.mMQTTTopicPrefix = ui->mCloudMQTTTopicPrefixEdit->text();
|
||||
if(mCloudParams.mMQTTTopicPrefix.isEmpty() == false)
|
||||
|
||||
int index = ui->mMQTTBrokersList->currentRow();
|
||||
|
||||
if(index < 0 || index >= mCloudParams.size())
|
||||
{
|
||||
if(mCloudParams.mMQTTTopicPrefix.endsWith("/") == false)
|
||||
qDebug("Big problem in LoggingSettingsPage : invalid broker index");
|
||||
return;
|
||||
}
|
||||
CCloudParams *BrokerParams;
|
||||
BrokerParams = mCloudParams[index];
|
||||
|
||||
BrokerParams->mMQTTBrokerHostName = ui->mCloudMQTTHostNameEdit->text();
|
||||
BrokerParams->mMQTTBrokerPassword = ui->mCloudMQTTPasswordEdit->text();
|
||||
BrokerParams->mMQTTBrokerPort = (quint32)ui->mCloudMQTTPortSpinBx->value();
|
||||
BrokerParams->mMQTTTopicPrefix = ui->mCloudMQTTTopicPrefixEdit->text();
|
||||
if(BrokerParams->mMQTTTopicPrefix.isEmpty() == false)
|
||||
{
|
||||
if(BrokerParams->mMQTTTopicPrefix.endsWith("/") == false)
|
||||
{
|
||||
mCloudParams.mMQTTTopicPrefix.append("/");
|
||||
ui->mCloudMQTTTopicPrefixEdit->setText(mCloudParams.mMQTTTopicPrefix);
|
||||
BrokerParams->mMQTTTopicPrefix.append("/");
|
||||
ui->mCloudMQTTTopicPrefixEdit->setText(BrokerParams->mMQTTTopicPrefix);
|
||||
}
|
||||
}
|
||||
mCloudParams.mMQTTBrokerUserName = ui->mCloudMQTTUserNameEdit->text();
|
||||
mCloudParams.mMQTTTransmitTimeout = (quint32)ui->mCloudMQTTRefreshRateSpinBx->value();
|
||||
mCloudParams.mMQTTClientID = ui->mCloudMQTTClientID->text();
|
||||
BrokerParams->mMQTTBrokerUserName = ui->mCloudMQTTUserNameEdit->text();
|
||||
BrokerParams->mMQTTTransmitTimeout = (quint32)ui->mCloudMQTTRefreshRateSpinBx->value();
|
||||
BrokerParams->mMQTTClientID = ui->mCloudMQTTClientID->text();
|
||||
ui->mMQTTBrokersList->item(index)->setText(BrokerParams->mMQTTBrokerHostName);
|
||||
|
||||
mProgramHandle->SaveCloudLoggingConfigRequest(&mCloudParams);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,19 +262,27 @@ void CLoggingSettingsPage::CancelBtnPressed()
|
||||
ui->mCloudMQTTUserNameEdit->setEnabled(false);
|
||||
ui->mCloudMQTTRefreshRateSpinBx->setEnabled(false);
|
||||
ui->mCloudMQTTClientID->setEnabled(false);
|
||||
ui->mMQTTBrokersList->setEnabled(true);
|
||||
|
||||
UpdateCloudConfig();
|
||||
}
|
||||
|
||||
int CLoggingSettingsPage::UpdateCloudConfig()
|
||||
{
|
||||
ui->mCloudMQTTHostNameEdit->setText(mCloudParams.mMQTTBrokerHostName);
|
||||
ui->mCloudMQTTPasswordEdit->setText(mCloudParams.mMQTTBrokerPassword);
|
||||
ui->mCloudMQTTPortSpinBx->setValue(mCloudParams.mMQTTBrokerPort);
|
||||
ui->mCloudMQTTTopicPrefixEdit->setText(mCloudParams.mMQTTTopicPrefix);
|
||||
ui->mCloudMQTTUserNameEdit->setText(mCloudParams.mMQTTBrokerUserName);
|
||||
ui->mCloudMQTTRefreshRateSpinBx->setValue(mCloudParams.mMQTTTransmitTimeout);
|
||||
ui->mCloudMQTTClientID->setText(mCloudParams.mMQTTClientID);
|
||||
int index = ui->mMQTTBrokersList->currentRow();
|
||||
if(index < 0 || index >= mCloudParams.size())
|
||||
{
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
CCloudParams *BrokerParams = mCloudParams.at(index);
|
||||
|
||||
ui->mCloudMQTTHostNameEdit->setText(BrokerParams->mMQTTBrokerHostName);
|
||||
ui->mCloudMQTTPasswordEdit->setText(BrokerParams->mMQTTBrokerPassword);
|
||||
ui->mCloudMQTTPortSpinBx->setValue(BrokerParams->mMQTTBrokerPort);
|
||||
ui->mCloudMQTTTopicPrefixEdit->setText(BrokerParams->mMQTTTopicPrefix);
|
||||
ui->mCloudMQTTUserNameEdit->setText(BrokerParams->mMQTTBrokerUserName);
|
||||
ui->mCloudMQTTRefreshRateSpinBx->setValue(BrokerParams->mMQTTTransmitTimeout);
|
||||
ui->mCloudMQTTClientID->setText(BrokerParams->mMQTTClientID);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
@@ -593,3 +643,45 @@ void CLoggingSettingsPage::DevicePresenceModifyParamsBtnPressed()
|
||||
mProgramHandle->SaveDeviceDetectionSettingsRequest(&mDeviceDetectConfigHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void CLoggingSettingsPage::AddMQTTBrokerBtnPressed()
|
||||
{
|
||||
CCloudParams *NewParam = new CCloudParams;
|
||||
mCloudParams.append(NewParam);
|
||||
ui->mMQTTBrokersList->addItem("Broker");
|
||||
ui->mMQTTBrokersList->setCurrentRow(ui->mMQTTBrokersList->count()-1);
|
||||
ModifyParamsBtnPressed();
|
||||
|
||||
}
|
||||
void CLoggingSettingsPage::DeleteMQTTBrokerBtnPressed()
|
||||
{
|
||||
int index = ui->mMQTTBrokersList->currentRow();
|
||||
|
||||
if(index < 0 || index >= mCloudParams.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
delete mCloudParams.takeAt(index);
|
||||
ui->mMQTTBrokersList->takeItem(index);
|
||||
if(ui->mMQTTBrokersList->count() == 0)
|
||||
{
|
||||
AddMQTTBrokerBtnPressed();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->mMQTTBrokersList->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
|
||||
void CLoggingSettingsPage::MQTTBrokerSelected()
|
||||
{
|
||||
int index = ui->mMQTTBrokersList->currentRow();
|
||||
|
||||
if(index < 0 || index >= mCloudParams.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateCloudConfig();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
explicit CLoggingSettingsPage(QWidget *parent = 0);
|
||||
~CLoggingSettingsPage();
|
||||
|
||||
int SetCloudParams(const CCloudParams *CloudParams);
|
||||
int SetCloudParams(QList<CCloudParams *> *CloudParams);
|
||||
int SetGeneralSettingsParams(const CGeneralSystemParams *GeneralParams);
|
||||
int SetCPUWatchdogSettings(const CCPUWatchdogConfig *CPUWatchdogParams);
|
||||
int SetDeviceConfigSettings(const CDeviceDetectionConfig *DevDetectCfgParams);
|
||||
@@ -43,7 +43,7 @@ private:
|
||||
Ui::CLoggingSettingsPage *ui;
|
||||
|
||||
bool EditMode;
|
||||
CCloudParams mCloudParams;
|
||||
QList<CCloudParams*> mCloudParams;
|
||||
CGeneralSystemParams mGeneralSystemParams;
|
||||
CCPUWatchdogConfig mCPUWatchdogParams;
|
||||
CDeviceDetectionConfig mDeviceDetectConfigHandle;
|
||||
@@ -63,6 +63,9 @@ public slots:
|
||||
void DevicePresenceModifyParamsBtnPressed();
|
||||
void DevicePresenceCancelBtnPressed();
|
||||
void SetInternetPresenceStatus(bool);
|
||||
void AddMQTTBrokerBtnPressed();
|
||||
void DeleteMQTTBrokerBtnPressed();
|
||||
void MQTTBrokerSelected();
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<x>220</x>
|
||||
<y>100</y>
|
||||
<width>461</width>
|
||||
<width>351</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Broker MQTT</string>
|
||||
<string>Paramètres du broker</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mCloudMQTTHostNameLbl">
|
||||
<property name="geometry">
|
||||
@@ -132,7 +132,7 @@
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>20</y>
|
||||
<width>321</width>
|
||||
<width>251</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -142,7 +142,7 @@
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>80</y>
|
||||
<width>321</width>
|
||||
<width>251</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -168,7 +168,7 @@
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>111</y>
|
||||
<width>321</width>
|
||||
<width>251</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -199,7 +199,7 @@
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>160</y>
|
||||
<width>321</width>
|
||||
<width>251</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -230,7 +230,7 @@
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>190</y>
|
||||
<width>321</width>
|
||||
<width>251</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -297,7 +297,7 @@
|
||||
<widget class="QPushButton" name="mChangeParamsBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<x>430</x>
|
||||
<y>380</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
@@ -310,7 +310,7 @@
|
||||
<widget class="QPushButton" name="mCancelBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<x>320</x>
|
||||
<y>380</y>
|
||||
<width>80</width>
|
||||
<height>22</height>
|
||||
@@ -1055,6 +1055,55 @@ et l'heure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QListWidget" name="mMQTTBrokersList">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>120</y>
|
||||
<width>181</width>
|
||||
<height>251</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>100</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Brokers MQTT</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mDeleteMQTTBrokerBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>370</y>
|
||||
<width>61</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Supprimer</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="mAddMQTTBrokerBtn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>370</y>
|
||||
<width>61</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ajouter</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user