mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
WIP, all servers with virtual stop and start working
This commit is contained in:
@ -11,7 +11,6 @@ add_executable(gotthard2DetectorServer_virtual
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/ASIC_Driver.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
)
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
#include "RegisterDefs.h"
|
||||
#include "clogger.h"
|
||||
#include "common.h"
|
||||
#include "sharedMemory.h"
|
||||
#include "versionAPI.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
@ -34,6 +34,7 @@ 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;
|
||||
@ -344,7 +345,9 @@ void initStopServer() {
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->stop = virtual_stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -395,7 +398,9 @@ void setupDetector() {
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->status = virtual_status;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2240,21 +2245,27 @@ int startStateMachine() {
|
||||
}
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_stop = thisMem->stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
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);
|
||||
}
|
||||
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->status = virtual_status;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
@ -2322,7 +2333,9 @@ void *start_timer(void *arg) {
|
||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_stop = thisMem->stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
// check if virtual_stop is high
|
||||
if (virtual_stop == 1) {
|
||||
break;
|
||||
@ -2401,7 +2414,9 @@ void *start_timer(void *arg) {
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
lockSharedMemory(thisMem);
|
||||
thisMem->status = virtual_status;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
@ -2413,14 +2428,20 @@ int stopStateMachine() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_stop = thisMem->stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while (tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
lockSharedMemory(thisMem);
|
||||
tempStatus = thisMem->status;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_stop = thisMem->stop;
|
||||
unlockSharedMemory(thisMem);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
@ -2434,7 +2455,9 @@ int stopStateMachine() {
|
||||
enum runStatus getRunStatus() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_status = thisMem->status;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
if (virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
@ -2512,7 +2535,9 @@ void readFrame(int *ret, char *mess) {
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
lockSharedMemory(thisMem);
|
||||
virtual_status = thisMem->status;
|
||||
unlockSharedMemory(thisMem);
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user