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:
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@ CGuiMain::CGuiMain(QWidget *parent)
|
||||
mAvReceiverGui = new CAvReceiverGui(this);
|
||||
mMainTabWidget = new QTabWidget(this);
|
||||
mChaletGui = new CChaletGui(this);
|
||||
mIspindelGui = new CIspindelGUI(this);
|
||||
mTowerLightShowGui = new CTowerLightShowGui;
|
||||
mPICUploaderGui = new CPICUploaderGui;
|
||||
setCentralWidget(mMainTabWidget);
|
||||
@@ -18,8 +19,9 @@ CGuiMain::CGuiMain(QWidget *parent)
|
||||
mMainTabWidget->addTab(mChaletGui,"Chalet");
|
||||
mMainTabWidget->addTab(mTowerLightShowGui,"Lightshow");
|
||||
mMainTabWidget->addTab(mPICUploaderGui,"Firmware Upload");
|
||||
mMainTabWidget->addTab(mIspindelGui,"ISpindel");
|
||||
|
||||
resize(1024,768);
|
||||
resize(1700,768);
|
||||
}
|
||||
|
||||
CGuiMain::~CGuiMain()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "ChaletGui.h"
|
||||
#include "TowerLightShowGui.h"
|
||||
#include "PICUploaderGui.h"
|
||||
#include "IspindelGUI.h"
|
||||
|
||||
class CGuiMain : public QMainWindow
|
||||
{
|
||||
@@ -26,6 +27,7 @@ public:
|
||||
QTabWidget *mMainTabWidget;
|
||||
CTowerLightShowGui *mTowerLightShowGui;
|
||||
CPICUploaderGui *mPICUploaderGui;
|
||||
CIspindelGUI *mIspindelGui;
|
||||
int RespawnMainWindow();
|
||||
int HideMainWindow();
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
#include "Ispindel.h"
|
||||
#include <QDataStream>
|
||||
#include "IspindelInterface.h"
|
||||
|
||||
CIspindel::CIspindel(CIspindelGUI *IspindelGui)
|
||||
{
|
||||
mIspindelGui = IspindelGui;
|
||||
IspindelGui->mProgramHandle = this;
|
||||
mNetworkInterface = new CIspindelInterface(this);
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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\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"));
|
||||
// FrameText = QString("\nLast Frame\n\
|
||||
// Angle: %1\n\
|
||||
// Battery Voltage: %2\n\
|
||||
// Gravity: %3\n\
|
||||
// Sample Interval: %4\n\
|
||||
// Ispindel ID: %5\n\
|
||||
// Ispindel Name: %6\n\
|
||||
// RSSI: %7\n\
|
||||
// Temperature: %8%9\n\
|
||||
// Sample date time: %10")\
|
||||
// .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"));
|
||||
|
||||
mIspindelGui->SetLastIspindelFrameData(FrameText);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#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);
|
||||
|
||||
QList<CIspindelData*> mIspindelDataList;
|
||||
CIspindelInterface *mNetworkInterface;
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // ISPINDEL_H
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,110 @@
|
||||
#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();
|
||||
}
|
||||
|
||||
CIspindelGUI::~CIspindelGUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CIspindelGUI::SetLastIspindelFrameData(QString Data)
|
||||
{
|
||||
ui->mLastFrameDataLbl->setText(Data);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
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);
|
||||
|
||||
mIspindelPlot->replot();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#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);
|
||||
int UpdateIspindelPlot(QList<CIspindelData*> *Data);
|
||||
int NewIspindelFrameReceived(CIspindelData *Data);
|
||||
|
||||
QCustomPlot *mIspindelPlot;
|
||||
|
||||
private:
|
||||
Ui::CIspindelGUI *ui;
|
||||
};
|
||||
|
||||
#endif // ISPINDELGUI_H
|
||||
@@ -0,0 +1,81 @@
|
||||
<?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>510</x>
|
||||
<y>20</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>50</y>
|
||||
<width>381</width>
|
||||
<height>211</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="tableWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>290</y>
|
||||
<width>461</width>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,64 @@
|
||||
#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_GET_FULL_DATA_BUFFER_REQUEST:
|
||||
case ISPINDLE_LATEST_DATA_REQUEST:
|
||||
default:
|
||||
{
|
||||
qDebug("Ispindel: Invalid Ethernet Msg received from MasterCtrl: %d",MessageID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -56,7 +56,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>192.168.50.126</string>
|
||||
<string>192.168.30.125</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mOpenedHexFilePathLbl">
|
||||
|
||||
+15
-1
@@ -59,10 +59,11 @@ enum DEVICES_IDS
|
||||
ID_DEADBOLT_INTERFACE,
|
||||
ID_AVRECEIVER_INTERFACE,
|
||||
ID_CHALET_INTERFACE,
|
||||
ID_CHALET_DEVICE,
|
||||
ID_ISPINDEL_INTERFACE,
|
||||
ID_NB_DEVICE_ID
|
||||
|
||||
};
|
||||
|
||||
// Commands definitions
|
||||
|
||||
enum MASTER_CMD
|
||||
@@ -273,6 +274,8 @@ enum CHALET_INTERFACE_CMDS
|
||||
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,
|
||||
|
||||
|
||||
MAX_CHALET_INTERFACE_CMD
|
||||
@@ -342,4 +345,15 @@ enum BOOTLOADER_CMDS
|
||||
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,
|
||||
|
||||
MAX_ISPINDLE_CMDS
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,7 @@ CSystemGui::CSystemGui(QObject *parent) : QObject(parent)
|
||||
mAvReceiver = new CAvReceiver(mGui->mAvReceiverGui);
|
||||
mChalet = new CChalet(mGui->mChaletGui);
|
||||
mPICUploader = new CPICUploader(mGui->mPICUploaderGui);
|
||||
mIspindel = new CIspindel(mGui->mIspindelGui);
|
||||
|
||||
mSysTrayMgr = new CSystemTrayManager();
|
||||
mSysTrayMgr->mProgramHandle=this;
|
||||
@@ -26,6 +27,7 @@ CSystemGui::~CSystemGui()
|
||||
delete mAvReceiver;
|
||||
delete mChalet;
|
||||
delete mPICUploader;
|
||||
delete mIspindel;
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +39,7 @@ void CSystemGui::Start()
|
||||
mAvReceiver->Start();
|
||||
mChalet->Start();
|
||||
mPICUploader->Start();
|
||||
mIspindel->Start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "AvReceiver.h"
|
||||
#include "CChalet.h"
|
||||
#include "PICUploader.h"
|
||||
#include "Ispindel.h"
|
||||
|
||||
|
||||
class CSystemGui : public QObject
|
||||
@@ -37,6 +38,7 @@ private:
|
||||
CAvReceiver *mAvReceiver;
|
||||
CChalet *mChalet;
|
||||
CPICUploader *mPICUploader;
|
||||
CIspindel *mIspindel;
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user