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