@@ -47,12 +47,12 @@ MainWindow::MainWindow(QWidget *parent)
4747
4848 , glWidget_(nullptr )
4949 , receiver_(new TCPReceiver())
50- , reader_(new OsiReader(&config_.ch1DeltaDelay_))
50+ , reader_(new OsiReader(&config_.ch1DeltaDelay_, config_.ch1EnableSendOut_, config_.ch1SendOutPortNum_.toStdString() ))
5151 , osiparser_(new OsiParser(config_.osiMsgSaveThreshold_))
5252
5353 , glWidget2_(nullptr )
5454 , receiver2_(new TCPReceiver())
55- , reader2_(new OsiReader(&config_.ch2DeltaDelay_))
55+ , reader2_(new OsiReader(&config_.ch2DeltaDelay_, config_.ch2EnableSendOut_, config_.ch2SendOutPortNum_.toStdString() ))
5656 , osiparser2_(new OsiParser(config_.osiMsgSaveThreshold_))
5757
5858 , colorWidgets_()
@@ -199,6 +199,18 @@ MainWindow::LoadFileBrowse2()
199199 }
200200}
201201
202+ void
203+ MainWindow::EnableSendToNetwork ()
204+ {
205+ ui_->sendOutPortNum ->setEnabled (ui_->enableSendToNetwork ->checkState () == Qt::Checked);
206+ }
207+
208+ void
209+ MainWindow::EnableSendToNetwork2 ()
210+ {
211+ ui_->sendOutPortNum_2 ->setEnabled (ui_->enableSendToNetwork_2 ->checkState () == Qt::Checked);
212+ }
213+
202214void
203215MainWindow::UpdateCombineChannelMenu ()
204216{
@@ -432,11 +444,15 @@ MainWindow::ConnectSignalsToSlots()
432444 connect (ui_->rbPlayback_2 , &QRadioButton::clicked, this , &MainWindow::RBPlayback2);
433445
434446 // load/save playback file
435- connect (ui_->loadFile , &QLineEdit::textEdited, this , &MainWindow::LoadFileEdited);
447+ connect (ui_->loadFile , &QLineEdit::textEdited, this , &MainWindow::LoadFileEdited);
436448 connect (ui_->loadFileBrowse , &QPushButton::clicked, this , &MainWindow::LoadFileBrowse);
437- connect (ui_->loadFile_2 , &QLineEdit::textEdited, this , &MainWindow::LoadFileEdited2);
449+ connect (ui_->loadFile_2 , &QLineEdit::textEdited, this , &MainWindow::LoadFileEdited2);
438450 connect (ui_->loadFileBrowse_2 , &QPushButton::clicked, this , &MainWindow::LoadFileBrowse2);
439451
452+ // enable sent out
453+ connect (ui_->enableSendToNetwork , &QCheckBox::clicked, this , &MainWindow::EnableSendToNetwork);
454+ connect (ui_->enableSendToNetwork_2 , &QCheckBox::clicked, this , &MainWindow::EnableSendToNetwork2);
455+
440456 // Play/Pause
441457 connect (ui_->playPauseButton , &QToolButton::clicked, this , &MainWindow::PlayPauseButtonClicked);
442458 connect (ui_->playPauseButton_2 , &QToolButton::clicked, this , &MainWindow::PlayPauseButtonClicked2);
@@ -617,6 +633,8 @@ MainWindow::EnablePlaybackGroup1(bool enable)
617633 ui_->loadFileBrowse ->setEnabled (enable);
618634 ui_->playbackDataType ->setEnabled (enable);
619635 ui_->deltaDelay ->setEnabled (enable);
636+ ui_->enableSendToNetwork ->setEnabled (enable);
637+ ui_->sendOutPortNum ->setEnabled (enable && ui_->enableSendToNetwork ->checkState () == Qt::Checked);
620638}
621639
622640void
@@ -626,6 +644,8 @@ MainWindow::EnablePlaybackGroup2(bool enable)
626644 ui_->loadFileBrowse_2 ->setEnabled (enable);
627645 ui_->playbackDataType_2 ->setEnabled (enable);
628646 ui_->deltaDelay_2 ->setEnabled (enable);
647+ ui_->enableSendToNetwork_2 ->setEnabled (enable);
648+ ui_->sendOutPortNum_2 ->setEnabled (enable && ui_->enableSendToNetwork_2 ->checkState () == Qt::Checked);
629649}
630650
631651void
756776MainWindow::UpdateConfigure ()
757777{
758778 bool hasChange (false );
779+ bool saveChange (false );
759780
760781 if (config_.ch1IPAddress_ != ui_->ipAddress ->text ())
761782 {
@@ -789,10 +810,24 @@ MainWindow::UpdateConfigure()
789810
790811 if (config_.ch1DeltaDelay_ != ui_->deltaDelay ->text ().toInt ())
791812 {
813+ saveChange = true ;
792814 config_.ch1DeltaDelay_ = ui_->deltaDelay ->text ().toInt ();
793- config_.Save ();
794815 }
795- else if (hasChange)
816+
817+ if (config_.ch1EnableSendOut_ != (ui_->enableSendToNetwork ->checkState () == Qt::Checked))
818+ {
819+ saveChange = true ;
820+ config_.ch1EnableSendOut_ = (ui_->enableSendToNetwork ->checkState () == Qt::Checked);
821+ }
822+
823+ if (config_.ch1SendOutPortNum_ != ui_->sendOutPortNum ->text ())
824+ {
825+ saveChange = true ;
826+ config_.ch1SendOutPortNum_ = ui_->sendOutPortNum ->text ();
827+ reader_->SetSendOutPortNum (config_.ch1SendOutPortNum_ .toStdString ());
828+ }
829+
830+ if (hasChange || saveChange)
796831 config_.Save ();
797832
798833 return hasChange;
802837MainWindow::UpdateConfigure2 ()
803838{
804839 bool hasChange (false );
840+ bool saveChange (false );
805841
806842 if (config_.ch2IPAddress_ != ui_->ipAddress_2 ->text ())
807843 {
@@ -835,10 +871,24 @@ MainWindow::UpdateConfigure2()
835871
836872 if (config_.ch2DeltaDelay_ != ui_->deltaDelay_2 ->text ().toInt ())
837873 {
874+ saveChange = true ;
838875 config_.ch2DeltaDelay_ = ui_->deltaDelay_2 ->text ().toInt ();
839- config_.Save ();
840876 }
841- else if (hasChange)
877+
878+ if (config_.ch2EnableSendOut_ != (ui_->enableSendToNetwork_2 ->checkState () == Qt::Checked))
879+ {
880+ saveChange = true ;
881+ config_.ch2EnableSendOut_ = (ui_->enableSendToNetwork_2 ->checkState () == Qt::Checked);
882+ }
883+
884+ if (config_.ch2SendOutPortNum_ != ui_->sendOutPortNum_2 ->text ())
885+ {
886+ saveChange = true ;
887+ config_.ch2SendOutPortNum_ = ui_->sendOutPortNum_2 ->text ();
888+ reader2_->SetSendOutPortNum (config_.ch2SendOutPortNum_ .toStdString ());
889+ }
890+
891+ if (hasChange || saveChange)
842892 config_.Save ();
843893
844894 return hasChange;
@@ -855,13 +905,25 @@ MainWindow::InitLoadConfigure()
855905 ui_->loadFile ->setText (config_.ch1LoadFile_ );
856906 ui_->playbackDataType ->setCurrentIndex ( static_cast <int >(config_.ch1PlaybackDataType_ ) );
857907 ui_->deltaDelay ->setText (QString::number (config_.ch1DeltaDelay_ ));
908+ if (config_.ch1EnableSendOut_ )
909+ ui_->enableSendToNetwork ->setCheckState (Qt::Checked);
910+ else
911+ ui_->enableSendToNetwork ->setCheckState (Qt::Unchecked);
912+ ui_->sendOutPortNum ->setText (config_.ch1SendOutPortNum_ );
913+ reader_->SetSendOutPortNum (config_.ch1SendOutPortNum_ .toStdString ());
858914
859915 ui_->ipAddress_2 ->setText (config_.ch2IPAddress_ );
860916 ui_->portNumber_2 ->setText (config_.ch2PortNum_ );
861917 ui_->dataType_2 ->setCurrentIndex ( static_cast <int >(config_.ch2DataType_ ) );
862918 ui_->loadFile_2 ->setText (config_.ch2LoadFile_ );
863919 ui_->playbackDataType_2 ->setCurrentIndex ( static_cast <int >(config_.ch2PlaybackDataType_ ) );
864920 ui_->deltaDelay_2 ->setText (QString::number (config_.ch2DeltaDelay_ ));
921+ if (config_.ch2EnableSendOut_ )
922+ ui_->enableSendToNetwork_2 ->setCheckState (Qt::Checked);
923+ else
924+ ui_->enableSendToNetwork_2 ->setCheckState (Qt::Unchecked);
925+ ui_->sendOutPortNum_2 ->setText (config_.ch2SendOutPortNum_ );
926+ reader2_->SetSendOutPortNum (config_.ch2SendOutPortNum_ .toStdString ());
865927
866928 ui_->actionCombiCh ->setChecked (config_.combineChannel_ );
867929 ui_->actionShowGrid ->setChecked (config_.showGrid_ );
@@ -1122,17 +1184,32 @@ MainWindow::Play()
11221184void
11231185MainWindow::TogglePause ()
11241186{
1187+ QString errMsg;
1188+
11251189 if (isConnected_)
11261190 {
11271191 receiver_->isPaused_ = isPlaying_;
11281192 }
11291193
11301194 if (isPlayed_)
11311195 {
1132- reader_->isPaused_ = isPlaying_;
1196+ if (isPlaying_)
1197+ {
1198+ reader_->isPaused_ = true ;
1199+ reader_->SetupConnection (false );
1200+ }
1201+ else
1202+ {
1203+ errMsg = reader_->SetupConnection (true );
1204+ if (errMsg.isEmpty ())
1205+ reader_->isPaused_ = false ;
1206+ else
1207+ ShowErrorMessage (errMsg);
1208+ }
11331209 }
11341210
1135- isPlaying_ = !isPlaying_;
1211+ if (errMsg.isEmpty ())
1212+ isPlaying_ = !isPlaying_;
11361213}
11371214
11381215void
@@ -1167,17 +1244,31 @@ MainWindow::Play2()
11671244void
11681245MainWindow::TogglePause2 ()
11691246{
1247+ QString errMsg;
1248+
11701249 if (isConnected2_)
11711250 {
11721251 receiver2_->isPaused_ = isPlaying2_;
11731252 }
1174-
1175- if (isPlayed2_)
1253+ else if (isPlayed2_)
11761254 {
1177- reader2_->isPaused_ = isPlaying2_;
1255+ if (isPlaying2_)
1256+ {
1257+ reader2_->isPaused_ = true ;
1258+ reader2_->SetupConnection (false );
1259+ }
1260+ else
1261+ {
1262+ errMsg = reader2_->SetupConnection (true );
1263+ if (errMsg.isEmpty ())
1264+ reader2_->isPaused_ = false ;
1265+ else
1266+ ShowErrorMessage (errMsg);
1267+ }
11781268 }
11791269
1180- isPlaying2_ = !isPlaying2_;
1270+ if (errMsg.isEmpty ())
1271+ isPlaying2_ = !isPlaying2_;
11811272}
11821273
11831274void
@@ -1269,7 +1360,8 @@ MainWindow::Disconnected2(const QString& message)
12691360 UpdateCombineChannelMenu ();
12701361}
12711362
1272- QString MainWindow::GetStringFromMilliSecond (int milliSec)
1363+ QString
1364+ MainWindow::GetStringFromMilliSecond (int milliSec)
12731365{
12741366 QString varString;
12751367
0 commit comments