This commit is contained in:
2020-06-29 19:11:57 +02:00
parent 0c045f0faa
commit 75e9d63341
10 changed files with 165 additions and 297 deletions

View File

@ -31,7 +31,6 @@ extern void getIpAddressinString(char *cip, uint32_t ip);
int initError = OK;
int initCheckDone = 0;
char initErrorMessage[MAX_STR_LENGTH];
sharedMem *thisMem;
int default_tau_from_file = -1;
enum detectorSettings thisSettings;
@ -367,9 +366,7 @@ void initStopServer() {
getModuleConfiguration();
virtual_stop = 0;
if (!isControlServer) {
lockSharedMemory(thisMem);
thisMem->stop = virtual_stop;
unlockSharedMemory(thisMem);
sharedMemory_setStop(virtual_stop);
}
// get top/master in virtual
readConfigFile();
@ -674,9 +671,7 @@ void setupDetector() {
#ifdef VIRTUAL
virtual_status = 0;
if (isControlServer) {
lockSharedMemory(thisMem);
thisMem->status = virtual_status;
unlockSharedMemory(thisMem);
sharedMemory_setStatus(virtual_status);
}
#endif
@ -1993,26 +1988,20 @@ int startStateMachine() {
}
LOG(logINFOBLUE, ("Starting State Machine\n"));
if (isControlServer) {
lockSharedMemory(thisMem);
virtual_stop = thisMem->stop;
unlockSharedMemory(thisMem);
virtual_stop = sharedMemory_getStop();
if (virtual_stop != 0) {
LOG(logERROR, ("Cant start acquisition. "
"Stop server has not updated stop status to 0\n"));
return FAIL;
}
virtual_status = 1;
lockSharedMemory(thisMem);
thisMem->status = virtual_status;
unlockSharedMemory(thisMem);
sharedMemory_setStatus(virtual_status);
}
if (pthread_create(&virtual_tid, NULL, &start_timer, NULL)) {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
virtual_status = 0;
if (isControlServer) {
lockSharedMemory(thisMem);
thisMem->status = virtual_status;
unlockSharedMemory(thisMem);
sharedMemory_setStatus(virtual_status);
}
return FAIL;
}
@ -2119,9 +2108,7 @@ void *start_timer(void *arg) {
usleep(eiger_virtual_transmission_delay_frame);
// update the virtual stop from stop server
lockSharedMemory(thisMem);
virtual_stop = thisMem->stop;
unlockSharedMemory(thisMem);
virtual_stop = sharedMemory_getStop();
// check if virtual_stop is high
if (virtual_stop == 1) {
setStartingFrameNumber(frameNr + iframes + 1);
@ -2224,9 +2211,7 @@ void *start_timer(void *arg) {
virtual_status = 0;
if (isControlServer) {
lockSharedMemory(thisMem);
thisMem->status = virtual_status;
unlockSharedMemory(thisMem);
sharedMemory_setStatus(virtual_status);
}
LOG(logINFOBLUE, ("Finished Acquiring\n"));
return NULL;
@ -2238,20 +2223,15 @@ int stopStateMachine() {
#ifdef VIRTUAL
if (!isControlServer) {
virtual_stop = 1;
lockSharedMemory(thisMem);
virtual_stop = thisMem->stop;
unlockSharedMemory(thisMem);
sharedMemory_setStop(virtual_stop);
// read till status is idle
int tempStatus = 1;
while (tempStatus == 1) {
lockSharedMemory(thisMem);
tempStatus = thisMem->status;
unlockSharedMemory(thisMem);
tempStatus = sharedMemory_getStatus();
}
virtual_stop = 0;
lockSharedMemory(thisMem);
virtual_stop = thisMem->stop;
unlockSharedMemory(thisMem);
sharedMemory_setStop(virtual_stop);
virtual_status = tempStatus;
LOG(logINFO, ("Stopped State Machine\n"));
}
return OK;
@ -2311,9 +2291,7 @@ int startReadOut() {
enum runStatus getRunStatus() {
#ifdef VIRTUAL
if (!isControlServer) {
lockSharedMemory(thisMem);
virtual_status = thisMem->status;
unlockSharedMemory(thisMem);
virtual_status = sharedMemory_getStatus();
}
if (virtual_status == 0) {
LOG(logINFO, ("Status: IDLE\n"));