mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
WIP
This commit is contained in:
@ -36,8 +36,6 @@ char initErrorMessage[MAX_STR_LENGTH];
|
||||
|
||||
#ifdef VIRTUAL
|
||||
pthread_t pthread_virtual_tid;
|
||||
int virtual_status = 0;
|
||||
int virtual_stop = 0;
|
||||
int virtual_image_test_mode = 0;
|
||||
#endif
|
||||
|
||||
@ -363,10 +361,7 @@ void initStopServer() {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
sharedMemory_setStop(virtual_stop);
|
||||
}
|
||||
sharedMemory_setStop(0);
|
||||
// temp threshold and reset event (read by stop server)
|
||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||
setTemperatureEvent(0);
|
||||
@ -382,10 +377,7 @@ void setupDetector() {
|
||||
clkPhase[i] = 0;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
sharedMemory_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
#endif
|
||||
|
||||
ALTERA_PLL_ResetPLL();
|
||||
@ -1672,22 +1664,15 @@ int startStateMachine() {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
if (isControlServer) {
|
||||
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;
|
||||
sharedMemory_setStatus(virtual_status);
|
||||
if (sharedMemory_getStop() != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
sharedMemory_setStatus(RUNNING);
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
sharedMemory_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -1740,10 +1725,8 @@ void *start_timer(void *arg) {
|
||||
|
||||
usleep(transmissionDelayUs);
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = sharedMemory_getStop();
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
// check if manual stop
|
||||
if (sharedMemory_getStop() == 1) {
|
||||
setStartingFrameNumber(frameNr + iframes + 1);
|
||||
break;
|
||||
}
|
||||
@ -1818,10 +1801,7 @@ void *start_timer(void *arg) {
|
||||
closeUDPSocket(1);
|
||||
}
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
sharedMemory_setStatus(virtual_status);
|
||||
}
|
||||
sharedMemory_setStatus(IDLE);
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -1830,23 +1810,16 @@ void *start_timer(void *arg) {
|
||||
int stopStateMachine() {
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
// if scan active, stop scan
|
||||
if (sharedMemory_getScanStatus()) {
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
sharedMemory_setScanStop(1);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
sharedMemory_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = sharedMemory_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
sharedMemory_setStop(virtual_stop);
|
||||
virtual_status = tempStatus;
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
sharedMemory_setStop(1);
|
||||
// read till status is idle
|
||||
while (sharedMemory_getStatus() == RUNNING)
|
||||
;
|
||||
sharedMemory_setStop(0);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
return OK;
|
||||
#endif
|
||||
// stop state machine
|
||||
@ -1860,18 +1833,24 @@ int stopStateMachine() {
|
||||
|
||||
enum runStatus getRunStatus() {
|
||||
LOG(logDEBUG1, ("Getting status\n"));
|
||||
// scan error or running
|
||||
if (sharedMemory_getScanStatus() == ERROR) {
|
||||
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||
return ERROR;
|
||||
}
|
||||
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
if (sharedMemory_getScanStatus() || sharedMemory_getStatus()) {
|
||||
if (sharedMemory_getStatus() == RUNNING) {
|
||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
#endif
|
||||
if (sharedMemory_getScanStatus()) {
|
||||
LOG(logINFOBLUE, ("Status: Scan RUNNING\n"));
|
||||
return RUNNING;
|
||||
}
|
||||
|
||||
enum runStatus s;
|
||||
u_int32_t retval = bus_r(STATUS_REG);
|
||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||
@ -1932,10 +1911,7 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = sharedMemory_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||
#endif
|
||||
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
|
||||
LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||
|
Reference in New Issue
Block a user