mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 23:37:14 +02:00
Merge branch 'refactor' of github.com:slsdetectorgroup/slsDetectorPackage into refactor
This commit is contained in:
@ -394,7 +394,7 @@ void multiSlsDetector::initSharedMemory(bool verify) {
|
|||||||
// shared memory object with name
|
// shared memory object with name
|
||||||
sharedMemory = new SharedMemory(detId, -1);
|
sharedMemory = new SharedMemory(detId, -1);
|
||||||
size_t sz = sizeof(sharedMultiSlsDetector);
|
size_t sz = sizeof(sharedMultiSlsDetector);
|
||||||
|
|
||||||
//create
|
//create
|
||||||
if (!sharedMemory->IsExisting()) {
|
if (!sharedMemory->IsExisting()) {
|
||||||
thisMultiDetector = (sharedMultiSlsDetector*)sharedMemory->CreateSharedMemory(sz);
|
thisMultiDetector = (sharedMultiSlsDetector*)sharedMemory->CreateSharedMemory(sz);
|
||||||
@ -940,8 +940,6 @@ int multiSlsDetector::readConfigurationFile(std::string const fname) {
|
|||||||
freeSharedMemory();
|
freeSharedMemory();
|
||||||
setupMultiDetector();
|
setupMultiDetector();
|
||||||
|
|
||||||
|
|
||||||
multiSlsDetectorClient* cmd;
|
|
||||||
std::string ans;
|
std::string ans;
|
||||||
std::string str;
|
std::string str;
|
||||||
std::ifstream infile;
|
std::ifstream infile;
|
||||||
@ -995,8 +993,7 @@ int multiSlsDetector::readConfigurationFile(std::string const fname) {
|
|||||||
std::cout << args[ia] << " ??????? ";
|
std::cout << args[ia] << " ??????? ";
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
#endif
|
#endif
|
||||||
cmd = new multiSlsDetectorClient(iargval, args, PUT_ACTION, this);
|
multiSlsDetectorClient(iargval, args, PUT_ACTION, this);
|
||||||
delete cmd;
|
|
||||||
}
|
}
|
||||||
++iline;
|
++iline;
|
||||||
}
|
}
|
||||||
@ -1043,18 +1040,18 @@ int multiSlsDetector::writeConfigurationFile(std::string const fname) {
|
|||||||
outfile.open(fname.c_str(), std::ios_base::out);
|
outfile.open(fname.c_str(), std::ios_base::out);
|
||||||
if (outfile.is_open()) {
|
if (outfile.is_open()) {
|
||||||
|
|
||||||
slsDetectorCommand* cmd = new slsDetectorCommand(this);
|
auto cmd = slsDetectorCommand(this);
|
||||||
|
|
||||||
// complete size of detector
|
// complete size of detector
|
||||||
std::cout << iline << " " << names[iline] << std::endl;
|
std::cout << iline << " " << names[iline] << std::endl;
|
||||||
strcpy(args[0], names[iline].c_str());
|
strcpy(args[0], names[iline].c_str());
|
||||||
outfile << names[iline] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl;
|
outfile << names[iline] << " " << cmd.executeLine(1, args, GET_ACTION) << std::endl;
|
||||||
++iline;
|
++iline;
|
||||||
|
|
||||||
// hostname of the detectors
|
// hostname of the detectors
|
||||||
std::cout << iline << " " << names[iline] << std::endl;
|
std::cout << iline << " " << names[iline] << std::endl;
|
||||||
strcpy(args[0], names[iline].c_str());
|
strcpy(args[0], names[iline].c_str());
|
||||||
outfile << names[iline] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl;
|
outfile << names[iline] << " " << cmd.executeLine(1, args, GET_ACTION) << std::endl;
|
||||||
++iline;
|
++iline;
|
||||||
|
|
||||||
// single detector configuration
|
// single detector configuration
|
||||||
@ -1072,11 +1069,9 @@ int multiSlsDetector::writeConfigurationFile(std::string const fname) {
|
|||||||
while (iline < nvar) {
|
while (iline < nvar) {
|
||||||
std::cout << iline << " " << names[iline] << std::endl;
|
std::cout << iline << " " << names[iline] << std::endl;
|
||||||
strcpy(args[0], names[iline].c_str());
|
strcpy(args[0], names[iline].c_str());
|
||||||
outfile << names[iline] << " " << cmd->executeLine(1, args, GET_ACTION) << std::endl;
|
outfile << names[iline] << " " << cmd.executeLine(1, args, GET_ACTION) << std::endl;
|
||||||
++iline;
|
++iline;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cmd;
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout << "wrote " << iline << " lines to configuration file " << std::endl;
|
std::cout << "wrote " << iline << " lines to configuration file " << std::endl;
|
||||||
@ -3547,7 +3542,7 @@ int multiSlsDetector::retrieveDetectorSetup(std::string const fname1, int level)
|
|||||||
|
|
||||||
infile.open(fname.c_str(), std::ios_base::in);
|
infile.open(fname.c_str(), std::ios_base::in);
|
||||||
if (infile.is_open()) {
|
if (infile.is_open()) {
|
||||||
cmd=new slsDetectorCommand(this);
|
auto cmd = slsDetectorCommand(this);
|
||||||
while (infile.good() and interrupt==0) {
|
while (infile.good() and interrupt==0) {
|
||||||
sargname="none";
|
sargname="none";
|
||||||
sargval="0";
|
sargval="0";
|
||||||
@ -3583,11 +3578,10 @@ int multiSlsDetector::retrieveDetectorSetup(std::string const fname1, int level)
|
|||||||
skip=1;
|
skip=1;
|
||||||
}
|
}
|
||||||
if (skip==0)
|
if (skip==0)
|
||||||
cmd->executeLine(iargval,args,PUT_ACTION);
|
cmd.executeLine(iargval,args,PUT_ACTION);
|
||||||
}
|
}
|
||||||
iline++;
|
iline++;
|
||||||
}
|
}
|
||||||
delete cmd;
|
|
||||||
infile.close();
|
infile.close();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -3606,8 +3600,6 @@ int multiSlsDetector::retrieveDetectorSetup(std::string const fname1, int level)
|
|||||||
|
|
||||||
|
|
||||||
int multiSlsDetector::dumpDetectorSetup(std::string const fname, int level){
|
int multiSlsDetector::dumpDetectorSetup(std::string const fname, int level){
|
||||||
|
|
||||||
slsDetectorCommand *cmd;
|
|
||||||
detectorType type = getDetectorsType();
|
detectorType type = getDetectorsType();
|
||||||
std::string names[100];
|
std::string names[100];
|
||||||
int nvar=0;
|
int nvar=0;
|
||||||
@ -3709,14 +3701,11 @@ int multiSlsDetector::dumpDetectorSetup(std::string const fname, int level){
|
|||||||
|
|
||||||
outfile.open(fname1.c_str(),std::ios_base::out);
|
outfile.open(fname1.c_str(),std::ios_base::out);
|
||||||
if (outfile.is_open()) {
|
if (outfile.is_open()) {
|
||||||
cmd=new slsDetectorCommand(this);
|
auto cmd = slsDetectorCommand(this);
|
||||||
for (iv=0; iv<nvar; iv++) {
|
for (iv=0; iv<nvar; iv++) {
|
||||||
strcpy(args[0],names[iv].c_str());
|
strcpy(args[0],names[iv].c_str());
|
||||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION) << std::endl;
|
outfile << names[iv] << " " << cmd.executeLine(1,args,GET_ACTION) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cmd;
|
|
||||||
|
|
||||||
outfile.close();
|
outfile.close();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -42,13 +42,12 @@ slsDetector::slsDetector(detectorType type, int multiId, int id, bool verify)
|
|||||||
* so sls shared memory will be created */
|
* so sls shared memory will be created */
|
||||||
|
|
||||||
// ensure shared memory was not created before
|
// ensure shared memory was not created before
|
||||||
SharedMemory* shm = new SharedMemory(multiId, id);
|
auto shm = SharedMemory(multiId, id);
|
||||||
if (shm->IsExisting()) {
|
if (shm.IsExisting()) {
|
||||||
cprintf(YELLOW BOLD,"Warning: Weird, this shared memory should have been "
|
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);
|
freeSharedMemory(multiId, id);
|
||||||
}
|
}
|
||||||
delete shm;
|
|
||||||
|
|
||||||
initSharedMemory(true, type, multiId, verify);
|
initSharedMemory(true, type, multiId, verify);
|
||||||
initializeDetectorStructure(type);
|
initializeDetectorStructure(type);
|
||||||
@ -261,9 +260,8 @@ int64_t slsDetector::getId( idMode mode) {
|
|||||||
|
|
||||||
|
|
||||||
void slsDetector::freeSharedMemory(int multiId, int slsId) {
|
void slsDetector::freeSharedMemory(int multiId, int slsId) {
|
||||||
SharedMemory* shm = new SharedMemory(multiId, slsId);
|
auto shm = SharedMemory(multiId, slsId);
|
||||||
shm->RemoveSharedMemory();
|
shm.RemoveSharedMemory();
|
||||||
delete shm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void slsDetector::freeSharedMemory() {
|
void slsDetector::freeSharedMemory() {
|
||||||
@ -1156,7 +1154,9 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
|
|||||||
int thisCP, thisSP;
|
int thisCP, thisSP;
|
||||||
int retval=OK;
|
int retval=OK;
|
||||||
|
|
||||||
if (strcmp(name.c_str(),"")!=0) {
|
if (name.empty()){
|
||||||
|
strcpy(thisName,thisDetector->hostname);
|
||||||
|
}else{
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
std::cout<< "setting hostname" << std::endl;
|
std::cout<< "setting hostname" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -1170,8 +1170,8 @@ int slsDetector::setTCPSocket(std::string const name, int const control_port, in
|
|||||||
delete stopSocket;
|
delete stopSocket;
|
||||||
stopSocket=0;
|
stopSocket=0;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
strcpy(thisName,thisDetector->hostname);
|
|
||||||
|
|
||||||
if (control_port>0) {
|
if (control_port>0) {
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -1704,8 +1704,7 @@ int slsDetector::writeConfigurationFile(std::string const fname, multiSlsDetecto
|
|||||||
|
|
||||||
|
|
||||||
int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m) {
|
int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector* m) {
|
||||||
;
|
|
||||||
slsDetectorCommand *cmd=new slsDetectorCommand(m);
|
|
||||||
detectorType type = thisDetector->myDetectorType;
|
detectorType type = thisDetector->myDetectorType;
|
||||||
std::string names[100];
|
std::string names[100];
|
||||||
int nvar=0;
|
int nvar=0;
|
||||||
@ -1773,25 +1772,23 @@ int slsDetector::writeConfigurationFile(std::ofstream &outfile, multiSlsDetector
|
|||||||
args[ia]=myargs[ia];
|
args[ia]=myargs[ia];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto cmd = slsDetectorCommand(m);
|
||||||
for (iv=0; iv<nvar; ++iv) {
|
for (iv=0; iv<nvar; ++iv) {
|
||||||
std::cout << iv << " " << names[iv] << std::endl;
|
std::cout << iv << " " << names[iv] << std::endl;
|
||||||
if (names[iv]=="extsig") {
|
if (names[iv]=="extsig") {
|
||||||
for (int is=0; is<nsig; ++is) {
|
for (int is=0; is<nsig; ++is) {
|
||||||
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
|
sprintf(args[0],"%s:%d",names[iv].c_str(),is);
|
||||||
outfile << detId << ":";
|
outfile << detId << ":";
|
||||||
outfile << args[0] << " " << cmd->executeLine(1,args,GET_ACTION)
|
outfile << args[0] << " " << cmd.executeLine(1,args,GET_ACTION)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strcpy(args[0],names[iv].c_str());
|
strcpy(args[0],names[iv].c_str());
|
||||||
outfile << detId << ":";
|
outfile << detId << ":";
|
||||||
outfile << names[iv] << " " << cmd->executeLine(1,args,GET_ACTION)
|
outfile << names[iv] << " " << cmd.executeLine(1,args,GET_ACTION)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete cmd;
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user