Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor

This commit is contained in:
2018-10-11 12:25:27 +02:00
2 changed files with 24 additions and 38 deletions

View File

@ -42,13 +42,12 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify)
* so sls shared memory will be created */
// ensure shared memory was not created before
SharedMemory* shm = new SharedMemory(multiId, id);
if (shm->IsExisting()) {
auto shm = SharedMemory(multiId, id);
if (shm.IsExisting()) {
cprintf(YELLOW BOLD,"Warning: Weird, this shared memory should have been "
"deleted before! %s. Freeing it again.\n", shm->GetName().c_str());
"deleted before! %s. Freeing it again.\n", shm.GetName().c_str());
freeSharedMemory(multiId, id);
}
delete shm;
initSharedMemory(true, type, multiId, verify);
initializeDetectorStructure(type);
@ -261,9 +260,8 @@ int64_t slsDetector::getId( idMode mode) {
void slsDetector::freeSharedMemory(int multiId, int slsId) {
SharedMemory* shm = new SharedMemory(multiId, slsId);
shm->RemoveSharedMemory();
delete shm;
auto shm = SharedMemory(multiId, slsId);
shm.RemoveSharedMemory();
}
void slsDetector::freeSharedMemory() {
@ -1156,7 +1154,9 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
int thisCP, thisSP;
int retval=OK;
if (strcmp(name.c_str(),"")!=0) {
if (name.empty()){
strcpy(thisName,thisDetector->hostname);
}else{
#ifdef VERBOSE
std::cout<< "setting hostname" << std::endl;
#endif
@ -1170,8 +1170,8 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
delete stopSocket;
stopSocket=0;
}
} else
strcpy(thisName,thisDetector->hostname);
}
if (control_port>0) {
#ifdef VERBOSE
@ -1704,8 +1704,7 @@ int slsDetector::writeConfigurationFile(std::string const fname, multiSlsDetecto
int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m) {
;
slsDetectorCommand *cmd=new slsDetectorCommand(m);
detectorType type = thisDetector->myDetectorType;
std::string names[100];
int nvar=0;
@ -1773,25 +1772,23 @@ int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector
args[ia]=myargs[ia];
}
auto cmd = slsDetectorCommand(m);
for (iv=0; iv<nvar; ++iv) {
std::cout << iv << " " << names[iv] << std::endl;
if (names[iv]=="extsig") {
for (int is=0; is<nsig; ++is) {
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
outfile << detId << ":";
outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION)
outfile << args[0] << " " << cmd.executeLine(1,args,GET_ACTION)
<< std::endl;
}
} else {
strcpy(args[0],names[iv].c_str());
outfile << detId << ":";
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION)
outfile << names[iv] << " " << cmd.executeLine(1,args,GET_ACTION)
<< std::endl;
}
}
delete cmd;
return OK;
}