Del (a lot!)
This commit is contained in:
@@ -7,6 +7,7 @@ CIspindel::CIspindel(CIspindelGUI *IspindelGui)
|
||||
mIspindelGui = IspindelGui;
|
||||
IspindelGui->mProgramHandle = this;
|
||||
mNetworkInterface = new CIspindelInterface(this);
|
||||
mOG = 0.0;
|
||||
|
||||
}
|
||||
|
||||
@@ -42,10 +43,12 @@ void CIspindel::IspindelFullBufferReceived(QByteArray *Data)
|
||||
|
||||
mIspindelDataList.append(NewFrame);
|
||||
}
|
||||
|
||||
mOG = mIspindelDataList.first()->mGravity;
|
||||
SetLasFrameTextInGUI(*mIspindelDataList.last());
|
||||
mIspindelGui->UpdateIspindelPlot(&mIspindelDataList);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CIspindel::IspindelLastFrameReceived(QByteArray Data)
|
||||
@@ -66,6 +69,19 @@ void CIspindel::IspindelLastFrameReceived(QByteArray Data)
|
||||
// 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()
|
||||
{
|
||||
@@ -88,8 +104,9 @@ void CIspindel::ConnectedToMaster(bool connected)
|
||||
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\nSample date time: %10\n------------------------------")\
|
||||
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)\
|
||||
@@ -98,26 +115,40 @@ void CIspindel::SetLasFrameTextInGUI(CIspindelData Frame)
|
||||
.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"));
|
||||
.arg(Frame.mSampleDateTime.toString("yyyy-MM-dd - hh:mm:ss"))\
|
||||
.arg(((Frame.mTemperature*9/5)+32));
|
||||
|
||||
mIspindelGui->SetLastIspindelFrameData(FrameText);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,13 @@ public:
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -57,6 +57,13 @@ CIspindelGUI::CIspindelGUI(QWidget *parent) :
|
||||
// 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()
|
||||
@@ -64,9 +71,10 @@ CIspindelGUI::~CIspindelGUI()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CIspindelGUI::SetLastIspindelFrameData(QString Data)
|
||||
void CIspindelGUI::SetLastIspindelFrameData(QString Data, QString ABVText)
|
||||
{
|
||||
ui->mLastFrameDataLbl->setText(Data);
|
||||
ui->mABVLabel->setText(ABVText);
|
||||
}
|
||||
|
||||
int CIspindelGUI::UpdateIspindelPlot(QList<CIspindelData *> *Data)
|
||||
@@ -98,6 +106,21 @@ int CIspindelGUI::UpdateIspindelPlot(QList<CIspindelData *> *Data)
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -106,5 +129,48 @@ 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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,18 @@ public:
|
||||
~CIspindelGUI();
|
||||
CIspindel *mProgramHandle;
|
||||
|
||||
void SetLastIspindelFrameData(QString Data);
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>20</y>
|
||||
<x>520</x>
|
||||
<y>0</y>
|
||||
<width>91</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
@@ -45,9 +45,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>50</y>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>211</height>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
@@ -65,7 +65,7 @@
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<widget class="QTableWidget" name="mSamplesTable">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
@@ -75,6 +75,52 @@
|
||||
</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/>
|
||||
|
||||
@@ -48,8 +48,14 @@ int CIspindelInterface::DeviceFrameReceived(int TargetDeviceID, int TargetDevice
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user