mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
fixed start stop tests
This commit is contained in:
@ -11,6 +11,7 @@ add_executable(gotthard2DetectorServer_virtual
|
||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||
../slsDetectorServer/src/ASIC_Driver.c
|
||||
../slsDetectorServer/src/programFpgaNios.c
|
||||
../slsDetectorServer/src/communication_virtual.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "ASIC_Driver.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "communication_virtual.h"
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
@ -27,6 +28,7 @@ extern udpStruct udpDetails;
|
||||
extern const enum detectorType myDetectorType;
|
||||
|
||||
// Global variable from communication_funcs.c
|
||||
extern int isControlServer;
|
||||
extern void getMacAddressinString(char* cmac, int size, uint64_t mac);
|
||||
extern void getIpAddressinString(char* cip, uint32_t ip);
|
||||
|
||||
@ -337,6 +339,12 @@ void initStopServer() {
|
||||
LOG(logERROR, ("Stop Server: Map Fail. Dangerous to continue. Goodbye!\n"));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -386,7 +394,12 @@ void setupDetector() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
#endif
|
||||
|
||||
// pll defines
|
||||
ALTERA_PLL_C10_SetDefines(REG_OFFSET, BASE_READOUT_PLL, BASE_SYSTEM_PLL, PLL_RESET_REG, PLL_RESET_REG, PLL_RESET_READOUT_MSK, PLL_RESET_SYSTEM_MSK, READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
|
||||
@ -2006,10 +2019,21 @@ int startStateMachine(){
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
if (virtual_stop != 0) {
|
||||
LOG(logERROR, ("Cant start acquisition. "
|
||||
"Stop server has not updated stop status to 0\n"));
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -2028,6 +2052,10 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
if (!isControlServer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int numRepeats = getNumTriggers();
|
||||
if (getTiming() == AUTO_TIMING) {
|
||||
if (burstMode == BURST_OFF) {
|
||||
@ -2067,6 +2095,8 @@ void* start_timer(void* arg) {
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
|
||||
// update the virtual stop from stop server
|
||||
virtual_stop = ComVirtual_getStop();
|
||||
//check if virtual_stop is high
|
||||
if(virtual_stop == 1){
|
||||
break;
|
||||
@ -2125,6 +2155,9 @@ void* start_timer(void* arg) {
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
if (isControlServer) {
|
||||
ComVirtual_setStatus(virtual_status);
|
||||
}
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
}
|
||||
@ -2134,7 +2167,18 @@ void* start_timer(void* arg) {
|
||||
int stopStateMachine(){
|
||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||
#ifdef VIRTUAL
|
||||
virtual_stop = 0;
|
||||
if (!isControlServer) {
|
||||
virtual_stop = 1;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
// read till status is idle
|
||||
int tempStatus = 1;
|
||||
while(tempStatus == 1) {
|
||||
tempStatus = ComVirtual_getStatus();
|
||||
}
|
||||
virtual_stop = 0;
|
||||
ComVirtual_setStop(virtual_stop);
|
||||
LOG(logINFO, ("Stopped State Machine\n"));
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
//stop state machine
|
||||
@ -2145,7 +2189,10 @@ int stopStateMachine(){
|
||||
|
||||
enum runStatus getRunStatus(){
|
||||
#ifdef VIRTUAL
|
||||
if(virtual_status == 0){
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
if(virtual_status == 0) {
|
||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||
return IDLE;
|
||||
}else{
|
||||
@ -2219,6 +2266,9 @@ void readFrame(int *ret, char *mess) {
|
||||
|
||||
u_int32_t runBusy() {
|
||||
#ifdef VIRTUAL
|
||||
if (!isControlServer) {
|
||||
virtual_status = ComVirtual_getStatus();
|
||||
}
|
||||
return virtual_status;
|
||||
#endif
|
||||
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
||||
|
Reference in New Issue
Block a user