mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-06 12:50:02 +02:00
included json example with dummy values
This commit is contained in:
parent
c16f251442
commit
f517eb7a41
@ -39,6 +39,12 @@ add_definitions(
|
||||
-DDACS_INT
|
||||
)
|
||||
|
||||
add_library(zmq STATIC IMPORTED )
|
||||
|
||||
set_target_properties(zmq PROPERTIES
|
||||
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/../slsReceiverSoftware/include/libzmq.a
|
||||
)
|
||||
|
||||
add_library(slsDetectorStatic STATIC
|
||||
${SOURCES}
|
||||
${HEADERS}
|
||||
|
@ -24,6 +24,7 @@ ID: $Id$
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <zmq.h>
|
||||
#include <rapidjson/document.h> //to scan json header in zmq stream
|
||||
using namespace std;
|
||||
|
||||
|
||||
@ -5012,16 +5013,44 @@ void multiSlsDetector::startReceivingData(){
|
||||
|
||||
if(!idet) framecount++; //update indices, count only once
|
||||
|
||||
// receive a message, this is a blocking function
|
||||
len = zmq_msg_init (&message); /* is this required? Xiaoqiang didnt have it*/
|
||||
if(len) {cprintf(RED,"Failed to initialize message %d for %d\n",len,ithread); continue; } //error
|
||||
|
||||
//scan header--------------------------------------------------------
|
||||
zmq_msg_init (&message);
|
||||
len = zmq_msg_recv(&message, zmqsocket, 0);
|
||||
if (len == -1) {
|
||||
zmq_msg_close(&message);
|
||||
cprintf(RED, "%d message null\n",ithread);
|
||||
continue;
|
||||
}
|
||||
rapidjson::Document d;
|
||||
d.Parse((char*)zmq_msg_data(&message));
|
||||
// htype is an array of strings
|
||||
rapidjson::Value::Array htype = d["htype"].GetArray();
|
||||
for(int i=0; i< htype.Size(); i++)
|
||||
cout << ithread << "htype: " << htype[i].GetString() << endl;/*print*/
|
||||
// shape is an array of ints
|
||||
rapidjson::Value::Array shape = d["shape"].GetArray();
|
||||
cout << ithread << "shape: "; /*print*/
|
||||
for(int i=0; i< shape.Size(); i++)
|
||||
cout << ithread << shape[i].GetInt() << " ";/*print*/
|
||||
cout << endl;
|
||||
|
||||
cout << ithread << "type: " << d["type"].GetString() << endl;/*print*/
|
||||
// close the message
|
||||
zmq_msg_close(&message);
|
||||
|
||||
|
||||
//scan data--------------------------------------------------------
|
||||
zmq_msg_init (&message);
|
||||
len = zmq_msg_recv(&message, zmqsocket, 0);
|
||||
|
||||
//if(len<1024*256)
|
||||
//cprintf(RED,"got less than planned for socket %d\n",ithread);
|
||||
//last one
|
||||
if(len<1024*256){
|
||||
cprintf(RED,"got less than planned for socket %d\n",ithread);
|
||||
//end of socket
|
||||
if (len <= 3 ) {
|
||||
//if (len <= 3 ) {
|
||||
if(!len) cprintf(RED,"Received no data in socket for %d\n", ithread);
|
||||
zmq_msg_close(&message);
|
||||
//cout<<ithread <<" sls Received end data"<<endl;
|
||||
singleframe[ithread] = NULL;
|
||||
pthread_mutex_lock(&ms);
|
||||
@ -5035,8 +5064,7 @@ void multiSlsDetector::startReceivingData(){
|
||||
break;
|
||||
}
|
||||
|
||||
if(zmq_msg_data(&message)==NULL) cprintf(RED,"GOT NULL FROM ZMQ\n"); /*not needed most likely*/
|
||||
|
||||
//actual data
|
||||
//cout<<"Received on " << ithread << " for frame " << framecount << endl;
|
||||
//if(len == singleDatabytes/numReadoutPerDetector){//hoow to solve this
|
||||
memcpy((char*)(singleframe[ithread]),(char*)zmq_msg_data(&message),singleDatabytes/numReadoutPerDetector);
|
||||
@ -5052,8 +5080,9 @@ void multiSlsDetector::startReceivingData(){
|
||||
sem_post(&sem_singledone[ithread]);//let multi know is ready
|
||||
//cprintf(GREEN,"single %d posted done for multi\n",ithread);
|
||||
|
||||
// close the message
|
||||
zmq_msg_close(&message);
|
||||
}
|
||||
zmq_msg_close(&message);
|
||||
|
||||
//close socket
|
||||
zmq_disconnect(zmqsocket, hostname);
|
||||
|
@ -521,7 +521,7 @@ int slsDetectorUtils::acquire(int delflag){
|
||||
setAcquiringFlag(false);
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
cprintf(BLUE,"Elapsed time:%f seconds\n",( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0);
|
||||
cout << "Elapsed time for acquisition:" << (( end.tv_sec - begin.tv_sec ) + ( end.tv_nsec - begin.tv_nsec ) / 1000000000.0) << " seconds" << endl;
|
||||
|
||||
return OK;
|
||||
|
||||
|
@ -18,6 +18,8 @@ add_executable(sls_detector_get
|
||||
target_link_libraries(sls_detector_get
|
||||
slsDetectorShared
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
set_target_properties(sls_detector_get PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
@ -30,6 +32,8 @@ add_executable(sls_detector_put
|
||||
target_link_libraries(sls_detector_put
|
||||
slsDetectorShared
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
set_target_properties(sls_detector_put PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
@ -42,6 +46,8 @@ add_executable(sls_detector_acquire
|
||||
target_link_libraries(sls_detector_acquire
|
||||
slsDetectorShared
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
set_target_properties(sls_detector_acquire PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
@ -54,6 +60,8 @@ add_executable(sls_detector_help
|
||||
target_link_libraries(sls_detector_help
|
||||
slsDetectorShared
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
set_target_properties(sls_detector_help PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
|
Loading…
x
Reference in New Issue
Block a user