Ajout interface ISpindel
This commit is contained in:
@@ -134,6 +134,11 @@ int CChalet::RequestDeviceWifiParams()
|
||||
|
||||
}
|
||||
|
||||
int CChalet::RequestFirmwareVersion()
|
||||
{
|
||||
mNetworkInterface->SendMasterCtrlCommand(CHALET_INTERFACE_GET_FIRMWARE_VERSION_REQUEST,QByteArray());
|
||||
}
|
||||
|
||||
int CChalet::DeviceWiFiParamsReceived(QByteArray *Data)
|
||||
{
|
||||
quint32 Add = 0;
|
||||
@@ -169,6 +174,11 @@ int CChalet::DeviceWiFiParamsReceived(QByteArray *Data)
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CChalet::DeviceFirmwareVersionReceived(QByteArray Data)
|
||||
{
|
||||
mChaletGui->UpdateFirmwareVersion(Data);
|
||||
}
|
||||
|
||||
int CChalet::SetDeviceWifiParams(QString IP, QString Gateway)
|
||||
{
|
||||
QHostAddress DeviceIP;
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
int RequestDeviceWifiParams();
|
||||
int DeviceWiFiParamsReceived(QByteArray *Data);
|
||||
int SetDeviceWifiParams(QString IP, QString Gateway);
|
||||
int RequestFirmwareVersion();
|
||||
int DeviceFirmwareVersionReceived(QByteArray Data);
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -15,6 +15,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()));
|
||||
@@ -25,6 +34,11 @@ CChaletGui::CChaletGui(QWidget *parent) :
|
||||
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()));
|
||||
|
||||
mBatteryPlotWidget = new QCustomPlot(ui->mPlotWidget);
|
||||
mBatteryPlotWidget->resize(ui->mPlotWidget->size());
|
||||
@@ -59,12 +73,18 @@ CChaletGui::CChaletGui(QWidget *parent) :
|
||||
mBatteryPlotWidget->graph(0)->addData(now,13.5);
|
||||
|
||||
mBatteryPlotWidget->replot();
|
||||
|
||||
mFirmVersionDefaultBtnPal = ui->mGetFirmwareVersionBtn->palette();
|
||||
mWifiDefaultBtnPal = ui->mGetFirmwareVersionBtn->palette();
|
||||
|
||||
}
|
||||
|
||||
CChaletGui::~CChaletGui()
|
||||
{
|
||||
delete ui;
|
||||
delete mBatteryPlotWidget;
|
||||
delete mGetFimwVersionButtonColorTimer;
|
||||
delete mGetWifiParamsButtonColorTimer;
|
||||
}
|
||||
|
||||
int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
|
||||
@@ -87,7 +107,8 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
|
||||
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->mSolarPanelCurrentLabel->setText("Raw Solar Panel Current: Unknown");
|
||||
ui->mSolarPanelCurrentCnvLbl->setText("Solar Panel Current (A): Unknown");
|
||||
ui->mLostReqPercentLbl->setText("N/A");
|
||||
ui->mChaletTemperatureLbl->setText("Temperature: -100)");
|
||||
|
||||
@@ -186,9 +207,17 @@ int CChaletGui::UpdateChaletStatus(CChaletMainStatus Status)
|
||||
QString Voltage = QString("Battery Voltage: %1").arg(Status.mBatteryVoltage);
|
||||
ui->mBatteryVoltageLabel->setText(Voltage);
|
||||
|
||||
QString Current = QString("Solar Panel Current: %1").arg(Status.mBatteryCurrent);
|
||||
QString Current = QString("Raw Solar Panel Current: %1").arg(Status.mBatteryCurrent);
|
||||
ui->mSolarPanelCurrentLabel->setText(Current);
|
||||
|
||||
float ConvertedCurrent = (float)Status.mBatteryCurrent * (3.3/1023); //*0.080645; // 3.3/(1023*0.04) = 0.080645;
|
||||
ConvertedCurrent -= (3.3/2);
|
||||
ConvertedCurrent *= 25;
|
||||
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);
|
||||
|
||||
@@ -331,4 +360,60 @@ void CChaletGui::RebootCPUButtonClicked()
|
||||
{
|
||||
ui->mWiFiIPAddressEditBx->setText(IP.toString());
|
||||
ui->mWiFiGatewayAddressEditBx->setText(Gateway.toString());
|
||||
|
||||
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::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::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\"");
|
||||
}
|
||||
|
||||
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\"");
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
int UpdateChaletStatus(CChaletMainStatus Status);
|
||||
int UpdateChaletLogPlot(QByteArray* Log);
|
||||
int ChaletCommActivity();
|
||||
QTimer *mGetWifiParamsButtonColorTimer, *mGetFimwVersionButtonColorTimer;
|
||||
QPalette mFirmVersionDefaultBtnPal, mWifiDefaultBtnPal;
|
||||
|
||||
private:
|
||||
Ui::CChaletGui *ui;
|
||||
@@ -42,6 +44,14 @@ public slots:
|
||||
void GetDeviceWiFiParamsButtonClicked(bool);
|
||||
void SetDeviceWiFiParamsButtonClicked(bool);
|
||||
void UpdateDeviceWiFiParameters(QHostAddress IP,QHostAddress Gateway);
|
||||
void GetFirmwareVersionBtnClicked();
|
||||
void UpdateFirmwareVersion(QByteArray Version);
|
||||
void StartSyslogShellBtnClicked();
|
||||
void StartTerminalShellBtnClicked();
|
||||
void GetWifiParamsBtnColorTimerExpired();
|
||||
void GetFirmwVersionBtnColorTimerExpired();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CHALETGUI_H
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1024</width>
|
||||
<height>598</height>
|
||||
<width>1443</width>
|
||||
<height>662</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -236,14 +236,14 @@
|
||||
</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>187</x>
|
||||
<y>280</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>187</x>
|
||||
<y>300</y>
|
||||
<x>190</x>
|
||||
<y>320</y>
|
||||
<width>241</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@@ -283,7 +283,7 @@
|
||||
<rect>
|
||||
<x>420</x>
|
||||
<y>240</y>
|
||||
<width>571</width>
|
||||
<width>1021</width>
|
||||
<height>321</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -341,7 +341,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>320</y>
|
||||
<y>340</y>
|
||||
<width>241</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@@ -457,6 +457,76 @@
|
||||
<string>WiFi parameters (stored in flash)</string>
|
||||
</property>
|
||||
</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>180</x>
|
||||
<y>520</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>90</x>
|
||||
<y>520</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>60</x>
|
||||
<y>590</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>150</x>
|
||||
<y>590</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Syslog</string>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>groupBox_2</zorder>
|
||||
<zorder>groupBox</zorder>
|
||||
<zorder>MainPageLabel</zorder>
|
||||
@@ -488,6 +558,11 @@
|
||||
<zorder>label</zorder>
|
||||
<zorder>mWiFiGatewayAddressEditBx</zorder>
|
||||
<zorder>label_2</zorder>
|
||||
<zorder>mSolarPanelCurrentCnvLbl</zorder>
|
||||
<zorder>mFirmwareVersionLabel</zorder>
|
||||
<zorder>mGetFirmwareVersionBtn</zorder>
|
||||
<zorder>mStartTerminalShellBtn</zorder>
|
||||
<zorder>mStartSyslogShellBtn</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -94,6 +94,11 @@ int CChaletMasterCtrlInterface::DeviceFrameReceived(int TargetDeviceID, int Targ
|
||||
{
|
||||
break;
|
||||
}
|
||||
case CHALET_INTERFACE_GET_FIRMWARE_VERSION_RESPONSE:
|
||||
{
|
||||
mProgramHandle->DeviceFirmwareVersionReceived(Data);
|
||||
break;
|
||||
}
|
||||
case CHALET_INTERFACE_GENERAL_STATUS_REQUEST:
|
||||
case CHALET_INTERFACE_AC_POWER_STATE_STATUS_REQUEST:
|
||||
case CHALET_INTERFACE_AC_POWER_SET_STATE_REQUEST:
|
||||
|
||||
Reference in New Issue
Block a user