mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
WIP
This commit is contained in:
@ -32,7 +32,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;
|
||||
@ -335,9 +334,7 @@ void initStopServer() {
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->stop = virtual_stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
sharedMemory_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -394,9 +391,7 @@ void setupDetector() {
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->status = virtual_status;
|
||||
unlockSharedMemory(thisMem);
|
||||
sharedMemory_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1987,9 +1982,7 @@ int startStateMachine() {
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
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"));
|
||||
@ -1997,17 +1990,13 @@ int startStateMachine() {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@ -2051,9 +2040,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;
|
||||
@ -2106,9 +2093,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;
|
||||
@ -2120,20 +2105,15 @@ int stopStateMachine() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->stop = virtual_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);
|
||||
thisMem->stop = virtual_stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
sharedMemory_setStop(virtual_stop);
|
||||
virtual_status = tempStatus;
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
@ -2147,9 +2127,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"));
|
||||
@ -2228,9 +2206,7 @@ void readFrame(int *ret, char *mess) {
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_status = thisMem->status;
|
||||
unlockSharedMemory(thisMem);
|
||||
virtual_status = sharedMemory_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user