zmq buffering when acquire form command line, stopping sockets when command line acquire or receiver start, restarting sockets at change of port numbers and a refresh button for the same

This commit is contained in:
Dhanya Maliakal
2017-11-21 13:38:31 +01:00
parent d7137e0c75
commit 49ba893d7e
4 changed files with 66 additions and 4 deletions

View File

@ -1264,7 +1264,7 @@ An extension given by the modules serial number will be attached.
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>ZMQ Port TX:</string> <string>ZMQ Port:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1314,6 +1314,26 @@ An extension given by the modules serial number will be attached.
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QPushButton" name="btnRestartStreaming">
<property name="geometry">
<rect>
<x>23</x>
<y>142</y>
<width>291</width>
<height>25</height>
</rect>
</property>
<property name="toolTip">
<string>Switching off and on the receiver data streaming from command line requires client sockets to be restarted as well.</string>
</property>
<property name="text">
<string>Restart Streaming (Receiver-&gt;GUI)</string>
</property>
<property name="icon">
<iconset resource="../include/icons.qrc">
<normaloff>:/icons/images/refresh.png</normaloff>:/icons/images/refresh.png</iconset>
</property>
</widget>
</widget> </widget>
<widget class="QWidget" name="gridLayoutWidget_7"> <widget class="QWidget" name="gridLayoutWidget_7">
<property name="geometry"> <property name="geometry">
@ -1625,7 +1645,7 @@ An extension given by the modules serial number will be attached.
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>ZMQ Port RX:</string> <string>ZMQ Port (GUI):</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -162,6 +162,10 @@ private slots:
*/ */
void SetReceiver(); void SetReceiver();
/** Restart data streaming in receiver and gui
*/
void RestartStreaming();
/** Add ROI Input if the value changed in the last slot /** Add ROI Input if the value changed in the last slot
*/ */
void AddROIInputSlot(){AddROIInput(1);}; void AddROIInputSlot(){AddROIInput(1);};

View File

@ -741,11 +741,20 @@ void* qDrawPlot::DataStartAcquireThread(void *this_pointer){
if(((qDrawPlot*)this_pointer)->myDet->setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) { if(((qDrawPlot*)this_pointer)->myDet->setReceiverOnline() == slsDetectorDefs::ONLINE_FLAG) {
// if receiver data up streaming not on, switch it on // if receiver data up streaming not on, switch it on
if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver() != 1) if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver() != 1) {cprintf(GREEN,"receiver not on\n");
// switch on receiver
if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver(1) != 1) { if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingFromReceiver(1) != 1) {
qDefs::checkErrorMessage(((qDrawPlot*)this_pointer)->myDet,"qDrawPlot::DataStartAcquireThread"); qDefs::checkErrorMessage(((qDrawPlot*)this_pointer)->myDet,"qDrawPlot::DataStartAcquireThread");
return this_pointer; return this_pointer;
} }
// switch off client
((qDrawPlot*)this_pointer)->myDet->enableDataStreamingToClient(0);
// switch on client
if (((qDrawPlot*)this_pointer)->myDet->enableDataStreamingToClient(1) != 1) {
qDefs::checkErrorMessage(((qDrawPlot*)this_pointer)->myDet,"qDrawPlot::DataStartAcquireThread");
return this_pointer;
}
}
} }
((qDrawPlot*)this_pointer)->myDet->acquire(1); ((qDrawPlot*)this_pointer)->myDet->acquire(1);

View File

@ -79,6 +79,7 @@ void qTabAdvanced::SetupWidgetWindow(){
isAngular = true; isAngular = true;
spinZmqPort->setEnabled(false); spinZmqPort->setEnabled(false);
spinZmqPort2->setEnabled(false); spinZmqPort2->setEnabled(false);
btnRestartStreaming->setEnabled(false);
break; break;
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
isEnergy = true; isEnergy = true;
@ -280,6 +281,7 @@ void qTabAdvanced::Initialization(){
connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters())); connect(dispUDPMAC, SIGNAL(editingFinished()), this, SLOT(SetNetworkParameters()));
connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver())); connect(btnRxr, SIGNAL(clicked()), this, SLOT(SetReceiver()));
connect(btnRestartStreaming,SIGNAL(clicked()), this, SLOT(RestartStreaming()));
} }
@ -729,12 +731,17 @@ void qTabAdvanced::SetRxrUDPPort(int port){
void qTabAdvanced::SetCltZmqPort(int port){ void qTabAdvanced::SetCltZmqPort(int port){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting Receiver UDP Port:" << port << endl; cout << "Setting Client UDP Port:" << port << endl;
#endif #endif
ostringstream ss; ss << port; string sport = ss.str(); ostringstream ss; ss << port; string sport = ss.str();
disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); disconnect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int)));
spinZmqPort->setValue(atoi(det->setClientStreamingPort(sport).c_str())); spinZmqPort->setValue(atoi(det->setClientStreamingPort(sport).c_str()));
myDet->enableDataStreamingFromReceiver(false);
myDet->enableDataStreamingToClient(false);
myDet->enableDataStreamingFromReceiver(true);
myDet->enableDataStreamingToClient(true);
qDefs::checkErrorMessage(det,"qTabAdvanced::SetCltZmqPort"); qDefs::checkErrorMessage(det,"qTabAdvanced::SetCltZmqPort");
connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int))); connect(spinZmqPort, SIGNAL(valueChanged(int)), this, SLOT(SetCltZmqPort(int)));
} }
@ -751,6 +758,11 @@ void qTabAdvanced::SetRxrZmqPort(int port){
disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); disconnect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int)));
spinZmqPort2->setValue(atoi(det->setReceiverStreamingPort(sport).c_str())); spinZmqPort2->setValue(atoi(det->setReceiverStreamingPort(sport).c_str()));
myDet->enableDataStreamingFromReceiver(false);
myDet->enableDataStreamingToClient(false);
myDet->enableDataStreamingFromReceiver(true);
myDet->enableDataStreamingToClient(true);
qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrZmqPort"); qDefs::checkErrorMessage(det,"qTabAdvanced::SetRxrZmqPort");
connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int))); connect(spinZmqPort2, SIGNAL(valueChanged(int)), this, SLOT(SetRxrZmqPort(int)));
} }
@ -854,6 +866,23 @@ void qTabAdvanced::SetReceiver(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabAdvanced::RestartStreaming(){
#ifdef VERBOSE
cout << "Restarting Data Streaming in Receiver and Gui" << endl;
#endif
disconnect(btnRestartStreaming,SIGNAL(clicked()), this, SLOT(RestartStreaming()));
myDet->enableDataStreamingFromReceiver(false);
myDet->enableDataStreamingToClient(false);
myDet->enableDataStreamingFromReceiver(true);
myDet->enableDataStreamingToClient(true);
connect(btnRestartStreaming,SIGNAL(clicked()), this, SLOT(RestartStreaming()));
}
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------