mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 00:07:13 +02:00
@ -16,7 +16,7 @@ add_executable(ctbDetectorServer_virtual
|
|||||||
../slsDetectorServer/src/LTC2620.c
|
../slsDetectorServer/src/LTC2620.c
|
||||||
../slsDetectorServer/src/MAX1932.c
|
../slsDetectorServer/src/MAX1932.c
|
||||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -6,13 +6,13 @@ support_lib = ../../slsSupportLib/include/
|
|||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DCHIPTESTBOARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = ctbDetectorServer
|
PROGS = ctbDetectorServer
|
||||||
DESTDIR ?= bin
|
DESTDIR ?= bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c
|
SRCS = slsDetectorFunctionList.c
|
||||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD7689.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)I2C.c $(main_src)INA226.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)/sharedMemory.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
#include "AD7689.h" // slow adcs
|
#include "AD7689.h" // slow adcs
|
||||||
@ -10,9 +11,6 @@
|
|||||||
#include "UDPPacketHeaderGenerator.h"
|
#include "UDPPacketHeaderGenerator.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "communication_funcs_UDP.h"
|
#include "communication_funcs_UDP.h"
|
||||||
#ifdef VIRTUAL
|
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -43,9 +41,8 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
|
||||||
int virtual_stop = 0;
|
|
||||||
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||||
|
int64_t virtual_currentFrameNumber = 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 1g readout
|
// 1g readout
|
||||||
@ -435,10 +432,7 @@ void initStopServer() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,10 +475,7 @@ void setupDetector() {
|
|||||||
naSamples = 1;
|
naSamples = 1;
|
||||||
ndSamples = 1;
|
ndSamples = 1;
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2222,22 +2213,15 @@ int startStateMachine() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 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)) {
|
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -2295,66 +2279,60 @@ void *start_timer(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send data
|
// Send data
|
||||||
{
|
// loop over number of frames
|
||||||
// loop over number of frames
|
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
break;
|
||||||
if (virtual_stop == 1) {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sleep for exposure time
|
// sleep for exposure time
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(expUs);
|
usleep(expUs);
|
||||||
|
|
||||||
int srcOffset = 0;
|
int srcOffset = 0;
|
||||||
// loop packet
|
// loop packet
|
||||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||||
|
|
||||||
char packetData[packetSize];
|
char packetData[packetSize];
|
||||||
memset(packetData, 0, packetSize);
|
memset(packetData, 0, packetSize);
|
||||||
// set header
|
// set header
|
||||||
sls_detector_header *header =
|
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||||
(sls_detector_header *)(packetData);
|
header->detType = (uint16_t)myDetectorType;
|
||||||
header->detType = (uint16_t)myDetectorType;
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
header->frameNumber = frameNr;
|
header->packetNumber = i;
|
||||||
header->packetNumber = i;
|
header->modId = 0;
|
||||||
header->modId = 0;
|
header->row = detPos[X];
|
||||||
header->row = detPos[X];
|
header->column = detPos[Y];
|
||||||
header->column = detPos[Y];
|
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header),
|
memcpy(packetData + sizeof(sls_detector_header),
|
||||||
imageData + srcOffset, dataSize);
|
imageData + srcOffset, dataSize);
|
||||||
srcOffset += dataSize;
|
srcOffset += dataSize;
|
||||||
|
|
||||||
sendUDPPacket(0, packetData, packetSize);
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
(long long unsigned int)virtual_currentFrameNumber));
|
||||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
int64_t timeNs =
|
||||||
|
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
// sleep for (period - exptime)
|
// sleep for (period - exptime)
|
||||||
if (frameNr < numFrames) { // if there is a next frame
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
if (periodNs > timeNs) {
|
if (periodNs > timeNs) {
|
||||||
usleep((periodNs - timeNs) / 1000);
|
usleep((periodNs - timeNs) / 1000);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++virtual_currentFrameNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeUDPSocket(0);
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2362,46 +2340,47 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||||
#ifdef VIRTUAL
|
// if scan active, stop scan first
|
||||||
if (!isControlServer) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setScanStop(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"));
|
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStop(1);
|
||||||
|
// read till status is idle
|
||||||
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
|
;
|
||||||
|
sharedMemory_setStop(0);
|
||||||
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
// stop state machine
|
// stop state machine
|
||||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STP_ACQSTN_MSK);
|
bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STP_ACQSTN_MSK);
|
||||||
usleep(WAIT_TIME_US_STP_ACQ);
|
usleep(WAIT_TIME_US_STP_ACQ);
|
||||||
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK);
|
bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK);
|
||||||
|
|
||||||
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
return RUNNING;
|
||||||
} else {
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
|
||||||
|
|
||||||
uint32_t retval = bus_r(STATUS_REG);
|
uint32_t retval = bus_r(STATUS_REG);
|
||||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||||
|
|
||||||
@ -2672,10 +2651,7 @@ int readFrameFromFifo() {
|
|||||||
|
|
||||||
uint32_t runBusy() {
|
uint32_t runBusy() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||||
virtual_status = ComVirtual_getStatus();
|
|
||||||
}
|
|
||||||
return virtual_status;
|
|
||||||
#endif
|
#endif
|
||||||
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
||||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||||
|
@ -5,7 +5,7 @@ set(src
|
|||||||
../slsDetectorServer/src/communication_funcs.c
|
../slsDetectorServer/src/communication_funcs.c
|
||||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||||
../slsDetectorServer/src/common.c
|
../slsDetectorServer/src/common.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -7,13 +7,13 @@ BLACKFIN_CC = bfin-uclinux-gcc
|
|||||||
CROSS = powerpc-4xx-softfloat-
|
CROSS = powerpc-4xx-softfloat-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DEIGERD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = eigerDetectorServer
|
PROGS = eigerDetectorServer
|
||||||
DESTDIR = bin
|
DESTDIR = bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c HardwareIO.c LocalLinkInterface.c FebInterface.c FebControl.c Beb.c
|
SRCS = slsDetectorFunctionList.c HardwareIO.c LocalLinkInterface.c FebInterface.c FebControl.c Beb.c
|
||||||
SRCS += $(main_src)communication_funcs.c $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs_UDP.c $(main_src)common.c
|
SRCS += $(main_src)communication_funcs.c $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs_UDP.c $(main_src)common.c $(main_src)/sharedMemory.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,13 +1,12 @@
|
|||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
#include "Beb.h"
|
#include "Beb.h"
|
||||||
#include "FebControl.h"
|
#include "FebControl.h"
|
||||||
#else
|
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -71,8 +70,6 @@ int eiger_tau_ns = 0;
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t virtual_tid;
|
pthread_t virtual_tid;
|
||||||
int virtual_status = 0;
|
|
||||||
int virtual_stop = 0;
|
|
||||||
// values for virtual server
|
// values for virtual server
|
||||||
int64_t eiger_virtual_exptime = 0;
|
int64_t eiger_virtual_exptime = 0;
|
||||||
int64_t eiger_virtual_subexptime = 0;
|
int64_t eiger_virtual_subexptime = 0;
|
||||||
@ -251,9 +248,10 @@ u_int64_t getDetectorMAC() {
|
|||||||
// execute and get address
|
// execute and get address
|
||||||
char output[255];
|
char output[255];
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
FILE *sysFile = popen("cat /sys/class/net/$(ip route show default | awk "
|
FILE *sysFile =
|
||||||
"'/default/ {print $5}')/address",
|
popen("cat /sys/class/net/$(ip route show default | grep -v vpn | awk "
|
||||||
"r");
|
"'/default/ {print $5}')/address",
|
||||||
|
"r");
|
||||||
#else
|
#else
|
||||||
FILE *sysFile = popen("more /sys/class/net/eth0/address", "r");
|
FILE *sysFile = popen("more /sys/class/net/eth0/address", "r");
|
||||||
#endif
|
#endif
|
||||||
@ -288,9 +286,10 @@ u_int32_t getDetectorIP() {
|
|||||||
// execute and get address
|
// execute and get address
|
||||||
char output[255];
|
char output[255];
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
FILE *sysFile = popen("ifconfig $(ip route show default | awk '/default/ "
|
FILE *sysFile =
|
||||||
"{print $5}') | grep 'inet ' | cut -d ' ' -f10",
|
popen("ifconfig $(ip route show default | grep -v vpn | awk '/default/ "
|
||||||
"r");
|
"{print $5}') | grep 'inet ' | cut -d ' ' -f10",
|
||||||
|
"r");
|
||||||
#else
|
#else
|
||||||
FILE *sysFile = popen(
|
FILE *sysFile = popen(
|
||||||
"ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2",
|
"ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2",
|
||||||
@ -363,10 +362,7 @@ void initStopServer() {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
LOG(logINFOBLUE, ("Configuring Stop server\n"));
|
||||||
getModuleConfiguration();
|
getModuleConfiguration();
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
// get top/master in virtual
|
// get top/master in virtual
|
||||||
readConfigFile();
|
readConfigFile();
|
||||||
#else
|
#else
|
||||||
@ -668,10 +664,7 @@ void setupDetector() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
LOG(logINFOBLUE, ("Setting Default Parameters\n"));
|
||||||
@ -1274,6 +1267,7 @@ int setHighVoltage(int val) {
|
|||||||
if (master) {
|
if (master) {
|
||||||
// set
|
// set
|
||||||
if (val != -1) {
|
if (val != -1) {
|
||||||
|
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||||
eiger_theo_highvoltage = val;
|
eiger_theo_highvoltage = val;
|
||||||
}
|
}
|
||||||
return eiger_theo_highvoltage;
|
return eiger_theo_highvoltage;
|
||||||
@ -1986,33 +1980,26 @@ int startStateMachine() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 0) {
|
|
||||||
LOG(logERROR, ("Cant start acquisition. "
|
|
||||||
"Stop server has not updated stop status to 0\n"));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
sharedMemory_setStatus(RUNNING);
|
||||||
if (pthread_create(&virtual_tid, NULL, &start_timer, NULL)) {
|
if (pthread_create(&virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Virtual Acquisition started\n"));
|
LOG(logINFO, ("Virtual Acquisition started\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFO, ("Acquisition started bit toggled\n"));
|
||||||
int ret = OK, prev_flag;
|
int ret = OK, prev_flag;
|
||||||
// get the DAQ toggle bit
|
// get the DAQ toggle bit
|
||||||
prev_flag = Feb_Control_AcquisitionStartedBit();
|
prev_flag = Feb_Control_AcquisitionStartedBit();
|
||||||
|
|
||||||
LOG(logINFO, ("Going to start acquisition\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
Feb_Control_StartAcquisition();
|
Feb_Control_StartAcquisition();
|
||||||
|
|
||||||
LOG(logINFO, ("requesting images right after start\n"));
|
LOG(logINFO, ("requesting images right after start\n"));
|
||||||
@ -2106,10 +2093,8 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
usleep(eiger_virtual_transmission_delay_frame);
|
usleep(eiger_virtual_transmission_delay_frame);
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
|
||||||
if (virtual_stop == 1) {
|
|
||||||
setStartingFrameNumber(frameNr + iframes + 1);
|
setStartingFrameNumber(frameNr + iframes + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2208,30 +2193,25 @@ void *start_timer(void *arg) {
|
|||||||
closeUDPSocket(0);
|
closeUDPSocket(0);
|
||||||
closeUDPSocket(1);
|
closeUDPSocket(1);
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Going to stop acquisition\n"));
|
LOG(logINFORED, ("Stopping state machine\n"));
|
||||||
#ifdef VIRTUAL
|
// if scan active, stop scan
|
||||||
if (!isControlServer) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setScanStop(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"));
|
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStop(1);
|
||||||
|
// read till status is idle
|
||||||
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
|
;
|
||||||
|
sharedMemory_setStop(0);
|
||||||
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
#else
|
||||||
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
|
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
|
||||||
@ -2287,19 +2267,24 @@ int startReadOut() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFO, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
|
||||||
} else {
|
|
||||||
LOG(logINFO, ("Status: RUNNING...\n"));
|
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
|
return RUNNING;
|
||||||
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int i = Feb_Control_AcquisitionInProgress();
|
int i = Feb_Control_AcquisitionInProgress();
|
||||||
if (i == STATUS_ERROR) {
|
if (i == STATUS_ERROR) {
|
||||||
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
LOG(logERROR, ("Status: ERROR reading status register\n"));
|
||||||
@ -2324,7 +2309,7 @@ enum runStatus getRunStatus() {
|
|||||||
void readFrame(int *ret, char *mess) {
|
void readFrame(int *ret, char *mess) {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
// wait for status to be done
|
// wait for status to be done
|
||||||
while (virtual_status == 1) {
|
while (sharedMemory_getStatus() == RUNNING) {
|
||||||
usleep(500);
|
usleep(500);
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||||
|
@ -11,7 +11,7 @@ add_executable(gotthard2DetectorServer_virtual
|
|||||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||||
../slsDetectorServer/src/ASIC_Driver.c
|
../slsDetectorServer/src/ASIC_Driver.c
|
||||||
../slsDetectorServer/src/programFpgaNios.c
|
../slsDetectorServer/src/programFpgaNios.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -6,13 +6,13 @@ support_lib = ../../slsSupportLib/include/
|
|||||||
CROSS = nios2-buildroot-linux-gnu-
|
CROSS = nios2-buildroot-linux-gnu-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DGOTTHARD2D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = gotthard2DetectorServer
|
PROGS = gotthard2DetectorServer
|
||||||
DESTDIR ?= bin
|
DESTDIR ?= bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c
|
SRCS = slsDetectorFunctionList.c
|
||||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programFpgaNios.c
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)common.c $(main_src)DAC6571.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)ASIC_Driver.c $(main_src)/programFpgaNios.c $(main_src)/sharedMemory.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -6,10 +6,10 @@
|
|||||||
#include "RegisterDefs.h"
|
#include "RegisterDefs.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include "communication_funcs_UDP.h"
|
#include "communication_funcs_UDP.h"
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -37,8 +37,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
int64_t virtual_currentFrameNumber = 2;
|
||||||
int virtual_stop = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum detectorSettings thisSettings = UNINITIALIZED;
|
enum detectorSettings thisSettings = UNINITIALIZED;
|
||||||
@ -342,10 +341,7 @@ void initStopServer() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,10 +389,7 @@ void setupDetector() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// pll defines
|
// pll defines
|
||||||
@ -1205,17 +1198,11 @@ int setHighVoltage(int val) {
|
|||||||
val = HV_SOFT_MAX_VOLTAGE;
|
val = HV_SOFT_MAX_VOLTAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
if (val >= 0)
|
|
||||||
highvoltage = val;
|
|
||||||
return highvoltage;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// setting hv
|
// setting hv
|
||||||
if (val >= 0) {
|
if (val >= 0) {
|
||||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||||
DAC6571_Set(val);
|
if (DAC6571_Set(val) == OK)
|
||||||
highvoltage = val;
|
highvoltage = val;
|
||||||
}
|
}
|
||||||
return highvoltage;
|
return highvoltage;
|
||||||
}
|
}
|
||||||
@ -2240,22 +2227,15 @@ int startStateMachine() {
|
|||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
// set status to running
|
// set status to running
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 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)) {
|
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -2310,86 +2290,80 @@ void *start_timer(void *arg) {
|
|||||||
*((uint16_t *)(vetoData + i)) = i;
|
*((uint16_t *)(vetoData + i)) = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
// loop over number of repeats
|
||||||
int frameHeaderNr = 0;
|
for (int repeatNr = 0; repeatNr != numRepeats; ++repeatNr) {
|
||||||
// loop over number of repeats
|
|
||||||
for (int repeatNr = 0; repeatNr != numRepeats; ++repeatNr) {
|
|
||||||
|
|
||||||
struct timespec rbegin, rend;
|
struct timespec rbegin, rend;
|
||||||
clock_gettime(CLOCK_REALTIME, &rbegin);
|
clock_gettime(CLOCK_REALTIME, &rbegin);
|
||||||
|
|
||||||
// loop over number of frames
|
// loop over number of frames
|
||||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
break;
|
||||||
if (virtual_stop == 1) {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sleep for exposure time
|
// sleep for exposure time
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(expUs);
|
usleep(expUs);
|
||||||
|
|
||||||
// first interface
|
// first interface
|
||||||
char packetData[packetsize];
|
char packetData[packetsize];
|
||||||
memset(packetData, 0, packetsize);
|
memset(packetData, 0, packetsize);
|
||||||
|
// set header
|
||||||
|
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||||
|
header->detType = (uint16_t)myDetectorType;
|
||||||
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
|
header->packetNumber = 0;
|
||||||
|
header->modId = 0;
|
||||||
|
header->row = detPos[X];
|
||||||
|
header->column = detPos[Y];
|
||||||
|
// fill data
|
||||||
|
memcpy(packetData + sizeof(sls_detector_header), imageData,
|
||||||
|
datasize);
|
||||||
|
// send 1 packet = 1 frame
|
||||||
|
sendUDPPacket(0, packetData, packetsize);
|
||||||
|
|
||||||
|
// second interface (veto)
|
||||||
|
char packetData2[vetopacketsize];
|
||||||
|
memset(packetData2, 0, vetopacketsize);
|
||||||
|
if (vetoEnabled && numInterfaces == 2) {
|
||||||
// set header
|
// set header
|
||||||
sls_detector_header *header =
|
veto_header *header = (veto_header *)(packetData2);
|
||||||
(sls_detector_header *)(packetData);
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
header->detType = (uint16_t)myDetectorType;
|
header->bunchId = 0;
|
||||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
|
||||||
header->frameNumber = frameHeaderNr;
|
|
||||||
header->packetNumber = 0;
|
|
||||||
header->modId = 0;
|
|
||||||
header->row = detPos[X];
|
|
||||||
header->column = detPos[Y];
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + sizeof(sls_detector_header), imageData,
|
memcpy(packetData2 + sizeof(veto_header), vetoData,
|
||||||
datasize);
|
vetodatasize);
|
||||||
// send 1 packet = 1 frame
|
// send 1 packet = 1 frame
|
||||||
sendUDPPacket(0, packetData, packetsize);
|
sendUDPPacket(1, packetData2, vetopacketsize);
|
||||||
|
}
|
||||||
|
LOG(logINFO,
|
||||||
|
("Sent frame: %d (bursts: %d) [%lld]\n", frameNr, repeatNr,
|
||||||
|
(long long unsigned int)virtual_currentFrameNumber));
|
||||||
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||||
|
(end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
// second interface (veto)
|
// sleep for (period - exptime)
|
||||||
char packetData2[vetopacketsize];
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
memset(packetData2, 0, vetopacketsize);
|
if (periodNs > timeNs) {
|
||||||
if (vetoEnabled && numInterfaces == 2) {
|
usleep((periodNs - timeNs) / 1000);
|
||||||
// set header
|
|
||||||
veto_header *header = (veto_header *)(packetData2);
|
|
||||||
header->frameNumber = frameHeaderNr;
|
|
||||||
header->bunchId = 0;
|
|
||||||
// fill data
|
|
||||||
memcpy(packetData2 + sizeof(veto_header), vetoData,
|
|
||||||
vetodatasize);
|
|
||||||
// send 1 packet = 1 frame
|
|
||||||
sendUDPPacket(1, packetData2, vetopacketsize);
|
|
||||||
}
|
|
||||||
++frameHeaderNr;
|
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
|
||||||
LOG(logINFO,
|
|
||||||
("Sent frame: %d (bursts: %d)\n", frameNr, repeatNr));
|
|
||||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
|
||||||
|
|
||||||
// sleep for (period - exptime)
|
|
||||||
if (frameNr < numFrames) { // if there is a next frame
|
|
||||||
if (periodNs > timeNs) {
|
|
||||||
usleep((periodNs - timeNs) / 1000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clock_gettime(CLOCK_REALTIME, &rend);
|
++virtual_currentFrameNumber;
|
||||||
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +
|
}
|
||||||
(rend.tv_nsec - rbegin.tv_nsec));
|
clock_gettime(CLOCK_REALTIME, &rend);
|
||||||
|
int64_t timeNs = ((rend.tv_sec - rbegin.tv_sec) * 1E9 +
|
||||||
|
(rend.tv_nsec - rbegin.tv_nsec));
|
||||||
|
|
||||||
// sleep for (repeatPeriodNs - time remaining)
|
// sleep for (repeatPeriodNs - time remaining)
|
||||||
if (repeatNr < numRepeats) { // if there is a next repeat
|
if (repeatNr < numRepeats) { // if there is a next repeat
|
||||||
if (repeatPeriodNs > timeNs) {
|
if (repeatPeriodNs > timeNs) {
|
||||||
usleep((repeatPeriodNs - timeNs) / 1000);
|
usleep((repeatPeriodNs - timeNs) / 1000);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2399,10 +2373,7 @@ void *start_timer(void *arg) {
|
|||||||
closeUDPSocket(1);
|
closeUDPSocket(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2410,19 +2381,16 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||||
#ifdef VIRTUAL
|
// if scan active, stop scan
|
||||||
if (!isControlServer) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setScanStop(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"));
|
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStop(1);
|
||||||
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
|
;
|
||||||
|
sharedMemory_setStop(0);
|
||||||
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
// stop state machine
|
// stop state machine
|
||||||
@ -2432,19 +2400,24 @@ int stopStateMachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
return RUNNING;
|
||||||
} else {
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
|
||||||
uint32_t retval = bus_r(FLOW_STATUS_REG);
|
uint32_t retval = bus_r(FLOW_STATUS_REG);
|
||||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||||
|
|
||||||
@ -2511,10 +2484,7 @@ void readFrame(int *ret, char *mess) {
|
|||||||
|
|
||||||
u_int32_t runBusy() {
|
u_int32_t runBusy() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||||
virtual_status = ComVirtual_getStatus();
|
|
||||||
}
|
|
||||||
return virtual_status;
|
|
||||||
#endif
|
#endif
|
||||||
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
||||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||||
|
@ -10,7 +10,7 @@ add_executable(gotthardDetectorServer_virtual
|
|||||||
../slsDetectorServer/src/common.c
|
../slsDetectorServer/src/common.c
|
||||||
../slsDetectorServer/src/commonServerFunctions.c
|
../slsDetectorServer/src/commonServerFunctions.c
|
||||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -6,13 +6,13 @@ support_lib = ../../slsSupportLib/include/
|
|||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DGOTTHARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DGOTTHARDD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = gotthardDetectorServer
|
PROGS = gotthardDetectorServer
|
||||||
DESTDIR ?= bin
|
DESTDIR ?= bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c
|
SRCS = slsDetectorFunctionList.c
|
||||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)AD9252.c $(main_src)AD9257.c $(main_src)LTC2620.c $(main_src)common.c $(main_src)commonServerFunctions.c
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)AD9252.c $(main_src)AD9257.c $(main_src)LTC2620.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)/sharedMemory.c
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
all: clean $(PROGS)
|
all: clean $(PROGS)
|
||||||
|
Binary file not shown.
@ -1,12 +1,12 @@
|
|||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "RegisterDefs.h"
|
#include "RegisterDefs.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
#include "LTC2620.h" // dacs
|
#include "LTC2620.h" // dacs
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include "communication_funcs_UDP.h"
|
#include "communication_funcs_UDP.h"
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
@ -34,9 +34,8 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
|
||||||
int virtual_stop = 0;
|
|
||||||
int highvoltage = 0;
|
int highvoltage = 0;
|
||||||
|
int64_t virtual_currentFrameNumber = 2;
|
||||||
#endif
|
#endif
|
||||||
int detPos[2] = {};
|
int detPos[2] = {};
|
||||||
|
|
||||||
@ -356,10 +355,7 @@ void initStopServer() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,10 +365,7 @@ void setupDetector() {
|
|||||||
LOG(logINFO, ("This Server is for 1 Gotthard module (1280 channels)\n"));
|
LOG(logINFO, ("This Server is for 1 Gotthard module (1280 channels)\n"));
|
||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
@ -1516,22 +1509,15 @@ int startStateMachine() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 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)) {
|
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -1576,59 +1562,52 @@ void *start_timer(void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send data
|
// Send data
|
||||||
{
|
// loop over number of frames
|
||||||
uint16_t frameHeaderNr = 2;
|
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||||
// loop over number of frames
|
|
||||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
break;
|
||||||
if (virtual_stop == 1) {
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sleep for exposure time
|
// sleep for exposure time
|
||||||
struct timespec begin, end;
|
struct timespec begin, end;
|
||||||
clock_gettime(CLOCK_REALTIME, &begin);
|
clock_gettime(CLOCK_REALTIME, &begin);
|
||||||
usleep(expUs);
|
usleep(expUs);
|
||||||
|
|
||||||
int srcOffset = 0;
|
int srcOffset = 0;
|
||||||
// loop packet
|
// loop packet
|
||||||
for (int i = 0; i != packetsPerFrame; ++i) {
|
for (int i = 0; i != packetsPerFrame; ++i) {
|
||||||
|
|
||||||
char packetData[packetSize];
|
char packetData[packetSize];
|
||||||
memset(packetData, 0, packetSize);
|
memset(packetData, 0, packetSize);
|
||||||
// set header
|
// set header
|
||||||
*((uint16_t *)(packetData)) = frameHeaderNr;
|
*((uint16_t *)(packetData)) = virtual_currentFrameNumber;
|
||||||
++frameHeaderNr;
|
++virtual_currentFrameNumber;
|
||||||
|
|
||||||
// fill data
|
// fill data
|
||||||
memcpy(packetData + 4, imageData + srcOffset, dataSize);
|
memcpy(packetData + 4, imageData + srcOffset, dataSize);
|
||||||
srcOffset += dataSize;
|
srcOffset += dataSize;
|
||||||
|
|
||||||
sendUDPPacket(0, packetData, packetSize);
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
LOG(logINFO,
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
("Sent frame: %d [%d]\n", frameNr, virtual_currentFrameNumber));
|
||||||
int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
(end.tv_nsec - begin.tv_nsec));
|
int64_t timeNs =
|
||||||
|
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||||
|
|
||||||
// sleep for (period - exptime)
|
// sleep for (period - exptime)
|
||||||
if (frameNr < numFrames) { // if there is a next frame
|
if (frameNr < numFrames) { // if there is a next frame
|
||||||
if (periodNs > timeNs) {
|
if (periodNs > timeNs) {
|
||||||
usleep((periodNs - timeNs) / 1000);
|
usleep((periodNs - timeNs) / 1000);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
closeUDPSocket(0);
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1636,17 +1615,17 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||||
|
// if scan active, stop scan
|
||||||
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
|
sharedMemory_setScanStop(1);
|
||||||
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
if (!isControlServer) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setStop(1);
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
// read till status is idle
|
// read till status is idle
|
||||||
int tempStatus = 1;
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
while (tempStatus == 1) {
|
;
|
||||||
tempStatus = ComVirtual_getStatus();
|
sharedMemory_setStop(0);
|
||||||
}
|
|
||||||
virtual_stop = 0;
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
LOG(logINFO, ("Stopped State Machine\n"));
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
@ -1669,19 +1648,24 @@ int stopStateMachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
return RUNNING;
|
||||||
} else {
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
|
||||||
|
|
||||||
enum runStatus s = IDLE;
|
enum runStatus s = IDLE;
|
||||||
u_int32_t retval = runState(logINFO);
|
u_int32_t retval = runState(logINFO);
|
||||||
@ -1751,7 +1735,7 @@ enum runStatus getRunStatus() {
|
|||||||
|
|
||||||
void readFrame(int *ret, char *mess) {
|
void readFrame(int *ret, char *mess) {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
while (virtual_status) {
|
while (sharedMemory_getStatus() == RUNNING) {
|
||||||
// LOG(logERROR, ("Waiting for finished flag\n");
|
// LOG(logERROR, ("Waiting for finished flag\n");
|
||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
@ -1775,17 +1759,14 @@ void readFrame(int *ret, char *mess) {
|
|||||||
|
|
||||||
u_int32_t runBusy() {
|
u_int32_t runBusy() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||||
virtual_status = ComVirtual_getStatus();
|
|
||||||
}
|
|
||||||
return virtual_status;
|
|
||||||
#endif
|
#endif
|
||||||
return runState(logDEBUG1) & STATUS_RN_BSY_MSK;
|
return runState(logDEBUG1) & STATUS_RN_BSY_MSK;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_int32_t runState(enum TLogLevel lev) {
|
u_int32_t runState(enum TLogLevel lev) {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
return virtual_status;
|
return (int)sharedMemory_getStatus();
|
||||||
#endif
|
#endif
|
||||||
u_int32_t s = bus_r(STATUS_REG);
|
u_int32_t s = bus_r(STATUS_REG);
|
||||||
LOG(lev, ("Status Register: 0x%08x\n", s));
|
LOG(lev, ("Status Register: 0x%08x\n", s));
|
||||||
|
@ -12,7 +12,7 @@ add_executable(jungfrauDetectorServer_virtual
|
|||||||
../slsDetectorServer/src/MAX1932.c
|
../slsDetectorServer/src/MAX1932.c
|
||||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||||
../slsDetectorServer/src/communication_funcs_UDP.c
|
../slsDetectorServer/src/communication_funcs_UDP.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(jungfrauDetectorServer_virtual
|
target_include_directories(jungfrauDetectorServer_virtual
|
||||||
|
@ -6,13 +6,13 @@ support_lib = ../../slsSupportLib/include/
|
|||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DJUNGFRAUD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DJUNGFRAUD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = jungfrauDetectorServer
|
PROGS = jungfrauDetectorServer
|
||||||
DESTDIR ?= bin
|
DESTDIR ?= bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c
|
SRCS = slsDetectorFunctionList.c
|
||||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)/sharedMemory.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
#include "ALTERA_PLL.h" // pll
|
#include "ALTERA_PLL.h" // pll
|
||||||
@ -8,7 +9,6 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include "communication_funcs_UDP.h"
|
#include "communication_funcs_UDP.h"
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -36,8 +36,6 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
|
||||||
int virtual_stop = 0;
|
|
||||||
int virtual_image_test_mode = 0;
|
int virtual_image_test_mode = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -363,10 +361,7 @@ void initStopServer() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
// temp threshold and reset event (read by stop server)
|
// temp threshold and reset event (read by stop server)
|
||||||
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
setThresholdTemperature(DEFAULT_TMP_THRSHLD);
|
||||||
setTemperatureEvent(0);
|
setTemperatureEvent(0);
|
||||||
@ -382,10 +377,7 @@ void setupDetector() {
|
|||||||
clkPhase[i] = 0;
|
clkPhase[i] = 0;
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ALTERA_PLL_ResetPLL();
|
ALTERA_PLL_ResetPLL();
|
||||||
@ -1672,22 +1664,15 @@ int startStateMachine() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 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)) {
|
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -1740,10 +1725,8 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
usleep(transmissionDelayUs);
|
usleep(transmissionDelayUs);
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
|
||||||
if (virtual_stop == 1) {
|
|
||||||
setStartingFrameNumber(frameNr + iframes + 1);
|
setStartingFrameNumber(frameNr + iframes + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1818,10 +1801,7 @@ void *start_timer(void *arg) {
|
|||||||
closeUDPSocket(1);
|
closeUDPSocket(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1829,19 +1809,17 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||||
#ifdef VIRTUAL
|
// if scan active, stop scan
|
||||||
if (!isControlServer) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setScanStop(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"));
|
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStop(1);
|
||||||
|
// read till status is idle
|
||||||
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
|
;
|
||||||
|
sharedMemory_setStop(0);
|
||||||
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
// stop state machine
|
// stop state machine
|
||||||
@ -1854,19 +1832,24 @@ int stopStateMachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
return RUNNING;
|
||||||
} else {
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
|
||||||
|
|
||||||
enum runStatus s;
|
enum runStatus s;
|
||||||
u_int32_t retval = bus_r(STATUS_REG);
|
u_int32_t retval = bus_r(STATUS_REG);
|
||||||
@ -1928,10 +1911,7 @@ void readFrame(int *ret, char *mess) {
|
|||||||
|
|
||||||
u_int32_t runBusy() {
|
u_int32_t runBusy() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||||
virtual_status = ComVirtual_getStatus();
|
|
||||||
}
|
|
||||||
return virtual_status;
|
|
||||||
#endif
|
#endif
|
||||||
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
|
u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK);
|
||||||
LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||||
|
@ -14,7 +14,7 @@ add_executable(moenchDetectorServer_virtual
|
|||||||
../slsDetectorServer/src/MAX1932.c
|
../slsDetectorServer/src/MAX1932.c
|
||||||
../slsDetectorServer/src/programFpgaBlackfin.c
|
../slsDetectorServer/src/programFpgaBlackfin.c
|
||||||
../slsDetectorServer/src/readDefaultPattern.c
|
../slsDetectorServer/src/readDefaultPattern.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -6,13 +6,13 @@ support_lib = ../../slsSupportLib/include/
|
|||||||
CROSS = bfin-uclinux-
|
CROSS = bfin-uclinux-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DMOENCHD -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir)#-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = moenchDetectorServer
|
PROGS = moenchDetectorServer
|
||||||
DESTDIR ?= bin
|
DESTDIR ?= bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c
|
SRCS = slsDetectorFunctionList.c
|
||||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)readDefaultPattern.c
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)blackfin.c $(main_src)common.c $(main_src)commonServerFunctions.c $(main_src)communication_funcs_UDP.c $(main_src)UDPPacketHeaderGenerator.c $(main_src)AD9257.c $(main_src)ALTERA_PLL.c $(main_src)LTC2620.c $(main_src)MAX1932.c $(main_src)programFpgaBlackfin.c $(main_src)readDefaultPattern.c $(main_src)/sharedMemory.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -1,5 +1,6 @@
|
|||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
|
|
||||||
#include "ALTERA_PLL.h" // pll
|
#include "ALTERA_PLL.h" // pll
|
||||||
@ -8,9 +9,6 @@
|
|||||||
#include "UDPPacketHeaderGenerator.h"
|
#include "UDPPacketHeaderGenerator.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "communication_funcs_UDP.h"
|
#include "communication_funcs_UDP.h"
|
||||||
#ifdef VIRTUAL
|
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -41,9 +39,8 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
|
||||||
int virtual_stop = 0;
|
|
||||||
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
uint64_t virtual_pattern[MAX_PATTERN_LENGTH];
|
||||||
|
int64_t virtual_currentFrameNumber = 2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 1g readout
|
// 1g readout
|
||||||
@ -431,10 +428,7 @@ void initStopServer() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,10 +481,7 @@ void setupDetector() {
|
|||||||
adcEnableMask_10g = 0;
|
adcEnableMask_10g = 0;
|
||||||
nSamples = 1;
|
nSamples = 1;
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
memset(virtual_pattern, 0, sizeof(virtual_pattern));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1855,22 +1846,15 @@ int startStateMachine() {
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 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)) {
|
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -1931,10 +1915,8 @@ void *start_timer(void *arg) {
|
|||||||
// loop over number of frames
|
// loop over number of frames
|
||||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
|
||||||
if (virtual_stop == 1) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1952,7 +1934,7 @@ void *start_timer(void *arg) {
|
|||||||
sls_detector_header *header = (sls_detector_header *)(packetData);
|
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||||
header->detType = (uint16_t)myDetectorType;
|
header->detType = (uint16_t)myDetectorType;
|
||||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
header->frameNumber = frameNr;
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
header->packetNumber = i;
|
header->packetNumber = i;
|
||||||
header->modId = 0;
|
header->modId = 0;
|
||||||
header->row = detPos[X];
|
header->row = detPos[X];
|
||||||
@ -1965,7 +1947,8 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
sendUDPPacket(0, packetData, packetSize);
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
|
||||||
|
(long long unsigned int)virtual_currentFrameNumber));
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
int64_t timeNs =
|
int64_t timeNs =
|
||||||
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||||
@ -1976,14 +1959,12 @@ void *start_timer(void *arg) {
|
|||||||
usleep((periodNs - timeNs) / 1000);
|
usleep((periodNs - timeNs) / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++virtual_currentFrameNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeUDPSocket(0);
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1991,19 +1972,17 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||||
#ifdef VIRTUAL
|
// if scan active, stop scan
|
||||||
if (!isControlServer) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setScanStop(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"));
|
|
||||||
}
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStop(1);
|
||||||
|
// read till status is idle
|
||||||
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
|
;
|
||||||
|
sharedMemory_setStop(0);
|
||||||
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
return OK;
|
return OK;
|
||||||
#endif
|
#endif
|
||||||
// stop state machine
|
// stop state machine
|
||||||
@ -2017,19 +1996,24 @@ int stopStateMachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
return RUNNING;
|
||||||
} else {
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
|
||||||
|
|
||||||
uint32_t retval = bus_r(STATUS_REG);
|
uint32_t retval = bus_r(STATUS_REG);
|
||||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||||
@ -2258,10 +2242,7 @@ int readFrameFromFifo() {
|
|||||||
|
|
||||||
uint32_t runBusy() {
|
uint32_t runBusy() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||||
virtual_status = ComVirtual_getStatus();
|
|
||||||
}
|
|
||||||
return virtual_status;
|
|
||||||
#endif
|
#endif
|
||||||
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
uint32_t s = (bus_r(STATUS_REG) & STATUS_RN_BSY_MSK);
|
||||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||||
|
@ -10,7 +10,7 @@ add_executable(mythen3DetectorServer_virtual
|
|||||||
../slsDetectorServer/src/LTC2620_Driver.c
|
../slsDetectorServer/src/LTC2620_Driver.c
|
||||||
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
|
||||||
../slsDetectorServer/src/programFpgaNios.c
|
../slsDetectorServer/src/programFpgaNios.c
|
||||||
../slsDetectorServer/src/communication_virtual.c
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
)
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -6,13 +6,13 @@ support_lib = ../../slsSupportLib/include/
|
|||||||
CROSS = nios2-buildroot-linux-gnu-
|
CROSS = nios2-buildroot-linux-gnu-
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
CFLAGS += -Wall -std=gnu99 -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
CFLAGS += -Wall -std=gnu99 -DMYTHEN3D -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||||
LDLIBS += -lm
|
LDLIBS += -lm -lrt -pthread
|
||||||
PROGS = mythen3DetectorServer
|
PROGS = mythen3DetectorServer
|
||||||
DESTDIR ?= bin
|
DESTDIR ?= bin
|
||||||
INSTMODE = 0777
|
INSTMODE = 0777
|
||||||
|
|
||||||
SRCS = slsDetectorFunctionList.c
|
SRCS = slsDetectorFunctionList.c
|
||||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)nios.c $(main_src)DAC6571.c $(main_src)common.c $(main_src)LTC2620_Driver.c $(main_src)ALTERA_PLL_CYCLONE10.c $(main_src)/programFpgaNios.c $(main_src)/sharedMemory.c
|
||||||
|
|
||||||
OBJS = $(SRCS:.c=.o)
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -5,10 +5,10 @@
|
|||||||
#include "RegisterDefs.h"
|
#include "RegisterDefs.h"
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
#include "communication_funcs_UDP.h"
|
#include "communication_funcs_UDP.h"
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -35,8 +35,7 @@ char initErrorMessage[MAX_STR_LENGTH];
|
|||||||
|
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
pthread_t pthread_virtual_tid;
|
pthread_t pthread_virtual_tid;
|
||||||
int virtual_status = 0;
|
int64_t virtual_currentFrameNumber = 2;
|
||||||
int virtual_stop = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sls_detector_module *detectorModules = NULL;
|
sls_detector_module *detectorModules = NULL;
|
||||||
@ -331,10 +330,7 @@ void initStopServer() {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_stop = 0;
|
sharedMemory_setStop(0);
|
||||||
if (!isControlServer) {
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -388,10 +384,7 @@ void setupDetector() {
|
|||||||
clkPhase[i] = 0;
|
clkPhase[i] = 0;
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// pll defines
|
// pll defines
|
||||||
@ -1140,17 +1133,12 @@ int setHighVoltage(int val) {
|
|||||||
if (val > HV_SOFT_MAX_VOLTAGE) {
|
if (val > HV_SOFT_MAX_VOLTAGE) {
|
||||||
val = HV_SOFT_MAX_VOLTAGE;
|
val = HV_SOFT_MAX_VOLTAGE;
|
||||||
}
|
}
|
||||||
#ifdef VIRTUAL
|
|
||||||
if (val >= 0)
|
|
||||||
highvoltage = val;
|
|
||||||
return highvoltage;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// setting hv
|
// setting hv
|
||||||
if (val >= 0) {
|
if (val >= 0) {
|
||||||
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
LOG(logINFO, ("Setting High voltage: %d V\n", val));
|
||||||
DAC6571_Set(val);
|
if (DAC6571_Set(val) == OK)
|
||||||
highvoltage = val;
|
highvoltage = val;
|
||||||
}
|
}
|
||||||
return highvoltage;
|
return highvoltage;
|
||||||
}
|
}
|
||||||
@ -1980,22 +1968,15 @@ int startStateMachine() {
|
|||||||
}
|
}
|
||||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||||
// set status to running
|
// set status to running
|
||||||
virtual_status = 1;
|
if (sharedMemory_getStop() != 0) {
|
||||||
if (isControlServer) {
|
LOG(logERROR, ("Cant start acquisition. "
|
||||||
ComVirtual_setStatus(virtual_status);
|
"Stop server has not updated stop status to 0\n"));
|
||||||
virtual_stop = ComVirtual_getStop();
|
return FAIL;
|
||||||
if (virtual_stop != 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)) {
|
if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||||
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||||
@ -2037,10 +2018,8 @@ void *start_timer(void *arg) {
|
|||||||
// loop over number of frames
|
// loop over number of frames
|
||||||
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||||
|
|
||||||
// update the virtual stop from stop server
|
// check if manual stop
|
||||||
virtual_stop = ComVirtual_getStop();
|
if (sharedMemory_getStop() == 1) {
|
||||||
// check if virtual_stop is high
|
|
||||||
if (virtual_stop == 1) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2059,7 +2038,7 @@ void *start_timer(void *arg) {
|
|||||||
sls_detector_header *header = (sls_detector_header *)(packetData);
|
sls_detector_header *header = (sls_detector_header *)(packetData);
|
||||||
header->detType = (uint16_t)myDetectorType;
|
header->detType = (uint16_t)myDetectorType;
|
||||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||||
header->frameNumber = frameNr + 1;
|
header->frameNumber = virtual_currentFrameNumber;
|
||||||
header->packetNumber = i;
|
header->packetNumber = i;
|
||||||
header->modId = 0;
|
header->modId = 0;
|
||||||
header->row = detPos[X];
|
header->row = detPos[X];
|
||||||
@ -2072,7 +2051,8 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
sendUDPPacket(0, packetData, packetSize);
|
sendUDPPacket(0, packetData, packetSize);
|
||||||
}
|
}
|
||||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
|
||||||
|
(long long unsigned int)virtual_currentFrameNumber));
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
int64_t timeNs =
|
int64_t timeNs =
|
||||||
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
|
||||||
@ -2083,14 +2063,12 @@ void *start_timer(void *arg) {
|
|||||||
usleep((periodNs - timeNs) / 1000);
|
usleep((periodNs - timeNs) / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++virtual_currentFrameNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
closeUDPSocket(0);
|
closeUDPSocket(0);
|
||||||
|
|
||||||
virtual_status = 0;
|
sharedMemory_setStatus(IDLE);
|
||||||
if (isControlServer) {
|
|
||||||
ComVirtual_setStatus(virtual_status);
|
|
||||||
}
|
|
||||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2098,17 +2076,17 @@ void *start_timer(void *arg) {
|
|||||||
|
|
||||||
int stopStateMachine() {
|
int stopStateMachine() {
|
||||||
LOG(logINFORED, ("Stopping State Machine\n"));
|
LOG(logINFORED, ("Stopping State Machine\n"));
|
||||||
|
// if scan active, stop scan
|
||||||
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
|
sharedMemory_setScanStop(1);
|
||||||
|
}
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
if (!isControlServer) {
|
||||||
virtual_stop = 1;
|
sharedMemory_setStop(1);
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
// read till status is idle
|
// read till status is idle
|
||||||
int tempStatus = 1;
|
while (sharedMemory_getStatus() == RUNNING)
|
||||||
while (tempStatus == 1) {
|
;
|
||||||
tempStatus = ComVirtual_getStatus();
|
sharedMemory_setStop(0);
|
||||||
}
|
|
||||||
virtual_stop = 0;
|
|
||||||
ComVirtual_setStop(virtual_stop);
|
|
||||||
LOG(logINFO, ("Stopped State Machine\n"));
|
LOG(logINFO, ("Stopped State Machine\n"));
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
@ -2120,19 +2098,25 @@ int stopStateMachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum runStatus getRunStatus() {
|
enum runStatus getRunStatus() {
|
||||||
#ifdef VIRTUAL
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
if (!isControlServer) {
|
// scan error or running
|
||||||
virtual_status = ComVirtual_getStatus();
|
if (sharedMemory_getScanStatus() == ERROR) {
|
||||||
|
LOG(logINFOBLUE, ("Status: scan ERROR\n"));
|
||||||
|
return ERROR;
|
||||||
}
|
}
|
||||||
if (virtual_status == 0) {
|
if (sharedMemory_getScanStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
LOG(logINFOBLUE, ("Status: scan RUNNING\n"));
|
||||||
return IDLE;
|
return RUNNING;
|
||||||
} else {
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
if (sharedMemory_getStatus() == RUNNING) {
|
||||||
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
LOG(logINFOBLUE, ("Status: RUNNING\n"));
|
||||||
return RUNNING;
|
return RUNNING;
|
||||||
}
|
}
|
||||||
|
LOG(logINFOBLUE, ("Status: IDLE\n"));
|
||||||
|
return IDLE;
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
|
||||||
uint32_t retval = bus_r(FLOW_STATUS_REG);
|
uint32_t retval = bus_r(FLOW_STATUS_REG);
|
||||||
LOG(logINFO, ("Status Register: %08x\n", retval));
|
LOG(logINFO, ("Status Register: %08x\n", retval));
|
||||||
|
|
||||||
@ -2200,10 +2184,7 @@ void readFrame(int *ret, char *mess) {
|
|||||||
|
|
||||||
u_int32_t runBusy() {
|
u_int32_t runBusy() {
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
if (!isControlServer) {
|
return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0);
|
||||||
virtual_status = ComVirtual_getStatus();
|
|
||||||
}
|
|
||||||
return virtual_status;
|
|
||||||
#endif
|
#endif
|
||||||
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
u_int32_t s = (bus_r(FLOW_STATUS_REG) & FLOW_STATUS_RUN_BUSY_MSK);
|
||||||
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
// LOG(logDEBUG1, ("Status Register: %08x\n", s));
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
// communciate between control and stop server
|
|
||||||
|
|
||||||
int ComVirtual_createFiles(const int port);
|
|
||||||
void ComVirtual_setFileNames(const int port);
|
|
||||||
void ComVirtual_setStatus(int value);
|
|
||||||
int ComVirtual_getStatus();
|
|
||||||
void ComVirtual_setStop(int value);
|
|
||||||
int ComVirtual_getStop();
|
|
||||||
int ComVirtual_writeToFile(int value, const char *fname,
|
|
||||||
const char *serverName);
|
|
||||||
int ComVirtual_readFromFile(int *value, const char *fname,
|
|
||||||
const char *serverName);
|
|
||||||
|
|
||||||
#endif
|
|
23
slsDetectorServers/slsDetectorServer/include/sharedMemory.h
Normal file
23
slsDetectorServers/slsDetectorServer/include/sharedMemory.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "sls_detector_defs.h"
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
|
void sharedMemory_print();
|
||||||
|
int sharedMemory_create(int port);
|
||||||
|
void sharedMemory_initialize();
|
||||||
|
int sharedMemory_open(int port);
|
||||||
|
int sharedMemory_attach();
|
||||||
|
int sharedMemory_detach();
|
||||||
|
int sharedMemory_remove();
|
||||||
|
void sharedMemory_lock();
|
||||||
|
void sharedMemory_unlock();
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
void sharedMemory_setStatus(enum runStatus s);
|
||||||
|
enum runStatus sharedMemory_getStatus();
|
||||||
|
void sharedMemory_setStop(int s);
|
||||||
|
int sharedMemory_getStop();
|
||||||
|
#endif
|
||||||
|
void sharedMemory_setScanStatus(enum runStatus s);
|
||||||
|
enum runStatus sharedMemory_getScanStatus();
|
||||||
|
void sharedMemory_setScanStop(int s);
|
||||||
|
int sharedMemory_getScanStop();
|
@ -36,6 +36,8 @@ int set_firmware_test(int);
|
|||||||
int set_bus_test(int);
|
int set_bus_test(int);
|
||||||
int set_image_test_mode(int);
|
int set_image_test_mode(int);
|
||||||
int get_image_test_mode(int);
|
int get_image_test_mode(int);
|
||||||
|
enum DACINDEX getDACIndex(enum dacIndex ind);
|
||||||
|
int validateAndSetDac(enum dacIndex ind, int val, int mV);
|
||||||
int set_dac(int);
|
int set_dac(int);
|
||||||
int get_adc(int);
|
int get_adc(int);
|
||||||
int write_register(int);
|
int write_register(int);
|
||||||
@ -43,6 +45,8 @@ int read_register(int);
|
|||||||
int set_module(int);
|
int set_module(int);
|
||||||
int set_settings(int);
|
int set_settings(int);
|
||||||
int get_threshold_energy(int);
|
int get_threshold_energy(int);
|
||||||
|
int acquire(int blocking, int file_des);
|
||||||
|
void *start_state_machine(void *arg);
|
||||||
int start_acquisition(int);
|
int start_acquisition(int);
|
||||||
int stop_acquisition(int);
|
int stop_acquisition(int);
|
||||||
int get_run_status(int);
|
int get_run_status(int);
|
||||||
@ -88,6 +92,7 @@ int get_last_client_ip(int);
|
|||||||
int set_port(int);
|
int set_port(int);
|
||||||
int calibrate_pedestal(int);
|
int calibrate_pedestal(int);
|
||||||
int enable_ten_giga(int);
|
int enable_ten_giga(int);
|
||||||
|
int validateAndSetAllTrimbits(int arg);
|
||||||
int set_all_trimbits(int);
|
int set_all_trimbits(int);
|
||||||
int set_pattern_io_control(int);
|
int set_pattern_io_control(int);
|
||||||
int set_pattern_word(int);
|
int set_pattern_word(int);
|
||||||
@ -118,7 +123,6 @@ int program_fpga(int);
|
|||||||
int reset_fpga(int);
|
int reset_fpga(int);
|
||||||
int power_chip(int);
|
int power_chip(int);
|
||||||
int set_activate(int);
|
int set_activate(int);
|
||||||
int prepare_acquisition(int);
|
|
||||||
int threshold_temp(int);
|
int threshold_temp(int);
|
||||||
int temp_control(int);
|
int temp_control(int);
|
||||||
int temp_event(int);
|
int temp_event(int);
|
||||||
@ -221,4 +225,7 @@ int get_exptime_all_gates(int);
|
|||||||
int get_gate_delay_all_gates(int);
|
int get_gate_delay_all_gates(int);
|
||||||
int get_veto(int);
|
int get_veto(int);
|
||||||
int set_veto(int);
|
int set_veto(int);
|
||||||
int set_pattern(int);
|
int set_pattern(int);
|
||||||
|
int get_scan(int);
|
||||||
|
int set_scan(int);
|
||||||
|
int get_scan_error_message(int);
|
@ -1,121 +0,0 @@
|
|||||||
#ifdef VIRTUAL
|
|
||||||
#include "communication_virtual.h"
|
|
||||||
#include "clogger.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h> // usleep
|
|
||||||
|
|
||||||
#define FILE_STATUS "/tmp/sls_virtual_server_status_"
|
|
||||||
#define FILE_STOP "/tmp/sls_virtual_server_stop_"
|
|
||||||
#define FD_STATUS 0
|
|
||||||
#define FD_STOP 1
|
|
||||||
#define FILE_NAME_LENGTH 1000
|
|
||||||
|
|
||||||
FILE *fd[2] = {NULL, NULL};
|
|
||||||
char fnameStatus[FILE_NAME_LENGTH];
|
|
||||||
char fnameStop[FILE_NAME_LENGTH];
|
|
||||||
int portNumber = 0;
|
|
||||||
|
|
||||||
int ComVirtual_createFiles(const int port) {
|
|
||||||
portNumber = port;
|
|
||||||
// control server writign status file
|
|
||||||
memset(fnameStatus, 0, FILE_NAME_LENGTH);
|
|
||||||
sprintf(fnameStatus, "%s%d", FILE_STATUS, port);
|
|
||||||
FILE *fd = NULL;
|
|
||||||
if (NULL == (fd = fopen(fnameStatus, "w"))) {
|
|
||||||
LOG(logERROR, ("Could not open the file %s for virtual communication\n",
|
|
||||||
fnameStatus));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fclose(fd);
|
|
||||||
LOG(logINFOBLUE, ("Created status file %s\n", fnameStatus));
|
|
||||||
|
|
||||||
// stop server writing stop file
|
|
||||||
memset(fnameStop, 0, FILE_NAME_LENGTH);
|
|
||||||
sprintf(fnameStop, "%s%d", FILE_STOP, port);
|
|
||||||
if (NULL == (fd = fopen(fnameStop, "w"))) {
|
|
||||||
LOG(logERROR, ("Could not open the file %s for virtual communication\n",
|
|
||||||
fnameStop));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fclose(fd);
|
|
||||||
LOG(logINFOBLUE, ("Created stop file %s\n", fnameStop));
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComVirtual_setFileNames(const int port) {
|
|
||||||
portNumber = port;
|
|
||||||
memset(fnameStatus, 0, FILE_NAME_LENGTH);
|
|
||||||
memset(fnameStop, 0, FILE_NAME_LENGTH);
|
|
||||||
sprintf(fnameStatus, "%s%d", FILE_STATUS, port);
|
|
||||||
sprintf(fnameStop, "%s%d", FILE_STOP, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComVirtual_setStatus(int value) {
|
|
||||||
while (!ComVirtual_writeToFile(value, fnameStatus, "Control")) {
|
|
||||||
usleep(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ComVirtual_getStatus() {
|
|
||||||
int retval = 0;
|
|
||||||
while (!ComVirtual_readFromFile(&retval, fnameStatus, "Stop")) {
|
|
||||||
usleep(100);
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ComVirtual_setStop(int value) {
|
|
||||||
while (!ComVirtual_writeToFile(value, fnameStop, "Stop")) {
|
|
||||||
usleep(100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ComVirtual_getStop() {
|
|
||||||
int retval = 0;
|
|
||||||
while (!ComVirtual_readFromFile(&retval, fnameStop, "Control")) {
|
|
||||||
usleep(100);
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ComVirtual_writeToFile(int value, const char *fname,
|
|
||||||
const char *serverName) {
|
|
||||||
FILE *fd = NULL;
|
|
||||||
if (NULL == (fd = fopen(fname, "w"))) {
|
|
||||||
LOG(logERROR, ("Vritual %s Server [%d] could not open "
|
|
||||||
"the file %s for writing\n",
|
|
||||||
serverName, portNumber, fname));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
while (fwrite(&value, sizeof(value), 1, fd) < 1) {
|
|
||||||
LOG(logERROR, ("Vritual %s Server [%d] could not write "
|
|
||||||
"to file %s\n",
|
|
||||||
serverName, portNumber, fname));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fclose(fd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ComVirtual_readFromFile(int *value, const char *fname,
|
|
||||||
const char *serverName) {
|
|
||||||
FILE *fd = NULL;
|
|
||||||
if (NULL == (fd = fopen(fname, "r"))) {
|
|
||||||
LOG(logERROR, ("Vritual %s Server [%d] could not open "
|
|
||||||
"the file %s for reading\n",
|
|
||||||
serverName, portNumber, fname));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
while (fread(value, sizeof(int), 1, fd) < 1) {
|
|
||||||
LOG(logERROR, ("Vritual %s Server [%d] could not read "
|
|
||||||
"from file %s\n",
|
|
||||||
serverName, portNumber, fname));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
fclose(fd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
189
slsDetectorServers/slsDetectorServer/src/sharedMemory.c
Normal file
189
slsDetectorServers/slsDetectorServer/src/sharedMemory.c
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
#include "sharedMemory.h"
|
||||||
|
#include "clogger.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define SHM_NAME "sls_server_shared_memory"
|
||||||
|
#define SHM_VERSION 0x200625
|
||||||
|
#define SHM_KEY 5678
|
||||||
|
|
||||||
|
typedef struct Memory {
|
||||||
|
int version;
|
||||||
|
sem_t sem;
|
||||||
|
enum runStatus scanStatus; // idle, running or error
|
||||||
|
int scanStop;
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
enum runStatus status;
|
||||||
|
int stop;
|
||||||
|
#endif
|
||||||
|
} sharedMem;
|
||||||
|
|
||||||
|
sharedMem *shm = NULL;
|
||||||
|
int shmFd = -1;
|
||||||
|
|
||||||
|
extern int isControlServer;
|
||||||
|
|
||||||
|
void sharedMemory_print() {
|
||||||
|
LOG(logINFO, ("%s Shared Memory:\n", isControlServer ? "c" : "s"));
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s version:0x%x\n", isControlServer ? "c" : "s", shm->version));
|
||||||
|
LOG(logINFO, ("%s scan status: %d\n", isControlServer ? "c" : "s",
|
||||||
|
(int)shm->scanStatus));
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s scan stop: %d\n", isControlServer ? "c" : "s", shm->scanStop));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
LOG(logINFO,
|
||||||
|
("%s status: %d\n", isControlServer ? "c" : "s", (int)shm->status));
|
||||||
|
LOG(logINFO, ("%s stop: %d\n", isControlServer ? "c" : "s", shm->stop));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
int sharedMemory_create(int port) {
|
||||||
|
// if sham existed, delete old shm and create again
|
||||||
|
shmFd =
|
||||||
|
shmget(SHM_KEY + port, sizeof(sharedMem), IPC_CREAT | IPC_EXCL | 0666);
|
||||||
|
if (shmFd == -1 && errno == EEXIST) {
|
||||||
|
char cmd[MAX_STR_LENGTH];
|
||||||
|
memset(cmd, 0, MAX_STR_LENGTH);
|
||||||
|
sprintf(cmd, "ipcrm -M 0x%x", SHM_KEY + port);
|
||||||
|
system(cmd);
|
||||||
|
LOG(logWARNING,
|
||||||
|
("Removed old shared memory with id 0x%x\n", SHM_KEY + port));
|
||||||
|
shmFd = shmget(SHM_KEY + port, sizeof(sharedMem),
|
||||||
|
IPC_CREAT | IPC_EXCL | 0666);
|
||||||
|
}
|
||||||
|
if (shmFd == -1) {
|
||||||
|
LOG(logERROR, ("Create shared memory failed: %s\n", strerror(errno)));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Shared memory created\n"));
|
||||||
|
if (sharedMemory_attach() == FAIL) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
sharedMemory_initialize();
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sharedMemory_initialize() {
|
||||||
|
shm->version = SHM_VERSION;
|
||||||
|
sem_init(&(shm->sem), 1, 1);
|
||||||
|
shm->scanStatus = IDLE;
|
||||||
|
shm->scanStop = 0;
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
shm->status = IDLE;
|
||||||
|
shm->stop = 0;
|
||||||
|
#endif
|
||||||
|
LOG(logINFO, ("Shared memory initialized\n"))
|
||||||
|
}
|
||||||
|
|
||||||
|
int sharedMemory_open(int port) {
|
||||||
|
shmFd = shmget(SHM_KEY + port, sizeof(sharedMem), 0666);
|
||||||
|
if (shmFd == -1) {
|
||||||
|
LOG(logERROR, ("Open shared memory failed: %s\n", strerror(errno)));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if (sharedMemory_attach() == FAIL) {
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
if (shm->version != SHM_VERSION) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("Shared memory version 0x%x does not match! (expected: 0x%x)\n",
|
||||||
|
shm->version, SHM_VERSION));
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Shared memory opened\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sharedMemory_attach() {
|
||||||
|
shm = (sharedMem *)shmat(shmFd, NULL, 0);
|
||||||
|
if (shm == (void *)-1) {
|
||||||
|
LOG(logERROR, ("could not attach: %s\n", strerror(errno)));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Shared memory attached\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sharedMemory_detach() {
|
||||||
|
if (shmdt(shm) == -1) {
|
||||||
|
LOG(logERROR, ("could not detach: %s\n", strerror(errno)));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Shared memory detached\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sharedMemory_remove() {
|
||||||
|
if (shmctl(shmFd, IPC_RMID, NULL) == -1) {
|
||||||
|
LOG(logERROR, ("could not remove: %s\n", strerror(errno)));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("Shared memory removed\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sharedMemory_lock() { sem_wait(&(shm->sem)); }
|
||||||
|
|
||||||
|
void sharedMemory_unlock() { sem_post(&(shm->sem)); }
|
||||||
|
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
void sharedMemory_setStatus(enum runStatus s) {
|
||||||
|
sharedMemory_lock();
|
||||||
|
shm->status = s;
|
||||||
|
sharedMemory_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum runStatus sharedMemory_getStatus() {
|
||||||
|
enum runStatus s = 0;
|
||||||
|
sharedMemory_lock();
|
||||||
|
s = shm->status;
|
||||||
|
sharedMemory_unlock();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sharedMemory_setStop(int s) {
|
||||||
|
sharedMemory_lock();
|
||||||
|
shm->stop = s;
|
||||||
|
sharedMemory_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
int sharedMemory_getStop() {
|
||||||
|
int s = 0;
|
||||||
|
sharedMemory_lock();
|
||||||
|
s = shm->stop;
|
||||||
|
sharedMemory_unlock();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void sharedMemory_setScanStatus(enum runStatus s) {
|
||||||
|
sharedMemory_lock();
|
||||||
|
shm->scanStatus = s;
|
||||||
|
sharedMemory_unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum runStatus sharedMemory_getScanStatus() {
|
||||||
|
enum runStatus s = IDLE;
|
||||||
|
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;
|
||||||
|
}
|
@ -3,13 +3,11 @@
|
|||||||
|
|
||||||
#include "clogger.h"
|
#include "clogger.h"
|
||||||
#include "communication_funcs.h"
|
#include "communication_funcs.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
#include "slsDetectorServer_defs.h"
|
#include "slsDetectorServer_defs.h"
|
||||||
#include "slsDetectorServer_funcs.h"
|
#include "slsDetectorServer_funcs.h"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
#include "versionAPI.h"
|
#include "versionAPI.h"
|
||||||
#ifdef VIRTUAL
|
|
||||||
#include "communication_virtual.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -100,6 +98,10 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
// control server
|
// control server
|
||||||
if (isControlServer) {
|
if (isControlServer) {
|
||||||
|
LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
|
||||||
|
if (sharedMemory_create(portno) == FAIL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
#ifdef STOP_SERVER
|
#ifdef STOP_SERVER
|
||||||
// start stop server process
|
// start stop server process
|
||||||
char cmd[MAX_STR_LENGTH];
|
char cmd[MAX_STR_LENGTH];
|
||||||
@ -121,21 +123,14 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
LOG(logDEBUG1, ("Command to start stop server:%s\n", cmd));
|
||||||
system(cmd);
|
system(cmd);
|
||||||
LOG(logINFOBLUE, ("Control Server [%d]\n", portno));
|
|
||||||
#ifdef VIRTUAL
|
|
||||||
// creating files for virtual servers to communicate with each other
|
|
||||||
if (!ComVirtual_createFiles(portno)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// stop server
|
// stop server
|
||||||
else {
|
else {
|
||||||
LOG(logINFOBLUE, ("Stop Server [%d]\n", portno));
|
LOG(logINFOBLUE, ("Stop Server [%d]\n", portno));
|
||||||
#ifdef VIRTUAL
|
if (sharedMemory_open(portno - 1) == FAIL) {
|
||||||
ComVirtual_setFileNames(portno - 1);
|
return -1;
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
init_detector();
|
init_detector();
|
||||||
@ -164,6 +159,17 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
exitServer(sockfd);
|
exitServer(sockfd);
|
||||||
|
|
||||||
|
// detach shared memory
|
||||||
|
if (sharedMemory_detach() == FAIL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// remove shared memory (control server)
|
||||||
|
if (isControlServer) {
|
||||||
|
if (sharedMemory_remove() == FAIL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (retval == REBOOT) {
|
if (retval == REBOOT) {
|
||||||
LOG(logINFORED, ("Rebooting!\n"));
|
LOG(logINFORED, ("Rebooting!\n"));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -394,7 +394,16 @@ class Detector {
|
|||||||
/** [Eiger] Sends an internal software trigger to the detector */
|
/** [Eiger] Sends an internal software trigger to the detector */
|
||||||
void sendSoftwareTrigger(Positions pos = {});
|
void sendSoftwareTrigger(Positions pos = {});
|
||||||
|
|
||||||
// TODO: remove resetframescaught in receiver
|
Result<defs::scanParameters> getScan(Positions pos = {}) const;
|
||||||
|
|
||||||
|
/** enables/ disables scans for dac, trimbits [Eiger/ Mythen3]
|
||||||
|
* TRIMBIT_SCAN. Enabling scan sets number of frames to number of steps in
|
||||||
|
* receiver. Disabling scan sets number of frames to 1 */
|
||||||
|
void setScan(const defs::scanParameters t);
|
||||||
|
|
||||||
|
/** gets scan error message in case of error during scan in case of non
|
||||||
|
* blocking acquisition (startDetector, not acquire) */
|
||||||
|
Result<std::string> getScanErrorMessage(Positions pos = {}) const;
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -178,7 +178,7 @@ std::string CmdProxy::VirtualServer(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::acquire(int action) {
|
std::string CmdProxy::Acquire(int action) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
if (action == defs::HELP_ACTION) {
|
if (action == defs::HELP_ACTION) {
|
||||||
os << cmd << " - Acquire the number of frames set up.\n";
|
os << cmd << " - Acquire the number of frames set up.\n";
|
||||||
@ -991,6 +991,60 @@ std::string CmdProxy::DetectorStatus(int action) {
|
|||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CmdProxy::Scan(int action) {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << cmd << ' ';
|
||||||
|
if (action == defs::HELP_ACTION) {
|
||||||
|
os << "[dac_name|0|trimbit_scan] [start_val] [stop_val] "
|
||||||
|
"[step_size] [dac settling time ns|us|ms|s]\n\tConfigures to "
|
||||||
|
"scan dac and sets number of frames to number of steps. Must "
|
||||||
|
"acquire after this. To cancel the scan configuration "
|
||||||
|
"set dac to '0' without further arguments. This also sets number "
|
||||||
|
"of frames back to 1."
|
||||||
|
"\n\t[Eiger]Use trimbit_scan as dac name for a trimbit scan."
|
||||||
|
<< '\n';
|
||||||
|
} else if (action == defs::GET_ACTION) {
|
||||||
|
if (args.size() != 0) {
|
||||||
|
WrongNumberOfParameters(0);
|
||||||
|
}
|
||||||
|
auto t = det->getScan();
|
||||||
|
os << OutString(t) << '\n';
|
||||||
|
} else if (action == defs::PUT_ACTION) {
|
||||||
|
if (det_id != -1) {
|
||||||
|
throw sls::RuntimeError(
|
||||||
|
"Cannot configure scan at module level");
|
||||||
|
}
|
||||||
|
// disable
|
||||||
|
if (args.size() == 1) {
|
||||||
|
if (StringTo<int>(args[0]) != 0) {
|
||||||
|
throw sls::RuntimeError("Did you mean '0' to disable?");
|
||||||
|
}
|
||||||
|
det->setScan(defs::scanParameters());
|
||||||
|
}
|
||||||
|
// enable without settling time
|
||||||
|
else if (args.size() == 4) {
|
||||||
|
det->setScan(defs::scanParameters(
|
||||||
|
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
|
||||||
|
StringTo<int>(args[2]), StringTo<int>(args[3])));
|
||||||
|
}
|
||||||
|
// enable with all parameters
|
||||||
|
else if (args.size() == 5) {
|
||||||
|
std::string time_str(args[4]);
|
||||||
|
std::string unit = RemoveUnit(time_str);
|
||||||
|
auto t = StringTo<time::ns>(time_str, unit);
|
||||||
|
det->setScan(defs::scanParameters(
|
||||||
|
StringTo<defs::dacIndex>(args[0]), StringTo<int>(args[1]),
|
||||||
|
StringTo<int>(args[2]), StringTo<int>(args[3]), t));
|
||||||
|
} else {
|
||||||
|
WrongNumberOfParameters(4);
|
||||||
|
}
|
||||||
|
os << ToString(args) << '\n';
|
||||||
|
} else {
|
||||||
|
throw sls::RuntimeError("Unknown action");
|
||||||
|
}
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
/* Network Configuration (Detector<->Receiver) */
|
/* Network Configuration (Detector<->Receiver) */
|
||||||
|
|
||||||
std::string CmdProxy::UDPDestinationIP(int action) {
|
std::string CmdProxy::UDPDestinationIP(int action) {
|
||||||
|
@ -612,7 +612,7 @@ class CmdProxy {
|
|||||||
{"gappixels", &CmdProxy::GapPixels},
|
{"gappixels", &CmdProxy::GapPixels},
|
||||||
|
|
||||||
/* acquisition parameters */
|
/* acquisition parameters */
|
||||||
{"acquire", &CmdProxy::acquire},
|
{"acquire", &CmdProxy::Acquire},
|
||||||
{"frames", &CmdProxy::frames},
|
{"frames", &CmdProxy::frames},
|
||||||
{"triggers", &CmdProxy::triggers},
|
{"triggers", &CmdProxy::triggers},
|
||||||
{"exptime", &CmdProxy::Exptime},
|
{"exptime", &CmdProxy::Exptime},
|
||||||
@ -737,6 +737,8 @@ class CmdProxy {
|
|||||||
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
|
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
|
||||||
{"startingfnum", &CmdProxy::startingfnum},
|
{"startingfnum", &CmdProxy::startingfnum},
|
||||||
{"trigger", &CmdProxy::trigger},
|
{"trigger", &CmdProxy::trigger},
|
||||||
|
{"scan", &CmdProxy::Scan},
|
||||||
|
{"scanerrmsg", &CmdProxy::scanerrmsg},
|
||||||
|
|
||||||
/* Network Configuration (Detector<->Receiver) */
|
/* Network Configuration (Detector<->Receiver) */
|
||||||
{"numinterfaces", &CmdProxy::numinterfaces},
|
{"numinterfaces", &CmdProxy::numinterfaces},
|
||||||
@ -965,7 +967,7 @@ class CmdProxy {
|
|||||||
std::string SettingsList(int action);
|
std::string SettingsList(int action);
|
||||||
std::string GapPixels(int action);
|
std::string GapPixels(int action);
|
||||||
/* acquisition parameters */
|
/* acquisition parameters */
|
||||||
std::string acquire(int action);
|
std::string Acquire(int action);
|
||||||
std::string Exptime(int action);
|
std::string Exptime(int action);
|
||||||
std::string Speed(int action);
|
std::string Speed(int action);
|
||||||
std::string Adcphase(int action);
|
std::string Adcphase(int action);
|
||||||
@ -983,6 +985,7 @@ class CmdProxy {
|
|||||||
/* acquisition */
|
/* acquisition */
|
||||||
std::string ReceiverStatus(int action);
|
std::string ReceiverStatus(int action);
|
||||||
std::string DetectorStatus(int action);
|
std::string DetectorStatus(int action);
|
||||||
|
std::string Scan(int action);
|
||||||
/* Network Configuration (Detector<->Receiver) */
|
/* Network Configuration (Detector<->Receiver) */
|
||||||
std::string UDPDestinationIP(int action);
|
std::string UDPDestinationIP(int action);
|
||||||
std::string UDPDestinationIP2(int action);
|
std::string UDPDestinationIP2(int action);
|
||||||
@ -1552,6 +1555,10 @@ class CmdProxy {
|
|||||||
trigger, sendSoftwareTrigger,
|
trigger, sendSoftwareTrigger,
|
||||||
"\n\t[Eiger] Sends software trigger signal to detector.");
|
"\n\t[Eiger] Sends software trigger signal to detector.");
|
||||||
|
|
||||||
|
GET_COMMAND(scanerrmsg, getScanErrorMessage,
|
||||||
|
"\n\tGets Scan error message if scan ended in error for non "
|
||||||
|
"blocking acquisitions.");
|
||||||
|
|
||||||
/* Network Configuration (Detector<->Receiver) */
|
/* Network Configuration (Detector<->Receiver) */
|
||||||
|
|
||||||
INTEGER_COMMAND(
|
INTEGER_COMMAND(
|
||||||
|
@ -525,9 +525,6 @@ void Detector::startReceiver() { pimpl->Parallel(&Module::startReceiver, {}); }
|
|||||||
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
void Detector::stopReceiver() { pimpl->Parallel(&Module::stopReceiver, {}); }
|
||||||
|
|
||||||
void Detector::startDetector() {
|
void Detector::startDetector() {
|
||||||
if (getDetectorType().squash() == defs::EIGER) {
|
|
||||||
pimpl->Parallel(&Module::prepareAcquisition, {});
|
|
||||||
}
|
|
||||||
pimpl->Parallel(&Module::startAcquisition, {});
|
pimpl->Parallel(&Module::startAcquisition, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,6 +559,18 @@ void Detector::sendSoftwareTrigger(Positions pos) {
|
|||||||
pimpl->Parallel(&Module::sendSoftwareTrigger, pos);
|
pimpl->Parallel(&Module::sendSoftwareTrigger, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result<defs::scanParameters> Detector::getScan(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getScan, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Detector::setScan(const defs::scanParameters t) {
|
||||||
|
pimpl->Parallel(&Module::setScan, {}, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<std::string> Detector::getScanErrorMessage(Positions pos) const {
|
||||||
|
return pimpl->Parallel(&Module::getScanErrorMessage, pos);
|
||||||
|
}
|
||||||
|
|
||||||
// Network Configuration (Detector<->Receiver)
|
// Network Configuration (Detector<->Receiver)
|
||||||
|
|
||||||
Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
|
Result<int> Detector::getNumberofUDPInterfaces(Positions pos) const {
|
||||||
|
@ -1046,9 +1046,6 @@ int DetectorImpl::acquire() {
|
|||||||
|
|
||||||
// start and read all
|
// start and read all
|
||||||
try {
|
try {
|
||||||
if (multi_shm()->multiDetectorType == EIGER) {
|
|
||||||
Parallel(&Module::prepareAcquisition, {});
|
|
||||||
}
|
|
||||||
Parallel(&Module::startAndReadAll, {});
|
Parallel(&Module::startAndReadAll, {});
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (receiver)
|
if (receiver)
|
||||||
|
@ -367,8 +367,6 @@ void Module::stopReceiver() {
|
|||||||
sendToReceiver(F_STOP_RECEIVER, arg, nullptr);
|
sendToReceiver(F_STOP_RECEIVER, arg, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::prepareAcquisition() { sendToDetector(F_PREPARE_ACQUISITION); }
|
|
||||||
|
|
||||||
void Module::startAcquisition() {
|
void Module::startAcquisition() {
|
||||||
shm()->stoppedFlag = false;
|
shm()->stoppedFlag = false;
|
||||||
sendToDetector(F_START_ACQUISITION);
|
sendToDetector(F_START_ACQUISITION);
|
||||||
@ -451,6 +449,22 @@ void Module::setStartingFrameNumber(uint64_t value) {
|
|||||||
|
|
||||||
void Module::sendSoftwareTrigger() { sendToDetectorStop(F_SOFTWARE_TRIGGER); }
|
void Module::sendSoftwareTrigger() { sendToDetectorStop(F_SOFTWARE_TRIGGER); }
|
||||||
|
|
||||||
|
defs::scanParameters Module::getScan() {
|
||||||
|
return sendToDetector<defs::scanParameters>(F_GET_SCAN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Module::setScan(const defs::scanParameters t) {
|
||||||
|
auto retval = sendToDetector<int64_t>(F_SET_SCAN, t);
|
||||||
|
// if disabled, retval is 1, else its number of steps
|
||||||
|
setNumberOfFrames(retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Module::getScanErrorMessage() {
|
||||||
|
char retval[MAX_STR_LENGTH]{};
|
||||||
|
sendToDetector(F_GET_SCAN_ERROR_MESSAGE, nullptr, retval);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
// Network Configuration (Detector<->Receiver)
|
// Network Configuration (Detector<->Receiver)
|
||||||
|
|
||||||
int Module::getNumberofUDPInterfacesFromShm() {
|
int Module::getNumberofUDPInterfacesFromShm() {
|
||||||
|
@ -155,7 +155,6 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
* ************************************************/
|
* ************************************************/
|
||||||
void startReceiver();
|
void startReceiver();
|
||||||
void stopReceiver();
|
void stopReceiver();
|
||||||
void prepareAcquisition();
|
|
||||||
void startAcquisition();
|
void startAcquisition();
|
||||||
void stopAcquisition();
|
void stopAcquisition();
|
||||||
void startAndReadAll();
|
void startAndReadAll();
|
||||||
@ -167,6 +166,9 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
uint64_t getStartingFrameNumber();
|
uint64_t getStartingFrameNumber();
|
||||||
void setStartingFrameNumber(uint64_t value);
|
void setStartingFrameNumber(uint64_t value);
|
||||||
void sendSoftwareTrigger();
|
void sendSoftwareTrigger();
|
||||||
|
defs::scanParameters getScan();
|
||||||
|
void setScan(const defs::scanParameters t);
|
||||||
|
std::string getScanErrorMessage();
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* *
|
* *
|
||||||
|
@ -1178,6 +1178,134 @@ TEST_CASE("startingfnum", "[.cmd][.new]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("scan", "[.cmd][.new]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
defs::dacIndex ind = defs::DAC_0;
|
||||||
|
defs::dacIndex notImplementedInd = defs::DAC_0;
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
switch (det_type) {
|
||||||
|
case defs::CHIPTESTBOARD:
|
||||||
|
ind = defs::DAC_0;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
|
case defs::EIGER:
|
||||||
|
ind = defs::VCMP_LL;
|
||||||
|
notImplementedInd = defs::VCASCP_PB;
|
||||||
|
break;
|
||||||
|
case defs::JUNGFRAU:
|
||||||
|
ind = defs::VB_COMP;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
|
case defs::GOTTHARD:
|
||||||
|
ind = defs::VREF_DS;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
|
case defs::MOENCH:
|
||||||
|
ind = defs::VBP_COLBUF;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
|
case defs::GOTTHARD2:
|
||||||
|
ind = defs::VB_COMP_FE;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
|
case defs::MYTHEN3:
|
||||||
|
ind = defs::VTH2;
|
||||||
|
notImplementedInd = defs::VSVP;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// when taking acquisition
|
||||||
|
// auto previous = det.getDAC(ind, false);
|
||||||
|
// auto notImplementedPrevious = det.getDAC(notImplementedInd, false);
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {sls::ToString(ind), "500", "1500", "500"}, -1, PUT,
|
||||||
|
oss);
|
||||||
|
REQUIRE(oss.str() ==
|
||||||
|
"scan [" + sls::ToString(ind) + ", 500, 1500, 500]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "scan [[enabled\ndac " + sls::ToString(ind) +
|
||||||
|
"\nstart 500\nstop 1500\nstep "
|
||||||
|
"500\nsettleTime 1ms\n]]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {sls::ToString(ind), "500", "1500", "500", "2s"}, -1,
|
||||||
|
PUT, oss);
|
||||||
|
REQUIRE(oss.str() ==
|
||||||
|
"scan [" + sls::ToString(ind) + ", 500, 1500, 500, 2s]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "scan [[enabled\ndac " + sls::ToString(ind) +
|
||||||
|
"\nstart 500\nstop 1500\nstep "
|
||||||
|
"500\nsettleTime 2s\n]]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {"0"}, -1, PUT, oss);
|
||||||
|
REQUIRE(oss.str() == "scan [0]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() == "scan [[disabled]]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {sls::ToString(ind), "1500", "500", "-500"}, -1, PUT,
|
||||||
|
oss);
|
||||||
|
REQUIRE(oss.str() ==
|
||||||
|
"scan [" + sls::ToString(ind) + ", 1500, 500, -500]\n");
|
||||||
|
}
|
||||||
|
REQUIRE_THROWS(proxy.Call(
|
||||||
|
"scan", {sls::ToString(notImplementedInd), "500", "1500", "500"}, -1,
|
||||||
|
PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call(
|
||||||
|
"scan", {sls::ToString(ind), "500", "1500", "-500"}, -1, PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call(
|
||||||
|
"scan", {sls::ToString(ind), "1500", "500", "500"}, -1, PUT));
|
||||||
|
|
||||||
|
if (det_type == defs::MYTHEN3 || defs::EIGER) {
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {"trimbit_scan", "0", "63", "16", "2s"}, -1, PUT,
|
||||||
|
oss);
|
||||||
|
REQUIRE(oss.str() == "scan [trimbit_scan, 0, 63, 16, 2s]\n");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::ostringstream oss;
|
||||||
|
proxy.Call("scan", {}, -1, GET, oss);
|
||||||
|
REQUIRE(oss.str() ==
|
||||||
|
"scan [[enabled\ndac trimbit_scan\nstart 0\nstop 48\nstep "
|
||||||
|
"16\nsettleTime 2s\n]]\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// acquire for each?
|
||||||
|
|
||||||
|
// when taking acquisition
|
||||||
|
// Reset all dacs to previous value
|
||||||
|
// for (int i = 0; i != det.size(); ++i) {
|
||||||
|
// det.setDAC(ind, previous[i], false, {i});
|
||||||
|
// det.setDAC(notImplementedInd, notImplementedPrevious[i], false, {i});
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("scanerrmsg", "[.cmd][.new]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
REQUIRE_NOTHROW(proxy.Call("scanerrmsg", {}, -1, GET));
|
||||||
|
REQUIRE_THROWS(proxy.Call("scanerrmsg", {""}, -1, PUT));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("gappixels", "[.cmd][.new]") {
|
TEST_CASE("gappixels", "[.cmd][.new]") {
|
||||||
Detector det;
|
Detector det;
|
||||||
CmdProxy proxy(&det);
|
CmdProxy proxy(&det);
|
||||||
|
@ -47,8 +47,10 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
std::string ToString(const slsDetectorDefs::patternParameters &r);
|
std::string ToString(const slsDetectorDefs::patternParameters &r);
|
||||||
std::ostream &operator<<(std::ostream &os,
|
std::ostream &operator<<(std::ostream &os,
|
||||||
const slsDetectorDefs::patternParameters &r);
|
const slsDetectorDefs::patternParameters &r);
|
||||||
|
std::string ToString(const slsDetectorDefs::scanParameters &r);
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const slsDetectorDefs::scanParameters &r);
|
||||||
const std::string &ToString(const std::string &s);
|
const std::string &ToString(const std::string &s);
|
||||||
|
|
||||||
/** Convert std::chrono::duration with specified output unit */
|
/** Convert std::chrono::duration with specified output unit */
|
||||||
template <typename T, typename Rep = double>
|
template <typename T, typename Rep = double>
|
||||||
typename std::enable_if<is_duration<T>::value, std::string>::type
|
typename std::enable_if<is_duration<T>::value, std::string>::type
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "sls_detector_exceptions.h"
|
#include "sls_detector_exceptions.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
#include <chrono>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
#else
|
#else
|
||||||
@ -303,6 +304,7 @@ typedef struct {
|
|||||||
TEMPERATURE_SODR,
|
TEMPERATURE_SODR,
|
||||||
TEMPERATURE_FPGA2,
|
TEMPERATURE_FPGA2,
|
||||||
TEMPERATURE_FPGA3,
|
TEMPERATURE_FPGA3,
|
||||||
|
TRIMBIT_SCAN,
|
||||||
V_POWER_A = 100,
|
V_POWER_A = 100,
|
||||||
V_POWER_B = 101,
|
V_POWER_B = 101,
|
||||||
V_POWER_C = 102,
|
V_POWER_C = 102,
|
||||||
@ -450,6 +452,36 @@ typedef struct {
|
|||||||
uint32_t patwait[3]{};
|
uint32_t patwait[3]{};
|
||||||
uint64_t patwaittime[3]{};
|
uint64_t patwaittime[3]{};
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
|
/** scan structure */
|
||||||
|
struct scanParameters {
|
||||||
|
int enable;
|
||||||
|
dacIndex dacInd;
|
||||||
|
int startOffset;
|
||||||
|
int stopOffset;
|
||||||
|
int stepSize;
|
||||||
|
int64_t dacSettleTime_ns;
|
||||||
|
|
||||||
|
/** disable scan */
|
||||||
|
scanParameters()
|
||||||
|
: enable(0), dacInd(DAC_0), startOffset(0), stopOffset(0),
|
||||||
|
stepSize(0), dacSettleTime_ns{0} {}
|
||||||
|
/** enable scan */
|
||||||
|
scanParameters(
|
||||||
|
dacIndex dac, int start, int stop, int step,
|
||||||
|
std::chrono::nanoseconds t = std::chrono::milliseconds{1})
|
||||||
|
: enable(1), dacInd(dac), startOffset(start), stopOffset(stop),
|
||||||
|
stepSize(step) {
|
||||||
|
dacSettleTime_ns = t.count();
|
||||||
|
}
|
||||||
|
bool operator==(const scanParameters &other) const {
|
||||||
|
return ((enable == other.enable) && (dacInd == other.dacInd) &&
|
||||||
|
(startOffset == other.startOffset) &&
|
||||||
|
(stopOffset == other.stopOffset) &&
|
||||||
|
(stepSize == other.stepSize) &&
|
||||||
|
(dacSettleTime_ns == other.dacSettleTime_ns));
|
||||||
|
}
|
||||||
|
} __attribute__((packed));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -101,7 +101,6 @@ enum detFuncs {
|
|||||||
F_RESET_FPGA,
|
F_RESET_FPGA,
|
||||||
F_POWER_CHIP,
|
F_POWER_CHIP,
|
||||||
F_ACTIVATE,
|
F_ACTIVATE,
|
||||||
F_PREPARE_ACQUISITION,
|
|
||||||
F_THRESHOLD_TEMP,
|
F_THRESHOLD_TEMP,
|
||||||
F_TEMP_CONTROL,
|
F_TEMP_CONTROL,
|
||||||
F_TEMP_EVENT,
|
F_TEMP_EVENT,
|
||||||
@ -201,6 +200,9 @@ enum detFuncs {
|
|||||||
F_GET_VETO,
|
F_GET_VETO,
|
||||||
F_SET_VETO,
|
F_SET_VETO,
|
||||||
F_SET_PATTERN,
|
F_SET_PATTERN,
|
||||||
|
F_GET_SCAN,
|
||||||
|
F_SET_SCAN,
|
||||||
|
F_GET_SCAN_ERROR_MESSAGE,
|
||||||
|
|
||||||
NUM_DET_FUNCTIONS,
|
NUM_DET_FUNCTIONS,
|
||||||
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this
|
||||||
@ -400,7 +402,6 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_RESET_FPGA: return "F_RESET_FPGA";
|
case F_RESET_FPGA: return "F_RESET_FPGA";
|
||||||
case F_POWER_CHIP: return "F_POWER_CHIP";
|
case F_POWER_CHIP: return "F_POWER_CHIP";
|
||||||
case F_ACTIVATE: return "F_ACTIVATE";
|
case F_ACTIVATE: return "F_ACTIVATE";
|
||||||
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
|
|
||||||
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
|
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
|
||||||
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
|
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
|
||||||
case F_TEMP_EVENT: return "F_TEMP_EVENT";
|
case F_TEMP_EVENT: return "F_TEMP_EVENT";
|
||||||
@ -500,6 +501,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_GET_VETO: return "F_GET_VETO";
|
case F_GET_VETO: return "F_GET_VETO";
|
||||||
case F_SET_VETO: return "F_SET_VETO";
|
case F_SET_VETO: return "F_SET_VETO";
|
||||||
case F_SET_PATTERN: return "F_SET_PATTERN";
|
case F_SET_PATTERN: return "F_SET_PATTERN";
|
||||||
|
case F_GET_SCAN: return "F_GET_SCAN";
|
||||||
|
case F_SET_SCAN: return "F_SET_SCAN";
|
||||||
|
case F_GET_SCAN_ERROR_MESSAGE: return "F_GET_SCAN_ERROR_MESSAGE";
|
||||||
|
|
||||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
#define APILIB 0x200409
|
#define APILIB 0x200409
|
||||||
#define APIRECEIVER 0x200409
|
#define APIRECEIVER 0x200409
|
||||||
#define APIGUI 0x200409
|
#define APIGUI 0x200409
|
||||||
#define APIEIGER 0x200623
|
#define APICTB 0x200703
|
||||||
#define APICTB 0x200623
|
#define APIGOTTHARD 0x200703
|
||||||
#define APIGOTTHARD 0x200623
|
#define APIGOTTHARD2 0x200703
|
||||||
#define APIGOTTHARD2 0x200623
|
#define APIJUNGFRAU 0x200703
|
||||||
#define APIJUNGFRAU 0x200623
|
#define APIMYTHEN3 0x200703
|
||||||
#define APIMYTHEN3 0x200623
|
#define APIMOENCH 0x200702
|
||||||
#define APIMOENCH 0x200623
|
#define APIEIGER 0x200703
|
||||||
|
@ -102,6 +102,30 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
return os << ToString(r);
|
return os << ToString(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ToString(const slsDetectorDefs::scanParameters &r) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << '[';
|
||||||
|
if (r.enable) {
|
||||||
|
oss << "enabled" << std::endl
|
||||||
|
<< "dac " << ToString(r.dacInd) << std::endl
|
||||||
|
<< "start " << r.startOffset << std::endl
|
||||||
|
<< "stop " << r.stopOffset << std::endl
|
||||||
|
<< "step " << r.stepSize << std::endl
|
||||||
|
<< "settleTime "
|
||||||
|
<< ToString(std::chrono::nanoseconds{r.dacSettleTime_ns})
|
||||||
|
<< std::endl;
|
||||||
|
} else {
|
||||||
|
oss << "disabled";
|
||||||
|
}
|
||||||
|
oss << ']';
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &operator<<(std::ostream &os,
|
||||||
|
const slsDetectorDefs::scanParameters &r) {
|
||||||
|
return os << ToString(r);
|
||||||
|
}
|
||||||
|
|
||||||
std::string ToString(const defs::runStatus s) {
|
std::string ToString(const defs::runStatus s) {
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case defs::ERROR:
|
case defs::ERROR:
|
||||||
@ -465,6 +489,12 @@ std::string ToString(const defs::dacIndex s) {
|
|||||||
return std::string("vipre_cds");
|
return std::string("vipre_cds");
|
||||||
case defs::IBIAS_SFP:
|
case defs::IBIAS_SFP:
|
||||||
return std::string("ibias_sfp");
|
return std::string("ibias_sfp");
|
||||||
|
case defs::TRIMBIT_SCAN:
|
||||||
|
return std::string("trimbit_scan");
|
||||||
|
case defs::HIGH_VOLTAGE:
|
||||||
|
return std::string("vhighvoltage");
|
||||||
|
case defs::IO_DELAY:
|
||||||
|
return std::string("iodelay");
|
||||||
default:
|
default:
|
||||||
return std::string("Unknown");
|
return std::string("Unknown");
|
||||||
}
|
}
|
||||||
@ -818,6 +848,13 @@ template <> defs::dacIndex StringTo(const std::string &s) {
|
|||||||
return defs::VIPRE_CDS;
|
return defs::VIPRE_CDS;
|
||||||
if (s == "ibias_sfp")
|
if (s == "ibias_sfp")
|
||||||
return defs::IBIAS_SFP;
|
return defs::IBIAS_SFP;
|
||||||
|
if (s == "trimbit_scan")
|
||||||
|
return defs::TRIMBIT_SCAN;
|
||||||
|
if (s == "vhighvoltage")
|
||||||
|
return defs::HIGH_VOLTAGE;
|
||||||
|
if (s == "iodelay")
|
||||||
|
return defs::IO_DELAY;
|
||||||
|
|
||||||
throw sls::RuntimeError("Unknown dac Index " + s);
|
throw sls::RuntimeError("Unknown dac Index " + s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,4 +273,29 @@ TEST_CASE("int or uin64_t to a string in hex") {
|
|||||||
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
REQUIRE(r == "[0xf4, 0xffff, 0x1900b6]");
|
||||||
r = ToStringHex(temp, 8);
|
r = ToStringHex(temp, 8);
|
||||||
REQUIRE(r == "[0x000000f4, 0x0000ffff, 0x001900b6]");
|
REQUIRE(r == "[0x000000f4, 0x0000ffff, 0x001900b6]");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Streaming of slsDetectorDefs::scanParameters") {
|
||||||
|
using namespace sls;
|
||||||
|
{
|
||||||
|
defs::scanParameters t{};
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << t;
|
||||||
|
REQUIRE(oss.str() == "[disabled]");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
defs::scanParameters t{defs::VTH2, 500, 1500, 500};
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << t;
|
||||||
|
REQUIRE(oss.str() == "[enabled\ndac vth2\nstart 500\nstop 1500\nstep "
|
||||||
|
"500\nsettleTime 1ms\n]");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
defs::scanParameters t{defs::VTH2, 500, 1500, 500,
|
||||||
|
std::chrono::milliseconds{500}};
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << t;
|
||||||
|
REQUIRE(oss.str() == "[enabled\ndac vth2\nstart 500\nstop 1500\nstep "
|
||||||
|
"500\nsettleTime 0.5s\n]");
|
||||||
|
}
|
||||||
}
|
}
|
@ -49,4 +49,26 @@ TEST_CASE("assign module", "[support]") {
|
|||||||
CHECK(m3.reg == 500);
|
CHECK(m3.reg == 500);
|
||||||
CHECK(m3.iodelay == 750);
|
CHECK(m3.iodelay == 750);
|
||||||
CHECK(m3.nchan == 256 * 256 * 4);
|
CHECK(m3.nchan == 256 * 256 * 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("default construct scanParameters"){
|
||||||
|
slsDetectorDefs::scanParameters p;
|
||||||
|
CHECK(p.dacSettleTime_ns == 0);
|
||||||
|
CHECK(p.dacInd == slsDetectorDefs::DAC_0);
|
||||||
|
CHECK(p.enable == 0);
|
||||||
|
CHECK(p.startOffset == 0);
|
||||||
|
CHECK(p.stopOffset == 0);
|
||||||
|
CHECK(p.stepSize == 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("compare two scanParameters"){
|
||||||
|
slsDetectorDefs::scanParameters p0;
|
||||||
|
slsDetectorDefs::scanParameters p1;
|
||||||
|
|
||||||
|
CHECK(p0 == p1);
|
||||||
|
|
||||||
|
p0.enable = 1;
|
||||||
|
CHECK_FALSE(p0 == p1);
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user