mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-13 07:52:12 +02:00
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:
parent
95254619c6
commit
3114512c3f
@ -883,14 +883,15 @@ void multiSlsDetector::initializeMembers(bool verify) {
|
||||
}
|
||||
zmqSocket.clear();
|
||||
|
||||
updateOffsets();
|
||||
createThreadPool();
|
||||
|
||||
// get objects from single det shared memory (open)
|
||||
for (int i = 0; i < thisMultiDetector->numberOfDetectors; i++) {
|
||||
slsDetector* sdet = new slsDetector(detId, i, verify, this);
|
||||
detectors.push_back(sdet);
|
||||
}
|
||||
|
||||
// depend on number of detectors
|
||||
updateOffsets();
|
||||
createThreadPool();
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,52 +41,75 @@ public:
|
||||
return; \
|
||||
}; \
|
||||
|
||||
|
||||
|
||||
// multi id scanned
|
||||
iv=sscanf(argv[0],"%d-%s",&id, cmd); \
|
||||
if (iv != 2 || id < 0) \
|
||||
id = 0; \
|
||||
if (iv == 2 && id >= 0) { \
|
||||
argv[0] = cmd; \
|
||||
cout << id << "-" ; \
|
||||
} \
|
||||
|
||||
// sls pos scanned
|
||||
iv=sscanf(argv[0],"%d:%s", &pos, cmd); \
|
||||
if (iv != 2 ) \
|
||||
pos = -1; \
|
||||
if (iv == 2 && pos >= 0) { \
|
||||
argv[0] = cmd; \
|
||||
cout << pos << ":" ; \
|
||||
} \
|
||||
|
||||
if ((action==slsDetectorDefs::READOUT_ACTION) && (pos != -1) ) { \
|
||||
cout << "pos " << pos << "is not allowed for readout!" << endl; \
|
||||
return; \
|
||||
} \
|
||||
|
||||
if (!strlen(cmd)) \
|
||||
strcpy(cmd, argv[0]); \
|
||||
|
||||
// special commands
|
||||
string scmd = cmd; \
|
||||
// free without calling multiSlsDetector constructor
|
||||
if (scmd == "free") { \
|
||||
if (pos != -1) \
|
||||
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
|
||||
iv=sscanf(argv[0],"%d-%s",&id, cmd); \
|
||||
// scan success
|
||||
if (iv == 2 && id >= 0) { \
|
||||
argv[0] = cmd; \
|
||||
cout << id << "-" ; \
|
||||
} else { \
|
||||
id = 0; \
|
||||
} \
|
||||
// sls pos scanned
|
||||
iv=sscanf(argv[0],"%d:%s", &pos, cmd); \
|
||||
// scan success
|
||||
if (iv == 2 && pos >= 0) { \
|
||||
argv[0] = cmd; \
|
||||
cout << pos << ":" ; \
|
||||
} \
|
||||
if (iv != 2) { \
|
||||
pos = -1; \
|
||||
} \
|
||||
// remove the %d- and %d:
|
||||
if (!strlen(cmd)) { \
|
||||
strcpy(cmd, argv[0]); \
|
||||
} \
|
||||
// special commands
|
||||
string scmd = cmd; \
|
||||
// free without calling multiSlsDetector constructor
|
||||
if (scmd == "free") { \
|
||||
if (pos != -1) \
|
||||
slsDetector::freeSharedMemory(id, pos); \
|
||||
else \
|
||||
else \
|
||||
multiSlsDetector::freeSharedMemory(id); \
|
||||
return; \
|
||||
} \
|
||||
// get user details without verify sharedMultiSlsDetector version
|
||||
else if ((scmd == "user") && (action==slsDetectorDefs::GET_ACTION)) { \
|
||||
verify = false; \
|
||||
update = false; \
|
||||
myDetector=NULL; \
|
||||
return; \
|
||||
} \
|
||||
// get user details without verify sharedMultiSlsDetector version
|
||||
else if ((scmd == "user") && (action==slsDetectorDefs::GET_ACTION)) { \
|
||||
verify = false; \
|
||||
update = false; \
|
||||
myDetector=NULL; \
|
||||
} \
|
||||
} \
|
||||
|
||||
|
||||
|
||||
cout<<"id:"<<id<<" pos:"<<pos<<endl;
|
||||
// create multiSlsDetector class if required
|
||||
if (myDetector==NULL) { \
|
||||
try { \
|
||||
@ -101,22 +124,24 @@ public:
|
||||
del=1; \
|
||||
} \
|
||||
|
||||
|
||||
// readout
|
||||
if (action==slsDetectorDefs::READOUT_ACTION) { \
|
||||
myCmd=new multiSlsDetectorCommand(myDetector); \
|
||||
answer=myCmd->executeLine(argc, argv, action); \
|
||||
cout << answer<< endl; \
|
||||
delete myCmd; \
|
||||
if (del) delete myDetector; \
|
||||
return; \
|
||||
}; \
|
||||
|
||||
//cout<<"id:"<<id<<" pos:"<<pos<<endl;
|
||||
// call multi detector command line
|
||||
myCmd=new multiSlsDetectorCommand(myDetector); \
|
||||
answer=myCmd->executeLine(argc, argv, action, pos); \
|
||||
cout << argv[0] << " " ; \
|
||||
try { \
|
||||
answer=myCmd->executeLine(argc, argv, action, pos); \
|
||||
} catch (const SharedMemoryException & e) { \
|
||||
cout << e.GetMessage() << endl; \
|
||||
delete myCmd; \
|
||||
if (del) delete myDetector; \
|
||||
return; \
|
||||
} catch (...) { \
|
||||
cout << " caught exception" << endl; \
|
||||
delete myCmd; \
|
||||
if (del) delete myDetector; \
|
||||
return; \
|
||||
} \
|
||||
if (action!=slsDetectorDefs::READOUT_ACTION) { \
|
||||
cout << argv[0] << " " ; \
|
||||
} \
|
||||
cout << answer<< endl; \
|
||||
delete myCmd; \
|
||||
if (del) delete myDetector; \
|
||||
|
@ -2496,7 +2496,10 @@ string slsDetectorCommand::cmdAcquire(int narg, char *args[], int action) {
|
||||
if (action==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);
|
||||
int r_online = myDet->setReceiverOnline(ONLINE_FLAG);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user