mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
Merge branch 'mainexceptions' into developer
This commit is contained in:
commit
c934e92a41
@ -23,8 +23,7 @@ using namespace std;
|
||||
int main(int argc, char *argv[]){
|
||||
qClient* cl = 0;
|
||||
try {
|
||||
qClient *c = new qClient(argv[1]);
|
||||
cl = c;
|
||||
cl = new qClient(argv[1]);
|
||||
} catch(...) {
|
||||
return 0;
|
||||
}
|
||||
@ -42,14 +41,11 @@ qClient::qClient(char* hostname):
|
||||
mySocket(0),
|
||||
myStopSocket(0){
|
||||
|
||||
|
||||
try {
|
||||
// control socket
|
||||
MySocketTCP* s = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO);
|
||||
mySocket = s;
|
||||
mySocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO);
|
||||
// stop socket
|
||||
s = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1);
|
||||
myStopSocket = s;
|
||||
myStopSocket = new MySocketTCP(hostname, DEFAULT_GUI_PORTNO+1);
|
||||
} catch(...) {
|
||||
if (mySocket == 0)
|
||||
cout << "Error: could not connect to control server:" <<
|
||||
|
@ -42,6 +42,7 @@ multiSlsDetector::multiSlsDetector(int id, bool verify, bool update)
|
||||
|
||||
|
||||
multiSlsDetector::~multiSlsDetector() {
|
||||
// delete zmq sockets first
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
@ -641,6 +642,12 @@ void multiSlsDetector::freeSharedMemory(int multiId) {
|
||||
|
||||
|
||||
void multiSlsDetector::freeSharedMemory() {
|
||||
// clear zmq vector
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
zmqSocket.clear();
|
||||
|
||||
// should be done before the detector list is deleted
|
||||
clearAllErrorMask();
|
||||
|
||||
@ -653,18 +660,14 @@ void multiSlsDetector::freeSharedMemory() {
|
||||
|
||||
// clear multi detector shm
|
||||
if (sharedMemory) {
|
||||
sharedMemory->UnmapSharedMemory(thisMultiDetector);
|
||||
if (thisMultiDetector) {
|
||||
sharedMemory->UnmapSharedMemory(thisMultiDetector);
|
||||
thisMultiDetector = 0;
|
||||
}
|
||||
sharedMemory->RemoveSharedMemory();
|
||||
delete sharedMemory;
|
||||
sharedMemory = 0;
|
||||
}
|
||||
thisMultiDetector = 0;
|
||||
|
||||
// clear zmq vector
|
||||
for (vector<ZmqSocket*>::const_iterator it = zmqSocket.begin(); it != zmqSocket.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
zmqSocket.clear();
|
||||
|
||||
// zmq
|
||||
destroyThreadPool();
|
||||
@ -696,47 +699,46 @@ std::string multiSlsDetector::getUserDetails() {
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pre: sharedMemory=0, thisMultiDetector = 0, detectors.size() = 0
|
||||
* exceptions are caught in calling function, shm unmapped and deleted
|
||||
*/
|
||||
bool multiSlsDetector::initSharedMemory(bool verify) {
|
||||
|
||||
// clear
|
||||
if (sharedMemory) {
|
||||
delete sharedMemory;
|
||||
}
|
||||
thisMultiDetector = 0;
|
||||
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
detectors.clear();
|
||||
|
||||
// create/open shm and map to structure
|
||||
size_t sz = sizeof(sharedMultiSlsDetector);
|
||||
|
||||
bool created = false;
|
||||
sharedMemory = new SharedMemory(detId, -1);
|
||||
if (sharedMemory->IsExisting()) {
|
||||
thisMultiDetector = (sharedMultiSlsDetector*)sharedMemory->OpenSharedMemory(sz);
|
||||
if (verify && thisMultiDetector->shmversion != MULTI_SHMVERSION) {
|
||||
cprintf(RED, "Multi shared memory (%d) version mismatch "
|
||||
"(expected 0x%x but got 0x%x)\n", detId,
|
||||
MULTI_SHMVERSION, thisMultiDetector->shmversion);
|
||||
sharedMemory->UnmapSharedMemory(thisMultiDetector);
|
||||
delete sharedMemory;
|
||||
sharedMemory = 0;
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
||||
try {
|
||||
// shared memory object with name
|
||||
sharedMemory = new SharedMemory(detId, -1);
|
||||
|
||||
//create
|
||||
if (!sharedMemory->IsExisting()) {
|
||||
thisMultiDetector = (sharedMultiSlsDetector*)sharedMemory->CreateSharedMemory(sz);
|
||||
created = true;
|
||||
} catch(...) {
|
||||
sharedMemory->RemoveSharedMemory();
|
||||
}
|
||||
// open and verify version
|
||||
else {
|
||||
thisMultiDetector = (sharedMultiSlsDetector*)sharedMemory->OpenSharedMemory(sz);
|
||||
if (verify && thisMultiDetector->shmversion != MULTI_SHMVERSION) {
|
||||
cprintf(RED, "Multi shared memory (%d) version mismatch "
|
||||
"(expected 0x%x but got 0x%x)\n", detId,
|
||||
MULTI_SHMVERSION, thisMultiDetector->shmversion);
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
if (sharedMemory) {
|
||||
// unmap
|
||||
if (thisMultiDetector) {
|
||||
sharedMemory->UnmapSharedMemory(thisMultiDetector);
|
||||
thisMultiDetector = 0;
|
||||
}
|
||||
// delete
|
||||
delete sharedMemory;
|
||||
sharedMemory = 0;
|
||||
thisMultiDetector = 0;
|
||||
throw;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
return created;
|
||||
@ -881,8 +883,17 @@ void multiSlsDetector::initializeMembers(bool verify) {
|
||||
|
||||
// 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);
|
||||
try {
|
||||
slsDetector* sdet = new slsDetector(detId, i, verify, this);
|
||||
detectors.push_back(sdet);
|
||||
} catch (...) {
|
||||
// clear detectors list
|
||||
for (vector<slsDetector*>::const_iterator it = detectors.begin(); it != detectors.end(); ++it) {
|
||||
delete(*it);
|
||||
}
|
||||
detectors.clear();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// depend on number of detectors
|
||||
|
@ -115,8 +115,8 @@ public:
|
||||
try { \
|
||||
multiSlsDetector* m = new multiSlsDetector(id, verify, update); \
|
||||
myDetector = m; \
|
||||
} catch (const SharedMemoryException & e) { \
|
||||
cout << e.GetMessage() << endl; \
|
||||
} catch (const SlsDetectorPackageExceptions & e) { \
|
||||
/*cout << e.GetMessage() << endl;*/ \
|
||||
return; \
|
||||
} catch (...) { \
|
||||
cout << " caught exception" << endl; \
|
||||
@ -129,8 +129,8 @@ public:
|
||||
myCmd=new multiSlsDetectorCommand(myDetector); \
|
||||
try { \
|
||||
answer=myCmd->executeLine(argc, argv, action, pos); \
|
||||
} catch (const SharedMemoryException & e) { \
|
||||
cout << e.GetMessage() << endl; \
|
||||
} catch (const SlsDetectorPackageExceptions & e) { \
|
||||
/*cout << e.GetMessage() << endl; */ \
|
||||
delete myCmd; \
|
||||
if (del) delete myDetector; \
|
||||
return; \
|
||||
|
@ -61,6 +61,7 @@ void* SharedMemory::CreateSharedMemory(size_t sz){
|
||||
cprintf(RED, "Error: Create shared memory %s failed at ftruncate: %s\n",
|
||||
name.c_str(), strerror(errno));
|
||||
close(fd);
|
||||
RemoveSharedMemory();
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
|
||||
@ -137,8 +138,10 @@ std::string SharedMemory::ConstructSharedMemoryName(int multiId, int slsId) {
|
||||
|
||||
std::string temp = ss.str();
|
||||
if (temp.length() > NAME_MAX) {
|
||||
cprintf(RED, "Error: Shared memory initialization %s failed: %s\n",
|
||||
name.c_str(), strerror(errno));
|
||||
cprintf(RED, "Error: Shared memory initialization failed. "
|
||||
"%s has %lu characters. \n"
|
||||
"Maximum is %d. Change the environment variable %s\n",
|
||||
temp.c_str(), temp.length(), NAME_MAX, SHM_ENV_NAME);
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
return temp;
|
||||
|
@ -91,8 +91,7 @@ int main(int argc, char* argv[])
|
||||
MySocketTCP* mySocket = 0;
|
||||
|
||||
try {
|
||||
MySocketTCP* s = new MySocketTCP(argv[1],1952);
|
||||
mySocket = s;
|
||||
mySocket = new MySocketTCP(argv[1],1952);
|
||||
} catch (...) {
|
||||
cerr << "could not create socket with " << argv[1] << endl;
|
||||
help();
|
||||
|
@ -53,7 +53,6 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify, mu
|
||||
}
|
||||
delete shm;
|
||||
|
||||
|
||||
initSharedMemory(true, type, multiId, verify);
|
||||
initializeDetectorStructure(type);
|
||||
initializeMembers();
|
||||
@ -81,8 +80,10 @@ slsDetector::slsDetector(int multiId, int id, bool verify, multiSlsDetector* m)
|
||||
offset(0) {
|
||||
/* called from multi constructor to populate structure,
|
||||
* so sls shared memory will be opened, not created */
|
||||
|
||||
// getDetectorType Froom shm will check if it was already existing
|
||||
detectorType type = getDetectorTypeFromShm(multiId, verify);
|
||||
|
||||
initSharedMemory(false, type, multiId, verify);
|
||||
initializeMembers();
|
||||
}
|
||||
@ -424,41 +425,46 @@ void slsDetector::addMultipleDetectors(const char* name) {
|
||||
cprintf(RED, "Error: Add Multiple Detectors should not be called at this level\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* pre: sharedMemory=0, thisDetector = 0
|
||||
* exceptions are caught in calling function, shm unmapped and deleted
|
||||
*/
|
||||
void slsDetector::initSharedMemory(bool created, detectorType type, int multiId,
|
||||
bool verify) {
|
||||
if (sharedMemory)
|
||||
delete sharedMemory;
|
||||
thisDetector = 0;
|
||||
try {
|
||||
// calculate shared memory size
|
||||
int sz = calculateSharedMemorySize(type);
|
||||
|
||||
// calculate shared memory size
|
||||
int sz = calculateSharedMemorySize(type);
|
||||
// shared memory object with name
|
||||
sharedMemory = new SharedMemory(multiId, detId);
|
||||
|
||||
// shared memory object with name
|
||||
sharedMemory = new SharedMemory(multiId, detId);
|
||||
// create
|
||||
if (created) {
|
||||
try {
|
||||
// create
|
||||
if (created) {
|
||||
thisDetector = (sharedSlsDetector*)sharedMemory->CreateSharedMemory(sz);
|
||||
} catch(...) {
|
||||
sharedMemory->RemoveSharedMemory();
|
||||
}
|
||||
// open and verify version
|
||||
else {
|
||||
thisDetector = (sharedSlsDetector*)sharedMemory->OpenSharedMemory(sz);
|
||||
if (verify && thisDetector->shmversion != SLS_SHMVERSION) {
|
||||
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
|
||||
"(expected 0x%x but got 0x%x)\n",
|
||||
multiId, detId, SLS_SHMVERSION,
|
||||
thisDetector->shmversion);
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
}
|
||||
} catch(...) {
|
||||
if (sharedMemory) {
|
||||
// unmap
|
||||
if (thisDetector) {
|
||||
sharedMemory->UnmapSharedMemory(thisDetector);
|
||||
thisDetector = 0;
|
||||
}
|
||||
// delete
|
||||
delete sharedMemory;
|
||||
sharedMemory = 0;
|
||||
thisDetector = 0;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
// open and verify version
|
||||
else {
|
||||
thisDetector = (sharedSlsDetector*)sharedMemory->OpenSharedMemory(sz);
|
||||
if (verify && thisDetector->shmversion != SLS_SHMVERSION) {
|
||||
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
|
||||
"(expected 0x%x but got 0x%x)\n",
|
||||
multiId, detId, SLS_SHMVERSION, thisDetector->shmversion);
|
||||
sharedMemory->UnmapSharedMemory(thisDetector); /** is this unncessary? */
|
||||
delete sharedMemory;/** is this unncessary? */
|
||||
sharedMemory = 0;
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1251,35 +1257,48 @@ int slsDetector::receiveModule(sls_detector_module* myMod) {
|
||||
|
||||
|
||||
slsReceiverDefs::detectorType slsDetector::getDetectorTypeFromShm(int multiId, bool verify) {
|
||||
SharedMemory* shm = new SharedMemory(multiId, detId);
|
||||
// shm not created before
|
||||
if (!shm->IsExisting()) {
|
||||
cprintf(RED,"Shared memory %s does not exist.\n"
|
||||
"Corrupted Multi Shared memory. Please free shared memory.\n",
|
||||
shm->GetName().c_str());
|
||||
throw SharedMemoryException();
|
||||
|
||||
detectorType type = GENERIC;
|
||||
SharedMemory* shm = 0;
|
||||
|
||||
try {
|
||||
// create
|
||||
shm = new SharedMemory(multiId, detId);
|
||||
|
||||
// shm not created before
|
||||
if (!shm->IsExisting()) {
|
||||
cprintf(RED,"Shared memory %s does not exist.\n"
|
||||
"Corrupted Multi Shared memory. Please free shared memory.\n",
|
||||
shm->GetName().c_str());
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
|
||||
// only basic size of structure (just version is required)
|
||||
sharedSlsDetector* sdet = 0;
|
||||
size_t sz = sizeof(sharedSlsDetector);
|
||||
|
||||
// open, map, verify version
|
||||
sdet = (sharedSlsDetector*)shm->OpenSharedMemory(sz);
|
||||
if (verify && sdet->shmversion != SLS_SHMVERSION) {
|
||||
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
|
||||
"(expected 0x%x but got 0x%x)\n",
|
||||
multiId, detId, SLS_SHMVERSION, sdet->shmversion);
|
||||
// unmap and throw
|
||||
sharedMemory->UnmapSharedMemory(thisDetector);
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
|
||||
// get type, unmap
|
||||
type = sdet->myDetectorType;
|
||||
shm->UnmapSharedMemory(sdet);
|
||||
delete shm;
|
||||
|
||||
} catch (...) {
|
||||
if (shm)
|
||||
delete shm;
|
||||
throw;
|
||||
}
|
||||
|
||||
// map basic size of sls detector structure (no need of offsets, just version is required)
|
||||
sharedSlsDetector* sdet = 0;
|
||||
size_t sz = sizeof(sharedSlsDetector);
|
||||
|
||||
// open, map, verify version, get type
|
||||
sdet = (sharedSlsDetector*)shm->OpenSharedMemory(sz);
|
||||
if (verify && sdet->shmversion != SLS_SHMVERSION) {
|
||||
cprintf(RED, "Single shared memory (%d-%d:)version mismatch "
|
||||
"(expected 0x%x but got 0x%x)\n",
|
||||
multiId, detId, SLS_SHMVERSION, sdet->shmversion);
|
||||
shm->UnmapSharedMemory(sdet); /** is this unncessary? */
|
||||
delete shm;/** is this unncessary? */
|
||||
throw SharedMemoryException();
|
||||
}
|
||||
detectorType type = sdet->myDetectorType;
|
||||
|
||||
// unmap
|
||||
shm->UnmapSharedMemory(sdet);
|
||||
delete shm;
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -1291,8 +1310,7 @@ slsDetectorDefs::detectorType slsDetector::getDetectorType(const char *name, int
|
||||
MySocketTCP* mySocket = 0;
|
||||
|
||||
try {
|
||||
MySocketTCP* s= new MySocketTCP(name, cport);
|
||||
mySocket = s;
|
||||
mySocket = new MySocketTCP(name, cport);
|
||||
} catch(...) {
|
||||
cout << "Cannot create socket to server " << name << " over port " << cport << endl;
|
||||
return t;
|
||||
@ -1755,7 +1773,7 @@ string slsDetector::checkOnline() {
|
||||
controlSocket->SetTimeOut(5);
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
delete controlSocket;
|
||||
controlSocket=NULL;
|
||||
controlSocket=0;
|
||||
retval = string(thisDetector->hostname);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "offline!" << std::endl;
|
||||
@ -1775,7 +1793,7 @@ string slsDetector::checkOnline() {
|
||||
stopSocket->SetTimeOut(5);
|
||||
thisDetector->onlineFlag=OFFLINE_FLAG;
|
||||
delete stopSocket;
|
||||
stopSocket=NULL;
|
||||
stopSocket=0;
|
||||
retval = string(thisDetector->hostname);
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "stop offline!" << std::endl;
|
||||
@ -1808,11 +1826,11 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
strcpy(thisDetector->hostname,thisName);
|
||||
if (controlSocket) {
|
||||
delete controlSocket;
|
||||
controlSocket=NULL;
|
||||
controlSocket=0;
|
||||
}
|
||||
if (stopSocket) {
|
||||
delete stopSocket;
|
||||
stopSocket=NULL;
|
||||
stopSocket=0;
|
||||
}
|
||||
} else
|
||||
strcpy(thisName,thisDetector->hostname);
|
||||
@ -1825,7 +1843,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
thisDetector->controlPort=thisCP;
|
||||
if (controlSocket) {
|
||||
delete controlSocket;
|
||||
controlSocket=NULL;
|
||||
controlSocket=0;
|
||||
}
|
||||
} else
|
||||
thisCP=thisDetector->controlPort;
|
||||
@ -1838,7 +1856,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
thisDetector->stopPort=thisSP;
|
||||
if (stopSocket) {
|
||||
delete stopSocket;
|
||||
stopSocket=NULL;
|
||||
stopSocket=0;
|
||||
}
|
||||
} else
|
||||
thisSP=thisDetector->stopPort;
|
||||
@ -1847,8 +1865,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
// create control socket
|
||||
if (!controlSocket) {
|
||||
try {
|
||||
MySocketTCP* s = new MySocketTCP(thisName, thisCP);
|
||||
controlSocket = s;
|
||||
controlSocket = new MySocketTCP(thisName, thisCP);
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< "Control socket connected " <<
|
||||
thisName << " " << thisCP << std::endl;
|
||||
@ -1858,7 +1875,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
std::cout<< "Could not connect Control socket " <<
|
||||
thisName << " " << thisCP << std::endl;
|
||||
#endif
|
||||
controlSocket = NULL;
|
||||
controlSocket = 0;
|
||||
retval = FAIL;
|
||||
}
|
||||
}
|
||||
@ -1867,8 +1884,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
// create stop socket
|
||||
if (!stopSocket) {
|
||||
try {
|
||||
MySocketTCP* s = new MySocketTCP(thisName, thisSP);
|
||||
stopSocket = s;
|
||||
stopSocket = new MySocketTCP(thisName, thisSP);
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< "Stop socket connected " <<
|
||||
thisName << " " << thisSP << std::endl;
|
||||
@ -1878,7 +1894,7 @@ int slsDetector::setTCPSocket(string const name, int const control_port, int con
|
||||
std::cout<< "Could not connect Stop socket " <<
|
||||
thisName << " " << thisSP << std::endl;
|
||||
#endif
|
||||
stopSocket = NULL;
|
||||
stopSocket = 0;
|
||||
retval = FAIL;
|
||||
}
|
||||
}
|
||||
@ -1921,7 +1937,7 @@ int slsDetector::setPort(portType index, int num) {
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int ret=FAIL;
|
||||
bool online=false;
|
||||
MySocketTCP *s;
|
||||
MySocketTCP *s = 0;
|
||||
|
||||
if (num>1024) {
|
||||
switch(index) {
|
||||
@ -1933,7 +1949,7 @@ int slsDetector::setPort(portType index, int num) {
|
||||
cout << thisDetector->controlPort<< " " << " " << thisDetector->stopPort
|
||||
<< endl;
|
||||
#endif
|
||||
if (s==NULL) {
|
||||
if (s==0) {
|
||||
|
||||
#ifdef VERBOSE
|
||||
cout << "s=NULL"<< endl;
|
||||
@ -1971,7 +1987,7 @@ int slsDetector::setPort(portType index, int num) {
|
||||
s=dataSocket;
|
||||
retval=thisDetector->receiverTCPPort;
|
||||
if(strcmp(thisDetector->receiver_hostname,"none")){
|
||||
if (s==NULL) setReceiverTCPSocket("",retval);
|
||||
if (s==0) setReceiverTCPSocket("",retval);
|
||||
if (dataSocket)s=dataSocket;
|
||||
}
|
||||
online = (thisDetector->receiverOnlineFlag==ONLINE_FLAG);
|
||||
@ -1991,7 +2007,7 @@ int slsDetector::setPort(portType index, int num) {
|
||||
case STOP_PORT:
|
||||
s=stopSocket;
|
||||
retval=thisDetector->stopPort;
|
||||
if (s==NULL) setTCPSocket("",-1,DEFAULT_PORTNO+1);
|
||||
if (s==0) setTCPSocket("",-1,DEFAULT_PORTNO+1);
|
||||
if (stopSocket) s=stopSocket;
|
||||
else setTCPSocket("",-1,retval);
|
||||
online = (thisDetector->onlineFlag==ONLINE_FLAG);
|
||||
@ -2008,7 +2024,7 @@ int slsDetector::setPort(portType index, int num) {
|
||||
break;
|
||||
|
||||
default:
|
||||
s=NULL;
|
||||
s=0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -8271,7 +8287,7 @@ string slsDetector::checkReceiverOnline() {
|
||||
dataSocket->SetTimeOut(5);
|
||||
thisDetector->receiverOnlineFlag=OFFLINE_FLAG;
|
||||
delete dataSocket;
|
||||
dataSocket=NULL;
|
||||
dataSocket=0;
|
||||
#ifdef VERBOSE
|
||||
std::cout<< "receiver offline!" << std::endl;
|
||||
#endif
|
||||
@ -8308,7 +8324,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
|
||||
strcpy(thisDetector->receiver_hostname,thisName);
|
||||
if (dataSocket){
|
||||
delete dataSocket;
|
||||
dataSocket=NULL;
|
||||
dataSocket=0;
|
||||
}
|
||||
} else
|
||||
strcpy(thisName,thisDetector->receiver_hostname);
|
||||
@ -8322,7 +8338,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
|
||||
thisDetector->receiverTCPPort=thisRP;
|
||||
if (dataSocket){
|
||||
delete dataSocket;
|
||||
dataSocket=NULL;
|
||||
dataSocket=0;
|
||||
}
|
||||
} else
|
||||
thisRP=thisDetector->receiverTCPPort;
|
||||
@ -8330,8 +8346,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
|
||||
//create data socket
|
||||
if (!dataSocket) {
|
||||
try {
|
||||
MySocketTCP* s = new MySocketTCP(thisName, thisRP);
|
||||
dataSocket = s;
|
||||
dataSocket = new MySocketTCP(thisName, thisRP);
|
||||
#ifdef VERYVERBOSE
|
||||
std::cout<< "Data socket connected " <<
|
||||
thisName << " " << thisRP << std::endl;
|
||||
@ -8341,7 +8356,7 @@ int slsDetector::setReceiverTCPSocket(string const name, int const receiver_port
|
||||
std::cout<< "Could not connect Data socket " <<
|
||||
thisName << " " << thisRP << std::endl;
|
||||
#endif
|
||||
dataSocket = NULL;
|
||||
dataSocket = 0;
|
||||
retval = FAIL;
|
||||
}
|
||||
}
|
||||
|
@ -271,16 +271,14 @@ public:
|
||||
dset->extend(dims);
|
||||
delete dspace;
|
||||
dspace = 0;
|
||||
DataSpace* d = new DataSpace(dset->getSpace());
|
||||
dspace = d;
|
||||
dspace = new DataSpace(dset->getSpace());
|
||||
|
||||
hsize_t dims_para[1] = {dims[0]};
|
||||
for (unsigned int i = 0; i < dset_para.size(); ++i)
|
||||
dset_para[i]->extend(dims_para);
|
||||
delete dspace_para;
|
||||
dspace_para = 0;
|
||||
DataSpace* ds = new DataSpace(dset_para[0]->getSpace());
|
||||
dspace_para = ds;
|
||||
dspace_para = new DataSpace(dset_para[0]->getSpace());
|
||||
|
||||
}
|
||||
catch(Exception error){
|
||||
@ -322,16 +320,15 @@ public:
|
||||
|
||||
FileAccPropList flist;
|
||||
flist.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||
int k = 0;
|
||||
fd = 0;
|
||||
if(!owenable)
|
||||
k = new H5File( fname.c_str(), H5F_ACC_EXCL,
|
||||
fd = new H5File( fname.c_str(), H5F_ACC_EXCL,
|
||||
FileCreatPropList::DEFAULT,
|
||||
flist );
|
||||
else
|
||||
k = new H5File( fname.c_str(), H5F_ACC_TRUNC,
|
||||
fd = new H5File( fname.c_str(), H5F_ACC_TRUNC,
|
||||
FileCreatPropList::DEFAULT,
|
||||
flist );
|
||||
fd = k;
|
||||
|
||||
//variables
|
||||
DataSpace dataspace = DataSpace (H5S_SCALAR);
|
||||
@ -466,16 +463,15 @@ public:
|
||||
//file
|
||||
FileAccPropList fapl;
|
||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||
int k = 0;
|
||||
fd = 0;
|
||||
if(!owenable)
|
||||
k = new H5File( fname.c_str(), H5F_ACC_EXCL,
|
||||
fd = new H5File( fname.c_str(), H5F_ACC_EXCL,
|
||||
FileCreatPropList::DEFAULT,
|
||||
fapl );
|
||||
else
|
||||
k = new H5File( fname.c_str(), H5F_ACC_TRUNC,
|
||||
fd = new H5File( fname.c_str(), H5F_ACC_TRUNC,
|
||||
FileCreatPropList::DEFAULT,
|
||||
fapl );
|
||||
fd = k;
|
||||
|
||||
//attributes - version
|
||||
double dValue=version;
|
||||
@ -486,8 +482,8 @@ public:
|
||||
//dataspace
|
||||
hsize_t srcdims[3] = {nDimx, nDimy, nDimz};
|
||||
hsize_t srcdimsmax[3] = {H5S_UNLIMITED, nDimy, nDimz};
|
||||
DataSpace* d = new DataSpace (3,srcdims,srcdimsmax);
|
||||
dspace = d;
|
||||
dspace = 0;
|
||||
dspace = new DataSpace (3,srcdims,srcdimsmax);
|
||||
|
||||
|
||||
//dataset name
|
||||
@ -504,14 +500,14 @@ public:
|
||||
// always create chunked dataset as unlimited is only supported with chunked layout
|
||||
hsize_t chunk_dims[3] ={maxchunkedimages, nDimy, nDimz};
|
||||
plist.setChunk(3, chunk_dims);
|
||||
DataSet* ds = new DataSet (fd->createDataSet(dsetname.c_str(), dtype, *dspace, plist));
|
||||
dset = ds;
|
||||
dset = 0;
|
||||
dset = new DataSet (fd->createDataSet(dsetname.c_str(), dtype, *dspace, plist));
|
||||
|
||||
//create parameter datasets
|
||||
hsize_t dims[1] = {nDimx};
|
||||
hsize_t dimsmax[1] = {H5S_UNLIMITED};
|
||||
DataSpace* dsp = new DataSpace (1,dims,dimsmax);
|
||||
dspace_para = dsp;
|
||||
dspace_para = 0;
|
||||
dspace_para = new DataSpace (1,dims,dimsmax);
|
||||
|
||||
// always create chunked dataset as unlimited is only supported with chunked layout
|
||||
DSetCreatPropList paralist;
|
||||
@ -842,6 +838,7 @@ public:
|
||||
//new file
|
||||
FileAccPropList fapl;
|
||||
fapl.setFcloseDegree(H5F_CLOSE_STRONG);
|
||||
newfd = 0;
|
||||
if(!owenable)
|
||||
newfd = new H5File( newFileName.c_str(), H5F_ACC_EXCL,
|
||||
FileCreatPropList::DEFAULT,
|
||||
@ -851,7 +848,7 @@ public:
|
||||
FileCreatPropList::DEFAULT,
|
||||
fapl );
|
||||
//dataspace and dataset
|
||||
DataSpace* newDataspace;
|
||||
DataSpace* newDataspace = 0;
|
||||
if (rank == 3) {
|
||||
hsize_t dims[3] = {nDimx, nDimy, nDimz};
|
||||
newDataspace = new DataSpace (3,dims);
|
||||
@ -859,7 +856,8 @@ public:
|
||||
hsize_t dims[2] = {nDimx, nDimy};
|
||||
newDataspace = new DataSpace (2,dims);
|
||||
}
|
||||
DataSet* newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace));
|
||||
DataSet* newDataset = 0;
|
||||
newDataset = new DataSet( newfd->createDataSet(newDatasetName.c_str(), datatype, *newDataspace));
|
||||
//write and close
|
||||
newDataset->write(data_out,datatype);
|
||||
newfd->close();
|
||||
|
@ -10,26 +10,30 @@
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
struct SlsDetectorPackageExceptions : public std::exception {
|
||||
public:
|
||||
SlsDetectorPackageExceptions() {}
|
||||
std::string GetMessage() const { return "SLS Detector Package Failed";};
|
||||
};
|
||||
|
||||
struct SharedMemoryException : public std::exception {
|
||||
struct SharedMemoryException : public SlsDetectorPackageExceptions {
|
||||
public:
|
||||
SharedMemoryException() {}
|
||||
std::string GetMessage() const { return "Shared Memory Failed";};
|
||||
};
|
||||
|
||||
struct ThreadpoolException : public std::exception {
|
||||
struct ThreadpoolException : public SlsDetectorPackageExceptions {
|
||||
public:
|
||||
ThreadpoolException() {}
|
||||
std::string GetMessage() const { return "Threadpool Failed";};
|
||||
};
|
||||
|
||||
struct SocketException : public std::exception {
|
||||
struct SocketException : public SlsDetectorPackageExceptions {
|
||||
public:
|
||||
SocketException() {}
|
||||
std::string GetMessage() const { return "Socket Failed";};
|
||||
};
|
||||
|
||||
|
||||
struct SamePortSocketException : public SocketException {
|
||||
public:
|
||||
SamePortSocketException() {}
|
||||
|
@ -132,8 +132,7 @@ void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srci
|
||||
uint32_t portnum = port + index;
|
||||
|
||||
try {
|
||||
ZmqSocket* z = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||
zmqSocket = z;
|
||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
|
||||
throw;
|
||||
|
@ -194,10 +194,9 @@ int Listener::CreateUDPSockets() {
|
||||
ShutDownUDPSocket();
|
||||
|
||||
try{
|
||||
genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
||||
*udpSocketBufferSize);
|
||||
udpSocket = g;
|
||||
FILE_LOG(logINFO) << index << ": UDP port opened at port " << *udpPortNumber;
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber;
|
||||
@ -254,10 +253,9 @@ int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
||||
|
||||
//create dummy socket
|
||||
try {
|
||||
genericSocket* g = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||
generalData->packetSize, (strlen(eth)?eth:NULL), generalData->headerPacketSize,
|
||||
*udpSocketBufferSize);
|
||||
udpSocket = g;
|
||||
} catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create a test UDP socket on port " << *udpPortNumber;
|
||||
return FAIL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user