From c10e04c4eb4dbfa16a54d09769beb868ff4f88e5 Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Fri, 28 Feb 2020 12:25:48 +0100 Subject: [PATCH 1/8] explicitly setting rx zmq datastream int the ctb Gui --- ctbGui/ctbAcquisition.cpp | 20 ++++++++++++++++--- examples/moench03_T1.config | 8 ++++---- .../moenchExecutables/moenchPhotonCounter.cpp | 2 ++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ctbGui/ctbAcquisition.cpp b/ctbGui/ctbAcquisition.cpp index 812e5459b..b104d4544 100755 --- a/ctbGui/ctbAcquisition.cpp +++ b/ctbGui/ctbAcquisition.cpp @@ -663,8 +663,10 @@ hframe=new TGHorizontalFrame(this, 800,50); cout <<"Registering data callback" << endl; try { myDet->registerDataCallback(&dataCallback, (void*)this); - } CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition") - + } CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition") + try { + myDet->setRxZmqDataStream(true); + } CATCH_DISPLAY ("Could not get set RxZmqDataStream.", "ctbAcquisition::ctbAcquisition") cout <<"Done" << endl; // mgAdcs=new TMultiGraph(); @@ -1153,8 +1155,20 @@ void ctbAcquisition::Draw(){ void ctbAcquisition::changePlot(){ if (rbPlotOff->IsOn()) { adcPlot=0; - dbitPlot=0; + dbitPlot=0; + try { + myDet->registerDataCallback(nullptr, this); + } CATCH_DISPLAY ("Could not get unregister call back.", "ctbAcquisition::ctbAcquisition") + try { + myDet->setRxZmqDataStream(false); + } CATCH_DISPLAY ("Could not get unset RxZmqDataStream.", "ctbAcquisition::ctbAcquisition") } else { + try { + myDet->registerDataCallback(&dataCallback, (void*)this); + } CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition") + try { + myDet->setRxZmqDataStream(true); + } CATCH_DISPLAY ("Could not get set RxZmqDataStream.", "ctbAcquisition::ctbAcquisition") adcPlot=0; dbitPlot=0; for (int ii=0; ii=9) { nframes=atoi(argv[8]); } + int xmin=0, xmax=nx, ymin=0, ymax=ny; if (argc>=13) { xmin=atoi(argv[9]); @@ -185,6 +186,7 @@ int main(int argc, char *argv[]) { cout << "pedestal file is " << pedfile << endl; if (thr>0) cout << "threshold is " << thr << endl; + cout << "Nframes is " << nframes << endl; uint32 nnx, nny; double *gmap; From 84cd4d8436ef342918ccd55e0cae51fe6822d0dc Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 2 Mar 2020 11:34:30 +0100 Subject: [PATCH 2/8] generated python funcs --- conda-recepie/meta.yaml | 2 +- python/src/detector.cpp | 15 +++++++++++++++ python/src/enums.cpp | 7 +++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/conda-recepie/meta.yaml b/conda-recepie/meta.yaml index 361e1389a..5817e805f 100755 --- a/conda-recepie/meta.yaml +++ b/conda-recepie/meta.yaml @@ -7,7 +7,7 @@ source: - path: .. build: - number: 1 + number: 2 binary_relocation: True rpaths: - lib/ diff --git a/python/src/detector.cpp b/python/src/detector.cpp index ddd3e991f..c45daeb74 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -428,6 +428,13 @@ void init_det(py::module &m) { py::arg() = Positions{}) .def("setImageTestMode", &Detector::setImageTestMode, py::arg(), py::arg() = Positions{}) + .def("getNumberOfBursts", &Detector::getNumberOfBursts, + py::arg() = Positions{}) + .def("setNumberOfBursts", &Detector::setNumberOfBursts, py::arg()) + .def("getBurstPeriod", &Detector::getBurstPeriod, + py::arg() = Positions{}) + .def("setBurstPeriod", &Detector::setBurstPeriod, py::arg(), + py::arg() = Positions{}) .def("getInjectChannel", &Detector::getInjectChannel, py::arg() = Positions{}) .def("setInjectChannel", &Detector::setInjectChannel, py::arg(), @@ -441,6 +448,14 @@ void init_det(py::module &m) { .def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{}) .def("setBurstMode", &Detector::setBurstMode, py::arg(), py::arg() = Positions{}) + .def("getCurrentSource", &Detector::getCurrentSource, + py::arg() = Positions{}) + .def("setCurrentSource", &Detector::setCurrentSource, py::arg(), + py::arg() = Positions{}) + .def("getTimingSource", &Detector::getTimingSource, + py::arg() = Positions{}) + .def("setTimingSource", &Detector::setTimingSource, py::arg(), + py::arg() = Positions{}) .def("getCounterMask", &Detector::getCounterMask, py::arg() = Positions{}) .def("setCounterMask", &Detector::setCounterMask, py::arg(), diff --git a/python/src/enums.cpp b/python/src/enums.cpp index bb7671e6f..9b857aa79 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -284,4 +284,11 @@ void init_enums(py::module &m) { .value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL) .value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL) .export_values(); + + py::enum_(Defs, "timingSourceType") + .value("TIMING_INTERNAL", + slsDetectorDefs::timingSourceType::TIMING_INTERNAL) + .value("TIMING_EXTERNAL", + slsDetectorDefs::timingSourceType::TIMING_EXTERNAL) + .export_values(); } From 95d56ad5455a1a62a0b99d50492e7273eb723f9c Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 2 Mar 2020 11:57:35 +0100 Subject: [PATCH 3/8] lookup --- python/scripts/basic.py | 6 +++--- python/slsdet/lookup.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/scripts/basic.py b/python/scripts/basic.py index 8cdd99885..5c92b32c3 100755 --- a/python/scripts/basic.py +++ b/python/scripts/basic.py @@ -3,9 +3,9 @@ import sys import numpy as np sys.path.append(os.path.join(os.getcwd(), 'bin')) -from sls_detector import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb -from sls_detector import dacIndex, readoutMode -from sls_detector.lookup import view, find +from slsdet import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb +from slsdet import dacIndex, readoutMode +from slsdet.lookup import view, find d = Detector() # e = Eiger() diff --git a/python/slsdet/lookup.py b/python/slsdet/lookup.py index 30ad3842c..be157841d 100644 --- a/python/slsdet/lookup.py +++ b/python/slsdet/lookup.py @@ -1,9 +1,9 @@ from .detector import Detector -def view(name): - names = find(name) +def view(name, det = Detector): + names = find(name, det) for n in names: print(n) -def find(name): - return [n for n in dir(Detector) if name in n] \ No newline at end of file +def find(name, det = Detector): + return [n for n in dir(det) if name.lower() in n.lower()] \ No newline at end of file From cce659d98c034fa3aa7b9ba1a85262d0b1c601ac Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 2 Mar 2020 13:12:46 +0100 Subject: [PATCH 4/8] deploy only on tags --- .travis.yml | 1 + conda-recepie/meta.yaml | 2 +- python/setup.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6cd07a07..4b2a82db4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,4 +34,5 @@ deploy: script: find $HOME/miniconda/envs/testenv/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \; on: branch: developer + tags: true diff --git a/conda-recepie/meta.yaml b/conda-recepie/meta.yaml index 5817e805f..9bec2c228 100755 --- a/conda-recepie/meta.yaml +++ b/conda-recepie/meta.yaml @@ -1,7 +1,7 @@ package: name: sls_detector_software - version: "developer" + version: {{ environ.get('GIT_DESCRIBE_TAG', '') }} source: - path: .. diff --git a/python/setup.py b/python/setup.py index bdf459762..229e265b6 100755 --- a/python/setup.py +++ b/python/setup.py @@ -8,7 +8,7 @@ import sys import setuptools import os -__version__ = 'udp' +__version__ = os.environ.get('GIT_DESCRIBE_TAG', 'developer') def get_conda_path(): From 3e88beb8a5d3fa7c7ec0fc11779588b2c3c1c724 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Mon, 2 Mar 2020 13:50:16 +0100 Subject: [PATCH 5/8] O3 as default and option for mtune --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b7e23376..def39765a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) project(slsDetectorPackage) set(PROJECT_VERSION 5.0.0) include(CheckIPOSupported) - +set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") cmake_policy(SET CMP0074 NEW) include(cmake/project_version.cmake) @@ -44,6 +44,9 @@ option(SLS_USE_PYTHON "Python bindings" OFF) option(SLS_USE_CTBGUI "ctb GUI" OFF) option(SLS_BUILD_DOCS "docs" OFF) option(SLS_BUILD_EXAMPLES "examples" OFF) +option(SLS_TUNE_LOCAL "tune to local machine" OFF) + + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) @@ -111,6 +114,11 @@ if(SLS_USE_SANITIZER) # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) endif() +if(SLS_TUNE_LOCAL) + target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native) +endif() + + #rapidjson add_library(rapidjson INTERFACE) target_include_directories(rapidjson INTERFACE From 75e083ae46361dd2443b140b949c292ada04382c Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 3 Mar 2020 11:04:05 +0100 Subject: [PATCH 6/8] find tests and commands --- python/scripts/cmd_python.py | 3 ++- python/scripts/list_tested_cmd.py | 29 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/python/scripts/cmd_python.py b/python/scripts/cmd_python.py index a76812c82..ad7395f44 100644 --- a/python/scripts/cmd_python.py +++ b/python/scripts/cmd_python.py @@ -4,10 +4,11 @@ out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.ge cmd = out.stdout.splitlines() cmd.pop(0) -from sls_detector import Detector, Eiger, Ctb +from slsdet import Detector, Eiger, Ctb pycmd = dir(Detector)+dir(Eiger)+dir(Ctb) +#Add commands that we should not expect as direct commands in python pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim', 'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb', 'rxb_lb', 'vref_prech', 'vref_rstore', 'vref_cds', diff --git a/python/scripts/list_tested_cmd.py b/python/scripts/list_tested_cmd.py index 74ebbc8be..4e4cbe6c8 100644 --- a/python/scripts/list_tested_cmd.py +++ b/python/scripts/list_tested_cmd.py @@ -1,11 +1,19 @@ +""" +Utility to find and list which command line functions have tests and +where the tests are located +""" +#local import for for parsing c++ import parse -from pathlib import Path + +#General python stuff import os import locale import argparse -path = Path('../../slsDetectorSoftware/tests/') import subprocess +from pathlib import Path +#Realative path from this dir +path = Path('../../slsDetectorSoftware/tests/') parser = argparse.ArgumentParser() parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None) args = parser.parse_args() @@ -15,15 +23,12 @@ tested = [] for fname in files: with open(path/fname) as f: data = f.read() - data = parse.remove_comments(data) data = data.splitlines() - - for line in data: if 'TEST_CASE' in line or 'SECTION' in line: cmd = line.split("\"")[1] - tested.append(cmd) + tested.append([cmd, fname]) out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding()) all_cmd = out.stdout.splitlines() @@ -33,18 +38,18 @@ all_cmd.pop(0) if args.startswith is not None: all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)] - tested = [cmd for cmd in tested if cmd.startswith(args.startswith)] + tested = [cmd for cmd in tested if cmd[0].startswith(args.startswith)] +tn = [cmd[0] for cmd in tested] - -not_tested = [cmd for cmd in all_cmd if cmd not in tested] -misnamed = [cmd for cmd in tested if cmd not in all_cmd] -tested = [cmd for cmd in tested if cmd in all_cmd] +not_tested = [cmd for cmd in all_cmd if cmd not in tn] +misnamed = [cmd for cmd in tn if cmd not in all_cmd] +tested = [cmd for cmd in tested if cmd[0] in all_cmd] print("\nThe following commands are tested:") for cmd in tested: - print(cmd) + print(f'{cmd[0]:>18} : {cmd[1]}') print("\nThe following commands are NOT tested:") for cmd in not_tested: From b2d88b441a18a9ad1d4ad3e7a95122ee840b2cd7 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 3 Mar 2020 11:17:26 +0100 Subject: [PATCH 7/8] removed comments --- slsReceiverSoftware/src/MultiReceiverApp.cpp | 19 +---- slsReceiverSoftware/src/ReceiverApp.cpp | 83 +------------------- 2 files changed, 2 insertions(+), 100 deletions(-) diff --git a/slsReceiverSoftware/src/MultiReceiverApp.cpp b/slsReceiverSoftware/src/MultiReceiverApp.cpp index b6c0c24e5..fc742ce42 100755 --- a/slsReceiverSoftware/src/MultiReceiverApp.cpp +++ b/slsReceiverSoftware/src/MultiReceiverApp.cpp @@ -1,21 +1,4 @@ -/** - \file mainReceiver.cpp - -This file is an example of how to implement the Receiver class -You can compile it linking it to the slsReceiver library - -g++ mainReceiver.cpp -L lib -lSlsReceiver -L/usr/lib64/ -L lib2 -lzmq -pthread -lrt -lm -lstdc++ - -where, - -lib is the location of lSlsReceiver.so - -lib2 is the location of the libzmq.a. -[ libzmq.a is required only when using data call backs and enabling data streaming from receiver to client. -It is linked in manual/manual-api from slsReceiverSoftware/include ] - - */ - +/* Creates the slsMultiReceiver for running multiple receivers form a single binary */ #include "sls_detector_defs.h" #include "Receiver.h" #include "container_utils.h" diff --git a/slsReceiverSoftware/src/ReceiverApp.cpp b/slsReceiverSoftware/src/ReceiverApp.cpp index e30785470..81508059f 100755 --- a/slsReceiverSoftware/src/ReceiverApp.cpp +++ b/slsReceiverSoftware/src/ReceiverApp.cpp @@ -1,5 +1,4 @@ -/* A simple server in the internet domain using TCP - The port number is passed as an argument */ +/* slsReceiver */ #include "logger.h" #include "Receiver.h" @@ -23,47 +22,6 @@ void sigInterruptHandler(int p){ sem_post(&semaphore); } -/** Define Colors to print data call back in different colors for different recievers */ -/* -#define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) - -int StartAcq(std::string filepath, std::string filename, uint64_t fileindex, uint32_t datasize, void*p){ - FILE_LOG(logINFO) << "#### StartAcq: " - "filepath: " << filepath << "filename: " << filename << - "fileindex: " << fileindex << "datasize: " << datasize << " ####"; - FILE_LOG(logINFO) << "--StartAcq: returning 0"; - return 0; -} - - -void AcquisitionFinished(uint64_t frames, void*p){ - FILE_LOG(logINFO) << "#### AcquisitionFinished: frames:" << frames << " ####"; -} - - -void GetData(char* metadata, char* datapointer, uint32_t datasize, void* p){ - slsDetectorDefs::sls_receiver_header* header = (slsDetectorDefs::sls_receiver_header*)metadata; - slsDetectorDefs::sls_detector_header detectorHeader = header->detHeader; - - PRINT_IN_COLOR (detectorHeader.modId?detectorHeader.modId:detectorHeader.row, - "#### %d GetData: ####\n" - "frameNumber: %lu\t\texpLength: %u\t\tpacketNumber: %u\t\tbunchId: %lu" - "\t\ttimestamp: %lu\t\tmodId: %u\t\t" - "row: %u\t\tcolumn: %u\t\treserved: %u\t\tdebug: %u" - "\t\troundRNumber: %u\t\tdetType: %u\t\tversion: %u" - //"\t\tpacketsMask:%s" - "\t\tfirstbytedata: 0x%x\t\tdatsize: %u\n\n", - detectorHeader.row, (long unsigned int)detectorHeader.frameNumber, - detectorHeader.expLength, detectorHeader.packetNumber, (long unsigned int)detectorHeader.bunchId, - (long unsigned int)detectorHeader.timestamp, detectorHeader.modId, - detectorHeader.row, detectorHeader.column, detectorHeader.reserved, - detectorHeader.debug, detectorHeader.roundRNumber, - detectorHeader.detType, detectorHeader.version, - //header->packetsMask.to_string().c_str(), - ((uint8_t)(*((uint8_t*)(datapointer)))), datasize); -} -*/ - int main(int argc, char *argv[]) { @@ -99,45 +57,6 @@ int main(int argc, char *argv[]) { throw; } - //register callbacks - - /** - callback arguments are - filepath - filename - fileindex - datasize - - return value is - 0 raw data ready callback takes care of open,close,write file - 1 callback writes file, we have to open, close it - 2 we open, close, write file, callback does not do anything - - registerCallBackStartAcquisition(int (*func)(std::string, std::string, int, int, void*),void *arg); - */ - //receiver->registerCallBackStartAcquisition(startAcquisitionCallBack,NULL); - - - /** - callback argument is - total farmes caught - registerCallBackAcquisitionFinished(void (*func)(int, void*),void *arg); - */ - //receiver->registerCallBackAcquisitionFinished(acquisitionFinishedCallBack,NULL); - - - /** - args to raw data ready callback are - sls_receiver_header frame metadata - datapointer - file descriptor - guidatapointer (NULL, no data required) - NEVER DELETE THE DATA POINTER - REMEMBER THAT THE CALLBACK IS BLOCKING - registerCallBackRawDataReady(void (*func)(char*, char*, uint32_t, void*),void *arg); - */ - //receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL); - FILE_LOG(logINFO) << "[ Press \'Ctrl+c\' to exit ]"; sem_wait(&semaphore); sem_destroy(&semaphore); From 1efacc9475eae77315785b244fc421452837e779 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 3 Mar 2020 11:33:28 +0100 Subject: [PATCH 8/8] cleaning up headers --- slsReceiverSoftware/src/MultiReceiverApp.cpp | 11 ++--------- slsReceiverSoftware/src/ReceiverApp.cpp | 10 +--------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/slsReceiverSoftware/src/MultiReceiverApp.cpp b/slsReceiverSoftware/src/MultiReceiverApp.cpp index fc742ce42..a4ee1646c 100755 --- a/slsReceiverSoftware/src/MultiReceiverApp.cpp +++ b/slsReceiverSoftware/src/MultiReceiverApp.cpp @@ -4,18 +4,11 @@ #include "container_utils.h" #include //SIGINT -#include //system #include #include -#include -#include -#include //wait #include //wait #include //tid -#include //usleep #include -using namespace std; - /** Define Colors to print data call back in different colors for different recievers */ #define PRINT_IN_COLOR(c,f, ...) printf ("\033[%dm" f RESET, 30 + c+1, ##__VA_ARGS__) @@ -241,7 +234,7 @@ int main(int argc, char *argv[]) { /** - Print Ready and Instructions how to exit */ - cout << "Ready ... " << endl; + std::cout << "Ready ... \n"; cprintf(RESET, "\n[ Press \'Ctrl+c\' to exit ]\n"); /** - Parent process waits for all child processes to exit */ @@ -263,7 +256,7 @@ int main(int argc, char *argv[]) { cprintf(BLUE,"Exiting Child Process [ Tid: %ld ]\n", (long int) childPid); } - cout << "Goodbye!" << endl; + std::cout << "Goodbye!\n"; return 0; } diff --git a/slsReceiverSoftware/src/ReceiverApp.cpp b/slsReceiverSoftware/src/ReceiverApp.cpp index 81508059f..0a098de92 100755 --- a/slsReceiverSoftware/src/ReceiverApp.cpp +++ b/slsReceiverSoftware/src/ReceiverApp.cpp @@ -1,19 +1,11 @@ /* slsReceiver */ - #include "logger.h" #include "Receiver.h" #include "sls_detector_defs.h" #include "container_utils.h" -#include //SIGINT -#include //system -#include -#include -#include //wait -#include //wait +#include //SIGINT #include -#include //usleep -#include #include sem_t semaphore;