Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit 79db298

Browse files
authored
Merge pull request #7 from Yang-Wu-Altran/master
Bug fix and new function: playback supports both sensor data and grou…
2 parents 5f8c8b9 + e845b03 commit 79db298

File tree

9 files changed

+188
-53
lines changed

9 files changed

+188
-53
lines changed

include/appconfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ class AppConfig
2222
QString ch1PortNum_;
2323
DataType ch1DataType_;
2424
QString ch1LoadFile_;
25+
DataType ch1PlaybackDataType_;
2526
int ch1DeltaDelay_;
2627

2728
QString ch2IPAddress_;
2829
QString ch2PortNum_;
2930
DataType ch2DataType_;
3031
QString ch2LoadFile_;
32+
DataType ch2PlaybackDataType_;
3133
int ch2DeltaDelay_;
3234

3335
bool combineChannel_;

include/mainwindow.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ class MainWindow : public QMainWindow
4141

4242
void ConnectRequested(const QString& ipAddress,
4343
const QString& port,
44-
const DataType& dataType);
44+
const DataType dataType);
4545

4646
void ConnectRequested2(const QString& ipAddress,
4747
const QString& port,
48-
const DataType& dataType);
48+
const DataType dataType);
4949

50-
void StartPlaybackRequested(const QString& fileName);
51-
void StartPlaybackRequested2(const QString& fileName);
50+
void StartPlaybackRequested(const QString& fileName,
51+
const DataType dataType);
52+
53+
void StartPlaybackRequested2(const QString& fileName,
54+
const DataType dataType);
5255

5356
public slots:
5457
void EnableExport(bool enable);
@@ -108,6 +111,9 @@ class MainWindow : public QMainWindow
108111

109112

110113
private:
114+
115+
void closeEvent(QCloseEvent * event);
116+
111117
void ConnectSignalsToSlots();
112118
void EnableSrcRadioButton(bool enable);
113119
void EnableSrcRadioButton2(bool enable);

include/osireader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class OsiReader: public QObject, public IMessageSource
3838
const DataType datatype);
3939

4040
public slots:
41-
void StartReadFile(const QString& osiFileName);
41+
void StartReadFile(const QString& osiFileName, const DataType dataType);
4242
void StopReadFile();
4343
void SliderValueChanged(int newValue);
4444

@@ -70,7 +70,7 @@ class OsiReader: public QObject, public IMessageSource
7070
const int* const deltaDelay_;
7171

7272
// read from input file: data type is always SensorData
73-
const DataType defaultDatatype_ = DataType::Groundtruth;
73+
DataType defaultDatatype_ = DataType::Groundtruth;
7474
const QString defaultHeaderPrifix_ = "Header_";
7575
};
7676

include/tcpreceiver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ class TCPReceiver : public QObject, public IMessageSource
3232

3333
public slots:
3434
void DisconnectRequested();
35-
void ConnectRequested(QString ipAddress, QString port, DataType dataType);
35+
void ConnectRequested(const QString& ipAddress,
36+
const QString& port,
37+
DataType dataType);
3638

3739
private:
3840

src/appconfig.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ AppConfig::AppConfig(QString fileName)
1111
, ch1PortNum_("")
1212
, ch1DataType_(DataType::Groundtruth)
1313
, ch1LoadFile_("")
14+
, ch1PlaybackDataType_(DataType::Groundtruth)
1415
, ch1DeltaDelay_(0)
1516

1617
, ch2IPAddress_("")
1718
, ch2PortNum_("")
1819
, ch2DataType_(DataType::Groundtruth)
1920
, ch2LoadFile_("")
21+
, ch2PlaybackDataType_(DataType::Groundtruth)
2022
, ch2DeltaDelay_(0)
2123

2224
, combineChannel_(false)
@@ -55,12 +57,14 @@ AppConfig::Load()
5557
ch1PortNum_ = root.elementsByTagName("CH1PortNumber").at(0).toElement().text();
5658
ch1DataType_ = (DataType)root.elementsByTagName("CH1DataType").at(0).toElement().text().toInt();
5759
ch1LoadFile_ = root.elementsByTagName("CH1LoadFile").at(0).toElement().text();
60+
ch1PlaybackDataType_ = (DataType)root.elementsByTagName("CH1PlaybackDataType").at(0).toElement().text().toInt();
5861
ch1DeltaDelay_ = root.elementsByTagName("CH1DeltaDelay").at(0).toElement().text().toInt();
5962

6063
ch2IPAddress_ = root.elementsByTagName("CH2IpAddress").at(0).toElement().text();
6164
ch2PortNum_ = root.elementsByTagName("CH2PortNumber").at(0).toElement().text();
6265
ch2DataType_ = (DataType)root.elementsByTagName("CH2DataType").at(0).toElement().text().toInt();
6366
ch2LoadFile_ = root.elementsByTagName("CH2LoadFile").at(0).toElement().text();
67+
ch2PlaybackDataType_ = (DataType)root.elementsByTagName("CH2PlaybackDataType").at(0).toElement().text().toInt();
6468
ch2DeltaDelay_ = root.elementsByTagName("CH2DeltaDelay").at(0).toElement().text().toInt();
6569

6670
combineChannel_ = root.elementsByTagName("CombineChannel").at(0).toElement().text() == "1" ? true : false;
@@ -103,12 +107,14 @@ AppConfig::Save()
103107
writer.writeTextElement("CH1PortNumber", ch1PortNum_);
104108
writer.writeTextElement("CH1DataType", QString::number(static_cast<int>(ch1DataType_)));
105109
writer.writeTextElement("CH1LoadFile", ch1LoadFile_);
110+
writer.writeTextElement("CH1PlaybackDataType", QString::number(static_cast<int>(ch1PlaybackDataType_)));
106111
writer.writeTextElement("CH1DeltaDelay", QString::number(static_cast<int>(ch1DeltaDelay_)));
107112

108113
writer.writeTextElement("CH2IpAddress", ch2IPAddress_);
109114
writer.writeTextElement("CH2PortNumber", ch2PortNum_);
110115
writer.writeTextElement("CH2DataType", QString::number(static_cast<int>(ch2DataType_)));
111116
writer.writeTextElement("CH2LoadFile", ch2LoadFile_);
117+
writer.writeTextElement("CH2PlaybackDataType", QString::number(static_cast<int>(ch2PlaybackDataType_)));
112118
writer.writeTextElement("CH2DeltaDelay", QString::number(static_cast<int>(ch2DeltaDelay_)));
113119

114120
writer.writeTextElement("CombineChannel", QString::number(combineChannel_));

src/mainwindow.cpp

Lines changed: 87 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -326,29 +326,37 @@ MainWindow::CheckFieldsValidity()
326326
bool success (true);
327327
QString errMsg;
328328

329-
// IP address
330-
QHostAddress ipAddress;
331-
if(ipAddress.setAddress(ui_->ipAddress->text()) == false)
329+
if(isSrcConnection_)
332330
{
333-
errMsg += " Invalid IP address!\n";
334-
}
335-
336-
// Port number
337-
ui_->portNumber->text().toUInt(&success);
338-
if(success == false)
339-
errMsg += " Port number should be valid integer!\n";
331+
// IP address
332+
QHostAddress ipAddress;
333+
if(ipAddress.setAddress(ui_->ipAddress->text()) == false)
334+
{
335+
errMsg += " Invalid IP address!\n";
336+
}
340337

341-
// Load file
342-
if(QFileInfo::exists(ui_->loadFile->text()) == false)
343-
{
344-
success = false;
345-
errMsg += " Load file doesn't exist!\n";
338+
// Port number
339+
ui_->portNumber->text().toUInt(&success);
340+
if(success == false)
341+
errMsg += " Port number should be valid integer!\n";
346342
}
343+
else
344+
{
345+
// Load file
346+
if(QFileInfo::exists(ui_->loadFile->text()) == false)
347+
{
348+
success = false;
349+
errMsg += " Load file doesn't exist!\n";
350+
}
347351

348-
// Delta delay
349-
ui_->deltaDelay->text().toUInt(&success);
350-
if(success == false)
351-
errMsg += " Port number should be valid positive integer!\n";
352+
// Delta delay
353+
if(ui_->deltaDelay->text().isEmpty() == false)
354+
{
355+
ui_->deltaDelay->text().toUInt(&success);
356+
if(success == false)
357+
errMsg += " Port number should be valid positive integer!\n";
358+
}
359+
}
352360

353361
if(errMsg.isEmpty() == false)
354362
{
@@ -365,29 +373,37 @@ MainWindow::CheckFieldsValidity2()
365373
bool success (true);
366374
QString errMsg;
367375

368-
// IP address
369-
QHostAddress ipAddress;
370-
if(ipAddress.setAddress(ui_->ipAddress_2->text()) == false)
376+
if(isSrcConnection2_)
371377
{
372-
errMsg += " Invalid IP address!\n";
373-
}
374-
375-
// Port number
376-
ui_->portNumber_2->text().toUInt(&success);
377-
if(success == false)
378-
errMsg += " Port number should be valid integer!\n";
378+
// IP address
379+
QHostAddress ipAddress;
380+
if(ipAddress.setAddress(ui_->ipAddress_2->text()) == false)
381+
{
382+
errMsg += " Invalid IP address!\n";
383+
}
379384

380-
// Load file
381-
if(QFileInfo::exists(ui_->loadFile_2->text()) == false)
382-
{
383-
success = false;
384-
errMsg += " Load file doesn't exist!\n";
385+
// Port number
386+
ui_->portNumber_2->text().toUInt(&success);
387+
if(success == false)
388+
errMsg += " Port number should be valid integer!\n";
385389
}
390+
else
391+
{
392+
// Load file
393+
if(QFileInfo::exists(ui_->loadFile_2->text()) == false)
394+
{
395+
success = false;
396+
errMsg += " Load file doesn't exist!\n";
397+
}
386398

387-
// Delta delay
388-
ui_->deltaDelay_2->text().toUInt(&success);
389-
if(success == false)
390-
errMsg += " Port number should be valid positive integer!\n";
399+
// Delta delay
400+
if(ui_->deltaDelay_2->text().isEmpty() == false)
401+
{
402+
ui_->deltaDelay_2->text().toUInt(&success);
403+
if(success == false)
404+
errMsg += " Port number should be valid positive integer!\n";
405+
}
406+
}
391407

392408
if(errMsg.isEmpty() == false)
393409
{
@@ -600,6 +616,7 @@ MainWindow::EnablePlaybackGroup1(bool enable)
600616
{
601617
ui_->loadFile->setEnabled(enable);
602618
ui_->loadFileBrowse->setEnabled(enable);
619+
ui_->playbackDataType->setEnabled(enable);
603620
ui_->deltaDelay->setEnabled(enable);
604621
}
605622

@@ -608,6 +625,7 @@ MainWindow::EnablePlaybackGroup2(bool enable)
608625
{
609626
ui_->loadFile_2->setEnabled(enable);
610627
ui_->loadFileBrowse_2->setEnabled(enable);
628+
ui_->playbackDataType_2->setEnabled(enable);
611629
ui_->deltaDelay_2->setEnabled(enable);
612630
}
613631

@@ -764,6 +782,12 @@ MainWindow::UpdateConfigure()
764782
config_.ch1LoadFile_ = ui_->loadFile->text();
765783
}
766784

785+
if(config_.ch1PlaybackDataType_ != (DataType)ui_->playbackDataType->currentIndex())
786+
{
787+
hasChange = true;
788+
config_.ch1PlaybackDataType_ = (DataType)ui_->playbackDataType->currentIndex();
789+
}
790+
767791
if(hasChange)
768792
config_.Save();
769793

@@ -804,6 +828,12 @@ MainWindow::UpdateConfigure2()
804828
config_.ch2LoadFile_ = ui_->loadFile_2->text();
805829
}
806830

831+
if(config_.ch2PlaybackDataType_ != (DataType)ui_->playbackDataType_2->currentIndex())
832+
{
833+
hasChange = true;
834+
config_.ch2PlaybackDataType_ = (DataType)ui_->playbackDataType_2->currentIndex();
835+
}
836+
807837
if(hasChange)
808838
config_.Save();
809839

@@ -824,12 +854,14 @@ MainWindow::InitLoadConfigure()
824854
ui_->portNumber->setText(config_.ch1PortNum_);
825855
ui_->dataType->setCurrentIndex( static_cast<int>(config_.ch1DataType_) );
826856
ui_->loadFile->setText(config_.ch1LoadFile_);
857+
ui_->playbackDataType->setCurrentIndex( static_cast<int>(config_.ch1PlaybackDataType_) );
827858
ui_->deltaDelay->setText(QString::number(config_.ch1DeltaDelay_));
828859

829860
ui_->ipAddress_2->setText(config_.ch2IPAddress_);
830861
ui_->portNumber_2->setText(config_.ch2PortNum_);
831862
ui_->dataType_2->setCurrentIndex( static_cast<int>(config_.ch2DataType_) );
832863
ui_->loadFile_2->setText(config_.ch2LoadFile_);
864+
ui_->playbackDataType_2->setCurrentIndex( static_cast<int>(config_.ch2PlaybackDataType_) );
833865
ui_->deltaDelay_2->setText(QString::number(config_.ch2DeltaDelay_));
834866

835867
ui_->actionShowGrid->setChecked(config_.showGrid_);
@@ -866,6 +898,11 @@ MainWindow::InitComboBoxes()
866898
ui_->dataType->addItem("SensorData");
867899
ui_->dataType_2->addItem("GroundTruth");
868900
ui_->dataType_2->addItem("SensorData");
901+
902+
ui_->playbackDataType->addItem("GroundTruth");
903+
ui_->playbackDataType->addItem("SensorData");
904+
ui_->playbackDataType_2->addItem("GroundTruth");
905+
ui_->playbackDataType_2->addItem("SensorData");
869906
}
870907

871908
void
@@ -972,9 +1009,17 @@ MainWindow::Quit()
9721009
{
9731010
Stop();
9741011
Stop2();
1012+
while(isConnected_ == true || isConnected2_ == true);
9751013
QApplication::quit();
9761014
}
9771015

1016+
void
1017+
MainWindow::closeEvent(QCloseEvent * event)
1018+
{
1019+
Quit();
1020+
event->accept();
1021+
}
1022+
9781023
void
9791024
MainWindow::ShowContextMenu(const QPoint& pos)
9801025
{
@@ -1068,7 +1113,8 @@ MainWindow::Play()
10681113
}
10691114
else
10701115
{
1071-
emit StartPlaybackRequested(config_.ch1LoadFile_);
1116+
emit StartPlaybackRequested(config_.ch1LoadFile_,
1117+
config_.ch1PlaybackDataType_);
10721118
}
10731119
}
10741120

@@ -1112,7 +1158,8 @@ MainWindow::Play2()
11121158
}
11131159
else
11141160
{
1115-
emit StartPlaybackRequested2(config_.ch2LoadFile_);
1161+
emit StartPlaybackRequested2(config_.ch2LoadFile_,
1162+
config_.ch1PlaybackDataType_);
11161163
}
11171164
}
11181165

0 commit comments

Comments
 (0)