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

@ -38,7 +38,6 @@ extern void getIpAddressinString(char *cip, uint32_t ip);
int initError = OK;
int initCheckDone = 0;
char initErrorMessage[MAX_STR_LENGTH];
sharedMem *thisMem;
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
@ -437,9 +436,7 @@ void initStopServer() {
#ifdef VIRTUAL
virtual_stop = 0;
if (!isControlServer) {
lockSharedMemory(thisMem);
thisMem->stop = virtual_stop;
unlockSharedMemory(thisMem);
sharedMemory_setStop(virtual_stop);
}
#endif
}
@ -485,9 +482,7 @@ void setupDetector() {
#ifdef VIRTUAL
virtual_status = 0;
if (isControlServer) {
lockSharedMemory(thisMem);
thisMem->status = virtual_status;
unlockSharedMemory(thisMem);
sharedMemory_setStatus(virtual_status);
}
memset(virtual_pattern, 0, sizeof(virtual_pattern));
#endif
@ -2227,26 +2222,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(&pthread_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;
}
@ -2309,9 +2298,7 @@ void *start_timer(void *arg) {
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
// 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) {
break;
@ -2364,9 +2351,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;
@ -2378,20 +2363,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;
@ -2409,9 +2389,7 @@ int stopStateMachine() {
enum runStatus getRunStatus() {
#ifdef VIRTUAL
if (!isControlServer) {
lockSharedMemory(thisMem);
virtual_status = thisMem->status;
unlockSharedMemory(thisMem);
virtual_status = sharedMemory_getStatus();
}
if (virtual_status == 0) {
LOG(logINFOBLUE, ("Status: IDLE\n"));
@ -2694,9 +2672,7 @@ int readFrameFromFifo() {
uint32_t runBusy() {
#ifdef VIRTUAL
if (!isControlServer) {
lockSharedMemory(thisMem);
virtual_status = thisMem->status;
unlockSharedMemory(thisMem);
virtual_status = sharedMemory_getStatus();
}
return virtual_status;
#endif