mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
virtual servers checked
This commit is contained in:
@ -22,7 +22,7 @@ install(TARGETS slsProjectCWarnings
|
||||
add_subdirectory(ctbDetectorServer)
|
||||
add_subdirectory(eigerDetectorServer)
|
||||
add_subdirectory(gotthardDetectorServer)
|
||||
#add_subdirectory(jungfrauDetectorServer)
|
||||
#add_subdirectory(mythen3DetectorServer)
|
||||
#add_subdirectory(gotthard2DetectorServer)
|
||||
add_subdirectory(jungfrauDetectorServer)
|
||||
add_subdirectory(mythen3DetectorServer)
|
||||
add_subdirectory(gotthard2DetectorServer)
|
||||
add_subdirectory(moenchDetectorServer)
|
||||
|
@ -2233,13 +2233,13 @@ void* start_timer(void* arg) {
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
|
@ -1854,18 +1854,14 @@ void* start_timer(void* arg) {
|
||||
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = npixelsx;
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != numPacketsPerFrame; ++i) {
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = 3;//(uint16_t)myDetectorType; updated when firmware updates
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
@ -1874,8 +1870,10 @@ void* start_timer(void* arg) {
|
||||
header->row = row;
|
||||
header->column = colLeft;
|
||||
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
header = (sls_detector_header*)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->detType = 3;//(uint16_t)myDetectorType; updated when firmware updates
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
@ -1887,6 +1885,8 @@ void* start_timer(void* arg) {
|
||||
}
|
||||
|
||||
// fill data
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
{
|
||||
int psize = 0;
|
||||
for (psize = 0; psize < datasize; psize += npixelsx) {
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
@ -1191,42 +1192,30 @@ int configureMAC() {
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = BASE_UDP_RAM;
|
||||
@ -2015,7 +2004,7 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
@ -2040,10 +2029,18 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t exp_ns = getExpTime();
|
||||
int numRepeats = getNumTriggers();
|
||||
if (getTiming() == AUTO_TIMING) {
|
||||
if (burstMode == BURST_OFF) {
|
||||
numRepeats = 1;
|
||||
} else {
|
||||
numRepeats = getNumBursts();
|
||||
}
|
||||
}
|
||||
int repeatPeriodNs = getBurstPeriod();
|
||||
int numFrames = getNumFrames();
|
||||
int64_t periodNs = getPeriod();
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
int imagesize = NCHAN * NCHIP * 2;
|
||||
int datasize = imagesize;
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
@ -2053,11 +2050,20 @@ void* start_timer(void* arg) {
|
||||
memset(imageData, 0, imagesize);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < imagesize; i += sizeof(uint8_t)) {
|
||||
*((uint8_t*)(imageData + i)) = i;
|
||||
for (i = 0; i < imagesize; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int repeatNr = 0;
|
||||
int frameHeaderNr = 0;
|
||||
// loop over number of repeats
|
||||
for(repeatNr=0; repeatNr!= numRepeats; ++repeatNr ) {
|
||||
|
||||
struct timespec rbegin, rend;
|
||||
clock_gettime(CLOCK_REALTIME, &rbegin);
|
||||
|
||||
int frameNr = 0;
|
||||
// loop over number of frames
|
||||
for(frameNr = 0; frameNr != numFrames; ++frameNr ) {
|
||||
@ -2070,44 +2076,55 @@ void* start_timer(void* arg) {
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_ns / 1000);
|
||||
usleep(expUs);
|
||||
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->frameNumber = frameNr;
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameHeaderNr;
|
||||
++frameHeaderNr;
|
||||
header->packetNumber = 0;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData, datasize) ;
|
||||
|
||||
// send 1 packet = 1 frame
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
|
||||
// calculate time left in period
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
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 > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
if (repeatNr < numRepeats) { // if there is a next repeat
|
||||
if (repeatPeriodNs > timeNs) {
|
||||
usleep((repeatPeriodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// set register frames left
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
// set status to idle
|
||||
|
||||
virtual_status = 0;
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
|
@ -1565,13 +1565,13 @@ void* start_timer(void* arg) {
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
// set header
|
||||
*((uint16_t*)(packetData)) = frameHeaderNr;
|
||||
++frameHeaderNr;
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <sys/select.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
@ -1098,73 +1099,57 @@ int configureMAC() {
|
||||
int dstport = udpDetails.dstport;
|
||||
int dstport2 = udpDetails.dstport2;
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
char src_mac2[50], src_ip2[INET_ADDRSTRLEN],dst_mac2[50], dst_ip2[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac2, 50, srcmac2);
|
||||
getMacAddressinString(dst_mac2, 50, dstmac2);
|
||||
getIpAddressinString(src_ip2, srcip2);
|
||||
getIpAddressinString(dst_ip2, dstip2);
|
||||
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
int selInterface = getPrimaryInterface();
|
||||
LOG(logINFO, ("\t#Interfaces : %d\n", numInterfaces));
|
||||
LOG(logINFO, ("\tInterface : %d %s\n\n", selInterface, (selInterface ? "Inner" : "Outer")));
|
||||
|
||||
LOG(logINFO, ("\tOuter %s\n", (numInterfaces == 2) ? "(Bottom)": (selInterface ? "Not Used" : "Used")));
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
LOG(logINFO, ("\tInner %s\n", (numInterfaces == 2) ? "(Top)": (selInterface ? "Used" : "Not Used")));
|
||||
LOG(logINFO, ("\tSource IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip2>>24)&0xff,(srcip2>>16)&0xff,(srcip2>>8)&0xff,(srcip2)&0xff, srcip2));
|
||||
LOG(logINFO, ("\tSource MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac2>>40)&0xFF),
|
||||
(unsigned int)((srcmac2>>32)&0xFF),
|
||||
(unsigned int)((srcmac2>>24)&0xFF),
|
||||
(unsigned int)((srcmac2>>16)&0xFF),
|
||||
(unsigned int)((srcmac2>>8)&0xFF),
|
||||
(unsigned int)((srcmac2>>0)&0xFF),
|
||||
(long long unsigned int)srcmac2));
|
||||
LOG(logINFO, ("\tSource Port2: %d \t\t\t(0x%08x)\n", srcport2, srcport2));
|
||||
LOG(logINFO, (
|
||||
"\tSource IP2 : %s\n"
|
||||
"\tSource MAC2 : %s\n"
|
||||
"\tSource Port2: %d\n"
|
||||
"\tDest IP2 : %s\n"
|
||||
"\tDest MAC2 : %s\n"
|
||||
"\tDest Port2 : %d\n",
|
||||
src_ip2, src_mac2, srcport2,
|
||||
dst_ip2, dst_mac2, dstport2));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP2 : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip2>>24)&0xff,(dstip2>>16)&0xff,(dstip2>>8)&0xff,(dstip2)&0xff, dstip2));
|
||||
LOG(logINFO, ("\tDest. MAC2 : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac2>>40)&0xFF),
|
||||
(unsigned int)((dstmac2>>32)&0xFF),
|
||||
(unsigned int)((dstmac2>>24)&0xFF),
|
||||
(unsigned int)((dstmac2>>16)&0xFF),
|
||||
(unsigned int)((dstmac2>>8)&0xFF),
|
||||
(unsigned int)((dstmac2>>0)&0xFF),
|
||||
(long long unsigned int)dstmac2));
|
||||
LOG(logINFO, ("\tDest. Port2 : %d \t\t\t(0x%08x)\n", dstport2, dstport2));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port for interface 1\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (numInterfaces == 2 && setUDPDestinationDetails(1, dst_ip2, dstport2) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port for interface 2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
// default one rxr entry (others not yet implemented in client yet)
|
||||
int iRxEntry = 0;
|
||||
|
||||
@ -1639,6 +1624,9 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
if (getNumberofUDPInterfaces() == 2 && createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
@ -1665,15 +1653,16 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
int numInterfaces = getNumberofUDPInterfaces();
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() *
|
||||
(getNumAdditionalStorageCells() + 1));
|
||||
int64_t exp_us = getExpTime() / 1000;
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
const int npixels = 256 * 256 * 8;
|
||||
const int datasize = 8192;
|
||||
const int packetsize = datasize + sizeof(sls_detector_header);
|
||||
const int numPacketsPerFrame = 128;
|
||||
const int dataSize = 8192;
|
||||
const int packetsize = dataSize + sizeof(sls_detector_header);
|
||||
const int packetsPerFrame = numInterfaces == 1 ? 128 : 64;
|
||||
int transmissionDelayUs = getTransmissionDelayFrame() * 1000;
|
||||
|
||||
// Generate data
|
||||
@ -1703,50 +1692,73 @@ void* start_timer(void* arg) {
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_us);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
|
||||
int srcOffset2 = DATA_BYTES / 2;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != numPacketsPerFrame; ++i) {
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->row = detPos[2];
|
||||
header->column = detPos[3];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
||||
srcOffset += datasize;
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
|
||||
// second interface
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
if (numInterfaces == 2) {
|
||||
header = (sls_detector_header*)(packetData2);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[0];
|
||||
header->column = detPos[1];
|
||||
|
||||
// fill data
|
||||
memcpy(packetData2 + sizeof(sls_detector_header),
|
||||
imageData + srcOffset2, dataSize);
|
||||
srcOffset2 += dataSize;
|
||||
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
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 > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
closeUDPSocket(0);
|
||||
if (numInterfaces == 2) {
|
||||
closeUDPSocket(1);
|
||||
}
|
||||
|
||||
virtual_status = 0;
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
|
@ -1895,14 +1895,13 @@ void* start_timer(void* arg) {
|
||||
usleep(expNs / 1000);
|
||||
|
||||
int srcOffset = 0;
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != packetsPerFrame; ++i) {
|
||||
// set header
|
||||
char packetData[packetSize];
|
||||
memset(packetData, 0, packetSize);
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
#include <netinet/in.h>
|
||||
#ifdef VIRTUAL
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
@ -742,41 +743,29 @@ int configureMAC() {
|
||||
int srcport = udpDetails.srcport;
|
||||
int dstport = udpDetails.dstport;
|
||||
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
char src_mac[50], src_ip[INET_ADDRSTRLEN],dst_mac[50], dst_ip[INET_ADDRSTRLEN];
|
||||
getMacAddressinString(src_mac, 50, srcmac);
|
||||
getMacAddressinString(dst_mac, 50, dstmac);
|
||||
getIpAddressinString(src_ip, srcip);
|
||||
getIpAddressinString(dst_ip, dstip);
|
||||
|
||||
LOG(logINFO, (
|
||||
"\tSource IP : %s\n"
|
||||
"\tSource MAC : %s\n"
|
||||
"\tSource Port : %d\n"
|
||||
"\tDest IP : %s\n"
|
||||
"\tDest MAC : %s\n"
|
||||
"\tDest Port : %d\n",
|
||||
src_ip, src_mac, srcport,
|
||||
dst_ip, dst_mac, dstport));
|
||||
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff);
|
||||
LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, dstport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, dstport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, dst_ip, dstport) == FAIL) {
|
||||
LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
|
||||
LOG(logINFO, ("\tSource IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(srcip>>24)&0xff,(srcip>>16)&0xff,(srcip>>8)&0xff,(srcip)&0xff, srcip));
|
||||
LOG(logINFO, ("\tSource MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((srcmac>>40)&0xFF),
|
||||
(unsigned int)((srcmac>>32)&0xFF),
|
||||
(unsigned int)((srcmac>>24)&0xFF),
|
||||
(unsigned int)((srcmac>>16)&0xFF),
|
||||
(unsigned int)((srcmac>>8)&0xFF),
|
||||
(unsigned int)((srcmac>>0)&0xFF),
|
||||
(long long unsigned int)srcmac));
|
||||
LOG(logINFO, ("\tSource Port : %d \t\t\t(0x%08x)\n", srcport, srcport));
|
||||
|
||||
LOG(logINFO, ("\tDest. IP : %d.%d.%d.%d \t\t(0x%08x)\n",
|
||||
(dstip>>24)&0xff,(dstip>>16)&0xff,(dstip>>8)&0xff,(dstip)&0xff, dstip));
|
||||
LOG(logINFO, ("\tDest. MAC : %02x:%02x:%02x:%02x:%02x:%02x \t(0x%010llx)\n",
|
||||
(unsigned int)((dstmac>>40)&0xFF),
|
||||
(unsigned int)((dstmac>>32)&0xFF),
|
||||
(unsigned int)((dstmac>>24)&0xFF),
|
||||
(unsigned int)((dstmac>>16)&0xFF),
|
||||
(unsigned int)((dstmac>>8)&0xFF),
|
||||
(unsigned int)((dstmac>>0)&0xFF),
|
||||
(long long unsigned int)dstmac));
|
||||
LOG(logINFO, ("\tDest. Port : %d \t\t\t(0x%08x)\n\n",dstport, dstport));
|
||||
|
||||
// start addr
|
||||
uint32_t addr = BASE_UDP_RAM;
|
||||
@ -1358,7 +1347,7 @@ int startStateMachine(){
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
LOG(logINFOBLUE, ("Starting State Machine\n"));
|
||||
// set status to running
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
@ -1385,14 +1374,15 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int64_t periodns = getPeriod();
|
||||
int64_t periodNs = getPeriod();
|
||||
int numFrames = (getNumFrames() *
|
||||
getNumTriggers() );
|
||||
int64_t exp_ns = getExpTime();
|
||||
int64_t expUs = getExpTime() / 1000;
|
||||
|
||||
//int dr = setDynamicRange(-1);
|
||||
int imagesize = calculateDataBytes();
|
||||
int datasize = imagesize / PACKETS_PER_FRAME;
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
int dataSize = imagesize / PACKETS_PER_FRAME;
|
||||
int packetSize = dataSize + sizeof(sls_detector_header);
|
||||
|
||||
// Generate data
|
||||
char imageData[imagesize];
|
||||
@ -1404,6 +1394,8 @@ void* start_timer(void* arg) {
|
||||
}
|
||||
}
|
||||
|
||||
// Send data
|
||||
{
|
||||
int frameNr = 1;
|
||||
// loop over number of frames
|
||||
for (frameNr = 0; frameNr != numFrames; ++frameNr) {
|
||||
@ -1413,56 +1405,54 @@ void* start_timer(void* arg) {
|
||||
break;
|
||||
}
|
||||
|
||||
int srcOffset = 0;
|
||||
|
||||
// sleep for exposure time
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
usleep(exp_ns / 1000);
|
||||
usleep(expUs);
|
||||
|
||||
int srcOffset = 0;
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != PACKETS_PER_FRAME; ++i) {
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
char packetData[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 = frameNr + 1;
|
||||
header->packetNumber = i;
|
||||
header->modId = 0;
|
||||
header->row = detPos[X];
|
||||
header->column = detPos[Y];
|
||||
header->detType = (uint16_t)myDetectorType;
|
||||
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
|
||||
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
||||
srcOffset += datasize;
|
||||
memcpy(packetData + sizeof(sls_detector_header),
|
||||
imageData + srcOffset, dataSize);
|
||||
srcOffset += dataSize;
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
sendUDPPacket(0, packetData, packetSize);
|
||||
}
|
||||
}
|
||||
LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
|
||||
// calculate time left in period
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
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 > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
if (periodNs > timeNs) {
|
||||
usleep((periodNs - timeNs)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set register frames left
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
// set status to idle
|
||||
|
||||
virtual_status = 0;
|
||||
LOG(logINFOBLUE, ("Finished Acquiring\n"));
|
||||
return NULL;
|
||||
|
@ -1165,8 +1165,13 @@ int64_t Module::getTotalNumFramesToReceive() {
|
||||
int64_t repeats = shm()->nTriggers;
|
||||
// gotthard2 & auto & burst mode, use nBursts instead of nTriggers
|
||||
if (shm()->myDetectorType == GOTTHARD2) {
|
||||
if (shm()->burstMode != BURST_OFF && shm()->timingMode == AUTO_TIMING) {
|
||||
// auto mode (either bursts or no repeats)
|
||||
if (shm()->timingMode == AUTO_TIMING) {
|
||||
if (shm()->burstMode != BURST_OFF) {
|
||||
repeats = shm()->nBursts;
|
||||
} else {
|
||||
repeats = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (shm()->nFrames * repeats * (int64_t)(shm()->nAddStorageCells + 1));
|
||||
|
Reference in New Issue
Block a user