wip, top, master command line

This commit is contained in:
maliakal_d 2022-02-24 17:06:10 +01:00
parent 219318a52e
commit 5869c25658
2 changed files with 73 additions and 1 deletions

View File

@ -33,6 +33,10 @@ extern int isControlServer;
extern void getMacAddressinString(char *cmac, int size, uint64_t mac); extern void getMacAddressinString(char *cmac, int size, uint64_t mac);
extern void getIpAddressinString(char *cip, uint32_t ip); extern void getIpAddressinString(char *cip, uint32_t ip);
// Variables that will be exported
int masterCommandLine = -1;
int topCommandLine = -1;
int initError = OK; int initError = OK;
int initCheckDone = 0; int initCheckDone = 0;
char initErrorMessage[MAX_STR_LENGTH]; char initErrorMessage[MAX_STR_LENGTH];
@ -368,6 +372,7 @@ void initStopServer() {
return; return;
} }
#else #else
// control server read config file and already set up master/top
sharedMemory_lockLocalLink(); sharedMemory_lockLocalLink();
Feb_Interface_FebInterface(); Feb_Interface_FebInterface();
Feb_Control_FebControl(); Feb_Control_FebControl();
@ -432,6 +437,11 @@ int readConfigFile() {
return initError; return initError;
} }
#ifndef VIRTUAL
// if not found in config file, they will be reset to hardware settings
top = -1;
master = -1;
#endif
if (ignoreConfigFileFlag) { if (ignoreConfigFileFlag) {
return OK; return OK;
} }
@ -577,8 +587,10 @@ int readConfigFile() {
LOG(logINFO, ("Successfully read config file\n")); LOG(logINFO, ("Successfully read config file\n"));
} }
#ifndef VIRTUAL
// reset to hardware settings if not in config file (if overwritten) // reset to hardware settings if not in config file (if overwritten)
resetToHardwareSettings(); resetToHardwareSettings();
#endif
return initError; return initError;
} }
@ -590,6 +602,7 @@ void resetToHardwareSettings() {
} }
// top not set in config file // top not set in config file
if (top == -1) { if (top == -1) {
LOG(logINFO, ("Resetting Top to hardware settings\n"));
if (!Beb_SetTop(TOP_HARDWARE)) { if (!Beb_SetTop(TOP_HARDWARE)) {
initError = FAIL; initError = FAIL;
strcpy(initErrorMessage, strcpy(initErrorMessage,
@ -619,6 +632,7 @@ void resetToHardwareSettings() {
} }
// master not set in config file // master not set in config file
if (master == -1) { if (master == -1) {
LOG(logINFO, ("Resetting Master to hardware settings\n"));
if (!Beb_SetMaster(MASTER_HARDWARE)) { if (!Beb_SetMaster(MASTER_HARDWARE)) {
initError = FAIL; initError = FAIL;
strcpy(initErrorMessage, strcpy(initErrorMessage,
@ -649,6 +663,8 @@ void resetToHardwareSettings() {
#endif #endif
} }
int checkCommandLineConfiguration() {}
/* set up detector */ /* set up detector */
void allocateDetectorStructureMemory() { void allocateDetectorStructureMemory() {
@ -1462,7 +1478,7 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */ /* parameters - timing, extsig */
int setMaster(int m) { int setMaster(int m) {
LOG(logINFO, ("Setting up as %s\n", (m == 1 ? "Master" : "Slave"))); LOG(logINFOBLUE, ("Setting up as %s\n", (m == 1 ? "Master" : "Slave")));
#ifdef VIRTUAL #ifdef VIRTUAL
master = m; master = m;
#else #else

View File

@ -32,6 +32,13 @@ extern int ignoreConfigFileFlag;
#ifdef GOTTHARDD #ifdef GOTTHARDD
extern int phaseShift; extern int phaseShift;
#endif #endif
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
defined(MYTHEN3D)
extern int masterCommandLine;
#endif
#ifdef EIGERD
extern int topCommandLine;
#endif
void error(char *msg) { perror(msg); } void error(char *msg) { perror(msg); }
@ -50,6 +57,13 @@ int main(int argc, char *argv[]) {
checkModuleFlag = 1; checkModuleFlag = 1;
int version = 0; int version = 0;
ignoreConfigFileFlag = 0; ignoreConfigFileFlag = 0;
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
defined(MYTHEN3D)
masterCommandLine = -1;
#endif
#ifdef EIGERD
topCommandLine = -1;
#endif
// help message // help message
char helpMessage[MAX_STR_LENGTH]; char helpMessage[MAX_STR_LENGTH];
@ -70,6 +84,11 @@ int main(int argc, char *argv[]) {
"\t-i, --ignore-config : " "\t-i, --ignore-config : "
"[Virtual][Eiger][Jungfrau][Gotthard][Gotthard2] \n" "[Virtual][Eiger][Jungfrau][Gotthard][Gotthard2] \n"
"\t Ignore config file. \n" "\t Ignore config file. \n"
"\t-m, --master <master> : [Eiger][Mythen3][Gotthard][Gotthard2] \n"
"\t Set Master to 0 or 1. Precedence over "
"config file. \n"
"\t-t, --top <top> : [Eiger] Set Top to 0 or 1. Precedence "
"over config file. \n"
"\t-s, --stopserver : Stop server. Do not use as it is created " "\t-s, --stopserver : Stop server. Do not use as it is created "
"by control server \n\n", "by control server \n\n",
argv[0]); argv[0]);
@ -86,6 +105,8 @@ int main(int argc, char *argv[]) {
{"devel", no_argument, NULL, 'd'}, {"devel", no_argument, NULL, 'd'},
{"update", no_argument, NULL, 'u'}, {"update", no_argument, NULL, 'u'},
{"ignore-config", no_argument, NULL, 'i'}, {"ignore-config", no_argument, NULL, 'i'},
{"master", required_argument, NULL, 'm'},
{"top", required_argument, NULL, 't'},
{"stopserver", no_argument, NULL, 's'}, {"stopserver", no_argument, NULL, 's'},
{NULL, 0, NULL, 0}}; {NULL, 0, NULL, 0}};
@ -177,6 +198,41 @@ int main(int argc, char *argv[]) {
#endif #endif
break; break;
case 'm':
#if defined(GOTTHARDD) || defined(GOTTHARD2D) || defined(EIGERD) || \
defined(MYTHEN3D)
if (sscanf(optarg, "%d", &masterCommandLine) != 1) {
LOG(logERROR, ("Cannot scan master argument\n%s", helpMessage));
exit(EXIT_FAILURE);
}
if (masterCommandLine == 0) {
LOG(logINFO, ("Detector Slave mode\n"));
} else {
LOG(logINFO, ("Detector Master mode\n"));
}
#else
LOG(logERROR, ("No master implemented for this detector server\n"));
exit(EXIT_FAILURE);
#endif
break;
case 't':
#ifdef EIGERD
if (sscanf(optarg, "%d", &topCommandLine) != 1) {
LOG(logERROR, ("Cannot scan top argument\n%s", helpMessage));
exit(EXIT_FAILURE);
}
if (topCommandLine == 0) {
LOG(logINFO, ("Detector Top mode\n"));
} else {
LOG(logINFO, ("Detector Bottom mode\n"));
}
#else
LOG(logERROR, ("No top implemented for this detector server\n"));
exit(EXIT_FAILURE);
#endif
break;
case 'h': case 'h':
printf("%s", helpMessage); printf("%s", helpMessage);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);