mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
slsReceiver: removed special receiver config, added rx_dbitlist, rx_dbitoffset to put bits together in file, connected adcinvert, extsamplingsrc and extsampling properly to the detector, added tests
This commit is contained in:
@ -28,7 +28,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
bool* fp, bool* act, bool* depaden, bool* sm,
|
||||
int* ct, int* cdo, int* cad) :
|
||||
std::vector <int> * cdl, int* cdo, int* cad) :
|
||||
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
@ -50,6 +50,9 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
deactivatedPaddingEnable(depaden),
|
||||
silentMode(sm),
|
||||
framePadding(fp),
|
||||
ctbDbitList(cdl),
|
||||
ctbDbitOffset(cdo),
|
||||
ctbAnalogDataBytes(cad),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -57,12 +60,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
|
||||
numTotalFramesCaught(0),
|
||||
numFramesCaught(0),
|
||||
currentFrameIndex(0),
|
||||
ctbType(ct),
|
||||
ctbDigitalOffset(cdo),
|
||||
ctbAnalogDataBytes(cad),
|
||||
rawDataReadyCallBack(nullptr),
|
||||
rawDataModifyReadyCallBack(nullptr),
|
||||
ctbRawDataReadyCallBack(nullptr),
|
||||
pRawDataReady(nullptr)
|
||||
{
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
@ -356,6 +355,11 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
else if (!(*activated) && *deactivatedPaddingEnable)
|
||||
PadMissingPackets(buf);
|
||||
|
||||
// rearrange ctb digital bits (if ctbDbitlist is not empty)
|
||||
if (!(*ctbDbitList).empty()) {
|
||||
RearrangeDbitData(buf);
|
||||
}
|
||||
|
||||
// normal call back
|
||||
if (rawDataReadyCallBack) {
|
||||
rawDataReadyCallBack(
|
||||
@ -376,20 +380,6 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
(*((uint32_t*)buf)) = revsize;
|
||||
}
|
||||
|
||||
// ctb call back
|
||||
else if (ctbRawDataReadyCallBack) {
|
||||
uint32_t revsize = (uint32_t)(*((uint32_t*)buf));
|
||||
ctbRawDataReadyCallBack(
|
||||
(char*)rheader,
|
||||
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
|
||||
revsize,
|
||||
*ctbType,
|
||||
*ctbDigitalOffset,
|
||||
*ctbAnalogDataBytes,
|
||||
pRawDataReady);
|
||||
(*((uint32_t*)buf)) = revsize;
|
||||
}
|
||||
|
||||
|
||||
// write to file
|
||||
if (file)
|
||||
@ -397,8 +387,6 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
sizeof(sls_receiver_header) + (uint32_t)(*((uint32_t*)buf)), //+ size of data (resizable from previous call back
|
||||
fnum-firstMeasurementIndex, nump);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -464,12 +452,6 @@ void DataProcessor::registerCallBackRawDataModifyReady(void (*func)(char* ,
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
void DataProcessor::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t&, int, int, int, void*),void *arg) {
|
||||
ctbRawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
void DataProcessor::PadMissingPackets(char* buf) {
|
||||
FILE_LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||
|
||||
@ -519,6 +501,45 @@ void DataProcessor::PadMissingPackets(char* buf) {
|
||||
}
|
||||
}
|
||||
|
||||
/** ctb specific */
|
||||
void DataProcessor::RearrangeDbitData(char* buf) {
|
||||
int totalSize = (int)(*((uint32_t*)buf));
|
||||
int ctbDigitalDataBytes = totalSize - (*ctbAnalogDataBytes) - (*ctbDbitOffset);
|
||||
|
||||
// no digital data
|
||||
if (!ctbDigitalDataBytes) {
|
||||
FILE_LOG(logWARNING) << "No digital data for call back, yet dbitlist is not empty.";
|
||||
return;
|
||||
}
|
||||
|
||||
const int numSamples = (ctbDigitalDataBytes / sizeof(uint64_t));
|
||||
|
||||
// ceil as numResult64Bytes could be decimal
|
||||
const int numResult64Bytes = ceil((double)(numSamples * (*ctbDbitList).size()) / 64.00);
|
||||
std::vector<uint64_t> result(numResult64Bytes, 0);
|
||||
|
||||
auto dest = result.data();
|
||||
const int digOffset = FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header) + (*ctbAnalogDataBytes) + (*ctbDbitOffset);
|
||||
auto source = (uint64_t*)(buf + digOffset);
|
||||
|
||||
// loop through digital bit enable vector
|
||||
for (auto bi : (*ctbDbitList)) {
|
||||
// loop through the frame digital data
|
||||
for (auto ptr = source; ptr < (source + numSamples);) {
|
||||
// extract destination in 64 bit batches
|
||||
for (int i = 0; i != 64; ++i) {
|
||||
// get selected bit from each 64 bit
|
||||
int bit = (*ptr++ >> bi) & 1;
|
||||
*dest |= bit << i;
|
||||
}
|
||||
++dest;
|
||||
}
|
||||
}
|
||||
|
||||
// copy back to buf and update size
|
||||
memcpy(source + digOffset, result.data(), result.size() * sizeof(uint64_t));
|
||||
(*((uint32_t*)buf)) = result.size() * sizeof(uint64_t);
|
||||
}
|
||||
|
||||
/** eiger specific */
|
||||
void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
|
||||
|
@ -1,189 +0,0 @@
|
||||
/* A simple server in the internet domain using TCP
|
||||
The port number is passed as an argument */
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "slsReceiverUsers.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <signal.h> //SIGINT
|
||||
#include <cstdlib> //system
|
||||
#include <sys/types.h> //wait
|
||||
#include <sys/wait.h> //wait
|
||||
#include <unistd.h> //usleep
|
||||
#include <syscall.h>
|
||||
#include <map>
|
||||
#include <getopt.h>
|
||||
|
||||
bool keeprunning;
|
||||
int ctbOffset = 0;
|
||||
bool printData = false;
|
||||
|
||||
void sigInterruptHandler(int p){
|
||||
keeprunning = false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MYTHEN302
|
||||
void GetData(char* metadata, char* datapointer, uint32_t& datasize,
|
||||
int ctbType, int ctbDigitalOffset, int ctbAnalogDataBytes, void* p) {
|
||||
|
||||
// only analog data
|
||||
if (ctbAnalogDataBytes == (int)datasize) {
|
||||
FILE_LOG(logWARNING) << "No digital data for call back. Remove this unnecessary call back.";
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr int dynamicRange = 24;
|
||||
constexpr int numSamples = 32 * 3; // 32 channels * 3 counters = 96
|
||||
constexpr int numCounters = numSamples * 2; // 2 strips
|
||||
// validate datasize
|
||||
{
|
||||
FILE_LOG(logDEBUG) << "Datasize:" << datasize;
|
||||
int wordsCaught = ((datasize - ctbAnalogDataBytes) / sizeof(uint64_t)) - ctbOffset;
|
||||
int expectedWordSize = numSamples * dynamicRange;
|
||||
if (expectedWordSize != wordsCaught) {
|
||||
FILE_LOG(logWARNING) << "Number of words do not match, Expected "
|
||||
<< expectedWordSize << ", got " << wordsCaught;
|
||||
}
|
||||
}
|
||||
|
||||
// source
|
||||
uint64_t* ptr = (uint64_t*)(datapointer + ctbAnalogDataBytes);
|
||||
// remove the offset from source
|
||||
ptr += ctbOffset;
|
||||
// destination
|
||||
auto result = new int[numCounters];
|
||||
memset((char*)result, 0, numCounters * sizeof(int));
|
||||
auto strip0 = result;
|
||||
auto strip1 = strip0 + numSamples;
|
||||
constexpr int bit_index0 = 17;
|
||||
constexpr int bit_index1 = 6;
|
||||
FILE_LOG(logINFO) << "Bits (" << bit_index0 << ", " << bit_index1 << ")";
|
||||
constexpr int mask0 = (1 << bit_index0);
|
||||
constexpr int mask1 = (1 << bit_index1);
|
||||
|
||||
for (int j = 0; j < numSamples; ++j) {
|
||||
for (int i = 0; i < dynamicRange; ++i) {
|
||||
int bit0 = (*ptr & mask0) >> bit_index0;
|
||||
int bit1 = (*ptr++ & mask1) >> bit_index1;
|
||||
*strip0 |= bit0 << i;
|
||||
*strip1 |= bit1 << i;
|
||||
}
|
||||
strip0++;
|
||||
strip1++;
|
||||
}
|
||||
|
||||
if (printData) {
|
||||
slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata;
|
||||
slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader;
|
||||
FILE_LOG(logINFO) << "Frame Number: " << detectorHeader.frameNumber;
|
||||
for (int i = 0; i < numCounters; ++i) {
|
||||
cprintf(MAGENTA, "%d:%u\t", i, result[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
// update the size to be written to file & overwrite data in memory
|
||||
datasize = numCounters * sizeof(int);
|
||||
memcpy(datapointer + ctbAnalogDataBytes, (char*)result, datasize);
|
||||
delete[] result;
|
||||
datasize += ctbAnalogDataBytes;
|
||||
FILE_LOG(logDEBUG) << "Modified Size: " << datasize;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// options
|
||||
std::map<std::string, std::string> configuration_map;
|
||||
//parse command line for config
|
||||
static struct option long_options[] = {
|
||||
{"ctb_offset", required_argument, nullptr, 'o'},
|
||||
{"print_data", no_argument, nullptr, 'p'},
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
//initialize global optind variable (required when instantiating multiple receivers in the same process)
|
||||
optind = 1;
|
||||
// getopt_long stores the option index here.
|
||||
int option_index = 0;
|
||||
int c = 0;
|
||||
while ( c != -1 ) {
|
||||
c = getopt_long (argc, argv, "hvf:t:o:p", long_options, &option_index);
|
||||
// Detect the end of the options.
|
||||
if (c == -1)
|
||||
break;
|
||||
switch(c) {
|
||||
case 'o':
|
||||
sscanf(optarg, "%d", &ctbOffset);
|
||||
break;
|
||||
case 'p':
|
||||
printData = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MYTHEN302
|
||||
FILE_LOG(logINFOGREEN) << "Mythen 302 Receiver";
|
||||
FILE_LOG(logINFO) << "CTB Offset: " << ctbOffset;
|
||||
FILE_LOG(logINFO) << "Print Data: " << printData;
|
||||
#endif
|
||||
|
||||
keeprunning = true;
|
||||
FILE_LOG(logINFOBLUE) << "Created [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
|
||||
// Catch signal SIGINT to close files and call destructors properly
|
||||
struct sigaction sa;
|
||||
sa.sa_flags = 0; // no flags
|
||||
sa.sa_handler = sigInterruptHandler; // handler function
|
||||
sigemptyset(&sa.sa_mask); // dont block additional signals during invocation
|
||||
// of handler
|
||||
if (sigaction(SIGINT, &sa, nullptr) == -1) {
|
||||
FILE_LOG(logERROR) << "Could not set handler function for SIGINT";
|
||||
}
|
||||
|
||||
|
||||
// if socket crash, ignores SISPIPE, prevents global signal handler
|
||||
// subsequent read/write to socket gives error - must handle locally
|
||||
struct sigaction asa;
|
||||
asa.sa_flags=0; // no flags
|
||||
asa.sa_handler=SIG_IGN; // handler function
|
||||
sigemptyset(&asa.sa_mask); // dont block additional signals during invocation of handler
|
||||
if (sigaction(SIGPIPE, &asa, nullptr) == -1) {
|
||||
FILE_LOG(logERROR) << "Could not set handler function for SIGPIPE";
|
||||
}
|
||||
|
||||
int ret = slsDetectorDefs::OK;
|
||||
slsReceiverUsers *receiver = new slsReceiverUsers(argc, argv, ret);
|
||||
if(ret==slsDetectorDefs::FAIL){
|
||||
delete receiver;
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
//register callbacks
|
||||
receiver->registerCallBackCTBReceiverReady(GetData, NULL);
|
||||
|
||||
//start tcp server thread
|
||||
if (receiver->start() == slsDetectorDefs::FAIL){
|
||||
delete receiver;
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "Ready ... ";
|
||||
FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]";
|
||||
while(keeprunning)
|
||||
pause();
|
||||
|
||||
delete receiver;
|
||||
FILE_LOG(logINFOBLUE) << "Exiting [ Tid: " << syscall(SYS_gettid) << " ]";
|
||||
FILE_LOG(logINFO) << "Exiting Receiver";
|
||||
return 0;
|
||||
}
|
||||
|
@ -44,17 +44,13 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
|
||||
int c = 0;
|
||||
|
||||
while ( c != -1 ){
|
||||
c = getopt_long (argc, argv, "hvf:t:o:p", long_options, &option_index);
|
||||
c = getopt_long (argc, argv, "hvf:t:", long_options, &option_index);
|
||||
|
||||
// Detect the end of the options.
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch(c){
|
||||
// reserved for ctb receiver users
|
||||
case 'o':
|
||||
case 'p':
|
||||
break;
|
||||
|
||||
case 't':
|
||||
sscanf(optarg, "%d", &tcpip_port_no);
|
||||
@ -113,7 +109,6 @@ void slsReceiver::registerCallBackStartAcquisition(int (*func)(
|
||||
}
|
||||
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackAcquisitionFinished(
|
||||
void (*func)(uint64_t, void*),void *arg){
|
||||
tcpipInterface->registerCallBackAcquisitionFinished(func,arg);
|
||||
@ -131,8 +126,3 @@ void slsReceiver::registerCallBackRawDataModifyReady(void (*func)(char*,
|
||||
tcpipInterface->registerCallBackRawDataModifyReady(func,arg);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiver::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg){
|
||||
tcpipInterface->registerCallBackCTBReceiverReady(func,arg);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ void slsReceiverImplementation::DeleteMembers() {
|
||||
dataProcessor.clear();
|
||||
dataStreamer.clear();
|
||||
fifo.clear();
|
||||
ctbDbitList.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -80,6 +81,8 @@ void slsReceiverImplementation::InitializeMembers() {
|
||||
frameDiscardMode = NO_DISCARD;
|
||||
framePadding = false;
|
||||
silentMode = false;
|
||||
ctbDbitOffset = 0;
|
||||
ctbAnalogDataBytes = 0;
|
||||
|
||||
//***connection parameters***
|
||||
numUDPInterfaces = 1;
|
||||
@ -113,11 +116,6 @@ void slsReceiverImplementation::InitializeMembers() {
|
||||
//** class objects ***
|
||||
generalData = nullptr;
|
||||
|
||||
//** ctb callback parameters
|
||||
ctbType = 0;
|
||||
ctbDigitalOffset = 0;
|
||||
ctbAnalogDataBytes = 0;
|
||||
|
||||
//***callback parameters***
|
||||
startAcquisitionCallBack = nullptr;
|
||||
pStartAcquisition = nullptr;
|
||||
@ -125,7 +123,6 @@ void slsReceiverImplementation::InitializeMembers() {
|
||||
pAcquisitionFinished = nullptr;
|
||||
rawDataReadyCallBack = nullptr;
|
||||
rawDataModifyReadyCallBack = nullptr;
|
||||
ctbRawDataReadyCallBack = nullptr;
|
||||
pRawDataReady = nullptr;
|
||||
}
|
||||
|
||||
@ -383,6 +380,16 @@ bool slsReceiverImplementation::getSilentMode() const{
|
||||
return silentMode;
|
||||
}
|
||||
|
||||
std::vector <int> slsReceiverImplementation::getDbitList() const{
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
return ctbDbitList;
|
||||
}
|
||||
|
||||
int slsReceiverImplementation::getDbitOffset() const{
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
return ctbDbitOffset;
|
||||
}
|
||||
|
||||
bool slsReceiverImplementation::getActivate() const{
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
return activated;
|
||||
@ -703,7 +710,7 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
|
||||
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||
&ctbType, &ctbDigitalOffset, &ctbAnalogDataBytes));
|
||||
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
dataProcessor[i]->SetGeneralData(generalData);
|
||||
}
|
||||
catch (...) {
|
||||
@ -748,10 +755,6 @@ int slsReceiverImplementation::setNumberofUDPInterfaces(const int n) {
|
||||
for (const auto& it : dataProcessor)
|
||||
it->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
||||
}
|
||||
if(ctbRawDataReadyCallBack) {
|
||||
for (const auto& it : dataProcessor)
|
||||
it->registerCallBackCTBReceiverReady(ctbRawDataReadyCallBack,pRawDataReady);
|
||||
}
|
||||
|
||||
// test socket buffer size with current set up
|
||||
if (setUDPSocketBufferSize(0) == FAIL) {
|
||||
@ -1088,6 +1091,17 @@ void slsReceiverImplementation::setSilentMode(const bool i) {
|
||||
FILE_LOG(logINFO) << "Silent Mode: " << i;
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setDbitList(const std::vector <int> v) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
ctbDbitList = v;
|
||||
}
|
||||
|
||||
void slsReceiverImplementation::setDbitOffset(const int s) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
ctbDbitOffset = s;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Behavioral functions***************************************************
|
||||
@ -1148,7 +1162,7 @@ int slsReceiverImplementation::setDetectorType(const detectorType d) {
|
||||
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
|
||||
&framePadding, &activated, &deactivatedPaddingEnable, &silentMode,
|
||||
&ctbType, &ctbDigitalOffset, &ctbAnalogDataBytes));
|
||||
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
|
||||
}
|
||||
catch (...) {
|
||||
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
|
||||
@ -1434,15 +1448,6 @@ void slsReceiverImplementation::registerCallBackRawDataModifyReady(void (*func)(
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverImplementation::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t&, int, int, int, void*),void *arg) {
|
||||
ctbRawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
for (const auto& it : dataProcessor)
|
||||
it->registerCallBackCTBReceiverReady(ctbRawDataReadyCallBack,pRawDataReady);
|
||||
}
|
||||
|
||||
|
||||
void slsReceiverImplementation::SetLocalNetworkParameters() {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
|
@ -53,7 +53,6 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int pn):
|
||||
pAcquisitionFinished = nullptr;
|
||||
rawDataReadyCallBack = nullptr;
|
||||
rawDataModifyReadyCallBack = nullptr;
|
||||
ctbRawDataReadyCallBack = nullptr;
|
||||
pRawDataReady = nullptr;
|
||||
|
||||
// create socket
|
||||
@ -131,12 +130,6 @@ void slsReceiverTCPIPInterface::registerCallBackRawDataModifyReady(void (*func)(
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
void slsReceiverTCPIPInterface::registerCallBackCTBReceiverReady(void (*func)(char* ,
|
||||
char*, uint32_t &, int, int, int, void*),void *arg){
|
||||
ctbRawDataReadyCallBack=func;
|
||||
pRawDataReady=arg;
|
||||
}
|
||||
|
||||
void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
|
||||
((slsReceiverTCPIPInterface*)this_pointer)->startTCPServer();
|
||||
return this_pointer;
|
||||
@ -231,9 +224,12 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility;
|
||||
flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy;
|
||||
flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable;
|
||||
flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable;
|
||||
flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_padding_enable;
|
||||
flist[F_RECEIVER_SET_READOUT_FLAGS] = &slsReceiverTCPIPInterface::set_readout_flags;
|
||||
flist[F_RECEIVER_SET_ADC_MASK] = &slsReceiverTCPIPInterface::set_adc_mask;
|
||||
flist[F_SET_RECEIVER_DBIT_LIST] = &slsReceiverTCPIPInterface::set_dbit_list;
|
||||
flist[F_GET_RECEIVER_DBIT_LIST] = &slsReceiverTCPIPInterface::get_dbit_list;
|
||||
flist[F_RECEIVER_DBIT_OFFSET] = &slsReceiverTCPIPInterface::set_dbit_offset;
|
||||
|
||||
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
FILE_LOG(logDEBUG1) << "function fnum: " << i << " (" <<
|
||||
@ -556,6 +552,20 @@ int slsReceiverTCPIPInterface::send_update() {
|
||||
i32=(int)receiver->getSilentMode();
|
||||
n += mySock->SendDataOnly(&i32, sizeof(i32));
|
||||
|
||||
// dbit list
|
||||
{
|
||||
std::vector <int> list = receiver->getDbitList();
|
||||
int retvalsize = list.size();
|
||||
int retval[retvalsize];
|
||||
std::copy(std::begin(list), std::end(list), retval);
|
||||
mySock->SendDataOnly(&retvalsize, sizeof(retvalsize));
|
||||
mySock->SendDataOnly(retval, sizeof(retval));
|
||||
}
|
||||
|
||||
// dbit offset
|
||||
i32=receiver->getDbitOffset();
|
||||
n += mySock->SendDataOnly(&i32, sizeof(i32));
|
||||
|
||||
if (!lockStatus)
|
||||
strcpy(mySock->lastClientIP, mySock->thisClientIP);
|
||||
|
||||
@ -621,8 +631,6 @@ int slsReceiverTCPIPInterface::set_detector_type(){
|
||||
receiver->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
|
||||
if(rawDataModifyReadyCallBack)
|
||||
receiver->registerCallBackRawDataModifyReady(rawDataModifyReadyCallBack,pRawDataReady);
|
||||
if(ctbRawDataReadyCallBack)
|
||||
receiver->registerCallBackCTBReceiverReady(ctbRawDataReadyCallBack, pRawDataReady);
|
||||
|
||||
// client has started updating receiver, update ip
|
||||
if (!lockStatus)
|
||||
@ -2030,7 +2038,7 @@ int slsReceiverTCPIPInterface::set_padding_enable() {
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() {
|
||||
int slsReceiverTCPIPInterface::set_deactivated_padding_enable() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int enable = -1;
|
||||
@ -2123,5 +2131,100 @@ int slsReceiverTCPIPInterface::set_adc_mask() {
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "ADC enable mask retval: " << retval;
|
||||
}
|
||||
return interface->Server_SendResult(false, ret, &retval, sizeof(retval), mess);
|
||||
return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_dbit_list() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
|
||||
// receive arguments
|
||||
int narg = -1;
|
||||
if (mySock->ReceiveDataOnly(&narg,sizeof(narg)) < 0 )
|
||||
return interface->Server_SocketCrash();
|
||||
int narglist[narg];
|
||||
if (mySock->ReceiveDataOnly(narglist, narg * sizeof(int)) < 0 )
|
||||
return interface->Server_SocketCrash();
|
||||
std::vector <int> arg(narglist, narglist + narg);
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Setting DBIT list";
|
||||
for (auto &it : arg) {
|
||||
FILE_LOG(logDEBUG1) << it << " ";
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "\n";
|
||||
|
||||
// base object not null
|
||||
if (receiver == nullptr)
|
||||
interface->Server_NullObjectError(ret, mess);
|
||||
else {
|
||||
// only set
|
||||
// verify if receiver is unlocked and idle
|
||||
if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) {
|
||||
if (arg.size() > 64) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set dbit list as size is > 64\n");
|
||||
FILE_LOG(logERROR) << mess;
|
||||
} else
|
||||
receiver->setDbitList(arg);
|
||||
}
|
||||
}
|
||||
|
||||
return interface->Server_SendResult(true, ret, nullptr, 0, mess);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::get_dbit_list() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
std::vector<int> list;
|
||||
|
||||
// no arg, check receiver is null
|
||||
interface->Server_ReceiveArg(ret, mess, nullptr, 0, true, receiver);
|
||||
|
||||
// base object not null
|
||||
if (ret == OK) {
|
||||
// get
|
||||
list = receiver->getDbitList();
|
||||
FILE_LOG(logDEBUG1) << "Dbit list size retval:" << list.size();
|
||||
}
|
||||
|
||||
interface->Server_SendResult(false, ret, nullptr, 0, mess);
|
||||
int retvalsize = list.size();
|
||||
int retval[retvalsize];
|
||||
std::copy(std::begin(list), std::end(list), retval);
|
||||
mySock->SendDataOnly(&retvalsize, sizeof(retvalsize));
|
||||
mySock->SendDataOnly(retval, sizeof(retval));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_dbit_offset() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int arg = -1;
|
||||
int retval = -1;
|
||||
|
||||
// get args, return if socket crashed, ret is fail if receiver is not null
|
||||
if (interface->Server_ReceiveArg(ret, mess, &arg, sizeof(arg), true, receiver) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
// base object not null
|
||||
else if (ret == OK) {
|
||||
// set
|
||||
if (arg >= 0) {
|
||||
// verify if receiver is unlocked and idle
|
||||
if (interface->Server_VerifyLockAndIdle(ret, mess, lockStatus, receiver->getStatus(), fnum) == OK) {
|
||||
FILE_LOG(logDEBUG1) << "Setting Dbit offset: " << arg;
|
||||
receiver->setDbitOffset(arg);
|
||||
}
|
||||
}
|
||||
// get
|
||||
retval = receiver->getDbitOffset();
|
||||
validate(arg, retval, std::string("set dbit offset"), DEC);
|
||||
FILE_LOG(logDEBUG1) << "Dbit offset retval: " << retval;
|
||||
}
|
||||
return interface->Server_SendResult(true, ret, &retval, sizeof(retval), mess);
|
||||
}
|
@ -46,8 +46,3 @@ void slsReceiverUsers::registerCallBackRawDataModifyReady(void (*func)(char* hea
|
||||
receiver->registerCallBackRawDataModifyReady(func,arg);
|
||||
}
|
||||
|
||||
void slsReceiverUsers::registerCallBackCTBReceiverReady(void (*func)(char* header,
|
||||
char* datapointer, uint32_t& revDatasize,
|
||||
int type, int digitalOffset, int analogDataBytes, void*), void *arg){
|
||||
receiver->registerCallBackCTBReceiverReady(func,arg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user