mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 17:18:00 +02:00
WIP
This commit is contained in:
@ -20,6 +20,8 @@
|
||||
typedef struct Memory {
|
||||
int version;
|
||||
sem_t sem;
|
||||
int scanStatus;
|
||||
int scanStop;
|
||||
#ifdef VIRTUAL
|
||||
int status;
|
||||
int stop;
|
||||
@ -139,6 +141,7 @@ void sharedMemory_lock() { sem_wait(&(shm->sem)); }
|
||||
|
||||
void sharedMemory_unlock() { sem_post(&(shm->sem)); }
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void sharedMemory_setStatus(int s) {
|
||||
sharedMemory_lock();
|
||||
shm->status = s;
|
||||
@ -166,3 +169,32 @@ int sharedMemory_getStop() {
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void sharedMemory_setScanStatus(int s) {
|
||||
sharedMemory_lock();
|
||||
shm->scanStatus = s;
|
||||
sharedMemory_unlock();
|
||||
}
|
||||
|
||||
int sharedMemory_getScanStatus() {
|
||||
int s = 0;
|
||||
sharedMemory_lock();
|
||||
s = shm->scanStatus;
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
||||
|
||||
void sharedMemory_setScanStop(int s) {
|
||||
sharedMemory_lock();
|
||||
shm->scanStop = s;
|
||||
sharedMemory_unlock();
|
||||
}
|
||||
|
||||
int sharedMemory_getScanStop() {
|
||||
int s = 0;
|
||||
sharedMemory_lock();
|
||||
s = shm->scanStop;
|
||||
sharedMemory_unlock();
|
||||
return s;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#include "slsDetectorServer_funcs.h"
|
||||
#include "clogger.h"
|
||||
#include "communication_funcs.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "sls_detector_funcs.h"
|
||||
|
||||
@ -1725,10 +1726,19 @@ int start_state_machine(int blocking, int file_des) {
|
||||
LOG(logERROR, (mess));
|
||||
} else {
|
||||
int times = 1;
|
||||
// start of scan
|
||||
if (scan) {
|
||||
sharedMemory_setScanStop(0);
|
||||
sharedMemory_setScanStatus(1);
|
||||
times = numScanSteps;
|
||||
}
|
||||
for (int i = 0; i != times; ++i) {
|
||||
// if scanstop
|
||||
if (scan && sharedMemory_getScanStop()) {
|
||||
LOG(logINFORED, ("Scan stopped!\n"));
|
||||
sharedMemory_setScanStatus(0);
|
||||
break;
|
||||
}
|
||||
if (scanTrimbits) {
|
||||
LOG(logINFOBLUE, ("Trimbits scan %d/%d: [%d]\n", i, times,
|
||||
scanSteps[i]));
|
||||
@ -1744,15 +1754,27 @@ int start_state_machine(int blocking, int file_des) {
|
||||
int retval = getDAC(scanDac, 0);
|
||||
if (abs(retval - scanSteps[i]) > 5) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Setting dac %d : wrote %d but read %d\n",
|
||||
sprintf(mess,
|
||||
"Could not scan. Setting dac %d : wrote %d but "
|
||||
"read %d\n",
|
||||
scanDac, scanSteps[i], scanSteps[i]);
|
||||
LOG(logERROR, (mess));
|
||||
if (scan) {
|
||||
sharedMemory_setScanStatus(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("Normal Acquisition (not scan)\n"));
|
||||
}
|
||||
// if scanstop
|
||||
if (scan && sharedMemory_getScanStop()) {
|
||||
LOG(logINFORED, ("Scan stopped!\n"));
|
||||
sharedMemory_setScanStatus(0);
|
||||
break;
|
||||
}
|
||||
ret = startStateMachine();
|
||||
LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret));
|
||||
if (ret == FAIL) {
|
||||
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(VIRTUAL)
|
||||
sprintf(
|
||||
@ -1763,6 +1785,9 @@ int start_state_machine(int blocking, int file_des) {
|
||||
sprintf(mess, "Could not start acquisition\n");
|
||||
#endif
|
||||
LOG(logERROR, (mess));
|
||||
if (scan) {
|
||||
sharedMemory_setScanStatus(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// blocking or scan
|
||||
@ -1771,7 +1796,10 @@ int start_state_machine(int blocking, int file_des) {
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret));
|
||||
// end of scan
|
||||
if (scan) {
|
||||
sharedMemory_setScanStatus(0);
|
||||
}
|
||||
}
|
||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user