mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 08:10:02 +02:00
allowed virtual servers
This commit is contained in:
parent
a0bdfcdae3
commit
c6dddaba97
@ -67,6 +67,17 @@ int main(int argc, char *argv[]){
|
|||||||
FILE_LOG(logINFO, ("Detected developer mode\n"));
|
FILE_LOG(logINFO, ("Detected developer mode\n"));
|
||||||
debugflag = 1;
|
debugflag = 1;
|
||||||
}
|
}
|
||||||
|
else if(!strcasecmp(argv[i],"--port")){
|
||||||
|
if ((i + 1) >= argc) {
|
||||||
|
FILE_LOG(logERROR, ("no port value given. Exiting.\n"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (sscanf(argv[i + 1], "%d", &portno) == 0) {
|
||||||
|
FILE_LOG(logERROR, ("cannot decode port value %s. Exiting.\n", argv[i + 1]));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
FILE_LOG(logINFO, ("Detected port: %d\n", portno));
|
||||||
|
}
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
else if(!strcasecmp(argv[i],"-phaseshift")){
|
else if(!strcasecmp(argv[i],"-phaseshift")){
|
||||||
if ((i + 1) >= argc) {
|
if ((i + 1) >= argc) {
|
||||||
@ -88,20 +99,18 @@ int main(int argc, char *argv[]){
|
|||||||
memset(cmd, 0, 100);
|
memset(cmd, 0, 100);
|
||||||
#endif
|
#endif
|
||||||
if (isControlServer) {
|
if (isControlServer) {
|
||||||
portno = DEFAULT_PORTNO;
|
|
||||||
FILE_LOG(logINFO, ("Opening control server on port %d \n", portno));
|
FILE_LOG(logINFO, ("Opening control server on port %d \n", portno));
|
||||||
#ifdef STOP_SERVER
|
#ifdef STOP_SERVER
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < argc; ++i)
|
for (i = 0; i < argc; ++i)
|
||||||
sprintf(cmd, "%s %s", cmd, argv[i]);
|
sprintf(cmd, "%s %s", cmd, argv[i]);
|
||||||
sprintf(cmd,"%s -stopserver&", cmd);
|
sprintf(cmd,"%s -stopserver --port %d &", cmd, portno + 1);
|
||||||
FILE_LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
FILE_LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||||
system(cmd);
|
system(cmd);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
portno = DEFAULT_PORTNO + 1;
|
|
||||||
FILE_LOG(logINFO,("Opening stop server on port %d \n", portno));
|
FILE_LOG(logINFO,("Opening stop server on port %d \n", portno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -405,24 +405,36 @@ void multiSlsDetector::addMultipleDetectors(const char *name) {
|
|||||||
void multiSlsDetector::addSlsDetector(const std::string &hostname) {
|
void multiSlsDetector::addSlsDetector(const std::string &hostname) {
|
||||||
FILE_LOG(logDEBUG1) << "Adding detector " << hostname;
|
FILE_LOG(logDEBUG1) << "Adding detector " << hostname;
|
||||||
|
|
||||||
|
int port = DEFAULT_PORTNO;
|
||||||
|
std::string host = hostname;
|
||||||
|
auto res = sls::split(hostname, ':');
|
||||||
|
if (res.size() > 1) {
|
||||||
|
host = res[0];
|
||||||
|
port = std::stoi(res[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (host != "localhost") {
|
||||||
for (auto &d : detectors) {
|
for (auto &d : detectors) {
|
||||||
if (d->getHostname() == hostname) {
|
if (d->getHostname() == host) {
|
||||||
FILE_LOG(logWARNING)
|
FILE_LOG(logWARNING)
|
||||||
<< "Detector " << hostname
|
<< "Detector " << host
|
||||||
<< "already part of the multiDetector!" << std::endl
|
<< "already part of the multiDetector!" << std::endl
|
||||||
<< "Remove it before adding it back in a new position!";
|
<< "Remove it before adding it back in a new position!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get type by connecting
|
// get type by connecting
|
||||||
detectorType type =
|
detectorType type =
|
||||||
slsDetector::getTypeFromDetector(hostname, DEFAULT_PORTNO);
|
slsDetector::getTypeFromDetector(host, port);
|
||||||
int pos = (int)detectors.size();
|
int pos = (int)detectors.size();
|
||||||
detectors.push_back(
|
detectors.push_back(
|
||||||
sls::make_unique<slsDetector>(type, multiId, pos, false));
|
sls::make_unique<slsDetector>(type, multiId, pos, false));
|
||||||
multi_shm()->numberOfDetectors = detectors.size();
|
multi_shm()->numberOfDetectors = detectors.size();
|
||||||
detectors[pos]->setHostname(hostname);
|
detectors[pos]->setControlPort(port);
|
||||||
|
detectors[pos]->setStopPort(port + 1);
|
||||||
|
detectors[pos]->setHostname(host);
|
||||||
multi_shm()->multiDetectorType = getDetectorTypeAsEnum(-1);// -1 needed here
|
multi_shm()->multiDetectorType = getDetectorTypeAsEnum(-1);// -1 needed here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,13 +23,11 @@
|
|||||||
|
|
||||||
using namespace sls;
|
using namespace sls;
|
||||||
|
|
||||||
#define DEFAULT_HOSTNAME "localhost"
|
|
||||||
|
|
||||||
|
// create shm
|
||||||
slsDetector::slsDetector(detectorType type, int multi_id, int det_id,
|
slsDetector::slsDetector(detectorType type, int multi_id, int det_id,
|
||||||
bool verify)
|
bool verify)
|
||||||
: detId(det_id), shm(multi_id, det_id) {
|
: detId(det_id), shm(multi_id, det_id) {
|
||||||
/* called from put hostname command,
|
|
||||||
* so sls shared memory will be created */
|
|
||||||
|
|
||||||
// ensure shared memory was not created before
|
// ensure shared memory was not created before
|
||||||
if (shm.IsExisting()) {
|
if (shm.IsExisting()) {
|
||||||
@ -42,10 +40,9 @@ slsDetector::slsDetector(detectorType type, int multi_id, int det_id,
|
|||||||
initSharedMemory(type, multi_id, verify);
|
initSharedMemory(type, multi_id, verify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pick up from shm
|
||||||
slsDetector::slsDetector(int multi_id, int det_id, bool verify)
|
slsDetector::slsDetector(int multi_id, int det_id, bool verify)
|
||||||
: detId(det_id), shm(multi_id, det_id) {
|
: detId(det_id), shm(multi_id, det_id) {
|
||||||
/* called from multi constructor to populate structure,
|
|
||||||
* so sls shared memory will be opened, not created */
|
|
||||||
|
|
||||||
// getDetectorType From shm will check if it was already existing
|
// getDetectorType From shm will check if it was already existing
|
||||||
detectorType type = getDetectorTypeFromShm(multi_id, verify);
|
detectorType type = getDetectorTypeFromShm(multi_id, verify);
|
||||||
@ -305,8 +302,7 @@ void slsDetector::initSharedMemory(detectorType type, int multi_id,
|
|||||||
|
|
||||||
void slsDetector::initializeDetectorStructure(detectorType type) {
|
void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||||
shm()->shmversion = SLS_SHMVERSION;
|
shm()->shmversion = SLS_SHMVERSION;
|
||||||
shm()->controlPort = DEFAULT_PORTNO;
|
memset(shm()->hostname, 0, MAX_STR_LENGTH);
|
||||||
sls::strcpy_safe(shm()->hostname, DEFAULT_HOSTNAME);
|
|
||||||
shm()->myDetectorType = type;
|
shm()->myDetectorType = type;
|
||||||
shm()->multiSize.x = 0;
|
shm()->multiSize.x = 0;
|
||||||
shm()->multiSize.y = 0;
|
shm()->multiSize.y = 0;
|
||||||
@ -644,9 +640,13 @@ int slsDetector::setControlPort(int port_number) {
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting control port to " << port_number;
|
FILE_LOG(logDEBUG1) << "Setting control port to " << port_number;
|
||||||
if (port_number >= 0 && port_number != shm()->controlPort) {
|
if (port_number >= 0 && port_number != shm()->controlPort) {
|
||||||
|
if (strlen(shm()->hostname) > 0) {
|
||||||
sendToDetector(F_SET_PORT, port_number, retval);
|
sendToDetector(F_SET_PORT, port_number, retval);
|
||||||
shm()->controlPort = retval;
|
shm()->controlPort = retval;
|
||||||
FILE_LOG(logDEBUG1) << "Control port: " << retval;
|
FILE_LOG(logDEBUG1) << "Control port: " << retval;
|
||||||
|
} else {
|
||||||
|
shm()->controlPort = port_number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return shm()->controlPort;
|
return shm()->controlPort;
|
||||||
}
|
}
|
||||||
@ -655,9 +655,13 @@ int slsDetector::setStopPort(int port_number) {
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Setting stop port to " << port_number;
|
FILE_LOG(logDEBUG1) << "Setting stop port to " << port_number;
|
||||||
if (port_number >= 0 && port_number != shm()->stopPort) {
|
if (port_number >= 0 && port_number != shm()->stopPort) {
|
||||||
|
if (strlen(shm()->hostname) > 0) {
|
||||||
sendToDetectorStop(F_SET_PORT, port_number, retval);
|
sendToDetectorStop(F_SET_PORT, port_number, retval);
|
||||||
shm()->stopPort = retval;
|
shm()->stopPort = retval;
|
||||||
FILE_LOG(logDEBUG1) << "Stop port: " << retval;
|
FILE_LOG(logDEBUG1) << "Stop port: " << retval;
|
||||||
|
} else {
|
||||||
|
shm()->stopPort = port_number;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return shm()->stopPort;
|
return shm()->stopPort;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#define APILIB 0x190723
|
#define APILIB 0x190723
|
||||||
#define APIRECEIVER 0x190722
|
#define APIRECEIVER 0x190722
|
||||||
#define APIGUI 0x190723
|
#define APIGUI 0x190723
|
||||||
#define APIEIGER 0x190816
|
|
||||||
#define APIGOTTHARD 0x190816
|
#define APIGOTTHARD 0x190816
|
||||||
#define APIJUNGFRAU 0x190816
|
#define APIJUNGFRAU 0x190816
|
||||||
#define APIMOENCH 0x190816
|
#define APIMOENCH 0x190816
|
||||||
|
#define APIEIGER 0x190816
|
||||||
|
Loading…
x
Reference in New Issue
Block a user