sharedmem: sls_detector_acquire multi and sls index scaning, error message when trying to acquire from a differet multi shm id, updateoffset and create threadpool after adding slsdetectors

This commit is contained in:
maliakal_d 2018-06-27 17:20:05 +02:00
parent 95254619c6
commit 3114512c3f
3 changed files with 88 additions and 59 deletions

View File

@ -883,14 +883,15 @@ void multiSlsDetector::initializeMembers(bool verify) {
} }
zmqSocket.clear(); zmqSocket.clear();
updateOffsets();
createThreadPool();
// get objects from single det shared memory (open) // get objects from single det shared memory (open)
for (int i = 0; i < thisMultiDetector->numberOfDetectors; i++) { for (int i = 0; i < thisMultiDetector->numberOfDetectors; i++) {
slsDetector* sdet = new slsDetector(detId, i, verify, this); slsDetector* sdet = new slsDetector(detId, i, verify, this);
detectors.push_back(sdet); detectors.push_back(sdet);
} }
// depend on number of detectors
updateOffsets();
createThreadPool();
} }

View File

@ -41,34 +41,54 @@ public:
return; \ return; \
}; \ }; \
if (action==slsDetectorDefs::READOUT_ACTION) { \
id = 0; \
pos = -1; \
if (argc) { \
// multi id scanned
if (strchr(argv[0],'-')) { \
iv=sscanf(argv[0],"%d-%s",&id, cmd); \
//%s needn't be there (if not 1:), so 1 or 2 arguments scanned
if (iv >= 1 && id >= 0) { \
argv[0] = cmd; \
cout << id << "-" ; \
} else { \
id = 0; \
} \
} \
// single id scanned
if (strchr(argv[0],':')) { \
iv=sscanf(argv[0],"%d:",&pos, cmd); \
if (iv == 1 && pos >= 0) { \
cout << "pos " << pos << " is not allowed for readout!" << endl; \
return; \
} \
} \
} \
} else { \
// multi id scanned // multi id scanned
iv=sscanf(argv[0],"%d-%s",&id, cmd); \ iv=sscanf(argv[0],"%d-%s",&id, cmd); \
if (iv != 2 || id < 0) \ // scan success
id = 0; \
if (iv == 2 && id >= 0) { \ if (iv == 2 && id >= 0) { \
argv[0] = cmd; \ argv[0] = cmd; \
cout << id << "-" ; \ cout << id << "-" ; \
} else { \
id = 0; \
} \ } \
// sls pos scanned // sls pos scanned
iv=sscanf(argv[0],"%d:%s", &pos, cmd); \ iv=sscanf(argv[0],"%d:%s", &pos, cmd); \
if (iv != 2 ) \ // scan success
pos = -1; \
if (iv == 2 && pos >= 0) { \ if (iv == 2 && pos >= 0) { \
argv[0] = cmd; \ argv[0] = cmd; \
cout << pos << ":" ; \ cout << pos << ":" ; \
} \ } \
if (iv != 2) { \
if ((action==slsDetectorDefs::READOUT_ACTION) && (pos != -1) ) { \ pos = -1; \
cout << "pos " << pos << "is not allowed for readout!" << endl; \
return; \
} \ } \
// remove the %d- and %d:
if (!strlen(cmd)) \ if (!strlen(cmd)) { \
strcpy(cmd, argv[0]); \ strcpy(cmd, argv[0]); \
} \
// special commands // special commands
string scmd = cmd; \ string scmd = cmd; \
// free without calling multiSlsDetector constructor // free without calling multiSlsDetector constructor
@ -85,8 +105,11 @@ public:
update = false; \ update = false; \
myDetector=NULL; \ myDetector=NULL; \
} \ } \
} \
cout<<"id:"<<id<<" pos:"<<pos<<endl;
// create multiSlsDetector class if required // create multiSlsDetector class if required
if (myDetector==NULL) { \ if (myDetector==NULL) { \
try { \ try { \
@ -101,22 +124,24 @@ public:
del=1; \ del=1; \
} \ } \
// call multi detector command line
// readout
if (action==slsDetectorDefs::READOUT_ACTION) { \
myCmd=new multiSlsDetectorCommand(myDetector); \ myCmd=new multiSlsDetectorCommand(myDetector); \
answer=myCmd->executeLine(argc, argv, action); \ try { \
cout << answer<< endl; \ answer=myCmd->executeLine(argc, argv, action, pos); \
} catch (const SharedMemoryException & e) { \
cout << e.GetMessage() << endl; \
delete myCmd; \ delete myCmd; \
if (del) delete myDetector; \ if (del) delete myDetector; \
return; \ return; \
}; \ } catch (...) { \
cout << " caught exception" << endl; \
//cout<<"id:"<<id<<" pos:"<<pos<<endl; delete myCmd; \
// call multi detector command line if (del) delete myDetector; \
myCmd=new multiSlsDetectorCommand(myDetector); \ return; \
answer=myCmd->executeLine(argc, argv, action, pos); \ } \
if (action!=slsDetectorDefs::READOUT_ACTION) { \
cout << argv[0] << " " ; \ cout << argv[0] << " " ; \
} \
cout << answer<< endl; \ cout << answer<< endl; \
delete myCmd; \ delete myCmd; \
if (del) delete myDetector; \ if (del) delete myDetector; \

View File

@ -2496,7 +2496,10 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
if (action==HELP_ACTION) { if (action==HELP_ACTION) {
return helpAcquire(narg,args,HELP_ACTION); return helpAcquire(narg,args,HELP_ACTION);
} }
if (!myDet->getNumberOfDetectors()) {
cprintf(RED, "Error: This shared memory has no detectors added. Aborting.\n");
return string("acquire unsuccessful");
}
myDet->setOnline(ONLINE_FLAG); myDet->setOnline(ONLINE_FLAG);
int r_online = myDet->setReceiverOnline(ONLINE_FLAG); int r_online = myDet->setReceiverOnline(ONLINE_FLAG);