mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-18 15:57:13 +02:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
9738cb7d74 | |||
4f4125a3b2 | |||
51412f40cf | |||
ce7270e8a2 | |||
d72c9e29a4 | |||
62dc0e1a34 | |||
d7aa3305d1 | |||
96ed74c47c | |||
4198db8365 | |||
e2d7af28dc | |||
66d57c1852 | |||
aa4bf6e7f9 | |||
7f0868f344 | |||
e57cf49c49 | |||
66baaf1ebd | |||
7d7ac26c30 | |||
1a7c74fe4e | |||
01e4bcb47e | |||
397e846509 | |||
314a8a0daa | |||
ebb352b13a | |||
9b5d44f0b3 | |||
1892963fcb | |||
62f45b15d2 | |||
82ac45873c | |||
2b2e50916c | |||
d34f396ef8 | |||
f9c4405da6 |
2
.github/workflows/cmake.yml
vendored
2
.github/workflows/cmake.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: awalsh128/cache-apt-pkgs-action@latest
|
- uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
with:
|
with:
|
||||||
packages: libzmq3-dev libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
packages: libhdf5-dev qtbase5-dev qt5-qmake libqt5svg5-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
|
1
CMakeFiles/cmake.check_cache
Normal file
1
CMakeFiles/cmake.check_cache
Normal file
@ -0,0 +1 @@
|
|||||||
|
# This file is generated by cmake for dependency checking of the CMakeCache.txt file
|
@ -2,7 +2,7 @@
|
|||||||
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(slsDetectorPackage)
|
project(slsDetectorPackage)
|
||||||
set(PROJECT_VERSION 8.0.2)
|
set(PROJECT_VERSION 7.0.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ else()
|
|||||||
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
# Standard behaviour use libzmq included in this repo (libs/libzmq)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
libzmq
|
libzmq
|
||||||
URL ${CMAKE_CURRENT_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
URL ${CMAKE_SOURCE_DIR}/libs/libzmq/libzmq-4.3.4.tar.gz
|
||||||
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
URL_HASH MD5=cc20b769ac10afa352e5ed2769bb23b3
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
@ -244,6 +244,7 @@ if(SLS_USE_SANITIZER)
|
|||||||
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(SLS_TUNE_LOCAL)
|
if(SLS_TUNE_LOCAL)
|
||||||
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
|
target_compile_options(slsProjectOptions INTERFACE -mtune=native -march=native)
|
||||||
endif()
|
endif()
|
||||||
|
156
RELEASE.txt
156
RELEASE.txt
@ -1,13 +1,21 @@
|
|||||||
SLS Detector Package Bug Fix Release 8.0.2 released on 18.09.2024
|
SLS Detector Package Major Release 7.x.x released on xx.xx.2023
|
||||||
=================================================================
|
===============================================================
|
||||||
|
|
||||||
This document describes the differences between v8.0.2 and v8.0.1
|
This document describes the differences between v7.x.x and v7.0.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CONTENTS
|
CONTENTS
|
||||||
--------
|
--------
|
||||||
1 Resolved Issues
|
1 New, Changed or Resolved Features
|
||||||
|
1.1 Compilation
|
||||||
|
1.2 Callback
|
||||||
|
1.3 Python
|
||||||
|
1.4 Client
|
||||||
|
1.5 Detector Server
|
||||||
|
1.6 Simulator
|
||||||
|
1.7 Receiver
|
||||||
|
1.8 Gui
|
||||||
2 On-board Detector Server Compatibility
|
2 On-board Detector Server Compatibility
|
||||||
3 Firmware Requirements
|
3 Firmware Requirements
|
||||||
4 Kernel Requirements
|
4 Kernel Requirements
|
||||||
@ -16,108 +24,13 @@ This document describes the differences between v8.0.2 and v8.0.1
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
1 Resolved Issues
|
1 New, Changed or Resolved Features
|
||||||
=================
|
=====================================
|
||||||
|
|
||||||
|
|
||||||
Compilation
|
- moench being made compatible with jungfrau 2.0 boards (jungfrau structure, away from ctb)
|
||||||
-----------
|
- eiger febl and feb in versions
|
||||||
|
- fix ctb slow adcs
|
||||||
|
|
||||||
* Rapidjson compilation with gcc 14
|
|
||||||
Fixed a compile issue with gcc 14. Same fix in later commits to rapidjson.
|
|
||||||
|
|
||||||
|
|
||||||
Client
|
|
||||||
------
|
|
||||||
|
|
||||||
|
|
||||||
* getenv("HOME") returning nullptr
|
|
||||||
When this happens, especially for systemd, it segfaults. Protection
|
|
||||||
provided by using empty string in this case.
|
|
||||||
|
|
||||||
|
|
||||||
* [Mythen3] Bad channel list for multi module
|
|
||||||
Exception thrown when loading multi module bad channel file skipping
|
|
||||||
modules in between. Fixed.
|
|
||||||
|
|
||||||
|
|
||||||
* [Gotthard2] Stopping a blocking acquisition
|
|
||||||
A check added in v8.0.0 to catch slaves that might be in waiting forever
|
|
||||||
also catches Gotthard2 25um slaves that might only be in waiting
|
|
||||||
temporarily. This is fixed with a 50ms sleep before checking again
|
|
||||||
(upto 1s).
|
|
||||||
|
|
||||||
|
|
||||||
* [Moench] Acquire finished processing call back
|
|
||||||
New executable 'sls_detector_acquire_zmq' added to listen to all zmq
|
|
||||||
packets from post processor or external process to signal end of post
|
|
||||||
processing. Post processor refactoring of zmq socket creation added.
|
|
||||||
|
|
||||||
|
|
||||||
Gui / Callback
|
|
||||||
--------------
|
|
||||||
|
|
||||||
|
|
||||||
* [Gotthard2] Stopping a blocking acquisition
|
|
||||||
From the previous issue, call back for acquisition finished status gives
|
|
||||||
error for inconsistent states. Again, a check every 50ms upto 1s is
|
|
||||||
added to let go the temporarily waiting slave.
|
|
||||||
|
|
||||||
|
|
||||||
* Different file paths
|
|
||||||
Fixes file path resetting when different modules have different fpath set.
|
|
||||||
|
|
||||||
|
|
||||||
Receiver
|
|
||||||
--------
|
|
||||||
|
|
||||||
|
|
||||||
* HDF5 fill value
|
|
||||||
Fix the fill value to accomodate all datatypes.
|
|
||||||
|
|
||||||
|
|
||||||
Firmware
|
|
||||||
--------
|
|
||||||
|
|
||||||
|
|
||||||
* [Moench] Overflow with exptime of 0
|
|
||||||
Fixed overflow when subtracting 1 clock cycle from exptime.
|
|
||||||
|
|
||||||
|
|
||||||
On-board Detector Server
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
|
|
||||||
* [Moench] Few changes in Server:
|
|
||||||
- Max shifts of adc clock changed from 240 to 200.
|
|
||||||
|
|
||||||
- Fixed overflow when subtracting 2 clock cycles from exptime of 0ms.
|
|
||||||
|
|
||||||
- Default readout speed to half speed from quarter.
|
|
||||||
|
|
||||||
- Change default ADC phase to 150 for full readout speed.
|
|
||||||
|
|
||||||
- Change default vipre_cds dac from 800 to 1280.
|
|
||||||
|
|
||||||
|
|
||||||
* [Mythen3] Change Clk divider from 10 (100MHz) to 20 (50MHz) at startup.
|
|
||||||
|
|
||||||
|
|
||||||
* [Jungfrau] Fix for HW v1.0 boards for unreliable ADC 2
|
|
||||||
Issues sometimes seen on some HW v 1.0 boards are fixed with phase
|
|
||||||
relationship of 120 degrees. HW v2.0 boards are not affected.
|
|
||||||
|
|
||||||
|
|
||||||
Documentation
|
|
||||||
-------------
|
|
||||||
|
|
||||||
|
|
||||||
* Updated troubleshooting documentaion to check links and disable firewall
|
|
||||||
|
|
||||||
|
|
||||||
* Excluded non UTF-8 encoded libzmq documents due to machine dependent
|
|
||||||
compilation issues.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -125,13 +38,13 @@ This document describes the differences between v8.0.2 and v8.0.1
|
|||||||
==========================================
|
==========================================
|
||||||
|
|
||||||
|
|
||||||
Eiger 8.0.0
|
Eiger 7.0.0
|
||||||
Jungfrau 8.0.2
|
Jungfrau 7.0.2
|
||||||
Mythen3 8.0.2
|
Mythen3 7.0.0
|
||||||
Gotthard2 8.0.0
|
Gotthard2 7.0.0
|
||||||
Gotthard 8.0.0
|
Gotthard 7.0.0
|
||||||
Moench 8.0.2
|
Moench 7.0.0
|
||||||
Ctb 8.0.0
|
Ctb 7.0.0
|
||||||
|
|
||||||
|
|
||||||
On-board Detector Server Upgrade
|
On-board Detector Server Upgrade
|
||||||
@ -139,6 +52,8 @@ This document describes the differences between v8.0.2 and v8.0.1
|
|||||||
|
|
||||||
From v6.1.0 (without tftp):
|
From v6.1.0 (without tftp):
|
||||||
Using command 'updatedetectorserver'
|
Using command 'updatedetectorserver'
|
||||||
|
From 5.0.0 (with tftp):
|
||||||
|
Using command 'copydetectorserver'
|
||||||
|
|
||||||
Instructions available at
|
Instructions available at
|
||||||
https://slsdetectorgroup.github.io/devdoc/serverupgrade.html
|
https://slsdetectorgroup.github.io/devdoc/serverupgrade.html
|
||||||
@ -150,22 +65,21 @@ This document describes the differences between v8.0.2 and v8.0.1
|
|||||||
========================
|
========================
|
||||||
|
|
||||||
|
|
||||||
Eiger 02.10.2023 (v32) (updated in 7.0.3)
|
Eiger 20.02.2023 (v31)
|
||||||
|
|
||||||
Jungfrau 20.09.2023 (v1.5, HW v1.0) (updated in 8.0.0)
|
Jungfrau 04.11.2022 (v1.4, HW v1.0)
|
||||||
21.09.2023 (v2.5, HW v2.0) (updated in 8.0.0)
|
03.11.2022 (v2.4, HW v2.0)
|
||||||
|
|
||||||
Mythen3 24.01.2023 (v1.4) (updated in 7.0.0)
|
Mythen3 24.01.2023 (v1.4)
|
||||||
|
|
||||||
Gotthard2 23.11.2022 (v0.3) (updated in 7.0.0)
|
Gotthard2 23.11.2022 (v0.3)
|
||||||
|
|
||||||
Gotthard 08.02.2018 (50um and 25um Master)
|
Gotthard 08.02.2018 (50um and 25um Master)
|
||||||
09.02.2018 (25 um Slave)
|
09.02.2018 (25 um Slave)
|
||||||
|
|
||||||
Moench 26.10.2023 (v0.3.2) (updated in 8.0.2,
|
Moench 05.12.2022 (v0.3)
|
||||||
under development)
|
|
||||||
|
|
||||||
Ctb 28.08.2023 (v1.2) (updated in 8.0.0)
|
Ctb 03.04.2023 (v1.2?)
|
||||||
|
|
||||||
|
|
||||||
Detector Upgrade
|
Detector Upgrade
|
||||||
@ -184,10 +98,10 @@ This document describes the differences between v8.0.2 and v8.0.1
|
|||||||
|
|
||||||
Except Eiger,
|
Except Eiger,
|
||||||
upgrade
|
upgrade
|
||||||
using command 'programfpga' or
|
Using command 'programfpga' or
|
||||||
|
|
||||||
udpate both server and firmware simultaneously
|
udpate both server and firmware simultaneously
|
||||||
using command 'update'
|
Using command 'update'
|
||||||
|
|
||||||
|
|
||||||
Instructions available at
|
Instructions available at
|
||||||
|
1
bash_autocomplete.sh
Symbolic link
1
bash_autocomplete.sh
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
|
@ -890,7 +890,7 @@ EXCLUDE_SYMLINKS = NO
|
|||||||
# Note that the wildcards are matched against the file with absolute path, so to
|
# Note that the wildcards are matched against the file with absolute path, so to
|
||||||
# exclude all test directories for example use the pattern */test/*
|
# exclude all test directories for example use the pattern */test/*
|
||||||
|
|
||||||
EXCLUDE_PATTERNS = */docs/* */tests/* */python/* */manual */slsDetectorServers/* */libs/* */integrationTests *README* */slsDetectorGui/* */ctbGui/* */slsDetectorCalibration/* *TobiSchluter*
|
EXCLUDE_PATTERNS = */docs/* */tests/* */python/* */manual */slsDetectorServers/* */libs/* */integrationTests *README* */slsDetectorGui/* */ctbGui/* */slsDetectorCalibration/*
|
||||||
|
|
||||||
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
|
||||||
# (namespaces, classes, functions, etc.) that should be excluded from the
|
# (namespaces, classes, functions, etc.) that should be excluded from the
|
||||||
|
@ -22,8 +22,6 @@ Common
|
|||||||
* Check transeiver and fibers are compatible (all MMF 850nm or all SMF 1030nm)
|
* Check transeiver and fibers are compatible (all MMF 850nm or all SMF 1030nm)
|
||||||
* Check fiber
|
* Check fiber
|
||||||
* Check fiber polarity (if short range, unplug the link anywhere, and look at the light/dark pattern: dark has to mate with light)
|
* Check fiber polarity (if short range, unplug the link anywhere, and look at the light/dark pattern: dark has to mate with light)
|
||||||
* For Jungfrau, check if the blue sfp light is blinking rapidly (even when it is not sending data). If so, most likely the link is down and something is wrong with the board. If it connected to a switch, then you do not see it with the ethtool command if link is down. One option is to connect it directly to a pc to see if link is down.
|
|
||||||
* With nc, try "nc -u -p 50001 -l" in receiving pc, and from another pc try "echo hallo | nc -u 10.1.2.172 50001" to send something to the recieving pc interface to see if the link is up and see if the other nc console receives the hallo.
|
|
||||||
|
|
||||||
#. Detector is not acquiring (Not Eiger)
|
#. Detector is not acquiring (Not Eiger)
|
||||||
* Take an acquisition with many images and using the following steps instead of acquire:
|
* Take an acquisition with many images and using the following steps instead of acquire:
|
||||||
@ -49,20 +47,11 @@ Common
|
|||||||
* Ensure that the interfaces (on NIC and the switch) used in receiver pc have MTU 9000 (jumbo frames) enabled.
|
* Ensure that the interfaces (on NIC and the switch) used in receiver pc have MTU 9000 (jumbo frames) enabled.
|
||||||
|
|
||||||
|
|
||||||
#. Check if 'rx packets' counter in 'ifconfig' do not increment for interface.
|
#. Check if 'rx_frames' counter in 'ifconfig' do not increment for interface.
|
||||||
* If no, check switch configuration if present. Port counters of switch can also help to identify problem.
|
* If no, check switch configuration if present. Port counters of switch can also help to identify problem.
|
||||||
* If yes, but receiver software does not see it:
|
* If yes, but receiver software does not see it:
|
||||||
|
|
||||||
* Check no firewall (eg. firewalld) is present or add rules
|
* Check no firewall (eg. firewalld) is present or add rules
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
# Stop and disable firewall
|
|
||||||
service firewalld stop
|
|
||||||
systemctl disable firewalld
|
|
||||||
# Check status
|
|
||||||
service firewalld status
|
|
||||||
|
|
||||||
* Check that selinux is disabled ( or add rules)
|
* Check that selinux is disabled ( or add rules)
|
||||||
|
|
||||||
#. Source UDP IP in config file (Not Eiger)
|
#. Source UDP IP in config file (Not Eiger)
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
numfiles 1
|
|
||||||
nthreads 5,
|
|
||||||
fifosize 5000
|
|
||||||
nsigma 5
|
|
||||||
gainfile none
|
|
||||||
detectorMode counting
|
|
||||||
threshold 0
|
|
||||||
pedestalfile none
|
|
||||||
nframes 0
|
|
||||||
xMin 0
|
|
||||||
xMax 400
|
|
||||||
yMin 0
|
|
||||||
yMax 400
|
|
||||||
outdir ./
|
|
||||||
indir ./
|
|
||||||
flist none
|
|
||||||
fformat none
|
|
||||||
runmin 0
|
|
||||||
runmax -1
|
|
||||||
readnrows 400
|
|
||||||
eMin 0
|
|
||||||
eMax 16000
|
|
@ -1,16 +0,0 @@
|
|||||||
numinterfaces 1
|
|
||||||
rx_zmqip 10.1.2.102
|
|
||||||
rx_zmqport 1978
|
|
||||||
zmqip 129.129.202.57
|
|
||||||
zmqport 1979
|
|
||||||
nthreads 6
|
|
||||||
fifosize 5000
|
|
||||||
nsigma 5
|
|
||||||
gainfile none
|
|
||||||
nbinsx 5
|
|
||||||
nbinsy 5
|
|
||||||
etafile none
|
|
||||||
etabinsx 1000
|
|
||||||
etabinsy 1000
|
|
||||||
etamin -1
|
|
||||||
etamax 2
|
|
@ -316,8 +316,7 @@ struct GenericStringRef {
|
|||||||
|
|
||||||
GenericStringRef(const GenericStringRef& rhs) : s(rhs.s), length(rhs.length) {}
|
GenericStringRef(const GenericStringRef& rhs) : s(rhs.s), length(rhs.length) {}
|
||||||
|
|
||||||
// Removed to fix failing build in GCC 14
|
GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
|
||||||
// GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }
|
|
||||||
|
|
||||||
//! implicit conversion to plain CharType pointer
|
//! implicit conversion to plain CharType pointer
|
||||||
operator const Ch *() const { return s; }
|
operator const Ch *() const { return s; }
|
||||||
|
1
serverBin/ctbDetectorServer_developer
Symbolic link
1
serverBin/ctbDetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServerv8.0.0
|
|
1
serverBin/eigerDetectorServer_developer
Symbolic link
1
serverBin/eigerDetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServerv8.0.0
|
|
1
serverBin/gotthard2DetectorServer_developer
Symbolic link
1
serverBin/gotthard2DetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServerv8.0.0
|
|
1
serverBin/gotthardDetectorServer_developer
Symbolic link
1
serverBin/gotthardDetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServerv8.0.0
|
|
1
serverBin/jungfrauDetectorServer_developer
Symbolic link
1
serverBin/jungfrauDetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServerv8.0.2
|
|
1
serverBin/moenchDetectorServer_developer
Symbolic link
1
serverBin/moenchDetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServerv8.0.2
|
|
1
serverBin/mythen3DetectorServer_developer
Symbolic link
1
serverBin/mythen3DetectorServer_developer
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer
|
@ -1 +0,0 @@
|
|||||||
../slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServerv8.0.2
|
|
@ -1,240 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#ifndef MOENCH03v2DATA_H
|
|
||||||
#define MOENCH03v2DATA_H
|
|
||||||
//#define MYROOT
|
|
||||||
|
|
||||||
#ifndef MYROOT
|
|
||||||
#include "sls/sls_detector_defs.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MYROOT
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t frameNumber;
|
|
||||||
uint32_t expLength;
|
|
||||||
uint32_t packetNumber;
|
|
||||||
uint64_t bunchId;
|
|
||||||
uint64_t timestamp;
|
|
||||||
uint16_t modId;
|
|
||||||
uint16_t row;
|
|
||||||
uint16_t column;
|
|
||||||
uint16_t reserved;
|
|
||||||
uint32_t debug;
|
|
||||||
uint16_t roundRNumber;
|
|
||||||
uint8_t detType;
|
|
||||||
uint8_t version;
|
|
||||||
} sls_detector_header;
|
|
||||||
#define MAX_NUM_PACKETS 512
|
|
||||||
// using sls_bitset = std::bitset<MAX_NUM_PACKETS>;
|
|
||||||
// using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8];
|
|
||||||
struct sls_receiver_header {
|
|
||||||
sls_detector_header detHeader; /**< is the detector header */
|
|
||||||
uint8_t packetsMask[64]; /**< is the packets caught bit mask */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "slsDetectorData.h"
|
|
||||||
#ifdef RAWDATA
|
|
||||||
#define DATA_OFFSET sizeof(header)
|
|
||||||
#endif
|
|
||||||
#ifndef RAWDATA
|
|
||||||
#define DATA_OFFSET 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class moench03v2Data : public slsDetectorData<uint16_t> {
|
|
||||||
|
|
||||||
private:
|
|
||||||
int iframe;
|
|
||||||
const int nRows;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double ghost[200][25];
|
|
||||||
|
|
||||||
// Single point of definition if we need to customize
|
|
||||||
#ifndef MYROOT
|
|
||||||
using header = sls::defs::sls_receiver_header;
|
|
||||||
#endif
|
|
||||||
#ifdef MYROOT
|
|
||||||
sls_receiver_header header;
|
|
||||||
#endif
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
Implements the slsReceiverData structure for the moench02 prototype read
|
|
||||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
|
||||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
|
||||||
|
|
||||||
*/
|
|
||||||
moench03v2Data(int nrows = 200)
|
|
||||||
: slsDetectorData<uint16_t>(400, nrows*2,2* 400*nrows*2 + DATA_OFFSET),
|
|
||||||
nRows(nrows) {
|
|
||||||
|
|
||||||
std::cout << "MOENCH width new firmware " << dataSize << std::endl;
|
|
||||||
|
|
||||||
int off=DATA_OFFSET;
|
|
||||||
for (int ix = 0; ix < 400; ix++) {
|
|
||||||
for (int iy = 0; iy < nRows*2; iy++) {
|
|
||||||
dataMap[iy][ix]=off+2*(iy*400+ix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iframe = 0;
|
|
||||||
// cout << "data struct created" << endl;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the value of the selected channel for the given dataset as
|
|
||||||
double. \param data pointer to the dataset (including headers etc) \param
|
|
||||||
ix pixel number in the x direction \param iy pixel number in the y
|
|
||||||
direction \returns data for the selected channel, with inversion if
|
|
||||||
required as double
|
|
||||||
|
|
||||||
*/
|
|
||||||
double getValue(char *data, int ix, int iy = 0) override {
|
|
||||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
|
||||||
return val;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void calcGhost(char *data, int ix, int iy) {
|
|
||||||
double val = 0;
|
|
||||||
/* for (int ix=0; ix<25; ix++){ */
|
|
||||||
/* for (int iy=0; iy<200; iy++) { */
|
|
||||||
val = 0;
|
|
||||||
// cout << "** ";
|
|
||||||
for (int isc = 0; isc < 16; isc++) {
|
|
||||||
// for (int ii=0; ii<2; ii++) {
|
|
||||||
val += getChannel(data, ix + 25 * isc, iy);
|
|
||||||
// cout << "(" << isc << "," << val << " " ;
|
|
||||||
val += getChannel(data, ix + 25 * isc, 399 - iy);
|
|
||||||
// cout << val << " " ;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
ghost[iy][ix] = val; //-6224;
|
|
||||||
// cout << " --"<< endl;
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
// cout << "*" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void calcGhost(char *data) {
|
|
||||||
for (int ix = 0; ix < 25; ix++) {
|
|
||||||
for (int iy = 0; iy < 200; iy++) {
|
|
||||||
calcGhost(data, ix, iy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// cout << "*" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
double getGhost(int ix, int iy) {
|
|
||||||
if (iy < 200)
|
|
||||||
return ghost[iy][ix % 25];
|
|
||||||
if (iy < 400)
|
|
||||||
return ghost[399 - iy][ix % 25];
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Returns the frame number for the given dataset. Purely virtual func.
|
|
||||||
\param buff pointer to the dataset
|
|
||||||
\returns frame number
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
int getFrameNumber(char *buff) {
|
|
||||||
#ifdef RAWDATA
|
|
||||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.frameNumber;
|
|
||||||
#endif
|
|
||||||
#ifndef RAWDATA
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Returns the packet number for the given dataset. purely virtual func
|
|
||||||
\param buff pointer to the dataset
|
|
||||||
\returns packet number number
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
int getPacketNumber(char *buff) {
|
|
||||||
#ifdef RAWDATA
|
|
||||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.packetNumber;
|
|
||||||
#endif
|
|
||||||
#ifndef RAWDATA
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
char *readNextFrame(std::ifstream &filebin) override {
|
|
||||||
int ff = -1, np = -1;
|
|
||||||
return readNextFrame(filebin, ff, np);
|
|
||||||
}
|
|
||||||
|
|
||||||
// not present in base class
|
|
||||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
|
|
||||||
int np = -1;
|
|
||||||
return readNextFrame(filebin, ff, np);
|
|
||||||
};
|
|
||||||
|
|
||||||
// not present in base class
|
|
||||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
|
||||||
char *data = new char[dataSize];
|
|
||||||
char *d = readNextFrame(filebin, ff, np, data);
|
|
||||||
if (d == NULL) {
|
|
||||||
delete[] data;
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// not present in base class
|
|
||||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
|
||||||
char *data) {
|
|
||||||
np = 0;
|
|
||||||
if (filebin.is_open()) {
|
|
||||||
if (filebin.read(data, dataSize)) {
|
|
||||||
ff = getFrameNumber(data);
|
|
||||||
np = getPacketNumber(data);
|
|
||||||
// std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Loops over a memory slot until a complete frame is found (i.e. all
|
|
||||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
|
||||||
data pointer to the memory to be analyzed \param ndata reference to the
|
|
||||||
amount of data found for the frame, in case the frame is incomplete at
|
|
||||||
the end of the memory slot \param dsize size of the memory slot to be
|
|
||||||
analyzed \returns pointer to the beginning of the last good frame (might
|
|
||||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
|
||||||
found
|
|
||||||
|
|
||||||
*/
|
|
||||||
char *findNextFrame(char *data, int &ndata, int dsize) override {
|
|
||||||
if (dsize < dataSize)
|
|
||||||
ndata = dsize;
|
|
||||||
else
|
|
||||||
ndata = dataSize;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,240 +0,0 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
#ifndef MOENCH03v2DATA_H
|
|
||||||
#define MOENCH03v2DATA_H
|
|
||||||
//#define MYROOT
|
|
||||||
|
|
||||||
#ifndef MYROOT
|
|
||||||
#include "sls/sls_detector_defs.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MYROOT
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint64_t frameNumber;
|
|
||||||
uint32_t expLength;
|
|
||||||
uint32_t packetNumber;
|
|
||||||
uint64_t bunchId;
|
|
||||||
uint64_t timestamp;
|
|
||||||
uint16_t modId;
|
|
||||||
uint16_t row;
|
|
||||||
uint16_t column;
|
|
||||||
uint16_t reserved;
|
|
||||||
uint32_t debug;
|
|
||||||
uint16_t roundRNumber;
|
|
||||||
uint8_t detType;
|
|
||||||
uint8_t version;
|
|
||||||
} sls_detector_header;
|
|
||||||
#define MAX_NUM_PACKETS 512
|
|
||||||
// using sls_bitset = std::bitset<MAX_NUM_PACKETS>;
|
|
||||||
// using bitset_storage = uint8_t[MAX_NUM_PACKETS / 8];
|
|
||||||
struct sls_receiver_header {
|
|
||||||
sls_detector_header detHeader; /**< is the detector header */
|
|
||||||
uint8_t packetsMask[64]; /**< is the packets caught bit mask */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "slsDetectorData.h"
|
|
||||||
#ifdef RAWDATA
|
|
||||||
#define DATA_OFFSET sizeof(header)
|
|
||||||
#endif
|
|
||||||
#ifndef RAWDATA
|
|
||||||
#define DATA_OFFSET 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
class moench03v2Data : public slsDetectorData<uint16_t> {
|
|
||||||
|
|
||||||
private:
|
|
||||||
int iframe;
|
|
||||||
const int nRows;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double ghost[200][25];
|
|
||||||
|
|
||||||
// Single point of definition if we need to customize
|
|
||||||
#ifndef MYROOT
|
|
||||||
using header = sls::defs::sls_receiver_header;
|
|
||||||
#endif
|
|
||||||
#ifdef MYROOT
|
|
||||||
sls_receiver_header header;
|
|
||||||
#endif
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
Implements the slsReceiverData structure for the moench02 prototype read
|
|
||||||
out by a module i.e. using the slsReceiver (160x160 pixels, 40 packets
|
|
||||||
1286 large etc.) \param c crosstalk parameter for the output buffer
|
|
||||||
|
|
||||||
*/
|
|
||||||
moench03v2Data(int nrows = 200)
|
|
||||||
: slsDetectorData<uint16_t>(400, nrows*2,2* 400*nrows*2 + DATA_OFFSET),
|
|
||||||
nRows(nrows) {
|
|
||||||
|
|
||||||
std::cout << "MOENCH width new firmware " << dataSize << std::endl;
|
|
||||||
|
|
||||||
int off=DATA_OFFSET;
|
|
||||||
for (int ix = 0; ix < 400; ix++) {
|
|
||||||
for (int iy = 0; iy < nRows*2; iy++) {
|
|
||||||
dataMap[iy][ix]=off+2*(iy*400+ix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
iframe = 0;
|
|
||||||
// cout << "data struct created" << endl;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the value of the selected channel for the given dataset as
|
|
||||||
double. \param data pointer to the dataset (including headers etc) \param
|
|
||||||
ix pixel number in the x direction \param iy pixel number in the y
|
|
||||||
direction \returns data for the selected channel, with inversion if
|
|
||||||
required as double
|
|
||||||
|
|
||||||
*/
|
|
||||||
double getValue(char *data, int ix, int iy = 0) override {
|
|
||||||
uint16_t val = getChannel(data, ix, iy) & 0x3fff;
|
|
||||||
return val;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual void calcGhost(char *data, int ix, int iy) {
|
|
||||||
double val = 0;
|
|
||||||
/* for (int ix=0; ix<25; ix++){ */
|
|
||||||
/* for (int iy=0; iy<200; iy++) { */
|
|
||||||
val = 0;
|
|
||||||
// cout << "** ";
|
|
||||||
for (int isc = 0; isc < 16; isc++) {
|
|
||||||
// for (int ii=0; ii<2; ii++) {
|
|
||||||
val += getChannel(data, ix + 25 * isc, iy);
|
|
||||||
// cout << "(" << isc << "," << val << " " ;
|
|
||||||
val += getChannel(data, ix + 25 * isc, 399 - iy);
|
|
||||||
// cout << val << " " ;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
ghost[iy][ix] = val; //-6224;
|
|
||||||
// cout << " --"<< endl;
|
|
||||||
/* } */
|
|
||||||
/* } */
|
|
||||||
// cout << "*" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void calcGhost(char *data) {
|
|
||||||
for (int ix = 0; ix < 25; ix++) {
|
|
||||||
for (int iy = 0; iy < 200; iy++) {
|
|
||||||
calcGhost(data, ix, iy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// cout << "*" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
double getGhost(int ix, int iy) {
|
|
||||||
if (iy < 200)
|
|
||||||
return ghost[iy][ix % 25];
|
|
||||||
if (iy < 400)
|
|
||||||
return ghost[399 - iy][ix % 25];
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Returns the frame number for the given dataset. Purely virtual func.
|
|
||||||
\param buff pointer to the dataset
|
|
||||||
\returns frame number
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
int getFrameNumber(char *buff) {
|
|
||||||
#ifdef RAWDATA
|
|
||||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.frameNumber;
|
|
||||||
#endif
|
|
||||||
#ifndef RAWDATA
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Returns the packet number for the given dataset. purely virtual func
|
|
||||||
\param buff pointer to the dataset
|
|
||||||
\returns packet number number
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
int getPacketNumber(char *buff) {
|
|
||||||
#ifdef RAWDATA
|
|
||||||
return ((sls::defs::sls_receiver_header *)buff)->detHeader.packetNumber;
|
|
||||||
#endif
|
|
||||||
#ifndef RAWDATA
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
char *readNextFrame(std::ifstream &filebin) override {
|
|
||||||
int ff = -1, np = -1;
|
|
||||||
return readNextFrame(filebin, ff, np);
|
|
||||||
}
|
|
||||||
|
|
||||||
// not present in base class
|
|
||||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff) {
|
|
||||||
int np = -1;
|
|
||||||
return readNextFrame(filebin, ff, np);
|
|
||||||
};
|
|
||||||
|
|
||||||
// not present in base class
|
|
||||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np) {
|
|
||||||
char *data = new char[dataSize];
|
|
||||||
char *d = readNextFrame(filebin, ff, np, data);
|
|
||||||
if (d == NULL) {
|
|
||||||
delete[] data;
|
|
||||||
data = NULL;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// not present in base class
|
|
||||||
virtual char *readNextFrame(std::ifstream &filebin, int &ff, int &np,
|
|
||||||
char *data) {
|
|
||||||
np = 0;
|
|
||||||
if (filebin.is_open()) {
|
|
||||||
if (filebin.read(data, dataSize)) {
|
|
||||||
ff = getFrameNumber(data);
|
|
||||||
np = getPacketNumber(data);
|
|
||||||
std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::cout << "**" << ff << " " << dataSize << " " << ff << " " << np << std::endl;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
Loops over a memory slot until a complete frame is found (i.e. all
|
|
||||||
packets 0 to nPackets, same frame number). purely virtual func \param
|
|
||||||
data pointer to the memory to be analyzed \param ndata reference to the
|
|
||||||
amount of data found for the frame, in case the frame is incomplete at
|
|
||||||
the end of the memory slot \param dsize size of the memory slot to be
|
|
||||||
analyzed \returns pointer to the beginning of the last good frame (might
|
|
||||||
be incomplete if ndata smaller than dataSize), or NULL if no frame is
|
|
||||||
found
|
|
||||||
|
|
||||||
*/
|
|
||||||
char *findNextFrame(char *data, int &ndata, int dsize) override {
|
|
||||||
if (dsize < dataSize)
|
|
||||||
ndata = dsize;
|
|
||||||
else
|
|
||||||
ndata = dataSize;
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
// int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -33,7 +33,7 @@ int main(int argc, char *argv[]) {
|
|||||||
#ifndef FF
|
#ifndef FF
|
||||||
if (argc < 9) {
|
if (argc < 9) {
|
||||||
cout << "Wrong usage! Should be: " << argv[0]
|
cout << "Wrong usage! Should be: " << argv[0]
|
||||||
<< " infile etafile outfile runmin runmax ns [cmin cmax xmin xmax ymin ymax]" << endl;
|
<< " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -41,7 +41,7 @@ int main(int argc, char *argv[]) {
|
|||||||
#ifdef FF
|
#ifdef FF
|
||||||
if (argc < 7) {
|
if (argc < 7) {
|
||||||
cout << "Wrong usage! Should be: " << argv[0]
|
cout << "Wrong usage! Should be: " << argv[0]
|
||||||
<< " infile etafile runmin runmax [cmin cmax xmin xmax ymin ymax]" << endl;
|
<< " infile etafile runmin runmax cmin cmax" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -65,30 +65,13 @@ int main(int argc, char *argv[]) {
|
|||||||
nsubpix = atoi(argv[iarg++]);
|
nsubpix = atoi(argv[iarg++]);
|
||||||
cout << "Subpix: " << nsubpix << endl;
|
cout << "Subpix: " << nsubpix << endl;
|
||||||
#endif
|
#endif
|
||||||
|
float cmin = atof(argv[iarg++]);
|
||||||
float cmin = 0;
|
float cmax = atof(argv[iarg++]);
|
||||||
float cmax=1000000;
|
|
||||||
if (argc>iarg)
|
|
||||||
cmin=atof(argv[iarg++]);
|
|
||||||
if (argc>iarg)
|
|
||||||
cmax= atof(argv[iarg++]);
|
|
||||||
cout << "Energy min: " << cmin << endl;
|
cout << "Energy min: " << cmin << endl;
|
||||||
cout << "Energy max: " << cmax << endl;
|
cout << "Energy max: " << cmax << endl;
|
||||||
int xmin=0, xmax=NC, ymin=0, ymax=NR;
|
|
||||||
|
|
||||||
if (argc>iarg)
|
|
||||||
xmin=atof(argv[iarg++]);
|
|
||||||
if (argc>iarg)
|
|
||||||
xmax= atof(argv[iarg++]);
|
|
||||||
|
|
||||||
if (argc>iarg)
|
|
||||||
ymin=atof(argv[iarg++]);
|
|
||||||
if (argc>iarg)
|
|
||||||
ymax= atof(argv[iarg++]);
|
|
||||||
|
|
||||||
// int etabins=500;
|
// int etabins=500;
|
||||||
int etabins = 1000; // nsubpix*2*100;
|
int etabins = 1000; // nsubpix*2*100;
|
||||||
double etamin = -0.25, etamax = 1.25;
|
double etamin = -1, etamax = 2;
|
||||||
// double etamin=-0.1, etamax=1.1;
|
// double etamin=-0.1, etamax=1.1;
|
||||||
// double eta3min = -2, eta3max = 2;
|
// double eta3min = -2, eta3max = 2;
|
||||||
double sum, totquad;
|
double sum, totquad;
|
||||||
@ -97,7 +80,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
// double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||||
|
|
||||||
int ix, iy, isx, isy;
|
int ix, iy, isx, isy;
|
||||||
int nframes = 0, lastframe = -1, iframe, nphFrame;
|
int nframes = 0, lastframe = -1;
|
||||||
//double d_x, d_y, res = 5, xx, yy;
|
//double d_x, d_y, res = 5, xx, yy;
|
||||||
int nph = 0, totph = 0;
|
int nph = 0, totph = 0;
|
||||||
//badph = 0,
|
//badph = 0,
|
||||||
@ -115,7 +98,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// int nSubPixels = nsubpix;
|
// int nSubPixels = nsubpix;
|
||||||
#ifndef NOINTERPOLATION
|
#ifndef NOINTERPOLATION
|
||||||
eta2InterpolationPosXY *interp =
|
eta2InterpolationPosXY *interp =
|
||||||
new eta2InterpolationPosXY(NC, NR, nsubpix, nsubpix, etabins, etabins, etamin, etamax);
|
new eta2InterpolationPosXY(NC, NR, nsubpix, nsubpix,etabins,etabins, etamin, etamax);
|
||||||
// eta2InterpolationCleverAdaptiveBins *interp=new
|
// eta2InterpolationCleverAdaptiveBins *interp=new
|
||||||
// eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin,
|
// eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin,
|
||||||
// etamax);
|
// etamax);
|
||||||
@ -124,8 +107,8 @@ int main(int argc, char *argv[]) {
|
|||||||
noInterpolation *interp = new noInterpolation(NC, NR, nsubpix);
|
noInterpolation *interp = new noInterpolation(NC, NR, nsubpix);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int quad;
|
|
||||||
#ifndef FF
|
#ifndef FF
|
||||||
|
int quad;
|
||||||
#ifndef NOINTERPOLATION
|
#ifndef NOINTERPOLATION
|
||||||
char fname[10000];
|
char fname[10000];
|
||||||
int ok;
|
int ok;
|
||||||
@ -159,26 +142,19 @@ int main(int argc, char *argv[]) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int irun;
|
int irun;
|
||||||
for (irun = runmin; irun <= runmax; irun++) {
|
for (irun = runmin; irun < runmax; irun++) {
|
||||||
sprintf(infname, argv[1], irun);
|
sprintf(infname, argv[1], irun);
|
||||||
#ifndef FF
|
#ifndef FF
|
||||||
sprintf(outfname, argv[3], irun);
|
sprintf(outfname, argv[3], irun);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
f = fopen(infname, "r");
|
f = fopen(infname, "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
cout << infname << endl;
|
cout << infname << endl;
|
||||||
nframes = 0;
|
nframes = 0;
|
||||||
//f0 = -1;
|
//f0 = -1;
|
||||||
|
|
||||||
//iff=0;
|
while (cl.read(f)) {
|
||||||
while (fread((void*)&iframe, 1, sizeof(int), f)) {
|
|
||||||
//n=0;
|
|
||||||
if (fread((void*)&nphFrame, 1, sizeof(int), f)) {
|
|
||||||
for (int iph=0; iph<nphFrame; iph++) {
|
|
||||||
//while (cl.read(f)) {
|
|
||||||
if (cl.read(f)) {
|
|
||||||
totph++;
|
totph++;
|
||||||
if (lastframe != cl.iframe) {
|
if (lastframe != cl.iframe) {
|
||||||
lastframe = cl.iframe;
|
lastframe = cl.iframe;
|
||||||
@ -189,28 +165,18 @@ int main(int argc, char *argv[]) {
|
|||||||
nframes++;
|
nframes++;
|
||||||
}
|
}
|
||||||
// quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
// quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||||
// #ifndef FF
|
#ifndef FF
|
||||||
// quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
|
||||||
// totquad, sDum);
|
|
||||||
// #endif
|
|
||||||
// #ifdef FF
|
|
||||||
|
|
||||||
quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
quad = interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||||
totquad, sDum);
|
totquad, sDum);
|
||||||
|
#endif
|
||||||
|
#ifdef FF
|
||||||
/* cl.print();
|
interp->calcEta(cl.get_cluster(), etax, etay, sum,
|
||||||
cout << "(" << etax <<","<< etay <<")"<< quad<< endl;
|
totquad, sDum);
|
||||||
*/
|
#endif
|
||||||
//#endif
|
|
||||||
|
|
||||||
if (totquad > cmin && cl.x >= xmin && cl.x <= xmax &&
|
if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
|
||||||
cl.y >= ymin && cl.y <= ymax &&
|
sum < cmax) {
|
||||||
totquad < cmax) {
|
nph++;
|
||||||
|
|
||||||
// if (sum > cmin && totquad / sum > 0.8 && totquad / sum < 1.2 &&
|
|
||||||
// sum < cmax) {
|
|
||||||
nph++;
|
|
||||||
// if (sum>200 && sum<580) {
|
// if (sum>200 && sum<580) {
|
||||||
// interp->getInterpolatedPosition(cl.x,cl.y,
|
// interp->getInterpolatedPosition(cl.x,cl.y,
|
||||||
// totquad,quad,cl.get_cluster(),int_x, int_y);
|
// totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||||
@ -261,12 +227,9 @@ int main(int argc, char *argv[]) {
|
|||||||
#ifdef FF
|
#ifdef FF
|
||||||
interp->writeFlatField(outfname);
|
interp->writeFlatField(outfname);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
#ifdef FF
|
#ifdef FF
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifndef MOENCH04
|
#ifndef MOENCH04
|
||||||
#ifndef RECT
|
#ifndef RECT
|
||||||
#include "moench03v2Data.h"
|
#include "moench03T1ReceiverDataNew.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -41,147 +41,34 @@ using namespace std;
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
std::map<std::string, std::string> args = {
|
if (argc < 4) {
|
||||||
{"numfiles","1"},
|
|
||||||
{"nthreads","5"},
|
|
||||||
{"fifosize","5000"},
|
|
||||||
{"nsigma","5"},
|
|
||||||
{"gainfile","none"},
|
|
||||||
{"detectorMode","counting"},
|
|
||||||
{"threshold","0"},
|
|
||||||
{"pedestalfile","none"},
|
|
||||||
{"nframes","0"},
|
|
||||||
{"xMin","0"},
|
|
||||||
{"xMax","400"},
|
|
||||||
{"yMin","0"},
|
|
||||||
{"yMax","400"},
|
|
||||||
{"eMin","0"},
|
|
||||||
{"eMax","16000"},
|
|
||||||
{"outdir","./"},
|
|
||||||
{"indir","./"},
|
|
||||||
{"flist","none"},
|
|
||||||
{"fformat","none"},
|
|
||||||
{"runmin","0"},
|
|
||||||
{"runmax","-1"},
|
|
||||||
{"readnrows","400"}
|
|
||||||
};
|
|
||||||
//float *gm;
|
|
||||||
|
|
||||||
int ff, np;
|
|
||||||
// cout << " data size is " << dsize;
|
|
||||||
|
|
||||||
ifstream filebin;
|
|
||||||
if (argc < 4) {
|
|
||||||
std::string name, value,sline;
|
|
||||||
int ic=0;
|
|
||||||
ifstream flist;
|
|
||||||
flist.open (argv[1], std::ifstream::in);
|
|
||||||
if (flist.is_open()) {
|
|
||||||
cout << "Using config file " <<argv[1] << endl;
|
|
||||||
while (std::getline(flist,sline)){
|
|
||||||
if (sline.at(0)!='#') {
|
|
||||||
ic=sline.find(' ');
|
|
||||||
name = sline.substr(0,ic);
|
|
||||||
value = sline.substr(ic+1,sline.size()-ic);
|
|
||||||
args[name]=value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
flist.close();
|
|
||||||
} else {
|
|
||||||
cout << "Usage is " << argv[0]
|
cout << "Usage is " << argv[0]
|
||||||
<< "indir outdir fname(no extension) [runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
|
<< "indir outdir fname(no extension) [runmin] [runmax] [pedfile (raw or tiff)] [threshold] "
|
||||||
"[nframes] [xmin xmax ymin ymax] [gainmap]"
|
"[nframes] [xmin xmax ymin ymax] [gainmap]"
|
||||||
<< endl;
|
<< endl;
|
||||||
cout << "threshold <0 means analog; threshold=0 means cluster finder; "
|
cout << "threshold <0 means analog; threshold=0 means cluster finder; "
|
||||||
"threshold>0 means photon counting"
|
"threshold>0 means photon counting"
|
||||||
<< endl;
|
<< endl;
|
||||||
cout << "nframes <0 means sum everything; nframes=0 means one file per "
|
cout << "nframes <0 means sum everything; nframes=0 means one file per "
|
||||||
"run; nframes>0 means one file every nframes"
|
"run; nframes>0 means one file every nframes"
|
||||||
<< endl;
|
<< endl;
|
||||||
return EXIT_FAILURE;
|
return 1;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
args["indir"]=argv[1];
|
|
||||||
args["outdir"]=argv[1];
|
|
||||||
args["fformat"]=argv[3];
|
|
||||||
if (argc >= 5) {
|
|
||||||
args["runmin"] = argv[4];
|
|
||||||
}
|
|
||||||
args["runmax"] = args["runmin"];
|
|
||||||
|
|
||||||
if (argc >= 6) {
|
|
||||||
args["runmax"] = argv[5];
|
|
||||||
}
|
|
||||||
if (argc >= 7) {
|
|
||||||
args["pedestalfile"] = argv[6];
|
|
||||||
}
|
|
||||||
if (argc >= 8) {
|
|
||||||
args["threshold"] = argv[7];
|
|
||||||
}
|
|
||||||
if (argc >= 9) {
|
|
||||||
args["nframes"] = argv[8];
|
|
||||||
}
|
|
||||||
if (argc >= 13) {
|
|
||||||
args["xMin"] = argv[9];
|
|
||||||
args["xMax"] = argv[10];
|
|
||||||
args["yMin"] = argv[11];
|
|
||||||
args["yMax"] = argv[12];
|
|
||||||
}
|
|
||||||
if (argc > 13) {
|
|
||||||
args["gainfile"] = argv[13];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atof(args["threshold"].c_str())<0) {
|
|
||||||
args["detectorMode"]="analog";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fifosize = 1000;
|
||||||
|
int nthreads = 10;
|
||||||
for (auto const& x : args)
|
|
||||||
{
|
|
||||||
std::cout << x.first // string (key)
|
|
||||||
<< ':'
|
|
||||||
<< x.second // string's value
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
string indir=args["indir"];
|
|
||||||
string outdir = args["outdir"];
|
|
||||||
string fformat= args["fformat"];
|
|
||||||
int runmin = atoi(args["runmin"].c_str());
|
|
||||||
int runmax = atoi(args["runmin"].c_str());
|
|
||||||
string pedfile =args["pedestalfile"];
|
|
||||||
double thr = atof(args["threshold"].c_str());
|
|
||||||
double thr1 = 1;
|
|
||||||
|
|
||||||
int nframes = atoi(args["nframes"].c_str());
|
|
||||||
|
|
||||||
int xmin = atoi(args["xMin"].c_str()), xmax = atoi(args["xMax"].c_str()), ymin = atoi(args["yMin"].c_str()), ymax = atoi(args["yMax"].c_str());
|
|
||||||
|
|
||||||
string gainfname=args["gainfile"];
|
|
||||||
|
|
||||||
int fifosize = atoi(args["fifosize"].c_str());
|
|
||||||
int nthreads = atoi(args["nthreads"].c_str());
|
|
||||||
int nsigma = atoi(args["nsigma"].c_str());
|
|
||||||
int nrows = atoi(args["readnrows"].c_str());
|
|
||||||
float eMin = atof(args["eMin"].c_str());
|
|
||||||
float eMax = atof(args["eMax"].c_str());
|
|
||||||
int csize = 3;
|
int csize = 3;
|
||||||
int nped = 1000;
|
int nsigma = 5;
|
||||||
|
int nped = 10000;
|
||||||
int cf = 0;
|
|
||||||
int numberOfPackets=nrows/8;
|
|
||||||
|
|
||||||
|
int cf = 0;
|
||||||
|
int numberOfPackets=40;
|
||||||
#ifdef RECT
|
#ifdef RECT
|
||||||
cout << "Should be rectangular but now it will crash! No data structure defined!" << endl;
|
cout << "Should be rectangular but now it will crash! No data structure defined!" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MOENCH04
|
#ifndef MOENCH04
|
||||||
moench03v2Data *decoder = new moench03v2Data(100);
|
moench03T1ReceiverDataNew *decoder = new moench03T1ReceiverDataNew();
|
||||||
cout << "MOENCH03!" << endl;
|
cout << "MOENCH03!" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -190,7 +77,7 @@ int main(int argc, char *argv[]) {
|
|||||||
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(5000,0);
|
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(5000,0);
|
||||||
cout << "MOENCH04!" << endl;
|
cout << "MOENCH04!" << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MOENCH04_DGS
|
#ifdef MOENCH04_DGS
|
||||||
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(5000,5000);
|
moench04CtbZmq10GbData *decoder = new moench04CtbZmq10GbData(5000,5000);
|
||||||
cout << "MOENCH04 DGS!" << endl;
|
cout << "MOENCH04 DGS!" << endl;
|
||||||
@ -199,11 +86,63 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//Read detector size from decoder
|
||||||
int nx , ny;
|
int nx , ny;
|
||||||
decoder->getDetectorSize(nx, ny);
|
decoder->getDetectorSize(nx, ny);
|
||||||
|
|
||||||
//Read detector size from decoder
|
//float *gm;
|
||||||
|
|
||||||
|
int ff, np;
|
||||||
|
// cout << " data size is " << dsize;
|
||||||
|
|
||||||
|
ifstream filebin;
|
||||||
|
char *indir = argv[1];
|
||||||
|
char *outdir = argv[2];
|
||||||
|
char *fformat = argv[3];
|
||||||
|
int runmin = 0;
|
||||||
|
|
||||||
|
// cout << "argc is " << argc << endl;
|
||||||
|
if (argc >= 5) {
|
||||||
|
runmin = atoi(argv[4]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int runmax = runmin;
|
||||||
|
|
||||||
|
if (argc >= 6) {
|
||||||
|
runmax = atoi(argv[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *pedfile = NULL;
|
||||||
|
if (argc >= 7) {
|
||||||
|
pedfile = argv[6];
|
||||||
|
}
|
||||||
|
double thr = 0;
|
||||||
|
double thr1 = 1;
|
||||||
|
|
||||||
|
if (argc >= 8) {
|
||||||
|
thr = atof(argv[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int nframes = 0;
|
||||||
|
|
||||||
|
if (argc >= 9) {
|
||||||
|
nframes = atoi(argv[8]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int xmin = 0, xmax = nx, ymin = 0, ymax = ny;
|
||||||
|
if (argc >= 13) {
|
||||||
|
xmin = atoi(argv[9]);
|
||||||
|
xmax = atoi(argv[10]);
|
||||||
|
ymin = atoi(argv[11]);
|
||||||
|
ymax = atoi(argv[12]);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *gainfname = NULL;
|
||||||
|
if (argc > 13) {
|
||||||
|
gainfname = argv[13];
|
||||||
|
cout << "Gain map file name is: " << gainfname << endl;
|
||||||
|
}
|
||||||
|
|
||||||
char ffname[10000];
|
char ffname[10000];
|
||||||
char fname[10000];
|
char fname[10000];
|
||||||
char imgfname[10000];
|
char imgfname[10000];
|
||||||
@ -212,6 +151,17 @@ int main(int argc, char *argv[]) {
|
|||||||
std::time_t end_time;
|
std::time_t end_time;
|
||||||
|
|
||||||
FILE *of = NULL;
|
FILE *of = NULL;
|
||||||
|
cout << "input directory is " << indir << endl;
|
||||||
|
cout << "output directory is " << outdir << endl;
|
||||||
|
cout << "input file is " << fformat << endl;
|
||||||
|
cout << "runmin is " << runmin << endl;
|
||||||
|
cout << "runmax is " << runmax << endl;
|
||||||
|
if (pedfile)
|
||||||
|
cout << "pedestal file is " << pedfile << endl;
|
||||||
|
if (thr > 0)
|
||||||
|
cout << "threshold is " << thr << endl;
|
||||||
|
cout << "Nframes is " << nframes << endl;
|
||||||
|
|
||||||
uint32_t nnx, nny;
|
uint32_t nnx, nny;
|
||||||
|
|
||||||
|
|
||||||
@ -232,62 +182,50 @@ int main(int argc, char *argv[]) {
|
|||||||
singlePhotonDetector *filter = new singlePhotonDetector(
|
singlePhotonDetector *filter = new singlePhotonDetector(
|
||||||
decoder, csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
|
decoder, csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
|
||||||
|
|
||||||
//if (gainfname) {
|
if (gainfname) {
|
||||||
|
|
||||||
if (filter->readGainMap(gainfname.c_str()))
|
if (filter->readGainMap(gainfname))
|
||||||
cout << "using gain map " << gainfname << endl;
|
cout << "using gain map " << gainfname << endl;
|
||||||
else
|
else
|
||||||
cout << "Could not open gain map " << gainfname << endl;
|
cout << "Could not open gain map " << gainfname << endl;
|
||||||
// } else
|
} else
|
||||||
thr = 0.15 * thr;
|
thr = 0.15 * thr;
|
||||||
filter->newDataSet();
|
filter->newDataSet();
|
||||||
//int dsize = decoder->getDataSize();
|
//int dsize = decoder->getDataSize();
|
||||||
|
|
||||||
if (thr > 0) {
|
if (thr > 0) {
|
||||||
cout << "threshold is " << thr << endl;
|
cout << "threshold is " << thr << endl;
|
||||||
filter->setThreshold(thr);
|
filter->setThreshold(thr);
|
||||||
cf = 0;
|
cf = 0;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
cf = 1;
|
cf = 1;
|
||||||
|
|
||||||
filter->setROI(xmin, xmax, ymin, ymax);
|
filter->setROI(xmin, xmax, ymin, ymax);
|
||||||
filter->setEnergyRange(eMin, eMax);
|
|
||||||
std::time(&end_time);
|
std::time(&end_time);
|
||||||
cout << std::ctime(&end_time) << endl;
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
char *buff;
|
char *buff;
|
||||||
|
|
||||||
// multiThreadedAnalogDetector *mt=new
|
// multiThreadedAnalogDetector *mt=new
|
||||||
// multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
// multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
multiThreadedCountingDetector *mt =
|
multiThreadedCountingDetector *mt =
|
||||||
new multiThreadedCountingDetector(filter, nthreads, fifosize);
|
new multiThreadedCountingDetector(filter, nthreads, fifosize);
|
||||||
|
#ifndef ANALOG
|
||||||
if (args["detectorMode"]=="counting") {
|
mt->setDetectorMode(ePhotonCounting);
|
||||||
mt->setDetectorMode(ePhotonCounting);
|
cout << "Counting!" << endl;
|
||||||
if (thr > 0) {
|
if (thr > 0) {
|
||||||
cf = 0;
|
cf = 0;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mt->setDetectorMode(eAnalog);
|
|
||||||
cf = 0;
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
//{
|
||||||
// #ifndef ANALOG
|
#ifdef ANALOG
|
||||||
// mt->setDetectorMode(ePhotonCounting);
|
mt->setDetectorMode(eAnalog);
|
||||||
// cout << "Counting!" << endl;
|
cout << "Analog!" << endl;
|
||||||
// if (thr > 0) {
|
cf = 0;
|
||||||
// cf = 0;
|
// thr1=thr;
|
||||||
// }
|
#endif
|
||||||
// #endif
|
// }
|
||||||
// //{
|
|
||||||
// #ifdef ANALOG
|
|
||||||
// mt->setDetectorMode(eAnalog);
|
|
||||||
// cout << "Analog!" << endl;
|
|
||||||
// cf = 0;
|
|
||||||
// // thr1=thr;
|
|
||||||
// #endif
|
|
||||||
// // }
|
|
||||||
|
|
||||||
mt->StartThreads();
|
mt->StartThreads();
|
||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
@ -298,117 +236,84 @@ int main(int argc, char *argv[]) {
|
|||||||
char froot[1000];
|
char froot[1000];
|
||||||
double *ped=new double[nx * ny];//, *ped1;
|
double *ped=new double[nx * ny];//, *ped1;
|
||||||
int pos,pos1;
|
int pos,pos1;
|
||||||
//return 0;
|
|
||||||
if (pedfile.find(".raw") != std::string::npos) {
|
|
||||||
pos1=pedfile.rfind("/");
|
|
||||||
strcpy(froot,pedfile.substr(pos1).c_str());
|
|
||||||
pos=string(froot).find(".raw");
|
|
||||||
froot[pos]='\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "PEDESTAL " << endl;
|
if (pedfile) {
|
||||||
if (pedfile.find(".tif") == std::string::npos) {
|
if (string(pedfile).find(".raw") != std::string::npos) {
|
||||||
sprintf(fname, "%s", pedfile.c_str());
|
pos1=string(pedfile).rfind("/");
|
||||||
|
strcpy(froot,pedfile+pos1);
|
||||||
|
pos=string(froot).find(".raw");
|
||||||
|
froot[pos]='\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << "PEDESTAL " << endl;
|
||||||
|
if (string(pedfile).find(".tif") == std::string::npos) {
|
||||||
|
sprintf(fname, "%s", pedfile);
|
||||||
cout << fname << endl;
|
cout << fname << endl;
|
||||||
std::time(&end_time);
|
std::time(&end_time);
|
||||||
//cout << "aaa" << std::ctime(&end_time) << endl;
|
//cout << "aaa" << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
mt->setFrameMode(ePedestal);
|
mt->setFrameMode(ePedestal);
|
||||||
// sprintf(fn,fformat,irun);
|
// sprintf(fn,fformat,irun);
|
||||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||||
// //open file
|
// //open file
|
||||||
if (filebin.is_open()) {
|
if (filebin.is_open()) {
|
||||||
ff = -1;
|
ff = -1;
|
||||||
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
||||||
if (np == numberOfPackets) {
|
if (np == numberOfPackets) {
|
||||||
mt->pushData(buff);
|
mt->pushData(buff);
|
||||||
mt->nextThread();
|
mt->nextThread();
|
||||||
mt->popFree(buff);
|
mt->popFree(buff);
|
||||||
ifr++;
|
ifr++;
|
||||||
if (ifr % 100 == 0)
|
if (ifr % 100 == 0)
|
||||||
cout << ifr << " " << ff << " " << np << endl;
|
cout << ifr << " " << ff << " " << np << endl;
|
||||||
// break;
|
} else
|
||||||
} else {
|
cout << ifr << " " << ff << " " << np << endl;
|
||||||
cout << ifr << " " << ff << " " << np << endl;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ff = -1;
|
ff = -1;
|
||||||
}
|
}
|
||||||
filebin.close();
|
filebin.close();
|
||||||
while (mt->isBusy()) {
|
while (mt->isBusy()) {
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(imgfname, "%s/%s_ped.tiff", outdir.c_str(),froot);
|
sprintf(imgfname, "%s/%s_ped.tiff", outdir,froot);
|
||||||
mt->writePedestal(imgfname);
|
mt->writePedestal(imgfname);
|
||||||
sprintf(imgfname, "%s/%s_var.tiff", outdir.c_str(),froot);
|
sprintf(imgfname, "%s/%s_var.tiff", outdir,froot);
|
||||||
mt->writePedestalRMS(imgfname);
|
mt->writePedestalRMS(imgfname);
|
||||||
} else
|
} else
|
||||||
cout << "Could not open pedestal file " << fname
|
cout << "Could not open pedestal file " << fname
|
||||||
<< " for reading " << endl;
|
|
||||||
} else {
|
|
||||||
float *pp = ReadFromTiff(pedfile.c_str(), nny, nnx);
|
|
||||||
if (pp && (int)nnx == nx && (int)nny == ny) {
|
|
||||||
for (int i = 0; i < nx * ny; i++) {
|
|
||||||
ped[i] = pp[i];
|
|
||||||
}
|
|
||||||
delete[] pp;
|
|
||||||
mt->setPedestal(ped);
|
|
||||||
cout << "Pedestal set from tiff file " << pedfile << endl;
|
|
||||||
} else {
|
|
||||||
cout << "Could not open pedestal tiff file " << pedfile
|
|
||||||
<< " for reading " << endl;
|
<< " for reading " << endl;
|
||||||
}
|
} else {
|
||||||
|
float *pp = ReadFromTiff(pedfile, nny, nnx);
|
||||||
|
if (pp && (int)nnx == nx && (int)nny == ny) {
|
||||||
|
for (int i = 0; i < nx * ny; i++) {
|
||||||
|
ped[i] = pp[i];
|
||||||
|
}
|
||||||
|
delete[] pp;
|
||||||
|
mt->setPedestal(ped);
|
||||||
|
cout << "Pedestal set from tiff file " << pedfile << endl;
|
||||||
|
} else {
|
||||||
|
cout << "Could not open pedestal tiff file " << pedfile
|
||||||
|
<< " for reading " << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
}
|
}
|
||||||
std::time(&end_time);
|
|
||||||
cout << std::ctime(&end_time) << endl;
|
|
||||||
|
|
||||||
|
|
||||||
ifr = 0;
|
ifr = 0;
|
||||||
int ifile = 0;
|
int ifile = 0;
|
||||||
|
|
||||||
mt->setFrameMode(eFrame);
|
mt->setFrameMode(eFrame);
|
||||||
//t filelist=0;
|
|
||||||
ifstream flist;
|
|
||||||
flist.open (args["flist"].c_str(), std::ifstream::in);
|
|
||||||
if (flist.is_open()) {
|
|
||||||
cout << "Using file list" << endl;
|
|
||||||
runmin=0;
|
|
||||||
runmax=0;
|
|
||||||
while (flist.getline(ffname,10000)){
|
|
||||||
cout << ffname << endl;
|
|
||||||
runmax++;
|
|
||||||
}
|
|
||||||
runmax--;
|
|
||||||
flist.close();
|
|
||||||
cout << "Found " << runmax << " files " << endl;
|
|
||||||
flist.open (fformat, std::ifstream::in);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int irun = runmin; irun <= runmax; irun++) {
|
for (int irun = runmin; irun <= runmax; irun++) {
|
||||||
cout << "DATA ";
|
cout << "DATA ";
|
||||||
// sprintf(fn,fformat,irun);
|
// sprintf(fn,fformat,irun);
|
||||||
// sprintf(ffname, "%s/%s.raw", indir, fformat);
|
sprintf(ffname, "%s/%s.raw", indir, fformat);
|
||||||
// sprintf(fname, (const char*)ffname, irun);
|
sprintf(fname, (const char*)ffname, irun);
|
||||||
// sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||||
// sprintf(imgfname, (const char*)ffname, irun);
|
sprintf(imgfname, (const char*)ffname, irun);
|
||||||
// sprintf(ffname, "%s/%s.clust", outdir, fformat);
|
sprintf(ffname, "%s/%s.clust", outdir, fformat);
|
||||||
// sprintf(cfname, (const char*)ffname, irun);
|
sprintf(cfname, (const char*)ffname, irun);
|
||||||
if (flist.is_open()) {
|
|
||||||
flist.getline(ffname,10000);
|
|
||||||
cout << "file list " << ffname << endl;
|
|
||||||
} else {
|
|
||||||
//sprintf(ffname,(const char*)fformat,irun);
|
|
||||||
sprintf(ffname,args["fformat"].c_str(),irun);
|
|
||||||
cout << "loop " << ffname << endl;
|
|
||||||
}
|
|
||||||
cout << "ffname "<< ffname << endl;
|
|
||||||
sprintf(fname, "%s/%s.raw",indir.c_str(),ffname);
|
|
||||||
sprintf(imgfname, "%s/%s.tiff",outdir.c_str(),ffname);
|
|
||||||
sprintf(cfname, "%s/%s.clust",outdir.c_str(),ffname);
|
|
||||||
|
|
||||||
|
|
||||||
cout << fname << " ";
|
cout << fname << " ";
|
||||||
cout << imgfname << endl;
|
cout << imgfname << endl;
|
||||||
std::time(&end_time);
|
std::time(&end_time);
|
||||||
@ -418,7 +323,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// //open file
|
// //open file
|
||||||
ifile = 0;
|
ifile = 0;
|
||||||
if (filebin.is_open()) {
|
if (filebin.is_open()) {
|
||||||
if (cf != 0) { // cluster finder
|
if (thr <= 0 && cf != 0) { // cluster finder
|
||||||
if (of == NULL) {
|
if (of == NULL) {
|
||||||
of = fopen(cfname, "w");
|
of = fopen(cfname, "w");
|
||||||
if (of) {
|
if (of) {
|
||||||
@ -436,7 +341,7 @@ int main(int argc, char *argv[]) {
|
|||||||
ff = -1;
|
ff = -1;
|
||||||
ifr = 0;
|
ifr = 0;
|
||||||
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
while (decoder->readNextFrame(filebin, ff, np, buff)) {
|
||||||
if (np == numberOfPackets) {
|
if (np == numberOfPackets) {
|
||||||
// //push
|
// //push
|
||||||
mt->pushData(buff);
|
mt->pushData(buff);
|
||||||
// // //pop
|
// // //pop
|
||||||
@ -445,26 +350,21 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
ifr++;
|
ifr++;
|
||||||
if (ifr % 100 == 0)
|
if (ifr % 100 == 0)
|
||||||
cout << ifr << " " << ff << " " << np << endl;
|
cout << ifr << " " << ff << endl;
|
||||||
//break;
|
|
||||||
if (nframes > 0) {
|
if (nframes > 0) {
|
||||||
if (ifr % nframes == 0) {
|
if (ifr % nframes == 0) {
|
||||||
// sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
|
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat,
|
||||||
// ifile);
|
ifile);
|
||||||
// sprintf(imgfname, (const char*)ffname, irun);
|
sprintf(imgfname, (const char*)ffname, irun);
|
||||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir.c_str(),ffname,ifile);
|
|
||||||
while (mt->isBusy())
|
|
||||||
;
|
|
||||||
|
|
||||||
mt->writeImage(imgfname, thr1);
|
mt->writeImage(imgfname, thr1);
|
||||||
mt->clearImage();
|
mt->clearImage();
|
||||||
ifile++;
|
ifile++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cout << "bp " << ifr << " " << ff << " " << np << endl;
|
cout << "bp " << ifr << " " << ff << " " << np << endl;
|
||||||
//break;
|
//break;
|
||||||
}
|
}
|
||||||
ff = -1;
|
ff = -1;
|
||||||
}
|
}
|
||||||
cout << "--" << endl;
|
cout << "--" << endl;
|
||||||
@ -474,17 +374,13 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
if (nframes >= 0) {
|
if (nframes >= 0) {
|
||||||
if (nframes > 0) {
|
if (nframes > 0) {
|
||||||
sprintf(imgfname, "%s/%s_f%05d.tiff",outdir.c_str(),ffname,ifile);
|
sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
|
||||||
// sprintf(ffname, "%s/%s_f%05d.tiff", outdir, fformat, ifile);
|
sprintf(imgfname, (const char*)ffname, irun);
|
||||||
//sprintf(imgfname, (const char*)ffname, irun);
|
|
||||||
} else {
|
} else {
|
||||||
sprintf(imgfname, "%s/%s.tiff",outdir.c_str(),ffname);
|
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||||
// sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
sprintf(imgfname, (const char*)ffname, irun);
|
||||||
// sprintf(imgfname, (const char*)ffname, irun);
|
|
||||||
}
|
}
|
||||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||||
while (mt->isBusy())
|
|
||||||
;
|
|
||||||
mt->writeImage(imgfname, thr1);
|
mt->writeImage(imgfname, thr1);
|
||||||
mt->clearImage();
|
mt->clearImage();
|
||||||
if (of) {
|
if (of) {
|
||||||
@ -499,16 +395,11 @@ int main(int argc, char *argv[]) {
|
|||||||
cout << "Could not open " << fname << " for reading " << endl;
|
cout << "Could not open " << fname << " for reading " << endl;
|
||||||
}
|
}
|
||||||
if (nframes < 0) {
|
if (nframes < 0) {
|
||||||
//sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
sprintf(ffname, "%s/%s.tiff", outdir, fformat);
|
||||||
// strcpy(imgfname, ffname);
|
strcpy(imgfname, ffname);
|
||||||
sprintf(imgfname, "%s/%s_tot.tiff",outdir.c_str(),ffname);
|
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||||
cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
mt->writeImage(imgfname, thr1);
|
||||||
while (mt->isBusy())
|
|
||||||
;
|
|
||||||
mt->writeImage(imgfname, thr1);
|
|
||||||
}
|
|
||||||
if (flist.is_open()) {
|
|
||||||
flist.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,7 @@
|
|||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/sls_detector_defs.h"
|
||||||
#ifndef MOENCH04
|
#ifndef MOENCH04
|
||||||
//#ifndef RECT
|
//#ifndef RECT
|
||||||
#include "moench03v2Data.h"
|
#include "moench03T1ZmqDataNew.h"
|
||||||
//#include "moench03T1ZmqDataNew.h"
|
|
||||||
//#endif
|
//#endif
|
||||||
//#ifdef RECT
|
//#ifdef RECT
|
||||||
//#include "moench03T1ZmqDataNewRect.h"
|
//#include "moench03T1ZmqDataNewRect.h"
|
||||||
@ -32,7 +31,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
|
||||||
|
|
||||||
#include <rapidjson/document.h> //json header in zmq stream
|
#include <rapidjson/document.h> //json header in zmq stream
|
||||||
|
|
||||||
@ -65,48 +63,36 @@ int main(int argc, char *argv[]) {
|
|||||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port
|
* trial.o [socket ip] [starting port number] [send_socket ip] [send port
|
||||||
* number]
|
* number]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
std::map<std::string, std::string> args = {
|
FILE *of = NULL;
|
||||||
{"numinterfaces","1"},
|
int fifosize = 5000;
|
||||||
{"rx_zmqip","10.1.2.102"},
|
|
||||||
{"rx_zmqport","7770"},
|
|
||||||
{"zmqip","129.129.202.153"},
|
|
||||||
{"zmqport","7780"},
|
|
||||||
{"nthreads","5"},
|
|
||||||
{"fifosize","5000"},
|
|
||||||
{"nsigma","5"},
|
|
||||||
{"gainfile","none"},
|
|
||||||
{"nbinsx","5"},
|
|
||||||
{"nbinsy","5"},
|
|
||||||
{"etafile","none"},
|
|
||||||
{"etabinsx","1000"},
|
|
||||||
{"etamin","-1"},
|
|
||||||
{"etamax","2"} };
|
|
||||||
FILE *of = NULL;
|
|
||||||
int etabins = 1000, etabinsy = 1000; // nsubpix*2*100;
|
int etabins = 1000, etabinsy = 1000; // nsubpix*2*100;
|
||||||
double etamin = -1, etamax = 2;
|
double etamin = -1, etamax = 2;
|
||||||
int nSubPixelsX = 2;
|
int nSubPixelsX = 2;
|
||||||
int emin, emax;
|
int emin, emax;
|
||||||
int nSubPixelsY = 2;
|
int nSubPixelsY = 2;
|
||||||
int nthreads = 5;
|
|
||||||
int fifosize = 5000;
|
|
||||||
uint32_t nSigma = 5;
|
|
||||||
|
|
||||||
string etafname;// = NULL;
|
// help
|
||||||
string gainfname;// = NULL;
|
if (argc < 3) {
|
||||||
|
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port "
|
||||||
|
"number] [send_socket ip] [send starting port number] "
|
||||||
|
"[nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// receive parameters
|
// receive parameters
|
||||||
bool send = false;
|
bool send = false;
|
||||||
|
char *socketip = argv[1];
|
||||||
|
uint32_t portnum = atoi(argv[2]);
|
||||||
// send parameters if any
|
// send parameters if any
|
||||||
string socketip2;// = 0;
|
char *socketip2 = 0;
|
||||||
uint32_t portnum2 = 0;
|
uint32_t portnum2 = 0;
|
||||||
string socketip;// = 0;
|
|
||||||
uint32_t portnum = 0;
|
|
||||||
|
|
||||||
sls::zmqHeader zHeader, outHeader;
|
sls::zmqHeader zHeader, outHeader;
|
||||||
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||||
outHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
outHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
|
||||||
|
|
||||||
|
uint32_t nSigma = 5;
|
||||||
|
|
||||||
int ok;
|
int ok;
|
||||||
|
|
||||||
@ -116,85 +102,48 @@ int main(int argc, char *argv[]) {
|
|||||||
// time_t begin,end,finished;
|
// time_t begin,end,finished;
|
||||||
int rms = 0;
|
int rms = 0;
|
||||||
|
|
||||||
send = true;
|
if (argc > 4) {
|
||||||
// help
|
socketip2 = argv[3];
|
||||||
if (argc < 5) {
|
portnum2 = atoi(argv[4]);
|
||||||
std::string name, value,sline;
|
if (portnum2 > 0)
|
||||||
int ic=0;
|
send = true;
|
||||||
ifstream flist;
|
}
|
||||||
flist.open (argv[1], std::ifstream::in);
|
cout << "\nrx socket ip : " << socketip << "\nrx port num : " << portnum;
|
||||||
if (flist.is_open()) {
|
if (send) {
|
||||||
cout << "Using config file " <<argv[1] << endl;
|
cout << "\ntx socket ip : " << socketip2
|
||||||
while (std::getline(flist,sline)){
|
<< "\ntx port num : " << portnum2;
|
||||||
if (sline.at(0)!='#') {
|
}
|
||||||
ic=sline.find(' ');
|
int nthreads = 5;
|
||||||
name = sline.substr(0,ic);
|
if (argc > 5)
|
||||||
value = sline.substr(ic+1,sline.size()-ic);
|
nthreads = atoi(argv[5]);
|
||||||
args[name]=value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
cout << "Number of threads is: " << nthreads << endl;
|
||||||
flist.close();
|
if (argc > 6) {
|
||||||
} else {
|
nSubPixelsX = atoi(argv[6]);
|
||||||
cprintf(RED, "Arguments are either: \n [config file] \n or the following list (deprecated): [receive socket ip] [receive starting port "
|
nSubPixelsY = nSubPixelsX;
|
||||||
"number] [send_socket ip] [send starting port number] "
|
#ifdef RECT
|
||||||
"[nthreads] [nsubpix] [gainmap] [etafile]\n");
|
nSubPixelsX = 2;
|
||||||
return EXIT_FAILURE;
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY
|
||||||
args["rx_zmqip"]=argv[1];
|
<< endl;
|
||||||
args["rx_zmqport"]=argv[2];
|
|
||||||
|
|
||||||
args["zmqip"]=argv[3];
|
|
||||||
args["zmqport"]=argv[4];
|
|
||||||
if (argc > 5)
|
|
||||||
args["nthreads"] = argv[5];
|
|
||||||
if (argc > 6) {
|
|
||||||
args["nbinsx"]=argv[6];
|
|
||||||
args["nbinsy"]=argv[6];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc > 7) {
|
|
||||||
args["gainfile"]=argv[7];
|
|
||||||
}
|
|
||||||
if (argc > 8) {
|
|
||||||
args["etafilefile"]=argv[8];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
char *gainfname = NULL;
|
||||||
|
if (argc > 7) {
|
||||||
|
gainfname = argv[7];
|
||||||
|
cout << "Gain map file name is: " << gainfname << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& x : args)
|
char *etafname = NULL;
|
||||||
{
|
if (argc > 8) {
|
||||||
std::cout << x.first // string (key)
|
etafname = argv[8];
|
||||||
<< ':'
|
cout << "Eta file name is: " << etafname << endl;
|
||||||
<< x.second // string's value
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
socketip = args["rx_zmqip"];
|
|
||||||
portnum = atoi(args["rx_zmqport"].c_str());
|
|
||||||
|
|
||||||
socketip2 = args["zmqip"];
|
|
||||||
portnum2 = atoi(args["zmqport"].c_str());
|
|
||||||
|
|
||||||
nthreads = atoi(args["nthreads"].c_str());
|
|
||||||
nSubPixelsX =atoi(args["nbinsx"].c_str());
|
|
||||||
nSubPixelsY =atoi(args["nbinsy"].c_str());
|
|
||||||
gainfname = args["gainfile"];
|
|
||||||
etafname = args["etafilefile"];
|
|
||||||
|
|
||||||
if (atoi(args["numinterfaces"].c_str())>1){
|
|
||||||
cprintf(RED, "Sorry, at the moment only a single interface is supported instead of %d\n",atoi(args["numinterfaces"].c_str()));
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// slsDetectorData *det=new moench03T1ZmqDataNew();
|
// slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||||
#ifndef MOENCH04
|
#ifndef MOENCH04
|
||||||
cout << "This is a Moench03 v2" << endl;
|
cout << "This is a Moench03" << endl;
|
||||||
//moench03T1ZmqDataNew *det = new moench03T1ZmqDataNew();
|
moench03T1ZmqDataNew *det = new moench03T1ZmqDataNew();
|
||||||
moench03v2Data *det = new moench03v2Data();
|
|
||||||
cout << "MOENCH03!" << endl;
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef MOENCH04
|
#ifdef MOENCH04
|
||||||
cout << "This is a Moench04" << endl;
|
cout << "This is a Moench04" << endl;
|
||||||
@ -228,8 +177,8 @@ int main(int argc, char *argv[]) {
|
|||||||
double *gmap = NULL;
|
double *gmap = NULL;
|
||||||
|
|
||||||
uint32_t nnnx, nnny;
|
uint32_t nnnx, nnny;
|
||||||
//if (gainfname) {
|
if (gainfname) {
|
||||||
gm = ReadFromTiff(gainfname.c_str(), nnny, nnnx);
|
gm = ReadFromTiff(gainfname, nnny, nnnx);
|
||||||
if (gm && nnnx == (uint)npx && nnny == (uint)npy) {
|
if (gm && nnnx == (uint)npx && nnny == (uint)npy) {
|
||||||
gmap = new double[npx * npy];
|
gmap = new double[npx * npy];
|
||||||
for (int i = 0; i < npx * npy; i++) {
|
for (int i = 0; i < npx * npy; i++) {
|
||||||
@ -238,7 +187,7 @@ int main(int argc, char *argv[]) {
|
|||||||
delete[] gm;
|
delete[] gm;
|
||||||
} else
|
} else
|
||||||
cout << "Could not open gain map " << gainfname << endl;
|
cout << "Could not open gain map " << gainfname << endl;
|
||||||
//}
|
}
|
||||||
|
|
||||||
// analogDetector<uint16_t> *filter=new
|
// analogDetector<uint16_t> *filter=new
|
||||||
// analogDetector<uint16_t>(det,1,NULL,1000);
|
// analogDetector<uint16_t>(det,1,NULL,1000);
|
||||||
@ -256,8 +205,8 @@ int main(int argc, char *argv[]) {
|
|||||||
eta2InterpolationPosXY *interp = new eta2InterpolationPosXY(
|
eta2InterpolationPosXY *interp = new eta2InterpolationPosXY(
|
||||||
npx, npy, nSubPixelsX, nSubPixelsY, etabins, etabinsy, etamin, etamax);
|
npx, npy, nSubPixelsX, nSubPixelsY, etabins, etabinsy, etamin, etamax);
|
||||||
|
|
||||||
//if (etafname)
|
if (etafname)
|
||||||
interp->readFlatField(etafname.c_str());
|
interp->readFlatField(etafname);
|
||||||
|
|
||||||
interpolatingDetector *filter = new interpolatingDetector(
|
interpolatingDetector *filter = new interpolatingDetector(
|
||||||
det, interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
det, interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||||
@ -272,44 +221,84 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
sls::ZmqSocket *zmqsocket = NULL;
|
sls::ZmqSocket *zmqsocket = NULL;
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
// receive socket
|
// receive socket
|
||||||
try {
|
try {
|
||||||
zmqsocket = new sls::ZmqSocket(socketip.c_str(), portnum);
|
#endif
|
||||||
|
|
||||||
|
zmqsocket = new sls::ZmqSocket(socketip, portnum);
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
cprintf(RED,
|
cprintf(RED,
|
||||||
"Error: Could not create Zmq receiving socket on port %d with ip %s\n",
|
"Error: Could not create Zmq socket on port %d with ip %s\n",
|
||||||
portnum, socketip.c_str());
|
portnum, socketip);
|
||||||
delete zmqsocket;
|
delete zmqsocket;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
if (zmqsocket->IsError()) {
|
||||||
|
cprintf(RED,
|
||||||
|
"Error: Could not create Zmq socket on port %d with ip %s\n",
|
||||||
|
portnum, socketip);
|
||||||
|
delete zmqsocket;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (zmqsocket->Connect()) {
|
if (zmqsocket->Connect()) {
|
||||||
cprintf(RED, "Error: Could not connect to zmq receiving socket %s\n",
|
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||||
(zmqsocket->GetZmqServerAddress()).c_str());
|
(zmqsocket->GetZmqServerAddress()).c_str());
|
||||||
delete zmqsocket;
|
delete zmqsocket;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
} else
|
} else
|
||||||
|
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress().c_str());
|
||||||
printf("Zmq receiving at %s\n", zmqsocket->GetZmqServerAddress().c_str());
|
|
||||||
|
|
||||||
// send socket
|
// send socket
|
||||||
sls::ZmqSocket *zmqsocket2 = 0;
|
sls::ZmqSocket *zmqsocket2 = 0;
|
||||||
// cout << "zmq2 " << endl;
|
// cout << "zmq2 " << endl;
|
||||||
if (send) {
|
if (send) {
|
||||||
|
#ifdef NEWZMQ
|
||||||
// receive socket
|
// receive socket
|
||||||
try {
|
try {
|
||||||
zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2.c_str());
|
#endif
|
||||||
|
zmqsocket2 = new sls::ZmqSocket(portnum2, socketip2);
|
||||||
|
|
||||||
|
#ifdef NEWZMQ
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
cprintf(RED,
|
cprintf(RED,
|
||||||
"Error: Could not create Zmq sending socket on port %d and "
|
"Error: Could not create Zmq socket server on port %d and "
|
||||||
"ip %s\n",
|
"ip %s\n",
|
||||||
portnum2, socketip2.c_str());
|
portnum2, socketip2);
|
||||||
// delete zmqsocket2;
|
// delete zmqsocket2;
|
||||||
// zmqsocket2=NULL;
|
// zmqsocket2=NULL;
|
||||||
// delete zmqsocket;
|
// delete zmqsocket;
|
||||||
// return EXIT_FAILURE;
|
// return EXIT_FAILURE;
|
||||||
send = false;
|
send = false;
|
||||||
}
|
}
|
||||||
printf("Zmq sending socket at %s\n",
|
#endif
|
||||||
|
|
||||||
|
#ifndef NEWZMQ
|
||||||
|
if (zmqsocket2->IsError()) {
|
||||||
|
cprintf(RED,
|
||||||
|
"AAA Error: Could not create Zmq socket server on port %d "
|
||||||
|
"and ip %s\n",
|
||||||
|
portnum2, socketip2);
|
||||||
|
// delete zmqsocket2;
|
||||||
|
// delete zmqsocket;
|
||||||
|
// return EXIT_FAILURE;
|
||||||
|
send = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (zmqsocket2->Connect()) {
|
||||||
|
cprintf(RED, "BBB Error: Could not connect to socket %s\n",
|
||||||
|
zmqsocket2->GetZmqServerAddress().c_str());
|
||||||
|
// delete zmqsocket2;
|
||||||
|
send = false;
|
||||||
|
// return EXIT_FAILURE;
|
||||||
|
} else
|
||||||
|
printf("Zmq Client at %s\n",
|
||||||
zmqsocket2->GetZmqServerAddress().c_str());
|
zmqsocket2->GetZmqServerAddress().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,25 +722,6 @@ int main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||||
mt->setROI(xmin, xmax, ymin, ymax);
|
mt->setROI(xmin, xmax, ymin, ymax);
|
||||||
|
|
||||||
if (addJsonHeader.find("xMin") != addJsonHeader.end()) {
|
|
||||||
istringstream(addJsonHeader.at("xMin")) >> xmin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addJsonHeader.find("yMin") != addJsonHeader.end()) {
|
|
||||||
istringstream(addJsonHeader.at("yMin")) >> ymin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addJsonHeader.find("xMax") != addJsonHeader.end()) {
|
|
||||||
istringstream(addJsonHeader.at("xMax")) >> xmax;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (addJsonHeader.find("yMax") != addJsonHeader.end()) {
|
|
||||||
istringstream(addJsonHeader.at("yMax")) >> ymax;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {
|
if (addJsonHeader.find("dynamicRange") != addJsonHeader.end()) {
|
||||||
istringstream(addJsonHeader.at("dynamicRange")) >> dr;
|
istringstream(addJsonHeader.at("dynamicRange")) >> dr;
|
||||||
dr = 32;
|
dr = 32;
|
||||||
@ -851,7 +821,7 @@ int main(int argc, char *argv[]) {
|
|||||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << "
|
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << "
|
||||||
// "<< detSpec1 << " " << timestamp << " " << packetNumber << endl;
|
// "<< detSpec1 << " " << timestamp << " " << packetNumber << endl;
|
||||||
// cprintf(GREEN, "frame\n");
|
// cprintf(GREEN, "frame\n");
|
||||||
if (packetNumber <= 50) {
|
if (packetNumber >= 40) {
|
||||||
//*((int*)buff)=frameIndex;
|
//*((int*)buff)=frameIndex;
|
||||||
if (insubframe == 0)
|
if (insubframe == 0)
|
||||||
f0 = frameIndex;
|
f0 = frameIndex;
|
||||||
|
@ -839,8 +839,8 @@ void qTabMeasurement::UpdateProgress() {
|
|||||||
int qTabMeasurement::VerifyOutputDirectoryError() {
|
int qTabMeasurement::VerifyOutputDirectoryError() {
|
||||||
try {
|
try {
|
||||||
auto retval = det->getFilePath();
|
auto retval = det->getFilePath();
|
||||||
for (int i = 0; i < static_cast<int>(retval.size()); ++i) {
|
for (auto &it : retval) {
|
||||||
det->setFilePath(retval[i], {i});
|
det->setFilePath(it);
|
||||||
}
|
}
|
||||||
return slsDetectorDefs::OK;
|
return slsDetectorDefs::OK;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ install(TARGETS slsProjectCSettings
|
|||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
)
|
)
|
||||||
add_subdirectory(ctbDetectorServer)
|
add_subdirectory(ctbDetectorServer)
|
||||||
|
add_subdirectory(xilinx_ctbDetectorServer)
|
||||||
add_subdirectory(eigerDetectorServer)
|
add_subdirectory(eigerDetectorServer)
|
||||||
add_subdirectory(gotthardDetectorServer)
|
add_subdirectory(gotthardDetectorServer)
|
||||||
add_subdirectory(jungfrauDetectorServer)
|
add_subdirectory(jungfrauDetectorServer)
|
||||||
|
BIN
slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer
Executable file
BIN
slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer
Executable file
BIN
slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer
Executable file
Binary file not shown.
Binary file not shown.
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer
Executable file
BIN
slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer
Executable file
Binary file not shown.
Binary file not shown.
@ -90,6 +90,7 @@ void basictests() {
|
|||||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||||
LOG(logERROR, (initErrorMessage));
|
LOG(logERROR, (initErrorMessage));
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
|
BIN
slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
Executable file
BIN
slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
Executable file
Binary file not shown.
Binary file not shown.
@ -88,6 +88,7 @@ void basictests() {
|
|||||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||||
LOG(logERROR, (initErrorMessage));
|
LOG(logERROR, (initErrorMessage));
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
@ -488,7 +489,6 @@ void setupDetector() {
|
|||||||
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK,
|
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK,
|
||||||
ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK,
|
ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK,
|
||||||
ADC_SPI_SRL_DT_OTPT_OFST);
|
ADC_SPI_SRL_DT_OTPT_OFST);
|
||||||
AD9257_Set_Jungfrau_Hardware_Version_1_0(isHardwareVersion_1_0());
|
|
||||||
AD9257_Disable();
|
AD9257_Disable();
|
||||||
AD9257_Configure();
|
AD9257_Configure();
|
||||||
|
|
||||||
|
BIN
slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer
Executable file
BIN
slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer
Executable file
Binary file not shown.
Binary file not shown.
@ -82,6 +82,7 @@ void basictests() {
|
|||||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||||
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
@ -481,6 +482,7 @@ void setupDetector() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setReadoutSpeed(DEFAULT_SPEED);
|
||||||
cleanFifos();
|
cleanFifos();
|
||||||
resetCore();
|
resetCore();
|
||||||
|
|
||||||
@ -494,7 +496,6 @@ void setupDetector() {
|
|||||||
initReadoutConfiguration();
|
initReadoutConfiguration();
|
||||||
|
|
||||||
// Initialization of acquistion parameters
|
// Initialization of acquistion parameters
|
||||||
setReadoutSpeed(DEFAULT_SPEED);
|
|
||||||
setSettings(DEFAULT_SETTINGS);
|
setSettings(DEFAULT_SETTINGS);
|
||||||
setNumFrames(DEFAULT_NUM_FRAMES);
|
setNumFrames(DEFAULT_NUM_FRAMES);
|
||||||
setNumTriggers(DEFAULT_NUM_CYCLES);
|
setNumTriggers(DEFAULT_NUM_CYCLES);
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
#define ASIC_FILTER_MAX_RES_VALUE (1)
|
#define ASIC_FILTER_MAX_RES_VALUE (1)
|
||||||
#define MAX_SELECT_CHIP10_VAL (63)
|
#define MAX_SELECT_CHIP10_VAL (63)
|
||||||
|
|
||||||
#define MAX_PHASE_SHIFTS (200)
|
#define MAX_PHASE_SHIFTS (240)
|
||||||
#define BIT16_MASK (0xFFFF)
|
#define BIT16_MASK (0xFFFF)
|
||||||
|
|
||||||
#define ADC_DECMT_QUARTER_SPEED (0x3)
|
#define ADC_DECMT_QUARTER_SPEED (0x3)
|
||||||
@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
#define ADC_PHASE_DEG_QUARTER_SPEED (0)
|
#define ADC_PHASE_DEG_QUARTER_SPEED (0)
|
||||||
#define ADC_PHASE_DEG_HALF_SPEED (0)
|
#define ADC_PHASE_DEG_HALF_SPEED (0)
|
||||||
#define ADC_PHASE_DEG_FULL_SPEED (150)
|
#define ADC_PHASE_DEG_FULL_SPEED (300)
|
||||||
|
|
||||||
#define ADC_OFST_QUARTER_SPEED (0x12)
|
#define ADC_OFST_QUARTER_SPEED (0x12)
|
||||||
#define ADC_OFST_HALF_SPEED (0x12)
|
#define ADC_OFST_HALF_SPEED (0x12)
|
||||||
@ -133,7 +133,7 @@ enum DACINDEX {
|
|||||||
680, /* MO_VB_SDA */ \
|
680, /* MO_VB_SDA */ \
|
||||||
1428, /* MO_VCASC_SFP */ \
|
1428, /* MO_VCASC_SFP */ \
|
||||||
1200, /* MO_VOUT_CM */ \
|
1200, /* MO_VOUT_CM */ \
|
||||||
1280, /* MO_VIPRE_CDS */ \
|
800, /* MO_VIPRE_CDS */ \
|
||||||
900 /* MO_IBIAS_SFP */ \
|
900 /* MO_IBIAS_SFP */ \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Binary file not shown.
@ -92,6 +92,7 @@ void basictests() {
|
|||||||
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||||
LOG(logERROR, (initErrorMessage));
|
LOG(logERROR, (initErrorMessage));
|
||||||
initError = FAIL;
|
initError = FAIL;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#ifndef VIRTUAL
|
#ifndef VIRTUAL
|
||||||
// does check only if flag is 0 (by default), set by command line
|
// does check only if flag is 0 (by default), set by command line
|
||||||
@ -479,11 +480,6 @@ void setupDetector() {
|
|||||||
READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
|
READOUT_PLL_VCO_FREQ_HZ, SYSTEM_PLL_VCO_FREQ_HZ);
|
||||||
ALTERA_PLL_C10_ResetPLL(READOUT_PLL);
|
ALTERA_PLL_C10_ResetPLL(READOUT_PLL);
|
||||||
ALTERA_PLL_C10_ResetPLL(SYSTEM_PLL);
|
ALTERA_PLL_C10_ResetPLL(SYSTEM_PLL);
|
||||||
// change startup clock divider in software
|
|
||||||
// because firmware only sets max clock divider
|
|
||||||
setClockDividerWithTimeUpdateOption(READOUT_C0, DEFAULT_READOUT_C0_STARTUP,
|
|
||||||
0);
|
|
||||||
|
|
||||||
// hv
|
// hv
|
||||||
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
|
DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME);
|
||||||
// dac
|
// dac
|
||||||
@ -2336,7 +2332,6 @@ int setClockDividerWithTimeUpdateOption(enum CLKINDEX ind, int val,
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if (val < 2 || val > getMaxClockDivider()) {
|
if (val < 2 || val > getMaxClockDivider()) {
|
||||||
LOG(logERROR, ("Invalid clock divider %d\n", val));
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
char *clock_names[] = {CLK_NAMES};
|
char *clock_names[] = {CLK_NAMES};
|
||||||
|
@ -64,8 +64,6 @@
|
|||||||
#define DEFAULT_SYSTEM_C2 (5) //(200000000) // smp_clk, 200 MHz const
|
#define DEFAULT_SYSTEM_C2 (5) //(200000000) // smp_clk, 200 MHz const
|
||||||
#define DEFAULT_TRIMMING_RUN_CLKDIV (40) // (25000000) // 25 MHz
|
#define DEFAULT_TRIMMING_RUN_CLKDIV (40) // (25000000) // 25 MHz
|
||||||
|
|
||||||
#define DEFAULT_READOUT_C0_STARTUP (20) //(50000000) // rdo_clk, 50 MHz
|
|
||||||
|
|
||||||
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
|
#define DEFAULT_ASIC_LATCHING_NUM_PULSES (10)
|
||||||
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
|
#define DEFAULT_MSTR_OTPT_P1_NUM_PULSES (20)
|
||||||
#define DEFAULT_ADIF_PIPELINE_VAL (8)
|
#define DEFAULT_ADIF_PIPELINE_VAL (8)
|
||||||
|
@ -4,10 +4,6 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#ifdef JUNGFRAUD
|
|
||||||
void AD9257_Set_Jungfrau_Hardware_Version_1_0(int val);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Defines
|
* Set Defines
|
||||||
* @param reg spi register
|
* @param reg spi register
|
||||||
|
10
slsDetectorServers/slsDetectorServer/include/arm64.h
Normal file
10
slsDetectorServers/slsDetectorServer/include/arm64.h
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
int mapCSP0(void);
|
||||||
|
void bus_w(u_int32_t offset, u_int32_t data);
|
||||||
|
u_int32_t bus_r(u_int32_t offset);
|
@ -25,6 +25,10 @@
|
|||||||
#include "blackfin.h"
|
#include "blackfin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ARMPROCESSOR
|
||||||
|
#include "arm64.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
#include "mythen3.h"
|
#include "mythen3.h"
|
||||||
#endif
|
#endif
|
||||||
@ -61,9 +65,10 @@ typedef struct udpStruct_s {
|
|||||||
int isInitCheckDone();
|
int isInitCheckDone();
|
||||||
int getInitResult(char **mess);
|
int getInitResult(char **mess);
|
||||||
void basictests();
|
void basictests();
|
||||||
|
int checkType();
|
||||||
|
|
||||||
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
|
#if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \
|
||||||
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||||
int checkType();
|
|
||||||
int testFpga();
|
int testFpga();
|
||||||
int testBus();
|
int testBus();
|
||||||
#endif
|
#endif
|
||||||
@ -81,13 +86,17 @@ u_int64_t getFirmwareVersion();
|
|||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition);
|
uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
u_int64_t getFirmwareAPIVersion();
|
u_int64_t getFirmwareAPIVersion();
|
||||||
void getHardwareVersion(char *version);
|
void getHardwareVersion(char *version);
|
||||||
|
#endif
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
int getHardwareVersionNumber();
|
int getHardwareVersionNumber();
|
||||||
#else
|
#else
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
u_int16_t getHardwareVersionNumber();
|
u_int16_t getHardwareVersionNumber();
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD)
|
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD)
|
||||||
u_int16_t getHardwareSerialNumber();
|
u_int16_t getHardwareSerialNumber();
|
||||||
#endif
|
#endif
|
||||||
@ -111,7 +120,6 @@ int updateModuleId();
|
|||||||
void setModuleId(int modid);
|
void setModuleId(int modid);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u_int64_t getDetectorMAC();
|
u_int64_t getDetectorMAC();
|
||||||
u_int32_t getDetectorIP();
|
u_int32_t getDetectorIP();
|
||||||
|
|
||||||
@ -136,7 +144,7 @@ int updateDatabytesandAllocateRAM();
|
|||||||
void updateDataBytes();
|
void updateDataBytes();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CHIPTESTBOARDD
|
#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD)
|
||||||
int resetToDefaultDacs(int hardReset);
|
int resetToDefaultDacs(int hardReset);
|
||||||
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval);
|
int getDefaultDac(enum DACINDEX index, enum detectorSettings sett, int *retval);
|
||||||
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value);
|
int setDefaultDac(enum DACINDEX index, enum detectorSettings sett, int value);
|
||||||
@ -191,8 +199,10 @@ void setMasterSlaveConfiguration();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// parameters - dr, roi
|
// parameters - dr, roi
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int setDynamicRange(int dr);
|
int setDynamicRange(int dr);
|
||||||
int getDynamicRange(int *retval);
|
int getDynamicRange(int *retval);
|
||||||
|
#endif
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
int setROI(ROI arg);
|
int setROI(ROI arg);
|
||||||
ROI getROI();
|
ROI getROI();
|
||||||
@ -241,6 +251,7 @@ int getMaxStoragecellStart();
|
|||||||
int setNextFrameNumber(uint64_t value);
|
int setNextFrameNumber(uint64_t value);
|
||||||
int getNextFrameNumber(uint64_t *value);
|
int getNextFrameNumber(uint64_t *value);
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
void setNumFrames(int64_t val);
|
void setNumFrames(int64_t val);
|
||||||
int64_t getNumFrames();
|
int64_t getNumFrames();
|
||||||
void setNumTriggers(int64_t val);
|
void setNumTriggers(int64_t val);
|
||||||
@ -251,6 +262,7 @@ int64_t getExpTime();
|
|||||||
#endif
|
#endif
|
||||||
int setPeriod(int64_t val);
|
int setPeriod(int64_t val);
|
||||||
int64_t getPeriod();
|
int64_t getPeriod();
|
||||||
|
#endif
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
void setNumIntGates(int val);
|
void setNumIntGates(int val);
|
||||||
void setNumGates(int val);
|
void setNumGates(int val);
|
||||||
@ -337,10 +349,12 @@ int setTrimbits(int *trimbits);
|
|||||||
int setAllTrimbits(int val);
|
int setAllTrimbits(int val);
|
||||||
int getAllTrimbits();
|
int getAllTrimbits();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
#ifndef CHIPTESTBOARDD
|
#ifndef CHIPTESTBOARDD
|
||||||
enum detectorSettings setSettings(enum detectorSettings sett);
|
enum detectorSettings setSettings(enum detectorSettings sett);
|
||||||
#endif
|
#endif
|
||||||
enum detectorSettings getSettings();
|
enum detectorSettings getSettings();
|
||||||
|
#endif
|
||||||
#if defined(JUNGFRAUD)
|
#if defined(JUNGFRAUD)
|
||||||
enum gainMode getGainMode();
|
enum gainMode getGainMode();
|
||||||
void setGainMode(enum gainMode mode);
|
void setGainMode(enum gainMode mode);
|
||||||
@ -366,10 +380,14 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck);
|
|||||||
void setGeneralDAC(enum DACINDEX ind, int val, int mV);
|
void setGeneralDAC(enum DACINDEX ind, int val, int mV);
|
||||||
void setVthDac(int index, int enable);
|
void setVthDac(int index, int enable);
|
||||||
#else
|
#else
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
void setDAC(enum DACINDEX ind, int val, int mV);
|
void setDAC(enum DACINDEX ind, int val, int mV);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int getDAC(enum DACINDEX ind, int mV);
|
int getDAC(enum DACINDEX ind, int mV);
|
||||||
int getMaxDacSteps();
|
int getMaxDacSteps();
|
||||||
|
#endif
|
||||||
#if defined(CHIPTESTBOARDD)
|
#if defined(CHIPTESTBOARDD)
|
||||||
int dacToVoltage(int dac);
|
int dacToVoltage(int dac);
|
||||||
int checkVLimitCompliant(int mV);
|
int checkVLimitCompliant(int mV);
|
||||||
@ -394,14 +412,17 @@ void powerOff();
|
|||||||
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
#if defined(MYTHEN3D) || defined(GOTTHARD2D)
|
||||||
int getADC(enum ADCINDEX ind, int *value);
|
int getADC(enum ADCINDEX ind, int *value);
|
||||||
#else
|
#else
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int getADC(enum ADCINDEX ind);
|
int getADC(enum ADCINDEX ind);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef CHIPTESTBOARDD
|
#ifdef CHIPTESTBOARDD
|
||||||
int getSlowADC(int ichan);
|
int getSlowADC(int ichan);
|
||||||
int getSlowADCTemperature();
|
int getSlowADCTemperature();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int setHighVoltage(int val);
|
int setHighVoltage(int val);
|
||||||
|
#endif
|
||||||
|
|
||||||
// parameters - timing, extsig
|
// parameters - timing, extsig
|
||||||
#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD) || \
|
#if defined(EIGERD) || defined(GOTTHARD2D) || defined(JUNGFRAUD) || \
|
||||||
@ -426,8 +447,10 @@ void setSynchronization(int enable);
|
|||||||
void updatingRegisters();
|
void updatingRegisters();
|
||||||
int updateClockDivs();
|
int updateClockDivs();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
void setTiming(enum timingMode arg);
|
void setTiming(enum timingMode arg);
|
||||||
enum timingMode getTiming();
|
enum timingMode getTiming();
|
||||||
|
#endif
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
void setInitialExtSignals();
|
void setInitialExtSignals();
|
||||||
int setChipStatusRegister(int csr);
|
int setChipStatusRegister(int csr);
|
||||||
@ -478,7 +501,9 @@ void calcChecksum(udp_header *udp);
|
|||||||
int getAdcConfigured();
|
int getAdcConfigured();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int configureMAC();
|
int configureMAC();
|
||||||
|
#endif
|
||||||
int setDetectorPosition(int pos[]);
|
int setDetectorPosition(int pos[]);
|
||||||
int *getDetectorPosition();
|
int *getDetectorPosition();
|
||||||
|
|
||||||
@ -674,11 +699,13 @@ int setTransmissionDelayRight(int value);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// aquisition
|
// aquisition
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int startStateMachine();
|
int startStateMachine();
|
||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
void *start_timer(void *arg);
|
void *start_timer(void *arg);
|
||||||
#endif
|
#endif
|
||||||
int stopStateMachine();
|
int stopStateMachine();
|
||||||
|
#endif
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
int softwareTrigger();
|
int softwareTrigger();
|
||||||
#endif
|
#endif
|
||||||
@ -688,12 +715,16 @@ int softwareTrigger(int block);
|
|||||||
#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
|
#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD)
|
||||||
int startReadOut();
|
int startReadOut();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
enum runStatus getRunStatus();
|
enum runStatus getRunStatus();
|
||||||
|
#endif
|
||||||
#ifdef EIGERD
|
#ifdef EIGERD
|
||||||
void waitForAcquisitionEnd(int *ret, char *mess);
|
void waitForAcquisitionEnd(int *ret, char *mess);
|
||||||
#else
|
#else
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
void waitForAcquisitionEnd();
|
void waitForAcquisitionEnd();
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if defined(CHIPTESTBOARDD)
|
#if defined(CHIPTESTBOARDD)
|
||||||
int validateUDPSocket();
|
int validateUDPSocket();
|
||||||
void readandSendUDPFrames();
|
void readandSendUDPFrames();
|
||||||
@ -714,6 +745,7 @@ u_int32_t runState(enum TLogLevel lev);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// common
|
// common
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int calculateDataBytes();
|
int calculateDataBytes();
|
||||||
int getTotalNumberOfChannels();
|
int getTotalNumberOfChannels();
|
||||||
#if defined(CHIPTESTBOARDD)
|
#if defined(CHIPTESTBOARDD)
|
||||||
@ -722,3 +754,4 @@ void getNumberOfChannels(int *nchanx, int *nchany);
|
|||||||
int getNumberOfChips();
|
int getNumberOfChips();
|
||||||
int getNumberOfDACs();
|
int getNumberOfDACs();
|
||||||
int getNumberOfChannelsPerChip();
|
int getNumberOfChannelsPerChip();
|
||||||
|
#endif
|
@ -172,14 +172,6 @@ uint32_t AD9257_DigMask = 0x0;
|
|||||||
int AD9257_DigOffset = 0x0;
|
int AD9257_DigOffset = 0x0;
|
||||||
int AD9257_VrefVoltage = 0;
|
int AD9257_VrefVoltage = 0;
|
||||||
|
|
||||||
#ifdef JUNGFRAUD
|
|
||||||
int AD9257_is_Jungfrau_Hardware_Version_1_0 = 0;
|
|
||||||
|
|
||||||
void AD9257_Set_Jungfrau_Hardware_Version_1_0(int val) {
|
|
||||||
AD9257_is_Jungfrau_Hardware_Version_1_0 = val;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void AD9257_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk,
|
void AD9257_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk,
|
||||||
uint32_t dmsk, int dofst) {
|
uint32_t dmsk, int dofst) {
|
||||||
AD9257_Reg = reg;
|
AD9257_Reg = reg;
|
||||||
@ -294,18 +286,8 @@ void AD9257_Configure() {
|
|||||||
AD9257_OUT_BINARY_OFST_VAL | AD9257_OUT_LVDS_IEEE_VAL);
|
AD9257_OUT_BINARY_OFST_VAL | AD9257_OUT_LVDS_IEEE_VAL);
|
||||||
|
|
||||||
// output clock phase
|
// output clock phase
|
||||||
#ifdef JUNGFRAUD
|
|
||||||
if (AD9257_is_Jungfrau_Hardware_Version_1_0) {
|
|
||||||
LOG(logINFO, ("\tOutput clock phase: 120\n"));
|
|
||||||
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_120_VAL);
|
|
||||||
} else {
|
|
||||||
LOG(logINFO, ("\tOutput clock phase: 180\n"));
|
|
||||||
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
LOG(logINFO, ("\tOutput clock phase: 180\n"));
|
LOG(logINFO, ("\tOutput clock phase: 180\n"));
|
||||||
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
|
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
|
||||||
#endif
|
|
||||||
|
|
||||||
// all devices on chip to receive next command
|
// all devices on chip to receive next command
|
||||||
LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
|
||||||
|
75
slsDetectorServers/slsDetectorServer/src/arm64.c
Normal file
75
slsDetectorServers/slsDetectorServer/src/arm64.c
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#include "arm64.h"
|
||||||
|
#include "RegisterDefs.h"
|
||||||
|
#include "clogger.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "sls/ansi.h"
|
||||||
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
|
#include <fcntl.h> // open
|
||||||
|
#include <sys/mman.h> // mmap
|
||||||
|
|
||||||
|
|
||||||
|
/* global variables */
|
||||||
|
#define CSP0 (0xB0010000)/// 0xB008_0000
|
||||||
|
#define MEM_SIZE 0x100000
|
||||||
|
|
||||||
|
u_int32_t *csp0base = 0;
|
||||||
|
|
||||||
|
void bus_w(u_int32_t offset, u_int32_t data) {
|
||||||
|
volatile u_int32_t *ptr1;
|
||||||
|
ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t)));
|
||||||
|
*ptr1 = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_int32_t bus_r(u_int32_t offset) {
|
||||||
|
volatile u_int32_t *ptr1;
|
||||||
|
ptr1 = (u_int32_t *)(csp0base + offset / (sizeof(u_int32_t)));
|
||||||
|
return *ptr1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t getU64BitReg(int aLSB, int aMSB) {
|
||||||
|
uint64_t retval = bus_r(aMSB);
|
||||||
|
retval = (retval << 32) | bus_r(aLSB);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setU64BitReg(uint64_t value, int aLSB, int aMSB) {
|
||||||
|
bus_w(aLSB, value & (0xffffffff));
|
||||||
|
bus_w(aMSB, (value >> 32) & (0xffffffff));
|
||||||
|
}
|
||||||
|
|
||||||
|
int mapCSP0(void) {
|
||||||
|
// if not mapped
|
||||||
|
if (csp0base == 0) {
|
||||||
|
LOG(logINFO, ("Mapping memory\n"));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
csp0base = malloc(MEM_SIZE);
|
||||||
|
if (csp0base == NULL) {
|
||||||
|
LOG(logERROR, ("Could not allocate virtual memory.\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logINFO, ("memory allocated\n"));
|
||||||
|
#else
|
||||||
|
int fd;
|
||||||
|
fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
|
||||||
|
if (fd == -1) {
|
||||||
|
LOG(logERROR, ("Can't find /dev/mem\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
LOG(logDEBUG1, ("/dev/mem opened\n"));
|
||||||
|
csp0base = (u_int32_t*)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE,
|
||||||
|
MAP_FILE | MAP_SHARED, fd, CSP0);
|
||||||
|
if (csp0base == MAP_FAILED) {
|
||||||
|
LOG(logERROR, ("Can't map memmory area\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
LOG(logINFO, ("csp0base mapped from %p to %p\n", csp0base,
|
||||||
|
(csp0base + MEM_SIZE)));
|
||||||
|
} else
|
||||||
|
LOG(logINFO, ("Memory already mapped before\n"));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
@ -114,6 +114,10 @@ int getTimeFromString(char *buf, time_t *result) {
|
|||||||
t.tm_mday, t.tm_mon, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec));
|
t.tm_mday, t.tm_mon, t.tm_year + 1900, t.tm_hour, t.tm_min, t.tm_sec));
|
||||||
|
|
||||||
*result = mktime(&t);
|
*result = mktime(&t);
|
||||||
|
if (*result == -1) {
|
||||||
|
LOG(logERROR, ("Could not convert time structure to time_t\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +134,7 @@ int getKernelVersion(char *retvals) {
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int validateKernelVersion(char *expectedVersion) {
|
int validateKernelVersion(char *expectedVersion) {
|
||||||
// extract kernel date string
|
// extract kernel date string
|
||||||
char version[255] = {0};
|
char version[255] = {0};
|
||||||
@ -143,15 +148,26 @@ int validateKernelVersion(char *expectedVersion) {
|
|||||||
#ifdef VIRTUAL
|
#ifdef VIRTUAL
|
||||||
strcpy(currentVersion, expectedVersion);
|
strcpy(currentVersion, expectedVersion);
|
||||||
#else
|
#else
|
||||||
|
#ifndef ARMPROCESSOR
|
||||||
// remove first word (#version number)
|
// remove first word (#version number)
|
||||||
const char *ptr = strchr(version, ' ');
|
const char *ptr = strstr(version, " ");
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
LOG(logERROR, ("Could not parse kernel version\n"));
|
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
strcpy(currentVersion, version + (ptr - version + 1));
|
strcpy(currentVersion, ptr + 1);
|
||||||
|
#else
|
||||||
|
// remove first two words (#version number and SMP)
|
||||||
|
const char *ptr = strstr(version, "SMP ");
|
||||||
|
if (ptr == NULL) {
|
||||||
|
LOG(logERROR, ("Could not parse kernel version\n"));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
strcpy(currentVersion, ptr + 4);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
currentVersion[sizeof(currentVersion) - 1] = '\0';
|
||||||
|
|
||||||
// convert kernel date string into time
|
// convert kernel date string into time
|
||||||
time_t kernelDate;
|
time_t kernelDate;
|
||||||
if (getTimeFromString(currentVersion, &kernelDate) == FAIL) {
|
if (getTimeFromString(currentVersion, &kernelDate) == FAIL) {
|
||||||
@ -159,6 +175,7 @@ int validateKernelVersion(char *expectedVersion) {
|
|||||||
("Could not parse retrieved kernel date, %s\n", currentVersion));
|
("Could not parse retrieved kernel date, %s\n", currentVersion));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
LOG(logDEBUG, ("Kernel Date: [%s]\n", ctime(&kernelDate)));
|
||||||
|
|
||||||
// convert expected date into time
|
// convert expected date into time
|
||||||
time_t expDate;
|
time_t expDate;
|
||||||
@ -167,11 +184,12 @@ int validateKernelVersion(char *expectedVersion) {
|
|||||||
("Could not parse expected kernel date, %s\n", expectedVersion));
|
("Could not parse expected kernel date, %s\n", expectedVersion));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
LOG(logDEBUG, ("Expected Date: [%s]\n", ctime(&expDate)));
|
||||||
|
|
||||||
// compare if kernel time is older than expected time
|
// compare if kernel time is older than expected time
|
||||||
if (kernelDate < expDate) {
|
if (kernelDate < expDate) {
|
||||||
LOG(logERROR, ("Kernel Version Incompatible (too old)! Expected: [%s], "
|
LOG(logERROR, ("Kernel Version Incompatible (too old)!\nExpected: '%s'"
|
||||||
"Got [%s]\n",
|
"\nGot : '%s'\n",
|
||||||
expectedVersion, currentVersion));
|
expectedVersion, currentVersion));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ const enum detectorType myDetectorType = MOENCH;
|
|||||||
const enum detectorType myDetectorType = MYTHEN3;
|
const enum detectorType myDetectorType = MYTHEN3;
|
||||||
#elif GOTTHARD2D
|
#elif GOTTHARD2D
|
||||||
const enum detectorType myDetectorType = GOTTHARD2;
|
const enum detectorType myDetectorType = GOTTHARD2;
|
||||||
|
#elif XILINX_CHIPTESTBOARDD
|
||||||
|
const enum detectorType myDetectorType = XILINX_CHIPTESTBOARD;
|
||||||
#else
|
#else
|
||||||
const enum detectorType myDetectorType = GENERIC;
|
const enum detectorType myDetectorType = GENERIC;
|
||||||
#endif
|
#endif
|
||||||
@ -717,6 +719,9 @@ int set_timing_mode(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting external communication mode to %d\n", arg));
|
LOG(logDEBUG1, ("Setting external communication mode to %d\n", arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// set
|
// set
|
||||||
if (((int)arg != GET_FLAG) && (Server_VerifyLock() == OK)) {
|
if (((int)arg != GET_FLAG) && (Server_VerifyLock() == OK)) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
@ -753,7 +758,7 @@ int set_timing_mode(int file_des) {
|
|||||||
validate(&ret, mess, (int)arg, (int)retval, "set timing mode", DEC);
|
validate(&ret, mess, (int)arg, (int)retval, "set timing mode", DEC);
|
||||||
#endif
|
#endif
|
||||||
LOG(logDEBUG1, ("Timing Mode: %d\n", retval));
|
LOG(logDEBUG1, ("Timing Mode: %d\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,7 +792,7 @@ int get_serial_number(int file_des) {
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
#ifdef EIGERD
|
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
retval = getDetectorNumber();
|
retval = getDetectorNumber();
|
||||||
@ -1119,6 +1124,8 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
case IBIAS_SFP:
|
case IBIAS_SFP:
|
||||||
serverDacIndex = MO_IBIAS_SFP;
|
serverDacIndex = MO_IBIAS_SFP;
|
||||||
break;
|
break;
|
||||||
|
#elif XILINX_CHIPTESTBOARDD
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1137,8 +1144,9 @@ enum DACINDEX getDACIndex(enum dacIndex ind) {
|
|||||||
|
|
||||||
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
enum DACINDEX serverDacIndex = 0;
|
|
||||||
|
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
|
enum DACINDEX serverDacIndex = 0;
|
||||||
// valid enums
|
// valid enums
|
||||||
switch (ind) {
|
switch (ind) {
|
||||||
case HIGH_VOLTAGE:
|
case HIGH_VOLTAGE:
|
||||||
@ -1389,6 +1397,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) {
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1401,6 +1410,9 @@ int set_dac(int file_des) {
|
|||||||
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
if (receiveData(file_des, args, sizeof(args), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
enum dacIndex ind = args[0];
|
enum dacIndex ind = args[0];
|
||||||
int mV = args[1];
|
int mV = args[1];
|
||||||
int val = args[2];
|
int val = args[2];
|
||||||
@ -1411,6 +1423,7 @@ int set_dac(int file_des) {
|
|||||||
if ((val == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
if ((val == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
||||||
retval = validateAndSetDac(ind, val, mV);
|
retval = validateAndSetDac(ind, val, mV);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1423,6 +1436,9 @@ int get_adc(int file_des) {
|
|||||||
if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0)
|
if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
enum ADCINDEX serverAdcIndex = 0;
|
enum ADCINDEX serverAdcIndex = 0;
|
||||||
|
|
||||||
// get
|
// get
|
||||||
@ -1544,6 +1560,7 @@ int get_adc(int file_des) {
|
|||||||
LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
|
LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -1560,6 +1577,9 @@ int write_register(int file_des) {
|
|||||||
uint32_t val = args[1];
|
uint32_t val = args[1];
|
||||||
LOG(logDEBUG1, ("Writing to register 0x%x, data 0x%x\n", addr, val));
|
LOG(logDEBUG1, ("Writing to register 0x%x, data 0x%x\n", addr, val));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
@ -1594,6 +1614,7 @@ int write_register(int file_des) {
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG1, ("Write register (0x%x): 0x%x\n", retval));
|
LOG(logDEBUG1, ("Write register (0x%x): 0x%x\n", retval));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1608,6 +1629,10 @@ int read_register(int file_des) {
|
|||||||
|
|
||||||
LOG(logDEBUG1, ("Reading from register 0x%x\n", addr));
|
LOG(logDEBUG1, ("Reading from register 0x%x\n", addr));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
|
||||||
// get
|
// get
|
||||||
#ifdef GOTTHARDD
|
#ifdef GOTTHARDD
|
||||||
retval = readRegister16And32(addr);
|
retval = readRegister16And32(addr);
|
||||||
@ -1624,7 +1649,7 @@ int read_register(int file_des) {
|
|||||||
retval = readRegister(addr);
|
retval = readRegister(addr);
|
||||||
#endif
|
#endif
|
||||||
LOG(logINFO, ("Read register (0x%x): 0x%x\n", addr, retval));
|
LOG(logINFO, ("Read register (0x%x): 0x%x\n", addr, retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1828,7 +1853,7 @@ int set_settings(int file_des) {
|
|||||||
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
|
if (receiveData(file_des, &isett, sizeof(isett), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
#ifdef CHIPTESTBOARDD
|
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
LOG(logDEBUG1, ("Setting settings %d\n", isett));
|
LOG(logDEBUG1, ("Setting settings %d\n", isett));
|
||||||
@ -1905,6 +1930,9 @@ int acquire(int blocking, int file_des) {
|
|||||||
} else {
|
} else {
|
||||||
LOG(logINFOBLUE, ("Unblocking Acquisition\n"));
|
LOG(logINFOBLUE, ("Unblocking Acquisition\n"));
|
||||||
}
|
}
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
#if defined(JUNGFRAUD)
|
#if defined(JUNGFRAUD)
|
||||||
@ -2003,10 +2031,12 @@ int acquire(int blocking, int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *start_state_machine(void *arg) {
|
void *start_state_machine(void *arg) {
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
int *blocking = (int *)arg;
|
int *blocking = (int *)arg;
|
||||||
int times = 1;
|
int times = 1;
|
||||||
// start of scan
|
// start of scan
|
||||||
@ -2132,6 +2162,7 @@ void *start_state_machine(void *arg) {
|
|||||||
if (scan && sharedMemory_getScanStatus() != ERROR) {
|
if (scan && sharedMemory_getScanStatus() != ERROR) {
|
||||||
sharedMemory_setScanStatus(IDLE);
|
sharedMemory_setScanStatus(IDLE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2149,6 +2180,9 @@ int stop_acquisition(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Stopping Acquisition\n"));
|
LOG(logDEBUG1, ("Stopping Acquisition\n"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
ret = stopStateMachine();
|
ret = stopStateMachine();
|
||||||
@ -2158,6 +2192,7 @@ int stop_acquisition(int file_des) {
|
|||||||
}
|
}
|
||||||
LOG(logDEBUG1, ("Stopping Acquisition ret: %d\n", ret));
|
LOG(logDEBUG1, ("Stopping Acquisition ret: %d\n", ret));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2167,9 +2202,13 @@ int get_run_status(int file_des) {
|
|||||||
enum runStatus retval = ERROR;
|
enum runStatus retval = ERROR;
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Getting status\n"));
|
LOG(logDEBUG1, ("Getting status\n"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only get
|
// only get
|
||||||
retval = getRunStatus();
|
retval = getRunStatus();
|
||||||
LOG(logDEBUG1, ("Status: %d\n", retval));
|
LOG(logDEBUG1, ("Status: %d\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2180,6 +2219,9 @@ int get_num_frames(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
if (!scan) {
|
if (!scan) {
|
||||||
retval = getNumFrames();
|
retval = getNumFrames();
|
||||||
@ -2189,6 +2231,7 @@ int get_num_frames(int file_des) {
|
|||||||
LOG(logDEBUG1, ("retval num frames (num scan steps) %lld\n",
|
LOG(logDEBUG1, ("retval num frames (num scan steps) %lld\n",
|
||||||
(long long int)retval));
|
(long long int)retval));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2201,6 +2244,9 @@ int set_num_frames(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting number of frames %lld\n", (long long int)arg));
|
LOG(logDEBUG1, ("Setting number of frames %lld\n", (long long int)arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
// only set number of frames if normal mode (not scan)
|
// only set number of frames if normal mode (not scan)
|
||||||
@ -2246,6 +2292,7 @@ int set_num_frames(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2254,9 +2301,13 @@ int get_num_triggers(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = getNumTriggers();
|
retval = getNumTriggers();
|
||||||
LOG(logDEBUG1, ("retval num triggers %lld\n", (long long int)retval));
|
LOG(logDEBUG1, ("retval num triggers %lld\n", (long long int)retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2269,6 +2320,9 @@ int set_num_triggers(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting number of triggers %lld\n", (long long int)arg));
|
LOG(logDEBUG1, ("Setting number of triggers %lld\n", (long long int)arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
#if JUNGFRAUD
|
#if JUNGFRAUD
|
||||||
@ -2288,6 +2342,7 @@ int set_num_triggers(int file_des) {
|
|||||||
validate64(&ret, mess, arg, retval, "set number of triggers", DEC);
|
validate64(&ret, mess, arg, retval, "set number of triggers", DEC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2447,6 +2502,9 @@ int get_exptime(int file_des) {
|
|||||||
if (receiveData(file_des, &gateIndex, sizeof(gateIndex), INT32) < 0)
|
if (receiveData(file_des, &gateIndex, sizeof(gateIndex), INT32) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
if (gateIndex < 0 || gateIndex > 2) {
|
if (gateIndex < 0 || gateIndex > 2) {
|
||||||
@ -2470,6 +2528,7 @@ int get_exptime(int file_des) {
|
|||||||
retval = getExpTime();
|
retval = getExpTime();
|
||||||
LOG(logDEBUG1, ("retval exptime %lld ns\n", (long long int)retval));
|
LOG(logDEBUG1, ("retval exptime %lld ns\n", (long long int)retval));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -2486,6 +2545,9 @@ int set_exptime(int file_des) {
|
|||||||
LOG(logDEBUG1, ("Setting exptime %lld ns (gateIndex:%d)\n",
|
LOG(logDEBUG1, ("Setting exptime %lld ns (gateIndex:%d)\n",
|
||||||
(long long int)val, gateIndex));
|
(long long int)val, gateIndex));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
#ifdef MYTHEN3D
|
#ifdef MYTHEN3D
|
||||||
@ -2550,6 +2612,7 @@ int set_exptime(int file_des) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2558,9 +2621,13 @@ int get_period(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = getPeriod();
|
retval = getPeriod();
|
||||||
LOG(logDEBUG1, ("retval period %lld ns\n", (long long int)retval));
|
LOG(logDEBUG1, ("retval period %lld ns\n", (long long int)retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2573,6 +2640,9 @@ int set_period(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting period %lld ns\n", (long long int)arg));
|
LOG(logDEBUG1, ("Setting period %lld ns\n", (long long int)arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
ret = setPeriod(arg);
|
ret = setPeriod(arg);
|
||||||
@ -2584,6 +2654,7 @@ int set_period(int file_des) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2991,6 +3062,9 @@ int set_dynamic_range(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Setting dr to %d\n", dr));
|
LOG(logDEBUG1, ("Setting dr to %d\n", dr));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// set & get
|
// set & get
|
||||||
if ((dr == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
if ((dr == GET_FLAG) || (Server_VerifyLock() == OK)) {
|
||||||
// check dr
|
// check dr
|
||||||
@ -3039,6 +3113,7 @@ int set_dynamic_range(int file_des) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3153,7 +3228,7 @@ int enable_ten_giga(int file_des) {
|
|||||||
LOG(logDEBUG, ("Setting 10GbE: %d\n", arg));
|
LOG(logDEBUG, ("Setting 10GbE: %d\n", arg));
|
||||||
|
|
||||||
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
|
#if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \
|
||||||
defined(GOTTHARD2D)
|
defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// set & get
|
// set & get
|
||||||
@ -4322,7 +4397,7 @@ int reboot_controller(int file_des) {
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
#ifdef EIGERD
|
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#elif VIRTUAL
|
#elif VIRTUAL
|
||||||
ret = GOODBYE;
|
ret = GOODBYE;
|
||||||
@ -4951,6 +5026,9 @@ int set_detector_position(int file_des) {
|
|||||||
LOG(logDEBUG, ("Setting detector positions: [maxy:%u, modIndex:%u]\n",
|
LOG(logDEBUG, ("Setting detector positions: [maxy:%u, modIndex:%u]\n",
|
||||||
args[0], args[1]));
|
args[0], args[1]));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
// if in update mode, there is no need to do this (also detector not set
|
// if in update mode, there is no need to do this (also detector not set
|
||||||
@ -4961,10 +5039,14 @@ int set_detector_position(int file_des) {
|
|||||||
calculate_and_set_position();
|
calculate_and_set_position();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_detector_idle(const char *s) {
|
int check_detector_idle(const char *s) {
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
return FAIL;
|
||||||
|
#else
|
||||||
enum runStatus status = getRunStatus();
|
enum runStatus status = getRunStatus();
|
||||||
if (status != IDLE && status != RUN_FINISHED && status != STOPPED &&
|
if (status != IDLE && status != RUN_FINISHED && status != STOPPED &&
|
||||||
status != ERROR) {
|
status != ERROR) {
|
||||||
@ -4976,6 +5058,7 @@ int check_detector_idle(const char *s) {
|
|||||||
LOG(logERROR, (mess));
|
LOG(logERROR, (mess));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_udp_configured() {
|
int is_udp_configured() {
|
||||||
@ -5042,6 +5125,7 @@ int is_udp_configured() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void configure_mac() {
|
void configure_mac() {
|
||||||
|
#ifndef XILINX_CHIPTESTBOARDD
|
||||||
if (isControlServer) {
|
if (isControlServer) {
|
||||||
if (is_udp_configured() == OK) {
|
if (is_udp_configured() == OK) {
|
||||||
ret = configureMAC();
|
ret = configureMAC();
|
||||||
@ -5068,6 +5152,7 @@ void configure_mac() {
|
|||||||
}
|
}
|
||||||
configured = FAIL;
|
configured = FAIL;
|
||||||
LOG(logWARNING, ("Configure FAIL, not all parameters configured yet\n"));
|
LOG(logWARNING, ("Configure FAIL, not all parameters configured yet\n"));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_source_udp_ip(int file_des) {
|
int set_source_udp_ip(int file_des) {
|
||||||
@ -5080,6 +5165,9 @@ int set_source_udp_ip(int file_des) {
|
|||||||
arg = __builtin_bswap32(arg);
|
arg = __builtin_bswap32(arg);
|
||||||
LOG(logINFO, ("Setting udp source ip: 0x%x\n", arg));
|
LOG(logINFO, ("Setting udp source ip: 0x%x\n", arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (check_detector_idle("configure mac") == OK) {
|
if (check_detector_idle("configure mac") == OK) {
|
||||||
@ -5092,6 +5180,7 @@ int set_source_udp_ip(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5101,11 +5190,14 @@ int get_source_udp_ip(int file_des) {
|
|||||||
uint32_t retval = -1;
|
uint32_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting udp source ip\n"));
|
LOG(logDEBUG1, ("Getting udp source ip\n"));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].srcip;
|
retval = udpDetails[0].srcip;
|
||||||
retval = __builtin_bswap32(retval);
|
retval = __builtin_bswap32(retval);
|
||||||
LOG(logDEBUG1, ("udp soure ip retval: 0x%x\n", retval));
|
LOG(logDEBUG1, ("udp soure ip retval: 0x%x\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5165,6 +5257,9 @@ int set_dest_udp_ip(int file_des) {
|
|||||||
arg = __builtin_bswap32(arg);
|
arg = __builtin_bswap32(arg);
|
||||||
LOG(logINFO, ("Setting udp destination ip: 0x%x\n", arg));
|
LOG(logINFO, ("Setting udp destination ip: 0x%x\n", arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (check_detector_idle("configure mac") == OK) {
|
if (check_detector_idle("configure mac") == OK) {
|
||||||
@ -5174,6 +5269,7 @@ int set_dest_udp_ip(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5183,11 +5279,14 @@ int get_dest_udp_ip(int file_des) {
|
|||||||
uint32_t retval = -1;
|
uint32_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting destination ip\n"));
|
LOG(logDEBUG1, ("Getting destination ip\n"));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].dstip;
|
retval = udpDetails[0].dstip;
|
||||||
retval = __builtin_bswap32(retval);
|
retval = __builtin_bswap32(retval);
|
||||||
LOG(logDEBUG1, ("udp destination ip retval: 0x%x\n", retval));
|
LOG(logDEBUG1, ("udp destination ip retval: 0x%x\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5243,6 +5342,9 @@ int set_source_udp_mac(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting udp source mac: 0x%lx\n", arg));
|
LOG(logINFO, ("Setting udp source mac: 0x%lx\n", arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (check_detector_idle("configure mac") == OK) {
|
if (check_detector_idle("configure mac") == OK) {
|
||||||
@ -5264,6 +5366,7 @@ int set_source_udp_mac(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5272,11 +5375,13 @@ int get_source_udp_mac(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
uint64_t retval = -1;
|
uint64_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting udp source mac\n"));
|
LOG(logDEBUG1, ("Getting udp source mac\n"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].srcmac;
|
retval = udpDetails[0].srcmac;
|
||||||
LOG(logDEBUG1, ("udp soure mac retval: 0x%lx\n", retval));
|
LOG(logDEBUG1, ("udp soure mac retval: 0x%lx\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5333,6 +5438,9 @@ int set_dest_udp_mac(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting udp destination mac: 0x%lx\n", arg));
|
LOG(logINFO, ("Setting udp destination mac: 0x%lx\n", arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (check_detector_idle("configure mac") == OK) {
|
if (check_detector_idle("configure mac") == OK) {
|
||||||
@ -5342,6 +5450,7 @@ int set_dest_udp_mac(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, NULL, 0);
|
return Server_SendResult(file_des, INT64, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5350,11 +5459,13 @@ int get_dest_udp_mac(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
uint64_t retval = -1;
|
uint64_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting udp destination mac\n"));
|
LOG(logDEBUG1, ("Getting udp destination mac\n"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].dstmac;
|
retval = udpDetails[0].dstmac;
|
||||||
LOG(logDEBUG1, ("udp destination mac retval: 0x%lx\n", retval));
|
LOG(logDEBUG1, ("udp destination mac retval: 0x%lx\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5408,6 +5519,9 @@ int set_dest_udp_port(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting udp destination port: %hu\n", arg));
|
LOG(logINFO, ("Setting udp destination port: %hu\n", arg));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (check_detector_idle("configure mac") == OK) {
|
if (check_detector_idle("configure mac") == OK) {
|
||||||
@ -5417,6 +5531,7 @@ int set_dest_udp_port(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT16, NULL, 0);
|
return Server_SendResult(file_des, INT16, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5425,11 +5540,13 @@ int get_dest_udp_port(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
uint16_t retval = -1;
|
uint16_t retval = -1;
|
||||||
LOG(logDEBUG1, ("Getting destination port"));
|
LOG(logDEBUG1, ("Getting destination port"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
retval = udpDetails[0].dstport;
|
retval = udpDetails[0].dstport;
|
||||||
LOG(logDEBUG, ("udp destination port retval: %hu\n", retval));
|
LOG(logDEBUG, ("udp destination port retval: %hu\n", retval));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT16, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT16, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5485,7 +5602,8 @@ int set_num_interfaces(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
|
LOG(logINFO, ("Setting number of interfaces: %d\n", arg));
|
||||||
|
|
||||||
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D)
|
#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D) && \
|
||||||
|
!defined(XLINX_CHIPTESTBOARDD)
|
||||||
// fixed number of udp interfaces
|
// fixed number of udp interfaces
|
||||||
int num_interfaces = getNumberofUDPInterfaces();
|
int num_interfaces = getNumberofUDPInterfaces();
|
||||||
if (arg != num_interfaces) {
|
if (arg != num_interfaces) {
|
||||||
@ -5557,7 +5675,6 @@ int get_num_interfaces(int file_des) {
|
|||||||
|
|
||||||
// get only
|
// get only
|
||||||
retval = getNumberofUDPInterfaces();
|
retval = getNumberofUDPInterfaces();
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval));
|
LOG(logDEBUG1, ("Number of udp interfaces retval: %u\n", retval));
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
@ -7020,6 +7137,10 @@ int get_receiver_parameters(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Getting receiver parameters\n"));
|
LOG(logDEBUG1, ("Getting receiver parameters\n"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
Server_SendResult(file_des, INT32, NULL, 0);
|
Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
|
|
||||||
@ -7477,7 +7598,7 @@ int get_receiver_parameters(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
LOG(logINFO, ("Sent %d bytes for receiver parameters\n", n));
|
LOG(logINFO, ("Sent %d bytes for receiver parameters\n", n));
|
||||||
|
#endif
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7819,6 +7940,9 @@ int set_scan(int file_des) {
|
|||||||
if (receiveData(file_des, &dacTime, sizeof(dacTime), INT64) < 0)
|
if (receiveData(file_des, &dacTime, sizeof(dacTime), INT64) < 0)
|
||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
int enable = args[0];
|
int enable = args[0];
|
||||||
@ -7908,6 +8032,7 @@ int set_scan(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT64, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8265,6 +8390,9 @@ int reconfigure_udp(int file_des) {
|
|||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
LOG(logINFO, ("Reconfiguring UDP\n"));
|
LOG(logINFO, ("Reconfiguring UDP\n"));
|
||||||
if (check_detector_idle("configure mac") == OK) {
|
if (check_detector_idle("configure mac") == OK) {
|
||||||
@ -8277,6 +8405,7 @@ int reconfigure_udp(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8377,7 +8506,7 @@ int reset_to_default_dacs(int file_des) {
|
|||||||
return printSocketReadError();
|
return printSocketReadError();
|
||||||
LOG(logDEBUG1, ("Resetting dacs to defaults (hard reset: %d)\n", arg));
|
LOG(logDEBUG1, ("Resetting dacs to defaults (hard reset: %d)\n", arg));
|
||||||
|
|
||||||
#ifdef CHIPTESTBOARDD
|
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
@ -8792,7 +8921,7 @@ int get_default_dac(int file_des) {
|
|||||||
LOG(logDEBUG1,
|
LOG(logDEBUG1,
|
||||||
("Getting default dac [dacindex:%d, settings: %d]\n", dacindex, sett));
|
("Getting default dac [dacindex:%d, settings: %d]\n", dacindex, sett));
|
||||||
|
|
||||||
#ifdef CHIPTESTBOARDD
|
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// get only
|
// get only
|
||||||
@ -8832,7 +8961,7 @@ int set_default_dac(int file_des) {
|
|||||||
LOG(logDEBUG1, ("Setting default dac [dacindex: %d, settings: %d] to %d\n",
|
LOG(logDEBUG1, ("Setting default dac [dacindex: %d, settings: %d] to %d\n",
|
||||||
(int)dacindex, (int)sett, value));
|
(int)dacindex, (int)sett, value));
|
||||||
|
|
||||||
#ifdef CHIPTESTBOARDD
|
#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
#else
|
#else
|
||||||
// only set
|
// only set
|
||||||
@ -9452,6 +9581,11 @@ int clear_all_udp_dst(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
|
|
||||||
LOG(logINFO, ("Clearing all udp destinations\n"));
|
LOG(logINFO, ("Clearing all udp destinations\n"));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (check_detector_idle("clear all udp destinations") == OK) {
|
if (check_detector_idle("clear all udp destinations") == OK) {
|
||||||
memset(udpDetails, 0, sizeof(udpDetails));
|
memset(udpDetails, 0, sizeof(udpDetails));
|
||||||
@ -9479,6 +9613,7 @@ int clear_all_udp_dst(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9618,7 +9753,9 @@ int get_kernel_version(int file_des) {
|
|||||||
memset(retvals, 0, MAX_STR_LENGTH);
|
memset(retvals, 0, MAX_STR_LENGTH);
|
||||||
|
|
||||||
LOG(logDEBUG1, ("Getting kernel version\n"));
|
LOG(logDEBUG1, ("Getting kernel version\n"));
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// get only
|
// get only
|
||||||
ret = getKernelVersion(retvals);
|
ret = getKernelVersion(retvals);
|
||||||
if (ret == FAIL) {
|
if (ret == FAIL) {
|
||||||
@ -9631,13 +9768,14 @@ int get_kernel_version(int file_des) {
|
|||||||
} else {
|
} else {
|
||||||
LOG(logDEBUG1, ("kernel version: [%s]\n", retvals));
|
LOG(logDEBUG1, ("kernel version: [%s]\n", retvals));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||||
}
|
}
|
||||||
|
|
||||||
int update_kernel(int file_des) {
|
int update_kernel(int file_des) {
|
||||||
ret = OK;
|
ret = OK;
|
||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
#ifdef EIGERD
|
#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD)
|
||||||
functionNotImplemented();
|
functionNotImplemented();
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
#else
|
#else
|
||||||
@ -9689,7 +9827,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
|||||||
LOG(logINFO, ("\tServer Name: %s\n", serverName));
|
LOG(logINFO, ("\tServer Name: %s\n", serverName));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
|
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD) && \
|
||||||
|
!defined(XILINX_CHIPTESTBOARDD)
|
||||||
int forceDeleteNormalFile = 0;
|
int forceDeleteNormalFile = 0;
|
||||||
if (receiveData(file_des, &forceDeleteNormalFile,
|
if (receiveData(file_des, &forceDeleteNormalFile,
|
||||||
sizeof(forceDeleteNormalFile), INT32) < 0)
|
sizeof(forceDeleteNormalFile), INT32) < 0)
|
||||||
@ -9725,7 +9864,8 @@ int receive_program(int file_des, enum PROGRAM_INDEX index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD)
|
#if defined(GOTTHARD2D) || defined(MYTHEN3D) || defined(EIGERD) || \
|
||||||
|
defined(XILINX_CHIPTESTBOARDD)
|
||||||
receive_program_default(file_des, index, functionType, filesize,
|
receive_program_default(file_des, index, functionType, filesize,
|
||||||
checksum, serverName);
|
checksum, serverName);
|
||||||
#else
|
#else
|
||||||
@ -9871,7 +10011,8 @@ void receive_program_via_blackfin(int file_des, enum PROGRAM_INDEX index,
|
|||||||
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
void receive_program_default(int file_des, enum PROGRAM_INDEX index,
|
||||||
char *functionType, uint64_t filesize,
|
char *functionType, uint64_t filesize,
|
||||||
char *checksum, char *serverName) {
|
char *checksum, char *serverName) {
|
||||||
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD)
|
#if !defined(GOTTHARD2D) && !defined(MYTHEN3D) && !defined(EIGERD) && \
|
||||||
|
!defined(XILINX_CHIPTESTBOARDD)
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
"Could not %s. program via blackfin not implmented for this "
|
"Could not %s. program via blackfin not implmented for this "
|
||||||
@ -10389,8 +10530,12 @@ int get_hardware_version(int file_des) {
|
|||||||
memset(mess, 0, sizeof(mess));
|
memset(mess, 0, sizeof(mess));
|
||||||
char retvals[MAX_STR_LENGTH];
|
char retvals[MAX_STR_LENGTH];
|
||||||
memset(retvals, 0, MAX_STR_LENGTH);
|
memset(retvals, 0, MAX_STR_LENGTH);
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
getHardwareVersion(retvals);
|
getHardwareVersion(retvals);
|
||||||
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
|
LOG(logDEBUG1, ("hardware version retval: %s\n", retvals));
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
return Server_SendResult(file_des, OTHER, retvals, sizeof(retvals));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10443,6 +10588,10 @@ int set_bit(int file_des) {
|
|||||||
int nBit = (int)args[1];
|
int nBit = (int)args[1];
|
||||||
LOG(logDEBUG1, ("Setting bit %d of reg 0x%x\n", nBit, addr));
|
LOG(logDEBUG1, ("Setting bit %d of reg 0x%x\n", nBit, addr));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
|
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (nBit < 0 || nBit > 31) {
|
if (nBit < 0 || nBit > 31) {
|
||||||
@ -10473,6 +10622,7 @@ int set_bit(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10487,6 +10637,9 @@ int clear_bit(int file_des) {
|
|||||||
int nBit = (int)args[1];
|
int nBit = (int)args[1];
|
||||||
LOG(logDEBUG1, ("Clearing bit %d of reg 0x%x\n", nBit, addr));
|
LOG(logDEBUG1, ("Clearing bit %d of reg 0x%x\n", nBit, addr));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
// only set
|
// only set
|
||||||
if (Server_VerifyLock() == OK) {
|
if (Server_VerifyLock() == OK) {
|
||||||
if (nBit < 0 || nBit > 31) {
|
if (nBit < 0 || nBit > 31) {
|
||||||
@ -10517,6 +10670,7 @@ int clear_bit(int file_des) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, NULL, 0);
|
return Server_SendResult(file_des, INT32, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -10532,6 +10686,9 @@ int get_bit(int file_des) {
|
|||||||
int nBit = (int)args[1];
|
int nBit = (int)args[1];
|
||||||
LOG(logDEBUG1, ("Getting bit %d of reg 0x%x\n", nBit, addr));
|
LOG(logDEBUG1, ("Getting bit %d of reg 0x%x\n", nBit, addr));
|
||||||
|
|
||||||
|
#ifdef XILINX_CHIPTESTBOARDD
|
||||||
|
functionNotImplemented();
|
||||||
|
#else
|
||||||
if (nBit < 0 || nBit > 31) {
|
if (nBit < 0 || nBit > 31) {
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
sprintf(mess,
|
sprintf(mess,
|
||||||
@ -10556,6 +10713,7 @@ int get_bit(int file_des) {
|
|||||||
LOG(logDEBUG1, ("regval: 0x%x bit value:0%d\n", regval, retval));
|
LOG(logDEBUG1, ("regval: 0x%x bit value:0%d\n", regval, retval));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
return Server_SendResult(file_des, INT32, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt
Normal file
38
slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
add_executable(xilinx_ctbDetectorServer_virtual
|
||||||
|
slsDetectorFunctionList.c
|
||||||
|
../slsDetectorServer/src/slsDetectorServer.c
|
||||||
|
../slsDetectorServer/src/slsDetectorServer_funcs.c
|
||||||
|
../slsDetectorServer/src/communication_funcs.c
|
||||||
|
../slsDetectorServer/src/arm64.c
|
||||||
|
../slsDetectorServer/src/common.c
|
||||||
|
../slsDetectorServer/src/sharedMemory.c
|
||||||
|
../../slsSupportLib/src/md5.c
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
../slsDetectorServer/include
|
||||||
|
../../slsSupportLib/include
|
||||||
|
../../slsDetectorSoftware/include/sls/
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(xilinx_ctbDetectorServer_virtual
|
||||||
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(xilinx_ctbDetectorServer_virtual
|
||||||
|
PUBLIC XILINX_CHIPTESTBOARDD ARMPROCESSOR VIRTUAL STOP_SERVER
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(xilinx_ctbDetectorServer_virtual
|
||||||
|
PUBLIC pthread rt slsProjectCSettings
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(xilinx_ctbDetectorServer_virtual PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS xilinx_ctbDetectorServer_virtual
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
47
slsDetectorServers/xilinx_ctbDetectorServer/Makefile
Executable file
47
slsDetectorServers/xilinx_ctbDetectorServer/Makefile
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
# Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
current_dir = $(shell pwd)
|
||||||
|
main_inc = ../slsDetectorServer/include/
|
||||||
|
main_src = ../slsDetectorServer/src/
|
||||||
|
support_lib = ../../slsSupportLib/include/
|
||||||
|
det_lib = ../../slsDetectorSoftware/include/sls/
|
||||||
|
md5_dir = ../../slsSupportLib/src/
|
||||||
|
|
||||||
|
CROSS = aarch64-none-linux-gnu-
|
||||||
|
CC = $(CROSS)gcc
|
||||||
|
#TODO: allow these warnings and fix code
|
||||||
|
CFLAGS += -Wall -std=gnu99 -Wno-format-overflow -Wno-format-truncation -DXILINX_CHIPTESTBOARDD -DARMPROCESSOR -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||||
|
#CFLAGS += -Wall -std=gnu99 -DXILINX_CHIPTESTBOARDD -DARMPROCESSOR -DSTOP_SERVER -I$(main_inc) -I$(support_lib) -I$(det_lib) -I$(current_dir) #-DDEBUG1 #-DVERBOSEI #-DVERBOSE
|
||||||
|
LDLIBS += -lm -lrt -pthread
|
||||||
|
PROGS = xilinx_ctbDetectorServer
|
||||||
|
DESTDIR ?= bin
|
||||||
|
INSTMODE = 0777
|
||||||
|
|
||||||
|
SRCS = slsDetectorFunctionList.c
|
||||||
|
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)arm64.c $(main_src)common.c $(main_src)/sharedMemory.c $(md5_dir)md5.c
|
||||||
|
|
||||||
|
OBJS = $(SRCS:.c=.o)
|
||||||
|
|
||||||
|
all: clean $(PROGS)
|
||||||
|
version: clean versioning $(PROGS)
|
||||||
|
|
||||||
|
boot: $(OBJS)
|
||||||
|
|
||||||
|
version_branch=$(API_BRANCH)
|
||||||
|
version_name=APIXILINXCTB
|
||||||
|
version_path=slsDetectorServers/xilinx_ctbDetectorServer
|
||||||
|
versioning:
|
||||||
|
cd ../../ && echo $(PWD) && echo `tput setaf 6; ./updateAPIVersion.sh $(version_name) $(version_path) $(version_branch); tput sgr0;`
|
||||||
|
|
||||||
|
|
||||||
|
$(PROGS): $(OBJS)
|
||||||
|
# echo $(OBJS)
|
||||||
|
mkdir -p $(DESTDIR)
|
||||||
|
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||||
|
mv $(PROGS) $(DESTDIR)
|
||||||
|
rm $(main_src)*.o $(md5_dir)*.o
|
||||||
|
clean:
|
||||||
|
rm -rf $(DESTDIR)/$(PROGS) *.o *.gdb $(main_src)*.o $(md5_dir)*.o
|
||||||
|
|
||||||
|
|
||||||
|
|
416
slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h
Normal file
416
slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h
Normal file
@ -0,0 +1,416 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define CTRLREG1 (0x0)
|
||||||
|
|
||||||
|
#define CTR1_OFST (0)
|
||||||
|
#define CTR1_MSK (0xffffffff << CTR1_OFST)
|
||||||
|
|
||||||
|
#define CTRLREG2 (0x4)
|
||||||
|
|
||||||
|
#define CTRL2_OFST (0)
|
||||||
|
#define CTRL2_MSK (0xffffffff << CTRL2_OFST)
|
||||||
|
|
||||||
|
#define STATUSREG1 (0x8)
|
||||||
|
|
||||||
|
#define STATUS1_OFST (0)
|
||||||
|
#define STATUS1_MSK (0xffffffff << STATUS1_OFST)
|
||||||
|
|
||||||
|
#define STATUSREG2 (0xC)
|
||||||
|
|
||||||
|
#define STATUS2_OFST (0)
|
||||||
|
#define STATUS2_MSK (0xffffffff << STATUS2_OFST)
|
||||||
|
|
||||||
|
#define FPGAVERSIONREG (0x10)
|
||||||
|
|
||||||
|
#define COMPDATE_OFST (0)
|
||||||
|
#define COMPDATE_MSK (0x00ffffff << COMPDATE_OFST)
|
||||||
|
#define DETTYPE_OFST (24)
|
||||||
|
#define DETTYPE_MSK (0x000000ff << DETTYPE_OFST)
|
||||||
|
|
||||||
|
#define PKTPACKETLENGTHREG (0x28)
|
||||||
|
|
||||||
|
#define PACKETLENGTH1G_OFST (0)
|
||||||
|
#define PACKETLENGTH1G_MSK (0x0000ffff << PACKETLENGTH1G_OFST)
|
||||||
|
#define PACKETLENGTH10G_OFST (16)
|
||||||
|
#define PACKETLENGTH10G_MSK (0x0000ffff << PACKETLENGTH10G_OFST)
|
||||||
|
|
||||||
|
#define PKTNOPACKETSREG (0x30)
|
||||||
|
|
||||||
|
#define NOPACKETS1G_OFST (0)
|
||||||
|
#define NOPACKETS1G_MSK (0x0000003f << NOPACKETS1G_OFST)
|
||||||
|
#define NOPACKETS10G_OFST (8)
|
||||||
|
#define NOPACKETS10G_MSK (0x0000003f << NOPACKETS10G_OFST)
|
||||||
|
|
||||||
|
#define PKTCTRLREG (0x38)
|
||||||
|
|
||||||
|
#define NSERVERS_OFST (0)
|
||||||
|
#define NSERVERS_MSK (0x0000003f << NSERVERS_OFST)
|
||||||
|
#define SERVERSTART_OFST (6)
|
||||||
|
#define SERVERSTART_MSK (0x0000001f << SERVERSTART_OFST)
|
||||||
|
#define ETHINTERF_OFST (11)
|
||||||
|
#define ETHINTERF_MSK (0x00000001 << ETHINTERF_OFST)
|
||||||
|
|
||||||
|
#define PKTCOORDREG1 (0x40)
|
||||||
|
|
||||||
|
#define COORDX_OFST (0)
|
||||||
|
#define COORDX_MSK (0x0000ffff << COORDX_OFST)
|
||||||
|
#define COORDY_OFST (16)
|
||||||
|
#define COORDY_MSK (0x0000ffff << COORDY_OFST)
|
||||||
|
|
||||||
|
#define PKTCOORDREG2 (0x48)
|
||||||
|
|
||||||
|
#define COORDZ_OFST (0)
|
||||||
|
#define COORDZ_MSK (0x0000ffff << COORDZ_OFST)
|
||||||
|
|
||||||
|
#define FLOWSTATUSREG (0x100)
|
||||||
|
|
||||||
|
#define RSMBUSY_OFST (0)
|
||||||
|
#define RSMBUSY_MSK (0x00000001 << RSMBUSY_OFST)
|
||||||
|
#define RSMTRGWAIT_OFST (3)
|
||||||
|
#define RSMTRGWAIT_MSK (0x00000001 << RSMTRGWAIT_OFST)
|
||||||
|
#define CSMBUSY_OFST (17)
|
||||||
|
#define CSMBUSY_MSK (0x00000001 << CSMBUSY_OFST)
|
||||||
|
|
||||||
|
#define FLOWCONTROLREG (0x108)
|
||||||
|
|
||||||
|
#define STARTF_OFST (0)
|
||||||
|
#define STARTF_MSK (0x00000001 << STARTF_OFST)
|
||||||
|
#define STOPF_OFST (1)
|
||||||
|
#define STOPF_MSK (0x00000001 << STOPF_OFST)
|
||||||
|
#define RSTF_OFST (2)
|
||||||
|
#define RSTF_MSK (0x00000001 << RSTF_OFST)
|
||||||
|
#define SWTRIGGERF_OFST (3)
|
||||||
|
#define SWTRIGGERF_MSK (0x00000001 << SWTRIGGERF_OFST)
|
||||||
|
#define TRIGGERENABLE_OFST (4)
|
||||||
|
#define TRIGGERENABLE_MSK (0x00000001 << TRIGGERENABLE_OFST)
|
||||||
|
|
||||||
|
#define TIMEFROMSTARTOUTREG1 (0x110)
|
||||||
|
|
||||||
|
#define TIMEFROMSTARTOUT1_OFST (0)
|
||||||
|
#define TIMEFROMSTARTOUT1_MSK (0xffffffff << TIMEFROMSTARTOUT1_OFST)
|
||||||
|
|
||||||
|
#define TIMEFROMSTARTOUTREG2 (0x114)
|
||||||
|
|
||||||
|
#define TIMEFROMSTARTOUT2_OFST (0)
|
||||||
|
#define TIMEFROMSTARTOUT2_MSK (0xffffffff << TIMEFROMSTARTOUT2_OFST)
|
||||||
|
|
||||||
|
#define FRAMESFROMSTARTOUTREG1 (0x118)
|
||||||
|
|
||||||
|
#define FRAMESFROMSTARTOUT1_OFST (0)
|
||||||
|
#define FRAMESFROMSTARTOUT1_MSK (0xffffffff << FRAMESFROMSTARTOUT1_OFST)
|
||||||
|
|
||||||
|
#define FRAMESFROMSTARTOUTREG2 (0x11C)
|
||||||
|
|
||||||
|
#define FRAMESFROMSTARTOUT2_OFST (0)
|
||||||
|
#define FRAMESFROMSTARTOUT2_MSK (0xffffffff << FRAMESFROMSTARTOUT2_OFST)
|
||||||
|
|
||||||
|
#define FRAMETIMEOUTREG1 (0x120)
|
||||||
|
|
||||||
|
#define FRAMETIMEOUT1_OFST (0)
|
||||||
|
#define FRAMETIMEOUT1_MSK (0xffffffff << FRAMETIMEOUT1_OFST)
|
||||||
|
|
||||||
|
#define FRAMETIMEOUTREG2 (0x124)
|
||||||
|
|
||||||
|
#define FRAMETIMEOUT2_OFST (0)
|
||||||
|
#define FRAMETIMEOUT2_MSK (0xffffffff << FRAMETIMEOUT2_OFST)
|
||||||
|
|
||||||
|
#define DELAYOUTREG1 (0x128)
|
||||||
|
|
||||||
|
#define DELAYOUT1_OFST (0)
|
||||||
|
#define DELAYOUT1_MSK (0xffffffff << DELAYOUT1_OFST)
|
||||||
|
|
||||||
|
#define DELAYOUTREG2 (0x12C)
|
||||||
|
|
||||||
|
#define DELAYOUT2_OFST (0)
|
||||||
|
#define DELAYOUT2_MSK (0xffffffff << DELAYOUT2_OFST)
|
||||||
|
|
||||||
|
#define CYCLESOUTREG1 (0x130)
|
||||||
|
|
||||||
|
#define CYCLESOUT1_OFST (0)
|
||||||
|
#define CYCLESOUT1_MSK (0xffffffff << CYCLESOUT1_OFST)
|
||||||
|
|
||||||
|
#define CYCLESOUTREG2 (0x134)
|
||||||
|
|
||||||
|
#define CYCLESOUT2_OFST (0)
|
||||||
|
#define CYCLESOUT2_MSK (0xffffffff << CYCLESOUT2_OFST)
|
||||||
|
|
||||||
|
#define FRAMESOUTREG1 (0x138)
|
||||||
|
|
||||||
|
#define FRAMESOUT1_OFST (0)
|
||||||
|
#define FRAMESOUT1_MSK (0xffffffff << FRAMESOUT1_OFST)
|
||||||
|
|
||||||
|
#define FRAMESOUTREG2 (0x13C)
|
||||||
|
|
||||||
|
#define FRAMESOUT2_OFST (0)
|
||||||
|
#define FRAMESOUT2_MSK (0xffffffff << FRAMESOUT2_OFST)
|
||||||
|
|
||||||
|
#define PERIODOUTREG1 (0x140)
|
||||||
|
|
||||||
|
#define PERIODOUT1_OFST (0)
|
||||||
|
#define PERIODOUT1_MSK (0xffffffff << PERIODOUT1_OFST)
|
||||||
|
|
||||||
|
#define PERIODOUTREG2 (0x144)
|
||||||
|
|
||||||
|
#define PERIODOUT2_OFST (0)
|
||||||
|
#define PERIODOUT2_MSK (0xffffffff << PERIODOUT2_OFST)
|
||||||
|
|
||||||
|
#define DELAYINREG1 (0x148)
|
||||||
|
|
||||||
|
#define DELAYIN1_OFST (0)
|
||||||
|
#define DELAYIN1_MSK (0xffffffff << DELAYIN1_OFST)
|
||||||
|
|
||||||
|
#define DELAYINREG2 (0x14C)
|
||||||
|
|
||||||
|
#define DELAYIN2_OFST (0)
|
||||||
|
#define DELAYIN2_MSK (0xffffffff << DELAYIN2_OFST)
|
||||||
|
|
||||||
|
#define CYCLESINREG1 (0x150)
|
||||||
|
|
||||||
|
#define CYCLESIN1_OFST (0)
|
||||||
|
#define CYCLESIN1_MSK (0xffffffff << CYCLESIN1_OFST)
|
||||||
|
|
||||||
|
#define CYCLESINREG2 (0x154)
|
||||||
|
|
||||||
|
#define CYCLESIN2_OFST (0)
|
||||||
|
#define CYCLESIN2_MSK (0xffffffff << CYCLESIN2_OFST)
|
||||||
|
|
||||||
|
#define FRAMESINREG1 (0x158)
|
||||||
|
|
||||||
|
#define FRAMESIN1_OFST (0)
|
||||||
|
#define FRAMESIN1_MSK (0xffffffff << FRAMESIN1_OFST)
|
||||||
|
|
||||||
|
#define FRAMESINREG2 (0x15C)
|
||||||
|
|
||||||
|
#define FRAMESIN2_OFST (0)
|
||||||
|
#define FRAMESIN2_MSK (0xffffffff << FRAMESIN2_OFST)
|
||||||
|
|
||||||
|
#define PERIODINREG1 (0x160)
|
||||||
|
|
||||||
|
#define PERIODIN1_OFST (0)
|
||||||
|
#define PERIODIN1_MSK (0xffffffff << PERIODIN1_OFST)
|
||||||
|
|
||||||
|
#define PERIODINREG2 (0x164)
|
||||||
|
|
||||||
|
#define PERIODIN2_OFST (0)
|
||||||
|
#define PERIODIN2_MSK (0xffffffff << PERIODIN2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNOUTREG0 (0x200)
|
||||||
|
|
||||||
|
#define PATTERNOUT0_OFST (0)
|
||||||
|
#define PATTERNOUT0_MSK (0xffffffff << PATTERNOUT0_OFST)
|
||||||
|
|
||||||
|
#define PATTERNOUTREG1 (0x204)
|
||||||
|
|
||||||
|
#define PATTERNOUT1_OFST (0)
|
||||||
|
#define PATTERNOUT1_MSK (0xffffffff << PATTERNOUT1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNINREG0 (0x208)
|
||||||
|
|
||||||
|
#define PATTERNIN0_OFST (0)
|
||||||
|
#define PATTERNIN0_MSK (0xffffffff << PATTERNIN0_OFST)
|
||||||
|
|
||||||
|
#define PATTERNINREG1 (0x20C)
|
||||||
|
|
||||||
|
#define PATTERNIN1_OFST (0)
|
||||||
|
#define PATTERNIN1_MSK (0xffffffff << PATTERNIN1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNIOMASKREG0 (0x210)
|
||||||
|
|
||||||
|
#define PATTERNIOMASK0_OFST (0)
|
||||||
|
#define PATTERNIOMASK0_MSK (0xffffffff << PATTERNIOMASK0_OFST)
|
||||||
|
|
||||||
|
#define PATTERNIOMASKREG1 (0x214)
|
||||||
|
|
||||||
|
#define PATTERNIOMASK1_OFST (0)
|
||||||
|
#define PATTERNIOMASK1_MSK (0xffffffff << PATTERNIOMASK1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNIOSETREG0 (0x218)
|
||||||
|
|
||||||
|
#define PATTERNIOSET0_OFST (0)
|
||||||
|
#define PATTERNIOSET0_MSK (0xffffffff << PATTERNIOSET0_OFST)
|
||||||
|
|
||||||
|
#define PATTERNIOSETREG1 (0x21C)
|
||||||
|
|
||||||
|
#define PATTERNIOSET1_OFST (0)
|
||||||
|
#define PATTERNIOSET1_MSK (0xffffffff << PATTERNIOSET1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNCONTROLREG (0x220)
|
||||||
|
|
||||||
|
#define PATTERNWRBIT_OFST (0)
|
||||||
|
#define PATTERNWRBIT_MSK (0x00000001 << PATTERNWRBIT_OFST)
|
||||||
|
#define PATTERNRDBIT_OFST (1)
|
||||||
|
#define PATTERNRDBIT_MSK (0x00000001 << PATTERNRDBIT_OFST)
|
||||||
|
#define PATTERNADDRESSPTR_OFST (16)
|
||||||
|
#define PATTERNADDRESSPTR_MSK (0x00001fff << PATTERNADDRESSPTR_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLIMITADDRESSREG (0x228)
|
||||||
|
|
||||||
|
#define PATTERNLIMITADDRESS_OFST (0)
|
||||||
|
#define PATTERNLIMITADDRESS_MSK (0xffffffff << PATTERNLIMITADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLOOP1ADDRESSREG (0x230)
|
||||||
|
|
||||||
|
#define PATTERNLOOP1ADDRESS_OFST (0)
|
||||||
|
#define PATTERNLOOP1ADDRESS_MSK (0xffffffff << PATTERNLOOP1ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS1REG (0x238)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS1_OFST (0)
|
||||||
|
#define PATTERNNLOOPS1_MSK (0xffffffff << PATTERNNLOOPS1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT1ADDRESSREG (0x240)
|
||||||
|
|
||||||
|
#define PATTERNWAIT1ADDRESS_OFST (0)
|
||||||
|
#define PATTERNWAIT1ADDRESS_MSK (0xffffffff << PATTERNWAIT1ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT1TIMEREG1 (0x248)
|
||||||
|
|
||||||
|
#define PATTERNWAIT1TIME1_OFST (0)
|
||||||
|
#define PATTERNWAIT1TIME1_MSK (0xffffffff << PATTERNWAIT1TIME1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT1TIMEREG2 (0x24C)
|
||||||
|
|
||||||
|
#define PATTERNWAIT1TIME2_OFST (0)
|
||||||
|
#define PATTERNWAIT1TIME2_MSK (0xffffffff << PATTERNWAIT1TIME2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLOOP2ADDRESSREG (0x250)
|
||||||
|
|
||||||
|
#define PATTERNLOOP2ADDRESS_OFST (0)
|
||||||
|
#define PATTERNLOOP2ADDRESS_MSK (0xffffffff << PATTERNLOOP2ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS2REG (0x258)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS2_OFST (0)
|
||||||
|
#define PATTERNNLOOPS2_MSK (0xffffffff << PATTERNNLOOPS2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT2ADDRESSREG (0x260)
|
||||||
|
|
||||||
|
#define PATTERNWAIT2ADDRESS_OFST (0)
|
||||||
|
#define PATTERNWAIT2ADDRESS_MSK (0xffffffff << PATTERNWAIT2ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT2TIMEREG1 (0x268)
|
||||||
|
|
||||||
|
#define PATTERNWAIT2TIME1_OFST (0)
|
||||||
|
#define PATTERNWAIT2TIME1_MSK (0xffffffff << PATTERNWAIT2TIME1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT2TIMEREG2 (0x26C)
|
||||||
|
|
||||||
|
#define PATTERNWAIT2TIME2_OFST (0)
|
||||||
|
#define PATTERNWAIT2TIME2_MSK (0xffffffff << PATTERNWAIT2TIME2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLOOP3ADDRESSREG (0x270)
|
||||||
|
|
||||||
|
#define PATTERNLOOP3ADDRESS_OFST (0)
|
||||||
|
#define PATTERNLOOP3ADDRESS_MSK (0xffffffff << PATTERNLOOP3ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS3REG (0x278)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS3_OFST (0)
|
||||||
|
#define PATTERNNLOOPS3_MSK (0xffffffff << PATTERNNLOOPS3_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT3ADDRESSREG (0x280)
|
||||||
|
|
||||||
|
#define PATTERNWAIT3ADDRESS_OFST (0)
|
||||||
|
#define PATTERNWAIT3ADDRESS_MSK (0xffffffff << PATTERNWAIT3ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT3TIMEREG1 (0x288)
|
||||||
|
|
||||||
|
#define PATTERNWAIT3TIME1_OFST (0)
|
||||||
|
#define PATTERNWAIT3TIME1_MSK (0xffffffff << PATTERNWAIT3TIME1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT3TIMEREG2 (0x28C)
|
||||||
|
|
||||||
|
#define PATTERNWAIT3TIME2_OFST (0)
|
||||||
|
#define PATTERNWAIT3TIME2_MSK (0xffffffff << PATTERNWAIT3TIME2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLOOP4ADDRESSREG (0x290)
|
||||||
|
|
||||||
|
#define PATTERNLOOP4ADDRESS_OFST (0)
|
||||||
|
#define PATTERNLOOP4ADDRESS_MSK (0xffffffff << PATTERNLOOP4ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS4REG (0x298)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS4_OFST (0)
|
||||||
|
#define PATTERNNLOOPS4_MSK (0xffffffff << PATTERNNLOOPS4_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT4ADDRESSREG (0x300)
|
||||||
|
|
||||||
|
#define PATTERNWAIT4ADDRESS_OFST (0)
|
||||||
|
#define PATTERNWAIT4ADDRESS_MSK (0xffffffff << PATTERNWAIT4ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT4TIMEREG1 (0x308)
|
||||||
|
|
||||||
|
#define PATTERNWAI4TIME1_OFST (0)
|
||||||
|
#define PATTERNWAI4TIME1_MSK (0xffffffff << PATTERNWAI4TIME1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT4TIMEREG2 (0x30C)
|
||||||
|
|
||||||
|
#define PATTERNWAIT4TIME2_OFST (0)
|
||||||
|
#define PATTERNWAIT4TIME2_MSK (0xffffffff << PATTERNWAIT4TIME2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLOOP5ADDRESSREG (0x310)
|
||||||
|
|
||||||
|
#define PATTERNLOOP5ADDRESS_OFST (0)
|
||||||
|
#define PATTERNLOOP5ADDRESS_MSK (0xffffffff << PATTERNLOOP5ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS5REG (0x318)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS5_OFST (0)
|
||||||
|
#define PATTERNNLOOPS5_MSK (0xffffffff << PATTERNNLOOPS5_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT5ADDRESSREG (0x320)
|
||||||
|
|
||||||
|
#define PATTERNWAIT5ADDRESS_OFST (0)
|
||||||
|
#define PATTERNWAIT5ADDRESS_MSK (0xffffffff << PATTERNWAIT5ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT5TIMEREG1 (0x328)
|
||||||
|
|
||||||
|
#define PATTERNWAIT5TIME1_OFST (0)
|
||||||
|
#define PATTERNWAIT5TIME1_MSK (0xffffffff << PATTERNWAIT5TIME1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT5TIMEREG2 (0x32C)
|
||||||
|
|
||||||
|
#define PATTERNWAIT5TIME2_OFST (0)
|
||||||
|
#define PATTERNWAIT5TIME2_MSK (0xffffffff << PATTERNWAIT5TIME2_OFST)
|
||||||
|
|
||||||
|
#define PATTERNLOOP6ADDRESSREG (0x330)
|
||||||
|
|
||||||
|
#define PATTERNLOOP6ADDRESS_OFST (0)
|
||||||
|
#define PATTERNLOOP6ADDRESS_MSK (0xffffffff << PATTERNLOOP6ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS6REG (0x338)
|
||||||
|
|
||||||
|
#define PATTERNNLOOPS6_OFST (0)
|
||||||
|
#define PATTERNNLOOPS6_MSK (0xffffffff << PATTERNNLOOPS6_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT6ADDRESSREG (0x340)
|
||||||
|
|
||||||
|
#define PATTERNWAIT6ADDRESS_OFST (0)
|
||||||
|
#define PATTERNWAIT6ADDRESS_MSK (0xffffffff << PATTERNWAIT6ADDRESS_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT6TIMEREG1 (0x348)
|
||||||
|
|
||||||
|
#define PATTERNWAIT6TIME1_OFST (0)
|
||||||
|
#define PATTERNWAIT6TIME1_MSK (0xffffffff << PATTERNWAIT6TIME1_OFST)
|
||||||
|
|
||||||
|
#define PATTERNWAIT6TIMEREG2 (0x34C)
|
||||||
|
|
||||||
|
#define PATTERNWAIT6TIME2_OFST (0)
|
||||||
|
#define PATTERNWAIT6TIME2_MSK (0xffffffff << PATTERNWAIT6TIME2_OFST)
|
||||||
|
|
||||||
|
#define EXPCTRLREG (0x400)
|
||||||
|
|
||||||
|
#define STARTP_OFST (0)
|
||||||
|
#define STARTP_MSK (0x00000001 << STARTP_OFST)
|
||||||
|
|
||||||
|
#define EXPFRAMESREG (0x408)
|
||||||
|
|
||||||
|
#define NOFRAMES_OFST (0)
|
||||||
|
#define NOFRAMES_MSK (0xffffffff << NOFRAMES_OFST)
|
||||||
|
|
||||||
|
#define EXPTIMEREG (0x410)
|
||||||
|
|
||||||
|
#define EXPTIME_OFST (0)
|
||||||
|
#define EXPTIME_MSK (0xffffffff << EXPTIME_OFST)
|
Binary file not shown.
@ -0,0 +1,211 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#include "slsDetectorFunctionList.h"
|
||||||
|
#include "arm64.h"
|
||||||
|
#include "clogger.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "sharedMemory.h"
|
||||||
|
#include "sls/versionAPI.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h> // usleep
|
||||||
|
#include <arpa/inet.h> // INET_ADDRSTRLEN
|
||||||
|
|
||||||
|
|
||||||
|
// Global variable from slsDetectorServer_funcs
|
||||||
|
extern int debugflag;
|
||||||
|
extern int updateFlag;
|
||||||
|
extern const enum detectorType myDetectorType;
|
||||||
|
|
||||||
|
// Global variable from communication_funcs.c
|
||||||
|
extern int isControlServer;
|
||||||
|
|
||||||
|
int initError = OK;
|
||||||
|
int initCheckDone = 0;
|
||||||
|
char initErrorMessage[MAX_STR_LENGTH];
|
||||||
|
|
||||||
|
int detPos[2] = {0, 0};
|
||||||
|
|
||||||
|
int isInitCheckDone() { return initCheckDone; }
|
||||||
|
|
||||||
|
int getInitResult(char **mess) {
|
||||||
|
*mess = initErrorMessage;
|
||||||
|
return initError;
|
||||||
|
}
|
||||||
|
|
||||||
|
void basictests() {
|
||||||
|
initError = OK;
|
||||||
|
initCheckDone = 0;
|
||||||
|
memset(initErrorMessage, 0, MAX_STR_LENGTH);
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
LOG(logINFOBLUE, ("****** Xilinx Chip Test Board Virtual Server ******\n"));
|
||||||
|
#else
|
||||||
|
LOG(logINFOBLUE, ("********** Xilinx Chip Test Board Server **********\n"));
|
||||||
|
#endif
|
||||||
|
if (mapCSP0() == FAIL) {
|
||||||
|
strcpy(initErrorMessage,
|
||||||
|
"Could not map to memory. Cannot proceed. Check Firmware.\n");
|
||||||
|
LOG(logERROR, (initErrorMessage));
|
||||||
|
initError = FAIL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef VIRTUAL
|
||||||
|
/*if ((!debugflag) && (!updateFlag) &&
|
||||||
|
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
|
||||||
|
(checkType() == FAIL) || (testFpga() == FAIL) ||
|
||||||
|
(testBus() == FAIL))) {*/
|
||||||
|
if ((!debugflag) && (!updateFlag) &&
|
||||||
|
((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) ||
|
||||||
|
(checkType() == FAIL) /*|| (testFpga() == FAIL) ||
|
||||||
|
(testBus() == FAIL)*/)) {
|
||||||
|
sprintf(initErrorMessage,
|
||||||
|
"Could not pass basic tests of FPGA and bus. Cannot proceed. "
|
||||||
|
"Check Firmware. (Firmware version:0x%lx) \n",
|
||||||
|
getFirmwareVersion());
|
||||||
|
LOG(logERROR, ("%s\n\n", initErrorMessage));
|
||||||
|
initError = FAIL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
uint32_t ipadd = getDetectorIP();
|
||||||
|
uint64_t macadd = getDetectorMAC();
|
||||||
|
int64_t fwversion = getFirmwareVersion();
|
||||||
|
char swversion[MAX_STR_LENGTH] = {0};
|
||||||
|
memset(swversion, 0, MAX_STR_LENGTH);
|
||||||
|
getServerVersion(swversion);
|
||||||
|
uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN;
|
||||||
|
|
||||||
|
LOG(logINFOBLUE,
|
||||||
|
("**************************************************\n"
|
||||||
|
"Detector IP Addr:\t\t 0x%x\n"
|
||||||
|
"Detector MAC Addr:\t\t 0x%lx\n\n"
|
||||||
|
|
||||||
|
"Firmware Version:\t\t 0x%lx\n"
|
||||||
|
"Software Version:\t\t %s\n"
|
||||||
|
"Required Firmware Version:\t 0x%x\n"
|
||||||
|
"********************************************************\n",
|
||||||
|
ipadd, macadd, fwversion, swversion, requiredFirmwareVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
int checkType() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return OK;
|
||||||
|
#endif
|
||||||
|
u_int32_t type =
|
||||||
|
((bus_r(FPGAVERSIONREG) & DETTYPE_MSK) >> DETTYPE_OFST);
|
||||||
|
if (type != XILINX_CHIPTESTBOARD) {
|
||||||
|
LOG(logERROR,
|
||||||
|
("This is not a Xilinx CTB firmware (read %d, expected %d)\n", type,
|
||||||
|
XILINX_CHIPTESTBOARD));
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ids */
|
||||||
|
|
||||||
|
void getServerVersion(char *version) { strcpy(version, APIXILINXCTB); }
|
||||||
|
|
||||||
|
uint64_t getFirmwareVersion() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return REQRD_FRMWRE_VRSN;
|
||||||
|
#endif
|
||||||
|
return ((bus_r(FPGAVERSIONREG) & COMPDATE_MSK) >> COMPDATE_OFST);
|
||||||
|
}
|
||||||
|
|
||||||
|
u_int64_t getDetectorMAC() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
char output[255], mac[255] = "";
|
||||||
|
u_int64_t res = 0;
|
||||||
|
FILE *sysFile =
|
||||||
|
popen("ifconfig eth0 | grep ether | awk '{ print $2 }'", "r");
|
||||||
|
fgets(output, sizeof(output), sysFile);
|
||||||
|
pclose(sysFile);
|
||||||
|
// getting rid of ":"
|
||||||
|
char *pch;
|
||||||
|
pch = strtok(output, ":");
|
||||||
|
while (pch != NULL) {
|
||||||
|
strcat(mac, pch);
|
||||||
|
pch = strtok(NULL, ":");
|
||||||
|
}
|
||||||
|
sscanf(mac, "%lx", &res);
|
||||||
|
return res;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
u_int32_t getDetectorIP() {
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
char temp[INET_ADDRSTRLEN] = "";
|
||||||
|
u_int32_t res = 0;
|
||||||
|
// execute and get address
|
||||||
|
char output[255];
|
||||||
|
FILE *sysFile = popen(
|
||||||
|
"ifconfig | grep 'inet '| grep -v '127.0.0.1' | awk '{ print $2 }'",
|
||||||
|
"r");
|
||||||
|
fgets(output, sizeof(output), sysFile);
|
||||||
|
pclose(sysFile);
|
||||||
|
|
||||||
|
// converting IPaddress to hex.
|
||||||
|
char *pcword = strtok(output, ".");
|
||||||
|
while (pcword != NULL) {
|
||||||
|
sprintf(output, "%02x", atoi(pcword));
|
||||||
|
strcat(temp, output);
|
||||||
|
pcword = strtok(NULL, ".");
|
||||||
|
}
|
||||||
|
strcpy(output, temp);
|
||||||
|
sscanf(output, "%x", &res);
|
||||||
|
// LOG(logINFO, ("ip:%x\n",res);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialization */
|
||||||
|
|
||||||
|
void initControlServer() {
|
||||||
|
if (!updateFlag && initError == OK) {
|
||||||
|
setupDetector();
|
||||||
|
}
|
||||||
|
initCheckDone = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initStopServer() {
|
||||||
|
if (!updateFlag && initError == OK) {
|
||||||
|
usleep(CTRL_SRVR_INIT_TIME_US);
|
||||||
|
if (mapCSP0() == FAIL) {
|
||||||
|
initError = FAIL;
|
||||||
|
strcpy(initErrorMessage,
|
||||||
|
"Stop Server: Map Fail. Cannot proceed. Check Firmware.\n");
|
||||||
|
LOG(logERROR, (initErrorMessage));
|
||||||
|
initCheckDone = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStop(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
initCheckDone = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set up detector */
|
||||||
|
|
||||||
|
void setupDetector() {
|
||||||
|
LOG(logINFO, ("This Server is for 1 Xilinx Chip Test Board\n"));
|
||||||
|
#ifdef VIRTUAL
|
||||||
|
sharedMemory_setStatus(IDLE);
|
||||||
|
#endif
|
||||||
|
LOG(logINFO, ("Goodbye...\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int setDetectorPosition(int pos[]) {
|
||||||
|
memcpy(detPos, pos, sizeof(detPos));
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int *getDetectorPosition() { return detPos; }
|
||||||
|
|
||||||
|
int getNumberofUDPInterfaces() { return 1; }
|
@ -0,0 +1,18 @@
|
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||||
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||||
|
#pragma once
|
||||||
|
#include "RegisterDefs.h"
|
||||||
|
#include "sls/sls_detector_defs.h"
|
||||||
|
|
||||||
|
#define REQRD_FRMWRE_VRSN (0x230000)
|
||||||
|
#define KERNEL_DATE_VRSN "Wed Nov 29 17:32:14 CET 2023"
|
||||||
|
|
||||||
|
#define LINKED_SERVER_NAME "xilinx_ctbDetectorServer"
|
||||||
|
|
||||||
|
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
|
||||||
|
|
||||||
|
/* Hardware Definitions */
|
||||||
|
#define NCHAN (1)
|
||||||
|
|
||||||
|
enum ADCINDEX { V_PWR_IO };
|
||||||
|
enum DACINDEX { D0 };
|
@ -4,10 +4,13 @@ set(SOURCES
|
|||||||
src/DetectorImpl.cpp
|
src/DetectorImpl.cpp
|
||||||
src/Module.cpp
|
src/Module.cpp
|
||||||
src/Detector.cpp
|
src/Detector.cpp
|
||||||
src/CmdProxy.cpp
|
src/HelpDacs.cpp
|
||||||
src/CmdParser.cpp
|
src/CmdParser.cpp
|
||||||
src/Pattern.cpp
|
src/Pattern.cpp
|
||||||
src/CtbConfig.cpp
|
src/CtbConfig.cpp
|
||||||
|
src/Caller.cpp
|
||||||
|
src/CallerSpecial.cpp
|
||||||
|
src/inferAction.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(slsDetectorObject OBJECT
|
add_library(slsDetectorObject OBJECT
|
||||||
@ -76,27 +79,30 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
if(SLS_USE_TEXTCLIENT)
|
if(SLS_USE_TEXTCLIENT)
|
||||||
# Loop over list to generate command line binaries
|
set(det_bin_names "sls_detector_put"
|
||||||
set(bin_names "sls_detector_put"
|
|
||||||
"sls_detector_get"
|
"sls_detector_get"
|
||||||
"sls_detector_acquire"
|
"sls_detector_acquire"
|
||||||
"sls_detector_acquire_zmq"
|
"sls_detector_help"
|
||||||
"sls_detector_help")
|
"sls_detector"
|
||||||
set(cmd_name "PUT" "GET" "READOUT" "READOUTZMQ" "HELP")
|
)
|
||||||
list(LENGTH bin_names len1)
|
set(det_cmd_name "PUT" "GET" "READOUT" "HELP" "INFER")
|
||||||
|
list(LENGTH det_bin_names len1)
|
||||||
math(EXPR len2 "${len1} - 1")
|
math(EXPR len2 "${len1} - 1")
|
||||||
|
|
||||||
foreach(val RANGE ${len2})
|
foreach(val RANGE ${len2})
|
||||||
list(GET bin_names ${val} val1)
|
list(GET det_bin_names ${val} val1)
|
||||||
list(GET cmd_name ${val} val2)
|
list(GET det_cmd_name ${val} val2)
|
||||||
message(STATUS "${val1} ${val2}")
|
message(STATUS "${val1} ${val2}")
|
||||||
|
|
||||||
add_executable(${val1} src/CmdLineApp.cpp)
|
add_executable(${val1} src/CmdApp.cpp)
|
||||||
|
|
||||||
target_link_libraries(${val1}
|
target_link_libraries(${val1}
|
||||||
slsDetectorStatic
|
slsDetectorStatic
|
||||||
pthread
|
pthread
|
||||||
rt
|
rt
|
||||||
)
|
)
|
||||||
|
SET_SOURCE_FILES_PROPERTIES( src/Caller.cpp PROPERTIES COMPILE_FLAGS "-Wno-unused-variable -Wno-unused-but-set-variable")
|
||||||
|
|
||||||
set_target_properties(${val1} PROPERTIES
|
set_target_properties(${val1} PROPERTIES
|
||||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||||
COMPILE_DEFINITIONS ${val2}=1
|
COMPILE_DEFINITIONS ${val2}=1
|
||||||
@ -105,7 +111,8 @@ if(SLS_USE_TEXTCLIENT)
|
|||||||
set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
set_property(TARGET ${val1} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
install(TARGETS ${bin_names} DESTINATION bin)
|
install(TARGETS ${det_bin_names} DESTINATION bin)
|
||||||
|
|
||||||
|
|
||||||
endif(SLS_USE_TEXTCLIENT)
|
endif(SLS_USE_TEXTCLIENT)
|
||||||
|
|
||||||
|
10
slsDetectorSoftware/generator/Caller.in.cpp
Normal file
10
slsDetectorSoftware/generator/Caller.in.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include "Caller.h"
|
||||||
|
#include "sls/logger.h"
|
||||||
|
#include "sls/string_utils.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE
|
||||||
|
|
||||||
|
}
|
88
slsDetectorSoftware/generator/Caller.in.h
Normal file
88
slsDetectorSoftware/generator/Caller.in.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// This file is used as input to generate the caller class
|
||||||
|
|
||||||
|
#include "CmdParser.h"
|
||||||
|
#include "HelpDacs.h"
|
||||||
|
#include "sls/Detector.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
class Caller {
|
||||||
|
public:
|
||||||
|
Caller(Detector *ptr) : det(ptr) {}
|
||||||
|
void call(const std::string &command,
|
||||||
|
const std::vector<std::string> &arguments, int detector_id,
|
||||||
|
int action, std::ostream &os = std::cout, int receiver_id = -1);
|
||||||
|
|
||||||
|
IpAddr getDstIpFromAuto();
|
||||||
|
IpAddr getSrcIpFromAuto();
|
||||||
|
UdpDestination getUdpEntry();
|
||||||
|
void GetLevelAndUpdateArgIndex(int action,
|
||||||
|
std::string levelSeparatedCommand,
|
||||||
|
int &level, int &iArg, size_t nGetArgs,
|
||||||
|
size_t nPutArgs);
|
||||||
|
void WrongNumberOfParameters(size_t expected);
|
||||||
|
|
||||||
|
template <typename V> std::string OutStringHex(const V &value) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToStringHex(value.front());
|
||||||
|
return ToStringHex(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutStringHex(const V &value, int width) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToStringHex(value.front(), width);
|
||||||
|
return ToStringHex(value, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutString(const Result<V> &value) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToString(value.front());
|
||||||
|
return ToString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutString(const V &value) {
|
||||||
|
return ToString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V>
|
||||||
|
std::string OutString(const V &value, const std::string &unit) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToString(value.front(), unit);
|
||||||
|
return ToString(value, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> getAllCommands();
|
||||||
|
std::string list(int action);
|
||||||
|
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1)
|
||||||
|
|
||||||
|
std::vector<std::string> args;
|
||||||
|
std::string cmd;
|
||||||
|
Detector *det;
|
||||||
|
int det_id{-1};
|
||||||
|
int rx_id{-1};
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool ReplaceIfDepreciated(std::string &command);
|
||||||
|
using FunctionMap = std::map<std::string, std::string (Caller::*)(int)>;
|
||||||
|
using StringMap = std::map<std::string, std::string>;
|
||||||
|
Detector *ptr; // pointer to the detector that executes the command
|
||||||
|
|
||||||
|
FunctionMap functions{
|
||||||
|
{"list", &Caller::list},
|
||||||
|
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2)
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
StringMap depreciated_functions{
|
||||||
|
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (3)
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
236
slsDetectorSoftware/generator/autocomplete/autocomplete.py
Normal file
236
slsDetectorSoftware/generator/autocomplete/autocomplete.py
Normal file
@ -0,0 +1,236 @@
|
|||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# command to generate the ast
|
||||||
|
# clang version: 14.0.0-1ubuntu1.1
|
||||||
|
# clang++ -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang StringTo -c ToString.cpp -I ../include/ -std=gnu++11
|
||||||
|
#
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
AUTOCOMPLETE_PATH = Path(__file__).parent
|
||||||
|
DUMP_PATH = AUTOCOMPLETE_PATH / 'dump.json'
|
||||||
|
FIXED_PATH = AUTOCOMPLETE_PATH / 'fixed.json'
|
||||||
|
|
||||||
|
type_values = {
|
||||||
|
'special::mv': ["mv", "mV"],
|
||||||
|
"special::deg": ["deg"],
|
||||||
|
"special::time_unit": ["s", "ms", "us", "ns"],
|
||||||
|
"special::hard": ["hard"],
|
||||||
|
"special::force-delete-normal-file": ["--force-delete-normal-file"],
|
||||||
|
"special::currentSourceFix": ["fix", "nofix"],
|
||||||
|
"special::currentSourceLow": ["normal", "low"],
|
||||||
|
"special::path": [],
|
||||||
|
"special::pedestal_parameters" : ["", "0"]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_types(arg_types):
|
||||||
|
ret = set()
|
||||||
|
for arg_type in arg_types:
|
||||||
|
if type_info(arg_type) == 'base':
|
||||||
|
if arg_type == 'bool':
|
||||||
|
ret = ret.union(["0", "1"])
|
||||||
|
else:
|
||||||
|
tmp = [not_list for not_list in type_values[arg_type] if not isinstance(not_list, list)]
|
||||||
|
ret = ret.union(tmp)
|
||||||
|
|
||||||
|
#Intercept the options and in case detector specific options appear replace the
|
||||||
|
#list of options with a command line call that fetches them
|
||||||
|
#TODO! Rename sls_detector_get
|
||||||
|
if "defs::dacIndex" in arg_types:
|
||||||
|
return "`sls_detector_get daclist | sed -e 's/.*\[\(.*\)\].*/\\1/' | sed 's/,//g'`"
|
||||||
|
elif "defs::detectorSettings" in arg_types:
|
||||||
|
return "`sls_detector_get settingslist | sed -e 's/.*\[\(.*\)\].*/\\1/' | sed 's/,//g'`"
|
||||||
|
elif "defs::timingMode" in arg_types:
|
||||||
|
return "`sls_detector_get timinglist | sed -e 's/.*\[\(.*\)\].*/\\1/' | sed 's/,//g'`"
|
||||||
|
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def type_info(type_name):
|
||||||
|
if type_name.startswith('defs::') or type_name.startswith('slsDetectorDefs::'):
|
||||||
|
return 'enum'
|
||||||
|
if type_name.startswith('special::'):
|
||||||
|
return 'special'
|
||||||
|
return 'base'
|
||||||
|
|
||||||
|
|
||||||
|
def get_enum(function):
|
||||||
|
return function['type']['qualType'].split(' ')[0]
|
||||||
|
|
||||||
|
|
||||||
|
def get_literal(ifstmt):
|
||||||
|
stringliteral = []
|
||||||
|
expression = ifstmt['inner'][0]
|
||||||
|
if expression['kind'] == 'BinaryOperator':
|
||||||
|
if expression['opcode'] == '!=':
|
||||||
|
return None, None
|
||||||
|
for cxxOperatorCall in expression['inner']:
|
||||||
|
if cxxOperatorCall['kind'] == 'CXXOperatorCallExpr':
|
||||||
|
implicitCastExpr = cxxOperatorCall['inner'][2]
|
||||||
|
stringliteral.append(implicitCastExpr['inner'][0]['value'][1:-1])
|
||||||
|
else:
|
||||||
|
cxxOperatorCall = expression
|
||||||
|
implicitCastExpr = cxxOperatorCall['inner'][2]
|
||||||
|
stringliteral = implicitCastExpr['inner'][0]['value'][1:-1]
|
||||||
|
|
||||||
|
retstmt = get_object_by_kind(ifstmt['inner'], 'ReturnStmt')
|
||||||
|
declrefexpt = get_object_by_kind(retstmt['inner'], 'DeclRefExpr')
|
||||||
|
enum_val = declrefexpt["referencedDecl"]["name"]
|
||||||
|
|
||||||
|
return enum_val, stringliteral
|
||||||
|
|
||||||
|
|
||||||
|
def get_object_by_kind(inner, kind, position=1):
|
||||||
|
for obj in inner:
|
||||||
|
if obj['kind'] == kind:
|
||||||
|
position -= 1
|
||||||
|
if position == 0:
|
||||||
|
return obj
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def generate_type_values():
|
||||||
|
functions = json.loads(FIXED_PATH.read_text())
|
||||||
|
for function in functions:
|
||||||
|
if function['kind'] != 'FunctionDecl' or function['name'] != 'StringTo':
|
||||||
|
continue
|
||||||
|
enum = get_enum(function)
|
||||||
|
|
||||||
|
if not enum.startswith('defs::'):
|
||||||
|
continue
|
||||||
|
# if enum != 'defs::dacIndex':
|
||||||
|
# continue
|
||||||
|
if not function['loc']['file'].endswith('ToString.cpp'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
compound_stmt = get_object_by_kind(function['inner'], 'CompoundStmt')
|
||||||
|
|
||||||
|
for ifstmt in compound_stmt['inner']:
|
||||||
|
if ifstmt['kind'] != 'IfStmt':
|
||||||
|
continue
|
||||||
|
enum_val, stringliteral = get_literal(ifstmt)
|
||||||
|
if enum_val is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if enum not in type_values or type_values[enum] is None:
|
||||||
|
type_values[enum] = []
|
||||||
|
type_values[enum].append(stringliteral)
|
||||||
|
items = list(type_values.items())
|
||||||
|
for key, val in items:
|
||||||
|
if key.startswith('defs::'):
|
||||||
|
new_key = key.split('::')[1]
|
||||||
|
new_key = 'slsDetectorDefs::' + new_key
|
||||||
|
type_values[new_key] = val
|
||||||
|
elif key.startswith('slsDetectorDefs::'):
|
||||||
|
new_key = key.split('::')[1]
|
||||||
|
new_key = 'defs::' + new_key
|
||||||
|
type_values[new_key] = val
|
||||||
|
|
||||||
|
return json.dumps(type_values, indent=2)
|
||||||
|
|
||||||
|
|
||||||
|
def fix_json():
|
||||||
|
with DUMP_PATH.open('r') as f:
|
||||||
|
tmp = '[\n'
|
||||||
|
for line in f.read().split('\n'):
|
||||||
|
if line.startswith('}'):
|
||||||
|
tmp += line + ',\n'
|
||||||
|
else:
|
||||||
|
tmp += line + '\n'
|
||||||
|
tmp = tmp[:-3] + '\n]'
|
||||||
|
with FIXED_PATH.open('w') as f:
|
||||||
|
f.write(tmp)
|
||||||
|
|
||||||
|
|
||||||
|
def generate_bash_autocomplete(output_path=Path(__file__).parent / 'bash_autocomplete.sh', input_path=Path(__file__).parent / 'bash_autocomplete.in.sh'):
|
||||||
|
generate_type_values()
|
||||||
|
output_file = output_path.open('w')
|
||||||
|
template_file = input_path.open('r')
|
||||||
|
|
||||||
|
def writeline(line):
|
||||||
|
output_file.write(line + '\n')
|
||||||
|
|
||||||
|
class if_block:
|
||||||
|
def __init__(self, condition):
|
||||||
|
self.condition = condition
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
output_file.write('if [[ ' + self.condition + ' ]]; then\n')
|
||||||
|
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
output_file.write('fi\n')
|
||||||
|
|
||||||
|
class function:
|
||||||
|
def __init__(self, name):
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
output_file.write(self.name + '() {\n')
|
||||||
|
|
||||||
|
def __exit__(self, type, value, traceback):
|
||||||
|
output_file.write('}\n')
|
||||||
|
|
||||||
|
command_path = Path(__file__).parent.parent / 'extended_commands.yaml'
|
||||||
|
commands = yaml.unsafe_load(command_path.open('r'))
|
||||||
|
|
||||||
|
for line in template_file:
|
||||||
|
if '-- THIS LINE WILL BE REPLACED WITH GENERATED CODE --' not in line:
|
||||||
|
output_file.write(line)
|
||||||
|
continue
|
||||||
|
writeline(f'local SLS_COMMANDS=" {" ".join(commands.keys())} "')
|
||||||
|
# generate functions
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
# added for debugging
|
||||||
|
if command_name == 'xxxexptime':
|
||||||
|
continue
|
||||||
|
with function('__' + command_name):
|
||||||
|
writeline('FCN_RETURN=""')
|
||||||
|
|
||||||
|
actions = ['GET', 'PUT']
|
||||||
|
for action in actions:
|
||||||
|
if action in command['actions'] and 'args' in command['actions'][action]:
|
||||||
|
args = command['actions'][action]['args']
|
||||||
|
possible_argc = {}
|
||||||
|
for arg in args:
|
||||||
|
if arg['argc'] == 0:
|
||||||
|
pass
|
||||||
|
for i in range(arg['argc']):
|
||||||
|
if i + 1 not in possible_argc:
|
||||||
|
possible_argc[i + 1] = []
|
||||||
|
possible_argc[i + 1].append(arg['arg_types'][i])
|
||||||
|
if possible_argc:
|
||||||
|
with if_block(f'${{IS_GET}} -eq {"1" if action == "GET" else "0"}'):
|
||||||
|
for argc in possible_argc:
|
||||||
|
with if_block(f'"${{cword}}" == "{argc + 1}"'):
|
||||||
|
if "defs::detectorSettings" in possible_argc[argc]:
|
||||||
|
print(argc, command_name, possible_argc[argc])
|
||||||
|
choices = get_types(possible_argc[argc])
|
||||||
|
|
||||||
|
#check if we got choices back or a bash command
|
||||||
|
if isinstance(choices, (list,set)):
|
||||||
|
writeline(f'FCN_RETURN="{" ".join(sorted(choices))}"')
|
||||||
|
else:
|
||||||
|
writeline(f'FCN_RETURN="{choices}"')
|
||||||
|
if 'special::path' in possible_argc[argc]:
|
||||||
|
writeline('IS_PATH=1')
|
||||||
|
|
||||||
|
writeline('return 0')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
output_file.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(description='use parsed c++ code to generate autocomplete snippets')
|
||||||
|
parser.add_argument('-f', '--fix', action='store_true', help='fix the parsed ast to make it loadable')
|
||||||
|
# parser.add_argument('-p', '--path', type=str, help='output path to the fixed ast', default='ast.json')
|
||||||
|
args = parser.parse_known_args()
|
||||||
|
if args[0].fix:
|
||||||
|
fix_json()
|
||||||
|
ret = generate_type_values()
|
||||||
|
print(ret)
|
@ -0,0 +1,167 @@
|
|||||||
|
# GENERATED FILE - DO NOT EDIT
|
||||||
|
# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN
|
||||||
|
|
||||||
|
_sd() {
|
||||||
|
|
||||||
|
# Taken from https://github.com/scop/bash-completion/blob/15b74b1050333f425877a7cbd99af2998b95c476/bash_completion#L770C12-L770C12
|
||||||
|
# Reassemble command line words, excluding specified characters from the
|
||||||
|
# list of word completion separators (COMP_WORDBREAKS).
|
||||||
|
# @param $1 chars Characters out of $COMP_WORDBREAKS which should
|
||||||
|
# NOT be considered word breaks. This is useful for things like scp where
|
||||||
|
# we want to return host:path and not only path, so we would pass the
|
||||||
|
# colon (:) as $1 here.
|
||||||
|
# @param $2 words Name of variable to return words to
|
||||||
|
# @param $3 cword Name of variable to return cword to
|
||||||
|
#
|
||||||
|
_comp__reassemble_words()
|
||||||
|
{
|
||||||
|
local exclude="" i j line ref
|
||||||
|
# Exclude word separator characters?
|
||||||
|
if [[ $1 ]]; then
|
||||||
|
# Yes, exclude word separator characters;
|
||||||
|
# Exclude only those characters, which were really included
|
||||||
|
exclude="[${1//[^$COMP_WORDBREAKS]/}]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default to cword unchanged
|
||||||
|
printf -v "$3" %s "$COMP_CWORD"
|
||||||
|
# Are characters excluded which were former included?
|
||||||
|
if [[ $exclude ]]; then
|
||||||
|
# Yes, list of word completion separators has shrunk;
|
||||||
|
line=$COMP_LINE
|
||||||
|
# Re-assemble words to complete
|
||||||
|
for ((i = 0, j = 0; i < ${#COMP_WORDS[@]}; i++, j++)); do
|
||||||
|
# Is current word not word 0 (the command itself) and is word not
|
||||||
|
# empty and is word made up of just word separator characters to
|
||||||
|
# be excluded and is current word not preceded by whitespace in
|
||||||
|
# original line?
|
||||||
|
while [[ $i -gt 0 && ${COMP_WORDS[i]} == +($exclude) ]]; do
|
||||||
|
# Is word separator not preceded by whitespace in original line
|
||||||
|
# and are we not going to append to word 0 (the command
|
||||||
|
# itself), then append to current word.
|
||||||
|
[[ $line != [[:blank:]]* ]] && ((j >= 2)) && ((j--))
|
||||||
|
# Append word separator to current or new word
|
||||||
|
ref="$2[$j]"
|
||||||
|
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||||
|
# Indicate new cword
|
||||||
|
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||||
|
# Remove optional whitespace + word separator from line copy
|
||||||
|
line=${line#*"${COMP_WORDS[i]}"}
|
||||||
|
# Indicate next word if available, else end *both* while and
|
||||||
|
# for loop
|
||||||
|
if ((i < ${#COMP_WORDS[@]} - 1)); then
|
||||||
|
((i++))
|
||||||
|
else
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
# Start new word if word separator in original line is
|
||||||
|
# followed by whitespace.
|
||||||
|
[[ $line == [[:blank:]]* ]] && ((j++))
|
||||||
|
done
|
||||||
|
# Append word to current word
|
||||||
|
ref="$2[$j]"
|
||||||
|
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||||
|
# Remove optional whitespace + word from line copy
|
||||||
|
line=${line#*"${COMP_WORDS[i]}"}
|
||||||
|
# Indicate new cword
|
||||||
|
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||||
|
done
|
||||||
|
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||||
|
else
|
||||||
|
# No, list of word completions separators hasn't changed;
|
||||||
|
for i in "${!COMP_WORDS[@]}"; do
|
||||||
|
printf -v "$2[i]" %s "${COMP_WORDS[i]}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
local FCN_RETURN=""
|
||||||
|
local IS_PATH=0
|
||||||
|
|
||||||
|
|
||||||
|
# -- THIS LINE WILL BE REPLACED WITH GENERATED CODE --
|
||||||
|
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
local OPTIONS_NEW=""
|
||||||
|
|
||||||
|
# check if bash or zsh
|
||||||
|
# _get_comp_words_by_ref is a bash built-in function, we check if it exists
|
||||||
|
declare -Ff _get_comp_words_by_ref > /dev/null && IS_BASH=1 || IS_BASH=0
|
||||||
|
|
||||||
|
|
||||||
|
# bash interprets the colon character : as a special character and splits the argument in two
|
||||||
|
# different than what zsh does
|
||||||
|
# https://stackoverflow.com/a/3224910
|
||||||
|
# https://stackoverflow.com/a/12495727
|
||||||
|
local cur
|
||||||
|
local cword words=()
|
||||||
|
_comp__reassemble_words ":" words cword
|
||||||
|
cur=${words[cword]}
|
||||||
|
|
||||||
|
# check the action (get or put)
|
||||||
|
case "${words[0]}" in
|
||||||
|
"sls_detector_get" | "g" | "detg")
|
||||||
|
local IS_GET=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
local IS_GET=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# if no command is written, autocomplete with the commands
|
||||||
|
if [[ ${cword} -eq 1 ]]; then
|
||||||
|
# local SLS_COMMANDS="trimbits exptime"
|
||||||
|
local SLS_COMMANDS_NEW=""
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
[0-9]*:*)
|
||||||
|
local suggestions=($(compgen -W "${SLS_COMMANDS}" -- "${cur#*:}"))
|
||||||
|
COMPREPLY=( ${suggestions[*]} )
|
||||||
|
;;
|
||||||
|
[0-9]*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=( $( compgen -W "$SLS_COMMANDS -h" -- "$cur" ) );;
|
||||||
|
|
||||||
|
esac
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${cword} -eq 2 ]] && [[ ${words[1]} == "-h" ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W "$SLS_COMMANDS" -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if a command is written, autocomplete with the options
|
||||||
|
# call the function for the command
|
||||||
|
|
||||||
|
if [[ "$SLS_COMMANDS" == *"${words[1]##*:}"* ]]; then
|
||||||
|
__"${words[1]##*:}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if IS_PATH is activated, autocomplete with the path
|
||||||
|
if [[ ${IS_PATH} -eq 1 ]]; then
|
||||||
|
COMPREPLY=($(compgen -f -- "${cur}"))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# autocomplete with the options
|
||||||
|
COMPREPLY=($(compgen -W "${FCN_RETURN}" -- "${cur}"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector_get
|
||||||
|
complete -F _sd -o filenames g
|
||||||
|
complete -F _sd -o filenames detg
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector_put
|
||||||
|
complete -F _sd -o filenames p
|
||||||
|
complete -F _sd -o filenames detp
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector
|
||||||
|
complete -F _sd -o filenames det
|
3255
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
Normal file
3255
slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh
Normal file
File diff suppressed because it is too large
Load Diff
62035
slsDetectorSoftware/generator/autocomplete/dump.json
Normal file
62035
slsDetectorSoftware/generator/autocomplete/dump.json
Normal file
File diff suppressed because it is too large
Load Diff
62037
slsDetectorSoftware/generator/autocomplete/fixed.json
Normal file
62037
slsDetectorSoftware/generator/autocomplete/fixed.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,177 @@
|
|||||||
|
#### simpler version of autocomplete.sh to understand the logic
|
||||||
|
#### each command has its own function when called it will produce the possible values for autocompletion
|
||||||
|
|
||||||
|
|
||||||
|
_sd() {
|
||||||
|
|
||||||
|
# Reassemble command line words, excluding specified characters from the
|
||||||
|
# list of word completion separators (COMP_WORDBREAKS).
|
||||||
|
# @param $1 chars Characters out of $COMP_WORDBREAKS which should
|
||||||
|
# NOT be considered word breaks. This is useful for things like scp where
|
||||||
|
# we want to return host:path and not only path, so we would pass the
|
||||||
|
# colon (:) as $1 here.
|
||||||
|
# @param $2 words Name of variable to return words to
|
||||||
|
# @param $3 cword Name of variable to return cword to
|
||||||
|
#
|
||||||
|
_comp__reassemble_words()
|
||||||
|
{
|
||||||
|
local exclude="" i j line ref
|
||||||
|
# Exclude word separator characters?
|
||||||
|
if [[ $1 ]]; then
|
||||||
|
# Yes, exclude word separator characters;
|
||||||
|
# Exclude only those characters, which were really included
|
||||||
|
exclude="[${1//[^$COMP_WORDBREAKS]/}]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default to cword unchanged
|
||||||
|
printf -v "$3" %s "$COMP_CWORD"
|
||||||
|
# Are characters excluded which were former included?
|
||||||
|
if [[ $exclude ]]; then
|
||||||
|
# Yes, list of word completion separators has shrunk;
|
||||||
|
line=$COMP_LINE
|
||||||
|
# Re-assemble words to complete
|
||||||
|
for ((i = 0, j = 0; i < ${#COMP_WORDS[@]}; i++, j++)); do
|
||||||
|
# Is current word not word 0 (the command itself) and is word not
|
||||||
|
# empty and is word made up of just word separator characters to
|
||||||
|
# be excluded and is current word not preceded by whitespace in
|
||||||
|
# original line?
|
||||||
|
while [[ $i -gt 0 && ${COMP_WORDS[i]} == +($exclude) ]]; do
|
||||||
|
# Is word separator not preceded by whitespace in original line
|
||||||
|
# and are we not going to append to word 0 (the command
|
||||||
|
# itself), then append to current word.
|
||||||
|
[[ $line != [[:blank:]]* ]] && ((j >= 2)) && ((j--))
|
||||||
|
# Append word separator to current or new word
|
||||||
|
ref="$2[$j]"
|
||||||
|
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||||
|
# Indicate new cword
|
||||||
|
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||||
|
# Remove optional whitespace + word separator from line copy
|
||||||
|
line=${line#*"${COMP_WORDS[i]}"}
|
||||||
|
# Indicate next word if available, else end *both* while and
|
||||||
|
# for loop
|
||||||
|
if ((i < ${#COMP_WORDS[@]} - 1)); then
|
||||||
|
((i++))
|
||||||
|
else
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
# Start new word if word separator in original line is
|
||||||
|
# followed by whitespace.
|
||||||
|
[[ $line == [[:blank:]]* ]] && ((j++))
|
||||||
|
done
|
||||||
|
# Append word to current word
|
||||||
|
ref="$2[$j]"
|
||||||
|
printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"
|
||||||
|
# Remove optional whitespace + word from line copy
|
||||||
|
line=${line#*"${COMP_WORDS[i]}"}
|
||||||
|
# Indicate new cword
|
||||||
|
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||||
|
done
|
||||||
|
((i == COMP_CWORD)) && printf -v "$3" %s "$j"
|
||||||
|
else
|
||||||
|
# No, list of word completions separators hasn't changed;
|
||||||
|
for i in "${!COMP_WORDS[@]}"; do
|
||||||
|
printf -v "$2[i]" %s "${COMP_WORDS[i]}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
__exptime(){
|
||||||
|
if [ "${IS_GET}" == "1" ]; then
|
||||||
|
if [ "${cword}" == "2" ]; then
|
||||||
|
FCN_RETURN="s ms us ns"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "${cword}" == "2" ]; then
|
||||||
|
FCN_RETURN=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${cword}" == "3" ]; then
|
||||||
|
FCN_RETURN="s ms us ns"
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# trimbits will activate IS_PATH and signal that its input is a path
|
||||||
|
__trimbits(){
|
||||||
|
if [ "${IS_GET}" == "1" ]; then
|
||||||
|
if [ "${cword}" == "2" ]; then
|
||||||
|
FCN_RETURN=""
|
||||||
|
IS_PATH=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "${cword}" == "2" ]; then
|
||||||
|
FCN_RETURN=""
|
||||||
|
IS_PATH=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
local cword words=()
|
||||||
|
_comp__reassemble_words ":" words cword
|
||||||
|
local FCN_RETURN=""
|
||||||
|
local IS_PATH=0
|
||||||
|
COMPREPLY=()
|
||||||
|
local OPTIONS_NEW=""
|
||||||
|
# _get_comp_words_by_ref -n : cur
|
||||||
|
local cur=${words[cword]}
|
||||||
|
# check the action (get or put)
|
||||||
|
if [ "${words[0]}" == "sls_detector_get" ]; then
|
||||||
|
local IS_GET=1
|
||||||
|
else
|
||||||
|
local IS_GET=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# if no command is written, autocomplete with the commands
|
||||||
|
if [[ ${cword} -eq 1 ]]; then
|
||||||
|
local SLS_COMMANDS="trimbits exptime"
|
||||||
|
local SLS_COMMANDS_NEW=""
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
[0-9]*:*)
|
||||||
|
local suggestions=($(compgen -W "${SLS_COMMANDS}" -- "${cur#*:}"))
|
||||||
|
COMPREPLY=( ${suggestions[*]} )
|
||||||
|
;;
|
||||||
|
[0-9]*)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=( $( compgen -W "$SLS_COMMANDS -h" -- "$cur" ) );;
|
||||||
|
|
||||||
|
esac
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if a command is written, autocomplete with the options
|
||||||
|
# call the function for the command
|
||||||
|
__"${words[1]##*:}"
|
||||||
|
|
||||||
|
# if IS_PATH is activated, autocomplete with the path
|
||||||
|
if [[ ${IS_PATH} -eq 1 ]]; then
|
||||||
|
COMPREPLY=($(compgen -f -- "${cur}"))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# autocomplete with the options
|
||||||
|
COMPREPLY=($(compgen -W "${FCN_RETURN}" -- "${cur}"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector_put
|
||||||
|
complete -F _sd -o filenames sls_detector_get
|
||||||
|
|
||||||
|
complete -F _sd -o filenames g
|
||||||
|
complete -F _sd -o filenames p
|
||||||
|
|
||||||
|
complete -F _sd -o filenames detg
|
||||||
|
complete -F _sd -o filenames detp
|
||||||
|
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector
|
||||||
|
complete -F _sd -o filenames det
|
||||||
|
|
@ -0,0 +1,77 @@
|
|||||||
|
# GENERATED FILE - DO NOT EDIT
|
||||||
|
# ANY CHANGES TO THIS FILE WILL BE OVERWRITTEN
|
||||||
|
|
||||||
|
_sd() {
|
||||||
|
|
||||||
|
|
||||||
|
# -- THIS LINE WILL BE REPLACED WITH GENERATED CODE --
|
||||||
|
|
||||||
|
|
||||||
|
local FCN_RETURN=""
|
||||||
|
local IS_PATH=0
|
||||||
|
COMPREPLY=()
|
||||||
|
local OPTIONS_NEW=""
|
||||||
|
words=("${COMP_WORDS[@]}")
|
||||||
|
cword=$COMP_CWORD
|
||||||
|
|
||||||
|
local cur=${words[cword]}
|
||||||
|
# check the action (get or put)
|
||||||
|
case "${words[0]}" in
|
||||||
|
"sls_detector_get" | "g" | "detg")
|
||||||
|
local IS_GET=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
local IS_GET=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# if no command is written, autocomplete with the commands
|
||||||
|
if [[ ${cword} -eq 1 ]]; then
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
[0-9]*)
|
||||||
|
for i in $SLS_COMMANDS; do
|
||||||
|
SLS_COMMANDS_NEW="${SLS_COMMANDS_NEW} ${cur%%:*}:$i"
|
||||||
|
done
|
||||||
|
COMPREPLY=( $( compgen -W "${SLS_COMMANDS_NEW}" -- "$cur" ) );;
|
||||||
|
*)
|
||||||
|
COMPREPLY=( $( compgen -W "$SLS_COMMANDS -h" -- "$cur" ) );;
|
||||||
|
esac
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${cword} -eq 2 ]] && [[ ${words[1]} == "-h" ]]; then
|
||||||
|
COMPREPLY=( $( compgen -W "$SLS_COMMANDS" -- "$cur" ) )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if a command is written, autocomplete with the options
|
||||||
|
# call the function for the command
|
||||||
|
|
||||||
|
if [[ "$SLS_COMMANDS" == *"${words[1]##*:}"* ]]; then
|
||||||
|
__"${words[1]##*:}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if IS_PATH is activated, autocomplete with the path
|
||||||
|
if [[ ${IS_PATH} -eq 1 ]]; then
|
||||||
|
COMPREPLY=($(compgen -f -- "${cur}"))
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# autocomplete with the options
|
||||||
|
COMPREPLY=($(compgen -W "${FCN_RETURN}" -- "${cur}"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector_get
|
||||||
|
complete -F _sd -o filenames g
|
||||||
|
complete -F _sd -o filenames detg
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector_put
|
||||||
|
complete -F _sd -o filenames p
|
||||||
|
complete -F _sd -o filenames detp
|
||||||
|
|
||||||
|
complete -F _sd -o filenames sls_detector
|
||||||
|
complete -F _sd -o filenames det
|
3165
slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh
Normal file
3165
slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh
Normal file
File diff suppressed because it is too large
Load Diff
4278
slsDetectorSoftware/generator/commands.yaml
Normal file
4278
slsDetectorSoftware/generator/commands.yaml
Normal file
File diff suppressed because it is too large
Load Diff
379
slsDetectorSoftware/generator/commands_parser/commands_parser.py
Normal file
379
slsDetectorSoftware/generator/commands_parser/commands_parser.py
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
import copy
|
||||||
|
import logging
|
||||||
|
import yaml
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
class CommandParser:
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
commands_file: Path = Path(__file__).parent.parent / 'commands.yaml',
|
||||||
|
output_file: Path = Path(__file__).parent.parent / 'extended_commands.yaml'
|
||||||
|
):
|
||||||
|
|
||||||
|
self.output_file = output_file
|
||||||
|
self.commands_file = commands_file
|
||||||
|
self.fp = self.commands_file.open('r')
|
||||||
|
self.simple_commands = yaml.unsafe_load(self.fp)
|
||||||
|
self.extended_commands = {}
|
||||||
|
self.argc_set = set()
|
||||||
|
self.logger = logging.getLogger('command_parser')
|
||||||
|
self.__current_action: str = ''
|
||||||
|
FORMAT = '[%(levelname)s] %(message)s'
|
||||||
|
logging.basicConfig(format=FORMAT, level=logging.INFO)
|
||||||
|
|
||||||
|
self.propagate_config = {
|
||||||
|
'require_det_id': False,
|
||||||
|
'convert_det_id': True,
|
||||||
|
'input': [],
|
||||||
|
'input_types': [],
|
||||||
|
'function': '',
|
||||||
|
'output': [],
|
||||||
|
'cast_input': [],
|
||||||
|
'check_det_id': False,
|
||||||
|
'arg_types': [],
|
||||||
|
# 'store_result_in_t': False, # always true in GET action
|
||||||
|
}
|
||||||
|
self.default_config = {
|
||||||
|
'infer_action': True,
|
||||||
|
'help': '',
|
||||||
|
'actions': {}
|
||||||
|
}
|
||||||
|
|
||||||
|
def _verify_argument(self, arg, infer_action, command_name, action):
|
||||||
|
if arg['function'] == '' and 'ctb_output_list' not in arg:
|
||||||
|
special_exception_message_list = ["Cannot put", "Cannot get"]
|
||||||
|
if 'exceptions' in arg and arg['exceptions'][0]['condition'] == 'true' and any(ele in arg['exceptions'][0]['message'] for ele in special_exception_message_list):
|
||||||
|
self.logger.warning(f"{command_name} has a special exception message for {action}.")
|
||||||
|
else:
|
||||||
|
self.logger.warning(f"{command_name} [{action}] does not have a function")
|
||||||
|
if len(arg['input_types']) != len(arg['input']):
|
||||||
|
raise ValueError(f'Argument {arg} does not have the correct number of inputs')
|
||||||
|
if 'separate_time_units' in arg:
|
||||||
|
|
||||||
|
if arg['separate_time_units']['input'] == "":
|
||||||
|
raise ValueError(f'Argument {arg} does not have the correct number of inputs for separate_time_units')
|
||||||
|
if len(arg['separate_time_units']['output']) != 2:
|
||||||
|
raise ValueError(f'Argument {arg} does not have the correct number of outputs for separate_time_units')
|
||||||
|
if 'convert_to_time' in arg:
|
||||||
|
if len(arg['convert_to_time']['input']) != 2:
|
||||||
|
raise ValueError(f'Argument {arg} does not have the correct number of inputs for convert_to_time')
|
||||||
|
if len(arg['convert_to_time']['output']) == "":
|
||||||
|
raise ValueError(f'Argument {arg} does not have the correct number of outputs for convert_to_time')
|
||||||
|
# if infer_action:
|
||||||
|
# if arg['argc'] in self.argc_set:
|
||||||
|
# raise ValueError(f'Argument {arg} has a duplicate argc')
|
||||||
|
# self.argc_set.add(arg['argc'])
|
||||||
|
|
||||||
|
def verify_format(self):
|
||||||
|
# todo verify detectors
|
||||||
|
# todo verify circular inheritance
|
||||||
|
# todo verify child commands (those that inherit)
|
||||||
|
# todo verify that there is no wrongly typed parameters
|
||||||
|
# todo verify that the same number of input_types and input are given
|
||||||
|
# todo verify that each argument has argc (error can happen when inheriting)
|
||||||
|
for command_name, command in self.simple_commands.items():
|
||||||
|
if 'inherit_actions' in command or 'template' in command and command[
|
||||||
|
'template'] or 'is_description' in command and command['is_description']:
|
||||||
|
continue
|
||||||
|
self.argc_set = set()
|
||||||
|
if 'infer_action' not in command:
|
||||||
|
command['infer_action'] = True
|
||||||
|
if 'actions' not in command:
|
||||||
|
raise ValueError(f'Command {command_name} does not have any actions')
|
||||||
|
for action, action_params in command['actions'].items():
|
||||||
|
if 'argc' in action_params:
|
||||||
|
if 'args' in action_params:
|
||||||
|
raise ValueError(f'Action {action} has both argc and args')
|
||||||
|
arg = {**self.propagate_config, **action_params}
|
||||||
|
self._verify_argument(arg, command['infer_action'], command_name, action)
|
||||||
|
elif 'args' in action_params:
|
||||||
|
if type(action_params['args']) is not list:
|
||||||
|
raise ValueError(f'Action {action} args is not a list')
|
||||||
|
if len(action_params['args']) == 0:
|
||||||
|
raise ValueError(f'Action {action} args is empty')
|
||||||
|
action_args = {**self.propagate_config, **action_params}
|
||||||
|
del action_args['args']
|
||||||
|
for arg in action_params['args']:
|
||||||
|
arg = {**action_args, **arg}
|
||||||
|
self._verify_argument(arg, command['infer_action'], command_name, action)
|
||||||
|
self.logger.info('Commands file is valid ✅️')
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _parse_inherited_command(self, parent, command, simple_parent):
|
||||||
|
"""
|
||||||
|
parse a command that inherits from parent command
|
||||||
|
:param parent: parsed parent command
|
||||||
|
:param command: the current command
|
||||||
|
:param simple_parent: unparsed parent command
|
||||||
|
:return: parsed command
|
||||||
|
"""
|
||||||
|
# deepcopy parent and command to avoid modifying the originals
|
||||||
|
command = copy.deepcopy(command)
|
||||||
|
config = copy.deepcopy(parent)
|
||||||
|
# add help
|
||||||
|
if 'help' in command:
|
||||||
|
config['help'] = command['help']
|
||||||
|
if 'actions' not in command:
|
||||||
|
return config
|
||||||
|
for action, command_params in command['actions'].items():
|
||||||
|
self.__current_action = action
|
||||||
|
if action not in config['actions']:
|
||||||
|
# todo: handle this case
|
||||||
|
pass
|
||||||
|
parent_params = config['actions'][action]
|
||||||
|
if 'args' in command_params:
|
||||||
|
# child has args => inherit action level params from parent + override with child args + use child's
|
||||||
|
# action level params
|
||||||
|
context = {**self.propagate_config, **simple_parent['actions'][action], **command_params}
|
||||||
|
config['actions'][action]['args'] = self.parse_action(context, command_params['args'])
|
||||||
|
elif 'argc' in command_params:
|
||||||
|
# child has action level args (argc)
|
||||||
|
context = {**self.propagate_config, **simple_parent['actions'][action], **command_params}
|
||||||
|
config['actions'][action]['args'] = self.parse_action(context, [])
|
||||||
|
else:
|
||||||
|
# child does not have args => use parent's action level params + override with child's action level
|
||||||
|
if 'args' in parent_params:
|
||||||
|
config['actions'][action]['args'] = self.parse_action({}, parent_params['args'], command_params)
|
||||||
|
|
||||||
|
if 'detectors' in command_params:
|
||||||
|
if command_params['detectors'] is None:
|
||||||
|
# if child has an empty detector section, then delete the parent's detector section
|
||||||
|
del config['actions'][action]['detectors']
|
||||||
|
continue
|
||||||
|
|
||||||
|
for detector_name, detector_params in command_params['detectors'].items():
|
||||||
|
if 'detectors' not in config['actions'][action]:
|
||||||
|
config['actions'][action]['detectors'] = {}
|
||||||
|
config_detector = config['actions'][action]['detectors']
|
||||||
|
if 'detectors' not in parent_params or detector_name not in parent_params['detectors']:
|
||||||
|
if 'args' in detector_params:
|
||||||
|
# if child has detector args and parent does not have detectors
|
||||||
|
# => use child's detector args
|
||||||
|
context = {**self.propagate_config, **simple_parent['actions'][action], **detector_params}
|
||||||
|
config_detector[detector_name] = self.parse_action(context, detector_params['args'])
|
||||||
|
elif 'args' in parent_params:
|
||||||
|
# if child does not have detector args and parent does not have detectors
|
||||||
|
# => use the child's action args
|
||||||
|
context = {**self.propagate_config, **simple_parent['actions'][action]}
|
||||||
|
config_detector[detector_name] = self.parse_action(context,
|
||||||
|
config['actions'][action]['args'],
|
||||||
|
detector_params)
|
||||||
|
elif detector_name in parent_params['detectors']:
|
||||||
|
|
||||||
|
if 'args' in detector_params:
|
||||||
|
# child and parent have the same detector and child has detector args
|
||||||
|
# => use child's detector args
|
||||||
|
context = {
|
||||||
|
**self.propagate_config,
|
||||||
|
**simple_parent['actions'][action],
|
||||||
|
**simple_parent['actions'][action]['detectors'][detector_name],
|
||||||
|
|
||||||
|
}
|
||||||
|
config_detector[detector_name] = self.parse_action(context, detector_params['args'])
|
||||||
|
else:
|
||||||
|
# child and parent have the same detector and child does not have detector args
|
||||||
|
# => use parent's detector args
|
||||||
|
priority_context = {**command_params, **detector_params}
|
||||||
|
config_detector[detector_name] = self.parse_action(
|
||||||
|
{},
|
||||||
|
parent_params['detectors'][detector_name],
|
||||||
|
priority_context
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
def _parse_command(self, command):
|
||||||
|
"""
|
||||||
|
logic function for parse_command.
|
||||||
|
This function is recursive
|
||||||
|
:return: parsed command
|
||||||
|
"""
|
||||||
|
config = self.default_config.copy()
|
||||||
|
config.update(command)
|
||||||
|
config['actions'] = {}
|
||||||
|
|
||||||
|
# check if command inherits from another command
|
||||||
|
if 'inherit_actions' in command:
|
||||||
|
if command['inherit_actions'] in self.extended_commands:
|
||||||
|
# if parent command has already been parsed, use that
|
||||||
|
parent = self.extended_commands[command['inherit_actions']]
|
||||||
|
else:
|
||||||
|
# if parent command has not been parsed, parse it
|
||||||
|
parent = self.parse_command(command['inherit_actions'])
|
||||||
|
# parse the current command and merge it with the parent command
|
||||||
|
config = self._parse_inherited_command(parent, command, self.simple_commands[command['inherit_actions']])
|
||||||
|
return config
|
||||||
|
|
||||||
|
if 'actions' not in command:
|
||||||
|
return config
|
||||||
|
|
||||||
|
for action, action_params in command['actions'].items():
|
||||||
|
self.__current_action = action
|
||||||
|
|
||||||
|
config['actions'][action] = {}
|
||||||
|
config_action = config['actions'][action]
|
||||||
|
# the context in the current command and the current action
|
||||||
|
action_context = {**self.propagate_config, **action_params}
|
||||||
|
if 'args' not in action_params:
|
||||||
|
# parse the action with the action context
|
||||||
|
if action_params.keys() != {'detectors'}:
|
||||||
|
config_action['args'] = self.parse_action(action_context, [])
|
||||||
|
else:
|
||||||
|
config_action['args'] = self.parse_action(action_context, action_params['args'])
|
||||||
|
|
||||||
|
# check if the action has detectors
|
||||||
|
if 'detectors' in action_params:
|
||||||
|
config_action['detectors'] = {}
|
||||||
|
for detector_name, detector_params in action_params['detectors'].items():
|
||||||
|
# get the context for the detector and merge it with the action context
|
||||||
|
detector_context = {**action_context, **detector_params}
|
||||||
|
|
||||||
|
# if the detector does not have args, then use the action args
|
||||||
|
# otherwise, use the detector args and override the action args
|
||||||
|
tmp_args = []
|
||||||
|
if 'args' not in detector_params:
|
||||||
|
if 'args' in config_action:
|
||||||
|
tmp_args = config_action['args']
|
||||||
|
else:
|
||||||
|
tmp_args = detector_params['args']
|
||||||
|
detector_params['args'] = tmp_args
|
||||||
|
|
||||||
|
# parse the action with the detector context
|
||||||
|
config_action['detectors'][detector_name] = self.parse_action(detector_context,
|
||||||
|
tmp_args,
|
||||||
|
detector_params)
|
||||||
|
return config
|
||||||
|
|
||||||
|
def sanitize_argument(func):
|
||||||
|
def f(self, action_context, args_old, priority_context={}):
|
||||||
|
args = func(self, action_context, args_old, priority_context)
|
||||||
|
for i, arg in enumerate(args):
|
||||||
|
if 'args' in arg:
|
||||||
|
del arg['args']
|
||||||
|
if 'detectors' in arg:
|
||||||
|
del arg['detectors']
|
||||||
|
if not arg['cast_input']:
|
||||||
|
# if the cast_input is empty, then set it to False
|
||||||
|
arg['cast_input'] = [False] * len(arg['input'])
|
||||||
|
|
||||||
|
elif len(arg['cast_input']) != len(arg['input']):
|
||||||
|
# if the cast_input is not the same length as the input, then set it to False
|
||||||
|
arg['cast_input'] = [False] * len(arg['input'])
|
||||||
|
self.logger.warning(f'cast_input for {arg["function"]} '
|
||||||
|
f'with argc: {arg["argc"]} has different length than input')
|
||||||
|
if 'store_result_in_t' not in arg:
|
||||||
|
if self.__current_action == 'GET':
|
||||||
|
arg['store_result_in_t'] = True
|
||||||
|
else:
|
||||||
|
arg['store_result_in_t'] = False
|
||||||
|
return args
|
||||||
|
|
||||||
|
return f
|
||||||
|
|
||||||
|
@sanitize_argument
|
||||||
|
def parse_action(self, action_context, args, priority_context={}):
|
||||||
|
"""
|
||||||
|
parse an action
|
||||||
|
:param action_context: context of the action
|
||||||
|
:param args: arguments to be used in the action
|
||||||
|
:param priority_context: context that should override the arguments params
|
||||||
|
:return: parsed action
|
||||||
|
"""
|
||||||
|
|
||||||
|
def add_cast_input(argument):
|
||||||
|
return argument
|
||||||
|
|
||||||
|
# deepcopy action_context to avoid modifying the original
|
||||||
|
action_context = {**self.propagate_config, **copy.deepcopy(action_context)}
|
||||||
|
priority_context = copy.deepcopy(priority_context)
|
||||||
|
|
||||||
|
if 'detectors' in action_context:
|
||||||
|
del action_context['detectors']
|
||||||
|
if 'detectors' in priority_context:
|
||||||
|
del priority_context['detectors']
|
||||||
|
|
||||||
|
if args == []:
|
||||||
|
# if there are no arguments, then the action has only one argument
|
||||||
|
context = {**action_context, **priority_context}
|
||||||
|
return [add_cast_input(context)]
|
||||||
|
|
||||||
|
ret_args = []
|
||||||
|
if 'args' in action_context:
|
||||||
|
del action_context['args']
|
||||||
|
if 'args' in priority_context:
|
||||||
|
del priority_context['args']
|
||||||
|
|
||||||
|
# if there are arguments, then merge them with the action context and priority context
|
||||||
|
for arg in args:
|
||||||
|
arg = {**action_context, **arg, **priority_context}
|
||||||
|
ret_args.append(add_cast_input(arg))
|
||||||
|
return ret_args
|
||||||
|
|
||||||
|
def parse_command(self, command_name):
|
||||||
|
"""
|
||||||
|
parse a single command
|
||||||
|
This function is recursive
|
||||||
|
|
||||||
|
:param command_name: name of the command to parse
|
||||||
|
:return: the parsed command
|
||||||
|
"""
|
||||||
|
command = self.simple_commands[command_name]
|
||||||
|
parsed_command = self._parse_command(command)
|
||||||
|
if 'function_alias' not in command:
|
||||||
|
if 'command_name' in command:
|
||||||
|
parsed_command['function_alias'] = command['command_name']
|
||||||
|
else:
|
||||||
|
parsed_command['function_alias'] = command_name
|
||||||
|
|
||||||
|
if 'command_name' not in command:
|
||||||
|
parsed_command['command_name'] = command_name
|
||||||
|
|
||||||
|
if 'template' in command and command['template']:
|
||||||
|
return parsed_command
|
||||||
|
self.extended_commands[command_name] = parsed_command
|
||||||
|
return self.extended_commands[command_name]
|
||||||
|
|
||||||
|
def parse_all_commands(self):
|
||||||
|
"""
|
||||||
|
iterate over all commands in yaml file and parse them
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
|
||||||
|
for command_name in self.simple_commands:
|
||||||
|
# todo remove this (added for debugging)
|
||||||
|
if command_name != 'xtiming':
|
||||||
|
self.parse_command(command_name)
|
||||||
|
|
||||||
|
# post-process the parsed commands
|
||||||
|
self.post_process_all_commands()
|
||||||
|
|
||||||
|
yaml.Dumper.ignore_aliases = lambda *args: True
|
||||||
|
self.logger.info(f'parsed {len(self.extended_commands)} commands')
|
||||||
|
yaml.dump(self.extended_commands, self.output_file.open('w'), default_flow_style=False)
|
||||||
|
|
||||||
|
def post_process_all_commands(self):
|
||||||
|
for command_name, command in self.extended_commands.items():
|
||||||
|
if 'is_description' in command and command['is_description']:
|
||||||
|
continue
|
||||||
|
for action_name, action, in command['actions'].items():
|
||||||
|
for arg in action['args']:
|
||||||
|
if arg['argc'] == 0:
|
||||||
|
arg['arg_types'] = []
|
||||||
|
continue
|
||||||
|
if arg['argc'] == -1:
|
||||||
|
pass
|
||||||
|
if arg['arg_types'] == []:
|
||||||
|
arg['arg_types'] = arg['input_types']
|
||||||
|
|
||||||
|
|
||||||
|
# command_parser = CommandParser(Path(
|
||||||
|
# '/afs/psi.ch/user/b/braham_b/github/slsDetectorPackage/slsDetectorSoftware/generator/tests/command_parser/data/detectors.yaml'))
|
||||||
|
command_parser = CommandParser()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
282
slsDetectorSoftware/generator/cpp_codegen/codegen.py
Normal file
282
slsDetectorSoftware/generator/cpp_codegen/codegen.py
Normal file
@ -0,0 +1,282 @@
|
|||||||
|
class CodeGenerator:
|
||||||
|
def __init__(self):
|
||||||
|
self.file = None
|
||||||
|
self.actions_dict = {
|
||||||
|
'GET': 'slsDetectorDefs::GET_ACTION',
|
||||||
|
'PUT': 'slsDetectorDefs::PUT_ACTION',
|
||||||
|
'READOUT': 'slsDetectorDefs::READOUT_ACTION',
|
||||||
|
'HELP': 'slsDetectorDefs::HELP_ACTION',
|
||||||
|
}
|
||||||
|
self.template_file = None
|
||||||
|
|
||||||
|
def open(self, path):
|
||||||
|
self.file = path.open('w')
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.file.close()
|
||||||
|
self.file = None
|
||||||
|
|
||||||
|
def write_line(self, line):
|
||||||
|
self.file.write(line + '\n')
|
||||||
|
|
||||||
|
def write(self, text):
|
||||||
|
self.file.write(text)
|
||||||
|
|
||||||
|
def write_opening(self, path):
|
||||||
|
"""Write the opening file for the caller.cpp file"""
|
||||||
|
self.template_file = path.open('r')
|
||||||
|
for line in self.template_file:
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE" in line:
|
||||||
|
return
|
||||||
|
self.file.write(line)
|
||||||
|
|
||||||
|
def write_closing(self):
|
||||||
|
"""Write the closing file for the caller.cpp file"""
|
||||||
|
for line in self.template_file.readlines():
|
||||||
|
self.file.write(line)
|
||||||
|
self.template_file.close()
|
||||||
|
|
||||||
|
def write_header(self, in_path, out_path, commands, deprecated_commands):
|
||||||
|
"""Write the header file for the caller.h file"""
|
||||||
|
with out_path.open('w') as fp:
|
||||||
|
with in_path.open('r') as fp2:
|
||||||
|
for line in fp2:
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1)" in line:
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
if 'duplicate_function' in command and command['duplicate_function']:
|
||||||
|
continue
|
||||||
|
fp.write(f'std::string {command["function_alias"]}(int action);\n')
|
||||||
|
continue
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2)" in line:
|
||||||
|
map_string = ''
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
map_string += f'{{"{command_name}", &Caller::{command["function_alias"]}}},'
|
||||||
|
fp.write(map_string[:-1] + '\n')
|
||||||
|
continue
|
||||||
|
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (3)" in line:
|
||||||
|
for key, value in deprecated_commands.items():
|
||||||
|
fp.write(f'{{"{key}", "{value}"}},\n')
|
||||||
|
continue
|
||||||
|
|
||||||
|
fp.write(line)
|
||||||
|
|
||||||
|
def write_infer_header(self, in_path, out_path, commands):
|
||||||
|
"""Write the header file for the inferAction.h file"""
|
||||||
|
with out_path.open('w+') as fp:
|
||||||
|
with in_path.open('r') as fp2:
|
||||||
|
for line in fp2:
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE" in line:
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
if 'duplicate_function' in command and command['duplicate_function']:
|
||||||
|
continue
|
||||||
|
|
||||||
|
fp.write(f'int {command["function_alias"]}();\n')
|
||||||
|
continue
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2) - DO NOT REMOVE" in line:
|
||||||
|
map_string = ''
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
map_string += f'{{"{command_name}", &InferAction::{command["function_alias"]}}},'
|
||||||
|
fp.write(map_string[:-1] + '\n')
|
||||||
|
continue
|
||||||
|
fp.write(line)
|
||||||
|
|
||||||
|
def write_infer_cpp(self, in_path, out_path, commands, non_dist, type_dist):
|
||||||
|
"""Write the source file for the inferAction.cpp file"""
|
||||||
|
with in_path.open('r') as fp2:
|
||||||
|
for line in fp2:
|
||||||
|
if "THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE" in line:
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
if 'duplicate_function' in command and command['duplicate_function']:
|
||||||
|
continue
|
||||||
|
|
||||||
|
with function('int', f"InferAction::{command['function_alias']}", []) as f:
|
||||||
|
if (command_name, -1) in non_dist| type_dist:
|
||||||
|
self.write_line(
|
||||||
|
f'throw RuntimeError("sls_detector is disabled for command: {command_name}. Use sls_detector_get or sls_detector_put");')
|
||||||
|
elif not command['infer_action']:
|
||||||
|
self.write_line('throw RuntimeError("infer_action is disabled");')
|
||||||
|
else:
|
||||||
|
checked_argcs = set()
|
||||||
|
for action, action_params in command['actions'].items():
|
||||||
|
for arg in action_params['args']:
|
||||||
|
if arg['argc'] in checked_argcs:
|
||||||
|
continue
|
||||||
|
checked_argcs.add(arg['argc'])
|
||||||
|
with if_block(f'args.size() == {arg["argc"]}'):
|
||||||
|
# check if this argc is not distinguishable
|
||||||
|
if (command_name, arg["argc"]) in non_dist | type_dist:
|
||||||
|
self.write_line(
|
||||||
|
f'throw RuntimeError("sls_detector is disabled for command: {command_name} with number of arguments {arg["argc"]}. Use sls_detector_get or sls_detector_put");')
|
||||||
|
else:
|
||||||
|
self.write_line(f'return {self.actions_dict[action]};')
|
||||||
|
with else_block():
|
||||||
|
self.write_line(
|
||||||
|
'throw RuntimeError("Could not infer action: Wrong number of arguments");')
|
||||||
|
continue
|
||||||
|
self.write_line(line)
|
||||||
|
|
||||||
|
def write_check_arg(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def write_arg(self, args, action, command_name):
|
||||||
|
for arg in args:
|
||||||
|
if arg['argc'] != -1:
|
||||||
|
if_block(f'args.size() == {arg["argc"]}',).__enter__()
|
||||||
|
if 'pattern_command' in arg and arg['pattern_command']:
|
||||||
|
self.write_line(f'int level = -1, iArg = 0, '
|
||||||
|
f'nGetArgs = {arg["pattern_command"]["nGetArgs"]},'
|
||||||
|
f' nPutArgs = {arg["pattern_command"]["nPutArgs"]};\nGetLevelAndUpdateArgIndex(action, '
|
||||||
|
f'"{arg["pattern_command"]["command_name"]}", level, iArg, nGetArgs,nPutArgs);'
|
||||||
|
)
|
||||||
|
|
||||||
|
if 'extra_variables' in arg:
|
||||||
|
for var in arg['extra_variables']:
|
||||||
|
codegen.write_line(f'{var["type"]} {var["name"]} = {var["value"]};')
|
||||||
|
if 'separate_time_units' in arg and arg['separate_time_units']:
|
||||||
|
self.write_line(f'std::string tmp_time({arg["separate_time_units"]["input"]});')
|
||||||
|
self.write_line(f'std::string {arg["separate_time_units"]["output"][1]}'
|
||||||
|
f' = RemoveUnit(tmp_time);')
|
||||||
|
self.write_line(f'auto {arg["separate_time_units"]["output"][0]} = '
|
||||||
|
f'StringTo < time::ns > (tmp_time,'
|
||||||
|
f' {arg["separate_time_units"]["output"][1]});')
|
||||||
|
if 'convert_to_time' in arg and arg['convert_to_time']:
|
||||||
|
self.write_line(f'auto {arg["convert_to_time"]["output"]} = '
|
||||||
|
f'StringTo < time::ns > ({", ".join(arg["convert_to_time"]["input"])});')
|
||||||
|
input_arguments = []
|
||||||
|
if 'exceptions' in arg:
|
||||||
|
for exception in arg['exceptions']:
|
||||||
|
self.write_line(f'if ({exception["condition"]}) {{ throw RuntimeError({exception["message"]}); }}')
|
||||||
|
if 'check_det_id' in arg and arg['check_det_id']:
|
||||||
|
self.write_line(
|
||||||
|
f'if (det_id != -1) {{ throw RuntimeError("Cannot execute {command_name} at module level"); }} '
|
||||||
|
)
|
||||||
|
# only used for 3 commands :(
|
||||||
|
if 'ctb_output_list' in arg:
|
||||||
|
self.write_line(f"""
|
||||||
|
std::string suffix = " {arg['ctb_output_list']['suffix']}";
|
||||||
|
auto t = det->{arg['ctb_output_list']['GETFCNLIST']}();""")
|
||||||
|
if arg['ctb_output_list']['GETFCNNAME'] != '':
|
||||||
|
self.write_line(f"""
|
||||||
|
auto names = det->{arg['ctb_output_list']['GETFCNNAME']}();
|
||||||
|
auto name_it = names.begin();""")
|
||||||
|
self.write_line("os << '[';")
|
||||||
|
with if_block(f't.size() > 0'):
|
||||||
|
self.write_line(f"""
|
||||||
|
auto it = t.cbegin();
|
||||||
|
os << ToString({arg['ctb_output_list']['printable_name']}) << ' ';
|
||||||
|
os << OutString(det->{arg['ctb_output_list']['GETFCN']}(*it++, std::vector<int>{{det_id}}))<< suffix;
|
||||||
|
while (it != t.cend()) {{
|
||||||
|
os << ", " << ToString({arg['ctb_output_list']['printable_name']}) << ' ';
|
||||||
|
os << OutString(det->{arg['ctb_output_list']['GETFCN']}(*it++, std::vector<int>{{det_id}}))<< suffix;
|
||||||
|
}}
|
||||||
|
""")
|
||||||
|
self.write_line('os << "]\\n";')
|
||||||
|
if arg['argc'] != -1:
|
||||||
|
if_block().__exit__()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
for i in range(len(arg['input'])):
|
||||||
|
if arg['cast_input'][i]:
|
||||||
|
self.write_line(
|
||||||
|
f'auto arg{i} = StringTo<{arg["input_types"][i]}>({arg["input"][i]});')
|
||||||
|
input_arguments.append(f'arg{i}')
|
||||||
|
else:
|
||||||
|
input_arguments.append(arg["input"][i])
|
||||||
|
if 'require_det_id' in arg and arg['require_det_id']:
|
||||||
|
if 'convert_det_id' in arg and arg['convert_det_id']:
|
||||||
|
input_arguments.append("std::vector<int>{ det_id }")
|
||||||
|
else:
|
||||||
|
input_arguments.append("det_id")
|
||||||
|
|
||||||
|
input_arguments = ", ".join(input_arguments)
|
||||||
|
# call function
|
||||||
|
if arg["function"]:
|
||||||
|
if arg['store_result_in_t']:
|
||||||
|
self.write_line(f'auto t = det->{arg["function"]}({input_arguments});')
|
||||||
|
else:
|
||||||
|
self.write_line(f'det->{arg["function"]}({input_arguments});')
|
||||||
|
else:
|
||||||
|
pass #We have no function so skip block
|
||||||
|
|
||||||
|
output_args = []
|
||||||
|
for output in arg['output']:
|
||||||
|
output_args.append(output)
|
||||||
|
if len(output_args) > 0:
|
||||||
|
self.write_line(f"os << {'<< '.join(output_args)} << '\\n';")
|
||||||
|
|
||||||
|
if arg['argc'] != -1:
|
||||||
|
if_block().__exit__()
|
||||||
|
|
||||||
|
|
||||||
|
class if_block:
|
||||||
|
def __init__(self, condition="", elseif=False):
|
||||||
|
self.condition = condition
|
||||||
|
self.elseif = elseif
|
||||||
|
self.block = False
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
if self.elseif:
|
||||||
|
codegen.write_line('else if (' + self.condition + ') {')
|
||||||
|
else:
|
||||||
|
codegen.write_line('if (' + self.condition + ') {')
|
||||||
|
if self.block:
|
||||||
|
codegen.write_line('{\n')
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
codegen.write_line('}')
|
||||||
|
if self.block:
|
||||||
|
codegen.write_line('}')
|
||||||
|
codegen.write_line('')
|
||||||
|
|
||||||
|
|
||||||
|
class else_block:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
codegen.write_line('else {')
|
||||||
|
codegen.write_line('')
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
codegen.write_line('}')
|
||||||
|
codegen.write_line('')
|
||||||
|
|
||||||
|
|
||||||
|
class for_block:
|
||||||
|
def __init__(self, condition):
|
||||||
|
self.condition = condition
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
codegen.write_line('for (' + self.condition + ') {')
|
||||||
|
codegen.write_line('')
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
codegen.write_line('}')
|
||||||
|
codegen.write_line('')
|
||||||
|
|
||||||
|
|
||||||
|
class function:
|
||||||
|
def __init__(self, return_type, name, args: list[tuple[str, str]]):
|
||||||
|
self.name = name
|
||||||
|
self.args = args
|
||||||
|
self.return_type = return_type
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
s = ""
|
||||||
|
for arg in self.args:
|
||||||
|
arg_type, arg_name = arg
|
||||||
|
s += arg_type + ' ' + arg_name + ', '
|
||||||
|
s = s[:-2]
|
||||||
|
codegen.write_line(self.return_type + ' ' + self.name +
|
||||||
|
f'({s}) {{')
|
||||||
|
codegen.write_line('')
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
codegen.write_line('}')
|
||||||
|
codegen.write_line('')
|
||||||
|
|
||||||
|
|
||||||
|
codegen = CodeGenerator()
|
176
slsDetectorSoftware/generator/deprecated_commands.yaml
Normal file
176
slsDetectorSoftware/generator/deprecated_commands.yaml
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
#configuration
|
||||||
|
detectorversion: firmwareversion
|
||||||
|
softwareversion: detectorserverversion
|
||||||
|
receiverversion: rx_version
|
||||||
|
detectornumber: serialnumber
|
||||||
|
thisversion: clientversion
|
||||||
|
detsizechan: detsize
|
||||||
|
trimdir: settingspath
|
||||||
|
settingsdir: settingspath
|
||||||
|
flippeddatax: fliprows
|
||||||
|
|
||||||
|
#acquisition parameters
|
||||||
|
cycles: triggers
|
||||||
|
cyclesl: triggersl
|
||||||
|
clkdivider: readoutspeed
|
||||||
|
speed: readoutspeed
|
||||||
|
vhighvoltage: highvoltage
|
||||||
|
digitest: imagetest
|
||||||
|
filter: filterresistor
|
||||||
|
readnlines: readnrows
|
||||||
|
|
||||||
|
# temperature
|
||||||
|
|
||||||
|
# super old dacs
|
||||||
|
vtr: vtrim
|
||||||
|
vrf: vrpreamp
|
||||||
|
vrs: vrshaper
|
||||||
|
vcall: vcal
|
||||||
|
vis: vishaper
|
||||||
|
vshaper: vrshaper
|
||||||
|
vpreamp: vrpreamp
|
||||||
|
vshaperneg: vrshaper_n
|
||||||
|
viinsh: vishaper
|
||||||
|
vpl: vcal_n
|
||||||
|
vph: vcal_p
|
||||||
|
|
||||||
|
# dacs
|
||||||
|
vthreshold: dac
|
||||||
|
vsvp: dac
|
||||||
|
vsvn: dac
|
||||||
|
vtrim: dac
|
||||||
|
vrpreamp: dac
|
||||||
|
vrshaper: dac
|
||||||
|
vtgstv: dac
|
||||||
|
vcmp_ll: dac
|
||||||
|
vcmp_lr: dac
|
||||||
|
vcal: dac
|
||||||
|
vcmp_rl: dac
|
||||||
|
vcmp_rr: dac
|
||||||
|
rxb_rb: dac
|
||||||
|
rxb_lb: dac
|
||||||
|
vcp: dac
|
||||||
|
vcn: dac
|
||||||
|
vishaper: dac
|
||||||
|
iodelay: dac
|
||||||
|
vref_ds: dac
|
||||||
|
vcascn_pb: dac
|
||||||
|
vcascp_pb: dac
|
||||||
|
vout_cm: dac
|
||||||
|
vcasc_out: dac
|
||||||
|
vin_cm: dac
|
||||||
|
vref_comp: dac
|
||||||
|
ib_test_c: dac
|
||||||
|
vrshaper_n: dac
|
||||||
|
vipre: dac
|
||||||
|
vdcsh: dac
|
||||||
|
vth1: dac
|
||||||
|
vth2: dac
|
||||||
|
vth3: dac
|
||||||
|
vcal_n: dac
|
||||||
|
vcal_p: dac
|
||||||
|
vcassh: dac
|
||||||
|
vcas: dac
|
||||||
|
vicin: dac
|
||||||
|
vipre_out: dac
|
||||||
|
vref_h_adc: dac
|
||||||
|
vb_comp_fe: dac
|
||||||
|
vb_comp_adc: dac
|
||||||
|
vcom_cds: dac
|
||||||
|
vref_rstore: dac
|
||||||
|
vb_opa_1st: dac
|
||||||
|
vref_comp_fe: dac
|
||||||
|
vcom_adc1: dac
|
||||||
|
vref_prech: dac
|
||||||
|
vref_l_adc: dac
|
||||||
|
vref_cds: dac
|
||||||
|
vb_cs: dac
|
||||||
|
vb_opa_fd: dac
|
||||||
|
vcom_adc2: dac
|
||||||
|
vb_ds: dac
|
||||||
|
vb_comp: dac
|
||||||
|
vb_pixbuf: dac
|
||||||
|
vin_com: dac
|
||||||
|
vdd_prot: dac
|
||||||
|
vbp_colbuf: dac
|
||||||
|
vb_sda: dac
|
||||||
|
vcasc_sfp: dac
|
||||||
|
vipre_cds: dac
|
||||||
|
ibias_sfp: dac
|
||||||
|
|
||||||
|
defaultdacs: resetdacs
|
||||||
|
|
||||||
|
#acquisition
|
||||||
|
busy: clearbusy
|
||||||
|
receiver: rx_status
|
||||||
|
framescaught: rx_framescaught
|
||||||
|
startingfnum: nextframenumber
|
||||||
|
|
||||||
|
#Network Configuration (Detector<->Receiver)
|
||||||
|
detectorip: udp_srcip
|
||||||
|
detectorip2: udp_srcip2
|
||||||
|
detectormac: udp_srcmac
|
||||||
|
detectormac2: udp_srcmac2
|
||||||
|
rx_udpip: udp_dstip
|
||||||
|
rx_udpip2: udp_dstip2
|
||||||
|
rx_udpmac: udp_dstmac
|
||||||
|
rx_udpmac2: udp_dstmac2
|
||||||
|
rx_udpport: udp_dstport
|
||||||
|
rx_udpport2: udp_dstport2
|
||||||
|
flowcontrol_10g: flowcontrol10g
|
||||||
|
txndelay_frame: txdelay_frame
|
||||||
|
txndelay_left: txdelay_left
|
||||||
|
txndelay_right: txdelay_right
|
||||||
|
|
||||||
|
#Receiver Config
|
||||||
|
r_silent: rx_silent
|
||||||
|
r_discardpolicy: rx_discardpolicy
|
||||||
|
r_padding: rx_padding
|
||||||
|
r_lock: rx_lock
|
||||||
|
r_lastclient: rx_lastclient
|
||||||
|
|
||||||
|
#File
|
||||||
|
fileformat: fformat
|
||||||
|
outdir: fpath
|
||||||
|
index: findex
|
||||||
|
enablefwrite: fwrite
|
||||||
|
masterfile: fmaster
|
||||||
|
overwrite: foverwrite
|
||||||
|
r_framesperfile: rx_framesperfile
|
||||||
|
|
||||||
|
#ZMQ Streaming Parameters (Receiver<->Client)
|
||||||
|
r_readfreq: rx_zmqfreq
|
||||||
|
rx_readfreq: rx_zmqfreq
|
||||||
|
rx_datastream: rx_zmqstream
|
||||||
|
|
||||||
|
#Eiger Specific
|
||||||
|
resmat: partialreset
|
||||||
|
|
||||||
|
#Jungfrau Specific
|
||||||
|
storagecells: extrastoragecells
|
||||||
|
auto_comp_disable: autocompdisable
|
||||||
|
comp_disable_time: compdisabletime
|
||||||
|
|
||||||
|
#Gotthard Specific
|
||||||
|
#Gotthard2 Specific
|
||||||
|
#Mythen3 Specific
|
||||||
|
#CTB Specific
|
||||||
|
adc: slowadc
|
||||||
|
flags: romode
|
||||||
|
i_a: im_a
|
||||||
|
i_b: im_b
|
||||||
|
i_c: im_c
|
||||||
|
i_d: im_d
|
||||||
|
i_io: im_io
|
||||||
|
|
||||||
|
#Pattern
|
||||||
|
#Moench
|
||||||
|
|
||||||
|
#Advanced
|
||||||
|
copydetectorserver: updatedetectorserver
|
||||||
|
|
||||||
|
#Insignificant
|
||||||
|
nframes: framecounter
|
||||||
|
now: runtime
|
||||||
|
timestamp: frametime
|
||||||
|
frameindex: rx_frameindex
|
13812
slsDetectorSoftware/generator/extended_commands.yaml
Normal file
13812
slsDetectorSoftware/generator/extended_commands.yaml
Normal file
File diff suppressed because it is too large
Load Diff
276
slsDetectorSoftware/generator/gen_commands.py
Normal file
276
slsDetectorSoftware/generator/gen_commands.py
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from autocomplete.autocomplete import type_info
|
||||||
|
from cpp_codegen.codegen import codegen, if_block, for_block, function, else_block
|
||||||
|
from infer_action.check_infer import check_infer
|
||||||
|
from autocomplete.autocomplete import type_values
|
||||||
|
|
||||||
|
GEN_PATH = Path(__file__).parent
|
||||||
|
|
||||||
|
COMMANDS_PATH = GEN_PATH / 'extended_commands.yaml'
|
||||||
|
DEPRECATED_COMMANDS_PATH = GEN_PATH / 'deprecated_commands.yaml'
|
||||||
|
CPP_INPUT_PATH = GEN_PATH / 'Caller.in.cpp'
|
||||||
|
HEADER_INPUT_PATH = GEN_PATH / 'Caller.in.h'
|
||||||
|
CPP_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'Caller.cpp'
|
||||||
|
HEADER_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'Caller.h'
|
||||||
|
|
||||||
|
INFER_HEADER_INPUT_PATH = GEN_PATH / 'inferAction.in.h'
|
||||||
|
INFER_CPP_INPUT_PATH = GEN_PATH / 'inferAction.in.cpp'
|
||||||
|
INFER_HEADER_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'inferAction.h'
|
||||||
|
INFER_CPP_OUTPUT_PATH = GEN_PATH.parent / 'src' / 'inferAction.cpp'
|
||||||
|
|
||||||
|
|
||||||
|
def generate(
|
||||||
|
commands_path=COMMANDS_PATH,
|
||||||
|
cpp_input_path=CPP_INPUT_PATH,
|
||||||
|
header_input_path=HEADER_INPUT_PATH,
|
||||||
|
cpp_output_path=CPP_OUTPUT_PATH,
|
||||||
|
header_output_path=HEADER_OUTPUT_PATH,
|
||||||
|
infer_header_input_path=INFER_HEADER_INPUT_PATH,
|
||||||
|
infer_cpp_input_path=INFER_CPP_INPUT_PATH,
|
||||||
|
infer_header_output_path=INFER_HEADER_OUTPUT_PATH,
|
||||||
|
infer_cpp_output_path=INFER_CPP_OUTPUT_PATH,
|
||||||
|
|
||||||
|
):
|
||||||
|
commands_config = yaml.unsafe_load(commands_path.open('r'))
|
||||||
|
deprecated_commands_config = yaml.unsafe_load(DEPRECATED_COMMANDS_PATH.open('r'))
|
||||||
|
type_dist, non_dist = check_infer(commands=commands_config)
|
||||||
|
|
||||||
|
codegen.open(cpp_output_path)
|
||||||
|
# write call function
|
||||||
|
codegen.write_opening(cpp_input_path)
|
||||||
|
|
||||||
|
# iterate over the commands and generate code for each
|
||||||
|
print(f"[X] found {len(commands_config)} commands")
|
||||||
|
print('[*] generating code for commands')
|
||||||
|
for command_name, command in commands_config.items():
|
||||||
|
if 'is_description' in command and command['is_description']:
|
||||||
|
continue
|
||||||
|
with function('std::string', 'Caller::' + command['function_alias'], [('int', 'action')]) as fn:
|
||||||
|
codegen.write_line('std::ostringstream os;')
|
||||||
|
|
||||||
|
# print help
|
||||||
|
codegen.write_line('// print help')
|
||||||
|
with if_block('action == slsDetectorDefs::HELP_ACTION'):
|
||||||
|
if command["help"].startswith('code:'):
|
||||||
|
codegen.write_line(command["help"].strip('code:'))
|
||||||
|
else:
|
||||||
|
codegen.write_line(f'os << "Command: {command_name}" << std::endl;')
|
||||||
|
codegen.write_line(f'os << R"V0G0N({command["help"]} )V0G0N" << std::endl;')
|
||||||
|
codegen.write_line('return os.str();')
|
||||||
|
|
||||||
|
# check if action and arguments are valid
|
||||||
|
|
||||||
|
codegen.write_line('// check if action and arguments are valid')
|
||||||
|
first = True
|
||||||
|
for action, action_params in command['actions'].items():
|
||||||
|
|
||||||
|
with if_block(f'action == {codegen.actions_dict[action]}', elseif=not first):
|
||||||
|
|
||||||
|
check_argc = True
|
||||||
|
for arg in action_params['args']:
|
||||||
|
if arg['argc'] == -1:
|
||||||
|
check_argc = False
|
||||||
|
break
|
||||||
|
# check number of arguments
|
||||||
|
condition = "1" if check_argc else "0"
|
||||||
|
|
||||||
|
if check_argc:
|
||||||
|
for arg in action_params['args']:
|
||||||
|
condition += f' && args.size() != {arg["argc"]}'
|
||||||
|
|
||||||
|
with if_block(condition):
|
||||||
|
codegen.write_line(f'throw RuntimeError("Wrong number of arguments for action {action}");')
|
||||||
|
|
||||||
|
for arg in action_params['args']:
|
||||||
|
if not check_argc:
|
||||||
|
continue
|
||||||
|
with if_block(f'args.size() == {arg["argc"]}'):
|
||||||
|
# check argument types
|
||||||
|
if 'extra_variables' in arg:
|
||||||
|
for var in arg['extra_variables']:
|
||||||
|
codegen.write_line(f'{var["type"]} {var["name"]} = {var["value"]};')
|
||||||
|
|
||||||
|
if 'separate_time_units' in arg and arg['separate_time_units']:
|
||||||
|
codegen.write_line(f'try {{')
|
||||||
|
# TODO: refactor this repeating code
|
||||||
|
codegen.write_line(f'std::string tmp_time({arg["separate_time_units"]["input"]});')
|
||||||
|
codegen.write_line(f'std::string {arg["separate_time_units"]["output"][1]}'
|
||||||
|
f' = RemoveUnit(tmp_time);')
|
||||||
|
codegen.write_line(f'auto {arg["separate_time_units"]["output"][0]} = '
|
||||||
|
f'StringTo < time::ns > (tmp_time,'
|
||||||
|
f' {arg["separate_time_units"]["output"][1]});')
|
||||||
|
codegen.write_line(
|
||||||
|
f'}} catch (...) {{ throw RuntimeError("Could not convert argument to time::ns");}}')
|
||||||
|
|
||||||
|
elif 'convert_to_time' in arg and arg['convert_to_time']:
|
||||||
|
codegen.write_line(f'try {{')
|
||||||
|
|
||||||
|
codegen.write_line(
|
||||||
|
f'StringTo < time::ns > ({", ".join(arg["convert_to_time"]["input"])});')
|
||||||
|
codegen.write_line(
|
||||||
|
f'}} catch (...) {{ throw RuntimeError("Could not convert arguments to time::ns");}}')
|
||||||
|
|
||||||
|
for i in range(len(arg['input'])):
|
||||||
|
if not arg['cast_input'][i]:
|
||||||
|
continue
|
||||||
|
codegen.write_line(f'try {{')
|
||||||
|
codegen.write_line(f'StringTo<{arg["input_types"][i]}>({arg["input"][i]});')
|
||||||
|
codegen.write_line(f'}} catch (...) {{')
|
||||||
|
codegen.write_line(
|
||||||
|
f' throw RuntimeError("Could not convert argument {i} to {arg["input_types"][i]}");')
|
||||||
|
codegen.write_line(f'}}')
|
||||||
|
first = False
|
||||||
|
with else_block():
|
||||||
|
codegen.write_line(
|
||||||
|
f'throw RuntimeError("INTERNAL ERROR: Invalid action: supported actions are {list(command["actions"].keys())}");')
|
||||||
|
|
||||||
|
# generate code for each action
|
||||||
|
codegen.write_line('// generate code for each action')
|
||||||
|
for action, action_params in command['actions'].items():
|
||||||
|
if 'detectors' in action_params:
|
||||||
|
codegen.write_line('auto detector_type = det->getDetectorType().squash();')
|
||||||
|
|
||||||
|
with if_block(f'action == {codegen.actions_dict[action]}'):
|
||||||
|
if 'detectors' in action_params:
|
||||||
|
first = True
|
||||||
|
for detector, detector_params in action_params['detectors'].items():
|
||||||
|
with if_block(f'detector_type == defs::{detector}', elseif=not first):
|
||||||
|
codegen.write_arg(detector_params, action, command_name)
|
||||||
|
|
||||||
|
else_block().__enter__()
|
||||||
|
|
||||||
|
if not action_params:
|
||||||
|
codegen.write_line(f'throw RuntimeError("detector not supported for action: {action}");')
|
||||||
|
else:
|
||||||
|
tmp_args = []
|
||||||
|
if 'args' in action_params:
|
||||||
|
tmp_args = action_params['args']
|
||||||
|
codegen.write_arg(tmp_args, action, command_name)
|
||||||
|
|
||||||
|
if 'detectors' in action_params:
|
||||||
|
else_block().__exit__()
|
||||||
|
|
||||||
|
codegen.write_line('return os.str();')
|
||||||
|
|
||||||
|
# close sls namespace
|
||||||
|
codegen.write_closing()
|
||||||
|
codegen.close()
|
||||||
|
print('[X] .cpp code generated')
|
||||||
|
deprecated_commands = []
|
||||||
|
codegen.write_header(header_input_path, header_output_path, commands_config, deprecated_commands_config)
|
||||||
|
print('[X] header code generated')
|
||||||
|
|
||||||
|
|
||||||
|
codegen.write_infer_header(infer_header_input_path, infer_header_output_path, commands_config) #TODO: add deprecated commands
|
||||||
|
print('[X] infer header code generated')
|
||||||
|
codegen.open(infer_cpp_output_path)
|
||||||
|
|
||||||
|
codegen.write_infer_cpp(infer_cpp_input_path, infer_cpp_output_path, commands_config, non_dist, type_dist)
|
||||||
|
codegen.close()
|
||||||
|
print('[X] infer cpp code generated')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='generate c++ code for cli commands from the commands.yaml file',
|
||||||
|
)
|
||||||
|
parser.add_argument('-f', '--format', action='store_true', default=False, dest='format',
|
||||||
|
help='format header and cpp file using clang-format')
|
||||||
|
parser.add_argument('-p', '--parse', action='store_true', default=False, dest='parse',
|
||||||
|
help='parse the commands.yaml file into extended_commands.yaml')
|
||||||
|
parser.add_argument('-c', '--check', action='store_true', default=False, dest='check',
|
||||||
|
help='check missing commands')
|
||||||
|
parser.add_argument('-g', '--generate', action='store_true', default=False, dest='generate', help='generate code (C++ or bash if -a is used)')
|
||||||
|
parser.add_argument('-a', '--autocomplete', action='store_true', default=False, dest='autocomplete',
|
||||||
|
help='print bash autocomplete values')
|
||||||
|
cli_args = parser.parse_args()
|
||||||
|
|
||||||
|
if cli_args.autocomplete:
|
||||||
|
from autocomplete.autocomplete import generate_type_values, generate_bash_autocomplete
|
||||||
|
if cli_args.generate:
|
||||||
|
generate_bash_autocomplete()
|
||||||
|
print('[X] bash autocomplete generated')
|
||||||
|
generate_bash_autocomplete(
|
||||||
|
output_path=Path(__file__).parent / 'autocomplete' / 'zsh_autocomplete.sh',
|
||||||
|
input_path=Path(__file__).parent / 'autocomplete' / 'zsh_autocomplete.in.sh'
|
||||||
|
)
|
||||||
|
print('[X] zsh autocomplete generated')
|
||||||
|
exit(0)
|
||||||
|
else:
|
||||||
|
ret = generate_type_values()
|
||||||
|
print(ret)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if cli_args.check:
|
||||||
|
from commands_parser.commands_parser import command_parser
|
||||||
|
|
||||||
|
commands_config = yaml.unsafe_load(COMMANDS_PATH.open('r'))
|
||||||
|
|
||||||
|
# infer action based on number of arguments and types
|
||||||
|
type_dist, non_dist = check_infer(commands=commands_config)
|
||||||
|
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
||||||
|
# generate list of commands found in sls_detector_get
|
||||||
|
glist_path = GEN_PATH / 'glist'
|
||||||
|
ret = subprocess.run([f"sls_detector_get list | tail -n +2 | sort > {glist_path.absolute()}"], shell=True,
|
||||||
|
capture_output=True, check=True)
|
||||||
|
if ret.stderr != b'':
|
||||||
|
print('[!] glist generation failed and glist not found')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if not COMMANDS_PATH.exists():
|
||||||
|
print('[!] extended_commands.yaml not found')
|
||||||
|
exit(1)
|
||||||
|
detglist = set(command['command_name'] for __, command in commands_config.items())
|
||||||
|
detglist.add('free')
|
||||||
|
detglist.add('list')
|
||||||
|
|
||||||
|
g_path = GEN_PATH / 'glist'
|
||||||
|
if not g_path.exists():
|
||||||
|
print('[!] glist not found')
|
||||||
|
exit(1)
|
||||||
|
glist = set(g_path.read_text().split('\n'))
|
||||||
|
if "" in glist:
|
||||||
|
glist.remove("")
|
||||||
|
if "" in detglist:
|
||||||
|
detglist.remove("")
|
||||||
|
|
||||||
|
not_found = set()
|
||||||
|
for command in glist:
|
||||||
|
if command not in detglist:
|
||||||
|
not_found.add(command)
|
||||||
|
print()
|
||||||
|
if len(not_found) > 0:
|
||||||
|
print(f'[!] found {len(not_found)} missing')
|
||||||
|
print(f"not_found: {not_found}")
|
||||||
|
else:
|
||||||
|
print(f'[X] found no missing commands')
|
||||||
|
|
||||||
|
for command in detglist:
|
||||||
|
if command not in glist:
|
||||||
|
print(f'[!] command {command} found in commands.yaml but not found in g list')
|
||||||
|
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
if cli_args.parse:
|
||||||
|
from commands_parser.commands_parser import command_parser
|
||||||
|
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
||||||
|
|
||||||
|
if cli_args.generate:
|
||||||
|
generate()
|
||||||
|
|
||||||
|
if cli_args.format:
|
||||||
|
files = [CPP_OUTPUT_PATH, HEADER_OUTPUT_PATH, INFER_HEADER_OUTPUT_PATH, INFER_CPP_OUTPUT_PATH]
|
||||||
|
for file in files:
|
||||||
|
os.system(f'clang-format -i {file.absolute()}')
|
||||||
|
#os.system(f'clang-format -i --style="{{Standard: C++11}}" {file.absolute()}')
|
||||||
|
print('[X] code formatted')
|
20
slsDetectorSoftware/generator/inferAction.in.cpp
Normal file
20
slsDetectorSoftware/generator/inferAction.in.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "inferAction.h"
|
||||||
|
#include "sls/sls_detector_defs.h"
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
int InferAction::infer(sls::CmdParser &parser, std::ostream &os) {
|
||||||
|
args = parser.arguments();
|
||||||
|
cmd = parser.command();
|
||||||
|
auto it = functions.find(parser.command());
|
||||||
|
if (it != functions.end()) {
|
||||||
|
return ((*this).*(it->second))();
|
||||||
|
} else {
|
||||||
|
throw RuntimeError(
|
||||||
|
"sls_detector not implemented for command: " + parser.command() +
|
||||||
|
". Use sls_detector_get or sls_detector_put.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE
|
||||||
|
|
||||||
|
} // namespace sls
|
30
slsDetectorSoftware/generator/inferAction.in.h
Normal file
30
slsDetectorSoftware/generator/inferAction.in.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include "CmdParser.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace sls {
|
||||||
|
class InferAction {
|
||||||
|
public:
|
||||||
|
InferAction() {}
|
||||||
|
int infer(sls::CmdParser &parser, std::ostream &os = std::cout);
|
||||||
|
std::vector<std::string> args;
|
||||||
|
std::string cmd;
|
||||||
|
|
||||||
|
// generated functions
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (1) - DO NOT REMOVE
|
||||||
|
// int frames();
|
||||||
|
|
||||||
|
private:
|
||||||
|
using FunctionMap = std::map<std::string, int (InferAction::*)()>;
|
||||||
|
FunctionMap functions{
|
||||||
|
// generated functions
|
||||||
|
|
||||||
|
// THIS COMMENT TO BE REPLACED BY THE ACTUAL CODE (2) - DO NOT REMOVE
|
||||||
|
|
||||||
|
// {"frames",&InferAction::frames}
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
64
slsDetectorSoftware/generator/infer_action/check_infer.py
Normal file
64
slsDetectorSoftware/generator/infer_action/check_infer.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def check_infer(EXTENDED_COMMANDS_PATH=Path(__file__).parent.parent / "extended_commands.yaml", commands=None):
|
||||||
|
if commands is None:
|
||||||
|
# load yaml file
|
||||||
|
with EXTENDED_COMMANDS_PATH.open('r') as f:
|
||||||
|
commands = yaml.safe_load(f)
|
||||||
|
|
||||||
|
type_distinguishable = {}
|
||||||
|
non_distinguishable = {}
|
||||||
|
|
||||||
|
for command_name, command in commands.items():
|
||||||
|
# todo: remove this (added for debug)
|
||||||
|
# if command_name != 'badchannels':
|
||||||
|
# continue
|
||||||
|
if len(command["actions"]) == 1:
|
||||||
|
action = list(command["actions"].items())[0][1]
|
||||||
|
for arg in action['args']:
|
||||||
|
if arg['argc'] == -1:
|
||||||
|
non_distinguishable[(command_name, arg['argc'])] = ([], arg['arg_types'])
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
get_argcs = {}
|
||||||
|
get_args = command['actions']['GET']['args']
|
||||||
|
for arg in get_args:
|
||||||
|
if arg['argc'] != -1:
|
||||||
|
get_argcs[arg["argc"]] = arg['arg_types']
|
||||||
|
else:
|
||||||
|
non_distinguishable[(command_name, arg['argc'])] = ([], arg['arg_types'])
|
||||||
|
put_args = command['actions']['PUT']['args']
|
||||||
|
for arg in put_args:
|
||||||
|
if arg['argc'] == -1:
|
||||||
|
non_distinguishable[(command_name, arg['argc'])] = ([], arg['arg_types'])
|
||||||
|
elif arg['argc'] in get_argcs:
|
||||||
|
if arg['arg_types'] != get_argcs[arg['argc']]:
|
||||||
|
type_distinguishable[(command_name, arg['argc'])] = (get_argcs[arg['argc']], arg['arg_types'])
|
||||||
|
else:
|
||||||
|
non_distinguishable[(command_name, arg['argc'])] = (get_argcs[arg['argc']], arg['arg_types'])
|
||||||
|
|
||||||
|
return type_distinguishable, non_distinguishable
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
argparse = argparse.ArgumentParser()
|
||||||
|
argparse.add_argument("--print", choices=['all', 'type', 'impossible'], default="all", help="command name")
|
||||||
|
args = argparse.parse_args()
|
||||||
|
|
||||||
|
type_distinguishable, non_distinguishable = check_infer()
|
||||||
|
if args.print == 'type' or args.print == 'all':
|
||||||
|
print("type distinguishable:")
|
||||||
|
print("command_name: argc get_arg_type put_arg_type\n")
|
||||||
|
for (command_name, argc), (get_arg_types, put_arg_types) in type_distinguishable.items():
|
||||||
|
print(f"{command_name}: {argc} {get_arg_types} {put_arg_types}")
|
||||||
|
|
||||||
|
if args.print == 'impossible' or args.print == 'all':
|
||||||
|
print("\n\nimpossible to distinguish:")
|
||||||
|
print("command_name: argc get_arg_type put_arg_type")
|
||||||
|
for (command_name, argc), (get_arg_types, put_arg_types) in non_distinguishable.items():
|
||||||
|
print(f"{command_name}: {argc} {get_arg_types} {put_arg_types}")
|
288
slsDetectorSoftware/generator/readme.md
Normal file
288
slsDetectorSoftware/generator/readme.md
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
# Generator
|
||||||
|
used to generate C++ cli commands. and bash autocompletion scripts.
|
||||||
|
## Autocomplete
|
||||||
|
|
||||||
|
### Overview
|
||||||
|
|
||||||
|
Looks through the `dump.json` file for the different values of an enum and stores them in the dictionary `type_values`.
|
||||||
|
```sh
|
||||||
|
# To print the different values for enums
|
||||||
|
python gen_commands.py -a
|
||||||
|
```
|
||||||
|
|
||||||
|
also the autocomplete.py generates shell autocompletion scripts for both bash and zsh. It uses the template file `bash_autocomplete.in.sh` and adds the necessary code in an output file `bash_autocomplete.sh` (same for zsh).
|
||||||
|
To use the bash autocompletion the `bash_autocomplete.sh` must be sourced.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source bash_autocomplete.sh
|
||||||
|
# g <Tab><Tab> will give the list of all commands
|
||||||
|
# p 0:<Tab><Tab> will also give the list of all commands
|
||||||
|
# g exp<Tab> will autocomplete to g exptime
|
||||||
|
# g exptime <Tab><Tab> will return "s ms us ns"
|
||||||
|
# p timing <Tab><Tab> will return "auto,burst_trigger,gating..."
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:**
|
||||||
|
The dump.json is the AST of the file `slsDetectorPackage/slsSupportLib/src/ToString.cpp`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# to generate the dump.json file
|
||||||
|
cd slsSupportLib/src/ToString.cpp
|
||||||
|
clang++ -Xclang -ast-dump=json -Xclang -ast-dump-filter -Xclang StringTo -c ToString.cpp -I ../include/ -std=gnu++11
|
||||||
|
# clang version used: 14.0.0-1ubuntu1.1
|
||||||
|
```
|
||||||
|
|
||||||
|
the `dump.json` file produced by clang is not a correct json file because we used the `-ast-dump-filter`. autocomplete.py can be used to fix the format of `dump.json` and produce a new file called `fixed.json` that is json format.
|
||||||
|
```
|
||||||
|
# to convert dump.json into correct json format.
|
||||||
|
python autocomplete.py -f # produces the file fixed.json
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code components
|
||||||
|
|
||||||
|
- `type_values` is a dictionary that contains the different values for commands args. It is populated with enum values that stard with defs:: or slsDetectorDefs:: (eg. defs::burstMode). Also it contains values added manually such as "mv,mV" and those start with special::
|
||||||
|
- `generate_type_values` parses the AST file to find the part that contains if statements. and extracts the different possible values for an enum.
|
||||||
|
- `generate_bash_autocomplete` generates autocompletion scripts for bash or zsh. the difference between zsh and bash scripts can be found in the template files. (bash handles 0:<Tab><Tab> completion differently than zsh more details can be found in the comments of the template files )
|
||||||
|
- `fix_json` fixes the file 'autocomplete/dump.json' and outputs a new corrected file in 'autocomplete/fixed.json'
|
||||||
|
|
||||||
|
## Command Parser
|
||||||
|
|
||||||
|
Definitely the most important component of all the generator module.
|
||||||
|
|
||||||
|
command_parser exist to keep the commands.yaml file concise and easy to read and produce a complete version of the commands.yaml for the code generator to work on.
|
||||||
|
|
||||||
|
The goal is that the code generator works on a version of commands.yaml that is easy to iterate over and generate code.
|
||||||
|
```
|
||||||
|
# complete version
|
||||||
|
some_command:
|
||||||
|
help: "do this"
|
||||||
|
infer_action: true
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
function: "getCommand"
|
||||||
|
...
|
||||||
|
- argc: 1
|
||||||
|
function: "getCommand"
|
||||||
|
...
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
- argc: 0
|
||||||
|
function: "getCommandMythen"
|
||||||
|
...
|
||||||
|
PUT:
|
||||||
|
args:
|
||||||
|
- argc: 2
|
||||||
|
function: "setCommand"
|
||||||
|
...
|
||||||
|
- argc: 3
|
||||||
|
function: "setCommand"
|
||||||
|
...
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
the complete vesion can only have `args` or `detectors` field inside an action (GET or PUT). **Each element in the args array have a different argc**. and in each element in the args array we can find all the information needed to generate the code for that one argc case. for example in the code `if(action == 'GET')` and `if (args.size() == 1)` then we can generate the code for that one case independetly.
|
||||||
|
|
||||||
|
|
||||||
|
commands.yaml has a lot on ~inheritance~. examples show best what it is:
|
||||||
|
|
||||||
|
> fields insides an action will be passed to args and detectors
|
||||||
|
|
||||||
|
> the extended args for default actions will be used for detectors
|
||||||
|
|
||||||
|
> any field can be overriden
|
||||||
|
|
||||||
|
```
|
||||||
|
resetdacs:
|
||||||
|
help: "[(optional) hard] ..."
|
||||||
|
actions:
|
||||||
|
PUT:
|
||||||
|
function: resetToDefaultDacs
|
||||||
|
require_det_id: true
|
||||||
|
output: [ '"successful"' ]
|
||||||
|
input_types: [ bool ]
|
||||||
|
args:
|
||||||
|
- argc: 1
|
||||||
|
arg_types: [ special::hard ]
|
||||||
|
input: [ '"1"' ]
|
||||||
|
- argc: 0
|
||||||
|
input: [ '"0"' ]
|
||||||
|
|
||||||
|
# this will be converted to
|
||||||
|
|
||||||
|
resetdacs:
|
||||||
|
actions:
|
||||||
|
PUT:
|
||||||
|
args:
|
||||||
|
- arg_types:
|
||||||
|
- special::hard
|
||||||
|
argc: 1
|
||||||
|
cast_input:
|
||||||
|
- false
|
||||||
|
check_det_id: false
|
||||||
|
convert_det_id: true
|
||||||
|
function: resetToDefaultDacs
|
||||||
|
input:
|
||||||
|
- '"1"'
|
||||||
|
input_types:
|
||||||
|
- bool
|
||||||
|
output:
|
||||||
|
- '"successful"'
|
||||||
|
require_det_id: true
|
||||||
|
store_result_in_t: false
|
||||||
|
- arg_types: []
|
||||||
|
argc: 0
|
||||||
|
cast_input:
|
||||||
|
- false
|
||||||
|
check_det_id: false
|
||||||
|
convert_det_id: true
|
||||||
|
function: resetToDefaultDacs
|
||||||
|
input:
|
||||||
|
- '"0"'
|
||||||
|
input_types:
|
||||||
|
- bool
|
||||||
|
output:
|
||||||
|
- '"successful"'
|
||||||
|
require_det_id: true
|
||||||
|
store_result_in_t: false
|
||||||
|
command_name: resetdacs
|
||||||
|
function_alias: resetdacs
|
||||||
|
help: "[(optional) hard] ..."
|
||||||
|
infer_action: true
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
command_parser does not have a specific schema for the commands.yaml this is by design so it can be very extensible and future-proof. This also can have problems when there is typos (writing intput instead of input...)
|
||||||
|
|
||||||
|
command_parser first verifies the commands.yaml and checks if there's some obvious problems in it.
|
||||||
|
|
||||||
|
templates found in commands.yaml were taken from the CmdProxy code they were added for debugging purposes when writing the generator.
|
||||||
|
|
||||||
|
|
||||||
|
tricky things:
|
||||||
|
--
|
||||||
|
- if input array has n elements and cast_input array is empty. command_parser will fill it with n false values.
|
||||||
|
- store_result_in_t will be added by default as true to GET action. but as false to PUT action. (unless it is written in the action)
|
||||||
|
- infer_action by default is true
|
||||||
|
- commands that have is_description true won't be verified
|
||||||
|
- function_alias is the name of the function in the c++ code. by default it is the command name. errors came up with the command virtual as virtual is a reserved keyword in c++
|
||||||
|
- command_name is the string of the command that will be typed in cli. (frames, exptime, ...). by default it is the command name. pattern is a special keyword in yaml. problems came up with the command pattern
|
||||||
|
- arg_types is by default input_types unless otherwise specified
|
||||||
|
- when the parent has specific detector behaviour and the child does not. writing an empty detector section in the action would not inherit any detector specific fields (check exptime1)
|
||||||
|
- commands can inherit other commands (check exptime1 and exptime2)
|
||||||
|
- argc: -1 means that the command has an unknown number of arguments
|
||||||
|
|
||||||
|
|
||||||
|
### Code Walkthrough
|
||||||
|
the code is well commented it is well explained in the script
|
||||||
|
|
||||||
|
### Tests
|
||||||
|
tests for command_parser can be found in `generator/tests/command_parser/`
|
||||||
|
```
|
||||||
|
pip install -r requirements.txt
|
||||||
|
python -m pytests
|
||||||
|
```
|
||||||
|
|
||||||
|
verification is not well tested
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## codegen
|
||||||
|
|
||||||
|
Now for C++ code generation. After parsing the commands.yaml file and producing the extended_commands.yaml `gen_commands.py` will iterate over the commands and generate `Caller.h`, `Caller.cpp`, `inferAction.cpp` and `inferAction.h` .
|
||||||
|
|
||||||
|
### infer action
|
||||||
|
|
||||||
|
the generated code will produce 5 new targets: "sls_detector_get sls_detector_put sls_detector_acquire sls_detector_help sls_detector"
|
||||||
|
|
||||||
|
`sls_detector_get` will set the action as GET
|
||||||
|
`sls_detector_put` will the action as PUT
|
||||||
|
|
||||||
|
`sls_detector` will guess the action depending on the number of arguments
|
||||||
|
|
||||||
|
the codegen module will generate a function for every command that will return the action based on the number of arguments
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
int InferAction::activate() {
|
||||||
|
|
||||||
|
if (args.size() == 0) {
|
||||||
|
return slsDetectorDefs::GET_ACTION;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size() == 1) {
|
||||||
|
return slsDetectorDefs::PUT_ACTION;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
throw RuntimeError("Could not infer action: Wrong number of arguments");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
the `inferAction` class will be called from `CmdApp.cpp` to infer the action and the command function will be called with the appropriate action.
|
||||||
|
|
||||||
|
some commands have the same number of argument count for both get and put. These commands can be found using the the `check_infer.py` script. in the generated code it will say that "sls_detector is disabled"
|
||||||
|
```bash
|
||||||
|
# to see these commands
|
||||||
|
python infer_action/check_infer.py
|
||||||
|
```
|
||||||
|
|
||||||
|
### Caller.cpp code
|
||||||
|
|
||||||
|
in this level we only use the extended_commands.yaml file.
|
||||||
|
the `generate()` function in `gen_commands.py` will iterate over all of the commands and :
|
||||||
|
- write the function signature
|
||||||
|
- write the help
|
||||||
|
- write c++ code to check the inputs: check argument count and check if we are able to convert the arguments into the required types
|
||||||
|
- iterate over actions and arguments
|
||||||
|
- iterate over the detectors and write code for each one of them (if mythen3 ... if eiger ... else default code... ) and call `codegen.write_arg()` to write the argument for a single argument
|
||||||
|
|
||||||
|
codegen.write_arg()
|
||||||
|
-
|
||||||
|
write_arg in codegen reads the argument fields and generate c++ code accordingly.
|
||||||
|
|
||||||
|
## fields explanations
|
||||||
|
- arg_types:[array of types] it is only used for autocompletion no C++ code is dependent on it
|
||||||
|
- is_description:[boolean] same as above
|
||||||
|
- template:[boolean] only used in commands.yaml and it won't present in extended_commands.yaml. it is inspired by the CmdProxy.h code
|
||||||
|
- help:[string] command help
|
||||||
|
- input:[array of variable names] the input arguments that will be passed to the function
|
||||||
|
- input_types:[array of types] the types of the input arguments given to the function
|
||||||
|
- cast_input:[array of boolean] if true it will cast the corresponding input to the type in input_types
|
||||||
|
- output:[array] outputs that will be printed (eg. ["123", "'a'"] will be os<<123<<'a')
|
||||||
|
- function: the function that will be called
|
||||||
|
- function_alias: the name of the function in the c++ code (more on it in tricky things)
|
||||||
|
- command_name: the string of the command that will be typed in cli. (more on it in tricky things)
|
||||||
|
- require_det_id: if true it will require a detector id to be passed as the last argument
|
||||||
|
- check_det_id: if true it will check the detector id and throw an error if it is not valid
|
||||||
|
- convert_det_id: if true it will convert the detector id to the correct type `std::vector<int>{ det_id }`
|
||||||
|
- store_result_in_t: if true it will store the result of the function in the variable t (more on it in tricky things)
|
||||||
|
- infer_action: if true it will infer the action (only if sls_detector is used)
|
||||||
|
- detectors: the detectors that have specific behaviour
|
||||||
|
- args: the arguments of the command
|
||||||
|
- argc: the number of arguments
|
||||||
|
- extra_variables[array]: each element takes three parameters: value, name, type and creates that variable in the beginning of the argument code
|
||||||
|
- exceptions[array]: each element takes two parameters: condition, message
|
||||||
|
- pattern_command: takes three arguments: nGetArgs, nPutArgs and command_name and it will write this code
|
||||||
|
```cpp
|
||||||
|
int level = -1, iArg = 0, nGetArgs = $nGetArgs$, nPutArgs = $nPutArgs$;
|
||||||
|
GetLevelAndUpdateArgIndex(action, $command_name$, level, iArg, nGetArgs,nPutArgs);
|
||||||
|
```
|
||||||
|
- separate_time_units: takes three parameters: input, output[0], output[1] each one is a variable name
|
||||||
|
```cpp
|
||||||
|
std::string tmp_time($input$);
|
||||||
|
std::string $output[1]$ = RemoveUnit(tmp_time);
|
||||||
|
auto $output[0]$ = StringTo<time::ns>(tmp_time, $output[1]$);
|
||||||
|
```
|
||||||
|
- convert_to_time: takes three parameters: input[0], input[1], output
|
||||||
|
```cpp
|
||||||
|
auto output = StringTo<time::ns>(input[0], input[1]);
|
||||||
|
```
|
||||||
|
- ctb_output_list: **maybe it should be removed?** takes 5 parameters: GETFCNLIST, GETFCNNAME, GETFCN, suffix, printable_name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
6
slsDetectorSoftware/generator/requirements.txt
Normal file
6
slsDetectorSoftware/generator/requirements.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
coverage==7.3.1
|
||||||
|
iniconfig==2.0.0
|
||||||
|
packaging==23.1
|
||||||
|
pluggy==1.3.0
|
||||||
|
pytest==7.4.2
|
||||||
|
PyYAML==6.0.1
|
@ -0,0 +1,16 @@
|
|||||||
|
basic:
|
||||||
|
infer_action: false
|
||||||
|
help: "xx11"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
function: 'func1'
|
||||||
|
output: [ OutString(t) ]
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
PUT:
|
||||||
|
function: 'func2'
|
||||||
|
output: [ 'args.front()' ]
|
||||||
|
input: [ 'args[0]' ]
|
||||||
|
input_types: [ int ]
|
||||||
|
cast_input: [ true ]
|
||||||
|
argc: 1
|
@ -0,0 +1,66 @@
|
|||||||
|
---
|
||||||
|
template:
|
||||||
|
infer_action: false
|
||||||
|
help: ""
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
function: 'func1'
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
output: [ OutString(t) ]
|
||||||
|
PUT:
|
||||||
|
function: 'func2'
|
||||||
|
output: [ 'args.front()' ]
|
||||||
|
input: [ 'args[0]' ]
|
||||||
|
input_types: [ int ]
|
||||||
|
cast_input: [ true ]
|
||||||
|
argc: 1
|
||||||
|
|
||||||
|
basic:
|
||||||
|
help: "xx11"
|
||||||
|
inherit_actions: template
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
function: 'x'
|
||||||
|
argc: 2
|
||||||
|
args:
|
||||||
|
- check_det_id: true
|
||||||
|
|
||||||
|
|
||||||
|
template2:
|
||||||
|
infer_action: false
|
||||||
|
template: true
|
||||||
|
help: ""
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
convert_to_time:
|
||||||
|
input: [ 'args[0]', 'args[1]' ]
|
||||||
|
output: converted_time
|
||||||
|
separate_time_units:
|
||||||
|
input: 'args[0]'
|
||||||
|
output: [ converted_time, unit ]
|
||||||
|
function: 'func1'
|
||||||
|
output: [ OutString(t) ]
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
- argc: 99
|
||||||
|
PUT:
|
||||||
|
function: funcTemplatePUT
|
||||||
|
args:
|
||||||
|
- argc: 19
|
||||||
|
function: 'func19'
|
||||||
|
- argc: 91
|
||||||
|
|
||||||
|
basic2:
|
||||||
|
inherit_actions: template2
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
function: 'x'
|
||||||
|
argc: 2
|
||||||
|
args:
|
||||||
|
- check_det_id: true
|
||||||
|
input: [ 'args[0]', a,b,c ]
|
||||||
|
input_types: [ int, int, int, int ]
|
||||||
|
PUT:
|
||||||
|
function: 'y'
|
||||||
|
|
@ -0,0 +1,208 @@
|
|||||||
|
basic:
|
||||||
|
infer_action: false
|
||||||
|
help: "xx11"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
function: 'func1'
|
||||||
|
output: [ OutString(t) ]
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
- argc : 1
|
||||||
|
output: [ testytest ]
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen3'
|
||||||
|
CHIPTESTBOARD:
|
||||||
|
args:
|
||||||
|
- argc: 55
|
||||||
|
output: [ ctbOutput ]
|
||||||
|
PUT:
|
||||||
|
detectors:
|
||||||
|
EIGER:
|
||||||
|
function: 'do_eiger'
|
||||||
|
argc: 99
|
||||||
|
output: [ eigerOutput ]
|
||||||
|
|
||||||
|
|
||||||
|
# classes of tests:
|
||||||
|
# classes of template tests: has args or has detectors => 4 cases noted (0,0) ... (1,1)
|
||||||
|
# classes of childs: has args or has detectors => 4 cases noted (0,0) ... (1,1)
|
||||||
|
# => 16 cases
|
||||||
|
# example: case_0111: template (0,1) and child (1,1)
|
||||||
|
#################### exhaustive testing over chosen classes of tests
|
||||||
|
|
||||||
|
template_01:
|
||||||
|
infer_action: true
|
||||||
|
help: "vv12"
|
||||||
|
template: true
|
||||||
|
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen3'
|
||||||
|
argc: 99
|
||||||
|
CHIPTESTBOARD:
|
||||||
|
function: 'do_ctb'
|
||||||
|
argc: 98
|
||||||
|
|
||||||
|
case_0100:
|
||||||
|
inherit_actions: template_01
|
||||||
|
help: "0100"
|
||||||
|
|
||||||
|
case_0101:
|
||||||
|
inherit_actions: template_01
|
||||||
|
help: "0101"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
function: 'get_function'
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen23'
|
||||||
|
argc: 420
|
||||||
|
|
||||||
|
case_0110:
|
||||||
|
inherit_actions: template_01
|
||||||
|
help: "0110"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
argc: 111
|
||||||
|
function: 'get_function'
|
||||||
|
|
||||||
|
case_0110v2:
|
||||||
|
inherit_actions: template_01
|
||||||
|
help: "0110v2"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 111
|
||||||
|
function: 'get_function'
|
||||||
|
|
||||||
|
|
||||||
|
case_0111:
|
||||||
|
inherit_actions: template_01
|
||||||
|
help: "0111"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 111
|
||||||
|
function: 'get_function'
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen23'
|
||||||
|
argc: 420
|
||||||
|
|
||||||
|
##### cases 10** tests
|
||||||
|
template_10:
|
||||||
|
template: true
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
- argc : 1
|
||||||
|
output: [ testytest ]
|
||||||
|
|
||||||
|
case_1000:
|
||||||
|
inherit_actions: template_10
|
||||||
|
help: "1000"
|
||||||
|
|
||||||
|
case_1001:
|
||||||
|
inherit_actions: template_10
|
||||||
|
help: "1001"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
args:
|
||||||
|
- function: 'do_mythen23'
|
||||||
|
argc: 420
|
||||||
|
- function: 'do_mythen3'
|
||||||
|
argc: 99
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case_1010:
|
||||||
|
inherit_actions: template_10
|
||||||
|
help: "1010"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 111
|
||||||
|
function: 'get_function'
|
||||||
|
|
||||||
|
case_1011:
|
||||||
|
inherit_actions: template_10
|
||||||
|
help: "1011"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 111
|
||||||
|
function: 'get_function'
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen23'
|
||||||
|
|
||||||
|
##### cases 11** tests
|
||||||
|
template_11:
|
||||||
|
template: true
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
args:
|
||||||
|
- argc: 0
|
||||||
|
- argc : 1
|
||||||
|
output: [ testytest ]
|
||||||
|
detectors:
|
||||||
|
EIGER:
|
||||||
|
function: 'do_eiger'
|
||||||
|
args:
|
||||||
|
- argc: 99
|
||||||
|
output: [ eigerOutput ]
|
||||||
|
POTATO:
|
||||||
|
function: 'do_potato'
|
||||||
|
|
||||||
|
|
||||||
|
case_1100:
|
||||||
|
inherit_actions: template_11
|
||||||
|
help: "1100"
|
||||||
|
|
||||||
|
case_1101:
|
||||||
|
inherit_actions: template_11
|
||||||
|
help: "1101"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen3'
|
||||||
|
POTATO:
|
||||||
|
function: 'do_potato'
|
||||||
|
args:
|
||||||
|
- argc: 101
|
||||||
|
function: 'potato_function'
|
||||||
|
- argc: 202
|
||||||
|
|
||||||
|
case_1110:
|
||||||
|
inherit_actions: template_11
|
||||||
|
help: "1110"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
argc: 77
|
||||||
|
function: 'get_function'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case_1111:
|
||||||
|
inherit_actions: template_11
|
||||||
|
help: "1111"
|
||||||
|
actions:
|
||||||
|
GET:
|
||||||
|
argc: 77
|
||||||
|
function: 'get_function'
|
||||||
|
detectors:
|
||||||
|
MYTHEN3:
|
||||||
|
function: 'do_mythen3'
|
||||||
|
POTATO:
|
||||||
|
function: 'do_potato'
|
||||||
|
args:
|
||||||
|
- argc: 101
|
||||||
|
function: 'potato_function'
|
||||||
|
- argc: 202
|
@ -0,0 +1,101 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from commands_parser.commands_parser import CommandParser
|
||||||
|
|
||||||
|
data_path = Path(__file__).parent.parent / "data"
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_propagation(tmp_path):
|
||||||
|
output_file = tmp_path / "basic.yaml"
|
||||||
|
command_parser = CommandParser(commands_file=data_path / "basic.yaml", output_file=output_file)
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
||||||
|
|
||||||
|
assert output_file.exists()
|
||||||
|
command = yaml.unsafe_load(output_file.open('r'))['basic']
|
||||||
|
assert command['help'] == "xx11"
|
||||||
|
assert len(command['actions']) == 2
|
||||||
|
# test 'GET' action
|
||||||
|
assert 'args' in command['actions']['GET']
|
||||||
|
assert len(command['actions']['GET'].keys()) == 1 # only 'args' key
|
||||||
|
assert len(command['actions']['GET']['args']) == 1 # only one argument
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['args'][0]['function'] == 'func1'
|
||||||
|
assert command['actions']['GET']['args'][0]['output'] == ['OutString(t)']
|
||||||
|
assert command['actions']['GET']['args'][0]['input'] == []
|
||||||
|
assert command['actions']['GET']['args'][0]['cast_input'] == []
|
||||||
|
assert command['actions']['GET']['args'][0]['require_det_id'] is False
|
||||||
|
# test PUT action
|
||||||
|
assert 'args' in command['actions']['PUT']
|
||||||
|
assert len(command['actions']['PUT'].keys()) == 1 # only 'args' key
|
||||||
|
assert len(command['actions']['PUT']['args']) == 1 # only one argument
|
||||||
|
assert command['actions']['PUT']['args'][0]['argc'] == 1
|
||||||
|
assert command['actions']['PUT']['args'][0]['function'] == 'func2'
|
||||||
|
assert command['actions']['PUT']['args'][0]['cast_input'] == [True]
|
||||||
|
assert command['actions']['PUT']['args'][0]['output'] == ['args.front()']
|
||||||
|
assert command['actions']['PUT']['args'][0]['input_types'] == ['int']
|
||||||
|
assert command['actions']['PUT']['args'][0]['require_det_id'] is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_inheritance(tmp_path):
|
||||||
|
output_file = tmp_path / "basic_inheritance.yaml"
|
||||||
|
command_parser = CommandParser(commands_file=data_path / "basic_inheritance.yaml", output_file=output_file)
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
||||||
|
assert output_file.exists()
|
||||||
|
command = yaml.unsafe_load(output_file.open('r'))['basic']
|
||||||
|
assert command['help'] == "xx11"
|
||||||
|
assert command['actions'].keys() == {'GET', 'PUT'}
|
||||||
|
# test 'GET' action
|
||||||
|
assert 'args' in command['actions']['GET']
|
||||||
|
assert command['actions']['GET'].keys() == {'args'} # only 'args' key
|
||||||
|
assert len(command['actions']['GET']['args']) == 1 # only one argument
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 2
|
||||||
|
assert command['actions']['GET']['args'][0]['function'] == 'x'
|
||||||
|
assert command['actions']['GET']['args'][0]['output'] == [] # test overwriting args when they are present in child
|
||||||
|
assert command['actions']['GET']['args'][0]['input'] == []
|
||||||
|
assert command['actions']['GET']['args'][0]['cast_input'] == []
|
||||||
|
assert command['actions']['GET']['args'][0]['require_det_id'] is False
|
||||||
|
# test PUT action
|
||||||
|
assert 'args' in command['actions']['PUT']
|
||||||
|
assert command['actions']['PUT'].keys() == {'args'} # only 'args' key
|
||||||
|
assert len(command['actions']['PUT']['args']) == 1 # only one argument
|
||||||
|
assert command['actions']['PUT']['args'][0]['argc'] == 1
|
||||||
|
assert command['actions']['PUT']['args'][0]['function'] == 'func2'
|
||||||
|
assert command['actions']['PUT']['args'][0]['cast_input'] == [True]
|
||||||
|
assert command['actions']['PUT']['args'][0]['output'] == ['args.front()']
|
||||||
|
assert command['actions']['PUT']['args'][0]['input_types'] == ['int']
|
||||||
|
assert command['actions']['PUT']['args'][0]['require_det_id'] is False
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_inheritance2(tmp_path):
|
||||||
|
output_file = tmp_path / "basic_inheritance.yaml"
|
||||||
|
command_parser = CommandParser(commands_file=data_path / "basic_inheritance.yaml", output_file=output_file)
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
||||||
|
assert output_file.exists()
|
||||||
|
command = yaml.unsafe_load(output_file.open('r'))['basic2']
|
||||||
|
# check GET
|
||||||
|
assert len(command['actions']['GET']['args']) == 1
|
||||||
|
assert command['actions']['GET'].keys() == {'args'}
|
||||||
|
arg = command['actions']['GET']['args'][0]
|
||||||
|
assert arg['argc'] == 2
|
||||||
|
assert arg['output'] == ['OutString(t)']
|
||||||
|
# check that length of cast input is equal to length of input_types and input
|
||||||
|
assert len(arg['input']) == len(arg['input_types']) == len(arg['cast_input']) == 4
|
||||||
|
assert arg['function'] == 'x'
|
||||||
|
assert 'convert_to_time' in arg
|
||||||
|
assert arg['convert_to_time'].keys() == {'input', 'output'}
|
||||||
|
assert 'separate_time_units' in arg
|
||||||
|
assert arg['separate_time_units'].keys() == {'input', 'output'}
|
||||||
|
|
||||||
|
# check PUT
|
||||||
|
assert command['actions']['PUT'].keys() == {'args'}
|
||||||
|
assert len(command['actions']['PUT']['args']) == 2
|
||||||
|
assert command['actions']['PUT']['args'][0]['argc'] == 19
|
||||||
|
assert command['actions']['PUT']['args'][0]['function'] == 'y'
|
||||||
|
assert command['actions']['PUT']['args'][1]['argc'] == 91
|
||||||
|
assert command['actions']['PUT']['args'][1]['function'] == 'y'
|
||||||
|
|
@ -0,0 +1,309 @@
|
|||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest as pytest
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from commands_parser.commands_parser import CommandParser
|
||||||
|
|
||||||
|
data_path = Path(__file__).parent.parent / "data"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def detector_file_commands(tmp_path):
|
||||||
|
output_file = tmp_path / "detectors.yaml"
|
||||||
|
command_parser = CommandParser(commands_file=data_path / "detectors.yaml", output_file=output_file)
|
||||||
|
command_parser.verify_format()
|
||||||
|
|
||||||
|
def func(command):
|
||||||
|
return command_parser.parse_command(command)
|
||||||
|
|
||||||
|
return func
|
||||||
|
|
||||||
|
|
||||||
|
def test_basic_propagation(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('basic')
|
||||||
|
|
||||||
|
assert command['help'] == "xx11"
|
||||||
|
|
||||||
|
# GET
|
||||||
|
assert command['actions']['GET'].keys() == {'detectors', 'args'}
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
|
||||||
|
mythen = command['actions']['GET']['detectors']['MYTHEN3']
|
||||||
|
assert len(mythen) == 2
|
||||||
|
assert mythen[0]['argc'] == 0
|
||||||
|
assert mythen[1]['argc'] == 1
|
||||||
|
assert mythen[0]['function'] == mythen[1]['function'] == 'do_mythen3'
|
||||||
|
assert mythen[0]['output'] == ['OutString(t)']
|
||||||
|
assert mythen[1]['output'] == ['testytest']
|
||||||
|
|
||||||
|
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
|
||||||
|
assert len(ctb) == 1
|
||||||
|
assert ctb[0]['argc'] == 55
|
||||||
|
assert ctb[0]['function'] == 'func1'
|
||||||
|
|
||||||
|
# PUT
|
||||||
|
assert command['actions']['PUT'].keys() == {'detectors'}
|
||||||
|
assert command['actions']['PUT']['detectors'].keys() == {'EIGER'}
|
||||||
|
eiger = command['actions']['PUT']['detectors']['EIGER']
|
||||||
|
assert len(eiger) == 1
|
||||||
|
assert eiger[0]['argc'] == 99
|
||||||
|
assert eiger[0]['function'] == 'do_eiger'
|
||||||
|
assert eiger[0]['output'] == ['eigerOutput']
|
||||||
|
|
||||||
|
# 16 test cases for inheritance
|
||||||
|
# 1st bit: parent has args
|
||||||
|
# 2nd bit: parent has detectors
|
||||||
|
# 3rd bit: child has args
|
||||||
|
# 4th bit: child has detectors
|
||||||
|
# each test case is a combination of the above bits
|
||||||
|
# all the possible combinations are tested
|
||||||
|
|
||||||
|
def test_inheritance_0100(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_0100')
|
||||||
|
assert command['help'] == "0100"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'detectors'}
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
|
||||||
|
mythen = command['actions']['GET']['detectors']['MYTHEN3']
|
||||||
|
assert len(mythen) == 1
|
||||||
|
assert mythen[0]['argc'] == 99
|
||||||
|
assert mythen[0]['function'] == 'do_mythen3'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_0101(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_0101')
|
||||||
|
assert command['help'] == "0101"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'detectors'}
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
|
||||||
|
mythen = command['actions']['GET']['detectors']['MYTHEN3']
|
||||||
|
assert len(mythen) == 1
|
||||||
|
assert mythen[0]['argc'] == 420
|
||||||
|
assert mythen[0]['function'] == 'do_mythen23'
|
||||||
|
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
|
||||||
|
assert len(ctb) == 1
|
||||||
|
assert ctb[0]['argc'] == 98
|
||||||
|
assert ctb[0]['function'] == 'do_ctb'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_0110(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_0110')
|
||||||
|
assert command['help'] == "0110"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 111
|
||||||
|
mythen = command['actions']['GET']['detectors']['MYTHEN3']
|
||||||
|
assert len(mythen) == 1
|
||||||
|
assert mythen[0]['argc'] == 99
|
||||||
|
assert mythen[0]['function'] == 'do_mythen3'
|
||||||
|
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
|
||||||
|
assert len(ctb) == 1
|
||||||
|
assert ctb[0]['argc'] == 98
|
||||||
|
assert ctb[0]['function'] == 'do_ctb'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_0110v2(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_0110v2')
|
||||||
|
assert command['help'] == "0110v2"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 111
|
||||||
|
mythen = command['actions']['GET']['detectors']['MYTHEN3']
|
||||||
|
assert len(mythen) == 1
|
||||||
|
assert mythen[0]['argc'] == 99
|
||||||
|
assert mythen[0]['function'] == 'do_mythen3'
|
||||||
|
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
|
||||||
|
assert len(ctb) == 1
|
||||||
|
assert ctb[0]['argc'] == 98
|
||||||
|
assert ctb[0]['function'] == 'do_ctb'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritacnce_0111(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_0111')
|
||||||
|
assert command['help'] == "0111"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3', 'CHIPTESTBOARD'}
|
||||||
|
mythen = command['actions']['GET']['detectors']['MYTHEN3']
|
||||||
|
assert len(mythen) == 1
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 111
|
||||||
|
assert len(mythen) == 1
|
||||||
|
assert mythen[0]['argc'] == 420
|
||||||
|
assert mythen[0]['function'] == 'do_mythen23'
|
||||||
|
ctb = command['actions']['GET']['detectors']['CHIPTESTBOARD']
|
||||||
|
assert len(ctb) == 1
|
||||||
|
assert ctb[0]['argc'] == 98
|
||||||
|
assert ctb[0]['function'] == 'do_ctb'
|
||||||
|
|
||||||
|
|
||||||
|
# cases 1000, 1001, 1010, 1011
|
||||||
|
def test_inheritance_1000(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1000')
|
||||||
|
assert command['help'] == "1000"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 2
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['args'][0]['output'] == []
|
||||||
|
|
||||||
|
assert command['actions']['GET']['args'][1]['argc'] == 1
|
||||||
|
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_1001(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1001')
|
||||||
|
assert command['help'] == "1001"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 2
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['args'][0]['output'] == []
|
||||||
|
assert command['actions']['GET']['args'][1]['argc'] == 1
|
||||||
|
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
|
||||||
|
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3'}
|
||||||
|
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 2
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 420
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen23'
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['argc'] == 99
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['function'] == 'do_mythen3'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_1010(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1010')
|
||||||
|
assert command['help'] == "1010"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 1
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 111
|
||||||
|
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_1011(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1011')
|
||||||
|
assert command['help'] == "1011"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 1
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 111
|
||||||
|
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
|
||||||
|
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'MYTHEN3'}
|
||||||
|
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 1
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 111
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen23'
|
||||||
|
|
||||||
|
|
||||||
|
# cases 1100, 1101, 1110, 1111
|
||||||
|
|
||||||
|
def test_inheritance_1100(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1100')
|
||||||
|
assert command['help'] == "1100"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 2
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['args'][0]['output'] == []
|
||||||
|
|
||||||
|
assert command['actions']['GET']['args'][1]['argc'] == 1
|
||||||
|
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
|
||||||
|
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'POTATO'}
|
||||||
|
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['output'] == ['eigerOutput']
|
||||||
|
|
||||||
|
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'do_potato'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_1101(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1101')
|
||||||
|
assert command['help'] == "1101"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 2
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['args'][0]['output'] == []
|
||||||
|
assert command['actions']['GET']['args'][1]['argc'] == 1
|
||||||
|
assert command['actions']['GET']['args'][1]['output'] == ['testytest']
|
||||||
|
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'MYTHEN3', 'POTATO'}
|
||||||
|
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 2
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen3'
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['argc'] == 1
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][1]['function'] == 'do_mythen3'
|
||||||
|
|
||||||
|
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['output'] == ['eigerOutput']
|
||||||
|
|
||||||
|
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 101
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'potato_function'
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][1]['argc'] == 202
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][1]['function'] == 'do_potato'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_1110(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1110')
|
||||||
|
assert command['help'] == "1110"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 1
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 77
|
||||||
|
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
|
||||||
|
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'POTATO'}
|
||||||
|
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
|
||||||
|
|
||||||
|
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 0
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'do_potato'
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][1]['argc'] == 1
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][1]['function'] == 'do_potato'
|
||||||
|
|
||||||
|
|
||||||
|
def test_inheritance_1111(tmp_path, detector_file_commands):
|
||||||
|
command = detector_file_commands('case_1111')
|
||||||
|
assert command['help'] == "1111"
|
||||||
|
assert 'actions' in command
|
||||||
|
assert command['actions'].keys() == {'GET'}
|
||||||
|
assert command['actions']['GET'].keys() == {'args', 'detectors'}
|
||||||
|
assert len(command['actions']['GET']['args']) == 1
|
||||||
|
assert command['actions']['GET']['args'][0]['argc'] == 77
|
||||||
|
assert command['actions']['GET']['args'][0]['function'] == 'get_function'
|
||||||
|
|
||||||
|
assert command['actions']['GET']['detectors'].keys() == {'EIGER', 'MYTHEN3', 'POTATO'}
|
||||||
|
assert len(command['actions']['GET']['detectors']['MYTHEN3']) == 1
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['argc'] == 77
|
||||||
|
assert command['actions']['GET']['detectors']['MYTHEN3'][0]['function'] == 'do_mythen3'
|
||||||
|
|
||||||
|
assert len(command['actions']['GET']['detectors']['EIGER']) == 1
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['argc'] == 99
|
||||||
|
assert command['actions']['GET']['detectors']['EIGER'][0]['function'] == 'do_eiger'
|
||||||
|
|
||||||
|
assert len(command['actions']['GET']['detectors']['POTATO']) == 2
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['argc'] == 101
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][0]['function'] == 'potato_function'
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][1]['argc'] == 202
|
||||||
|
assert command['actions']['GET']['detectors']['POTATO'][1]['function'] == 'do_potato'
|
@ -0,0 +1,29 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
from commands_parser.commands_parser import CommandParser
|
||||||
|
import gen_commands
|
||||||
|
|
||||||
|
data_path = Path(__file__).parent.parent
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_and_generate(tmp_path):
|
||||||
|
"""
|
||||||
|
tests that the parse and generate functions work without errors
|
||||||
|
:param tmp_path:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
output_file = tmp_path / "detectors.yaml"
|
||||||
|
command_parser = CommandParser(commands_file=data_path / "commands.yaml", output_file=output_file)
|
||||||
|
command_parser.verify_format()
|
||||||
|
command_parser.parse_all_commands()
|
||||||
|
assert output_file.exists()
|
||||||
|
|
||||||
|
GEN_PATH = Path(__file__).parent.parent
|
||||||
|
gen_commands.generate(
|
||||||
|
output_file,
|
||||||
|
GEN_PATH / "Caller.in.cpp",
|
||||||
|
GEN_PATH / "Caller.in.h",
|
||||||
|
tmp_path / "Caller.cpp",
|
||||||
|
tmp_path / "Caller.h",
|
||||||
|
)
|
||||||
|
assert (tmp_path / "Caller.cpp").exists()
|
||||||
|
assert (tmp_path / "Caller.h").exists()
|
28
slsDetectorSoftware/generator/very_special_functions.txt
Normal file
28
slsDetectorSoftware/generator/very_special_functions.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
hostname (find +)
|
||||||
|
acquire
|
||||||
|
versions (maybe with few tweaks)
|
||||||
|
threshold (+++++)
|
||||||
|
trimen (maybe with few tweaks)
|
||||||
|
badchannels (somewhat special)
|
||||||
|
currentsource (special)
|
||||||
|
dacvalues (can be done with the ctb_output_list)
|
||||||
|
udp_srcip (could be done if I add condition functionality for logging)
|
||||||
|
udp_srcip2 (same as above)
|
||||||
|
udp_dstip (same as above)
|
||||||
|
udp_dstip2
|
||||||
|
rx_hostname (split('+'))
|
||||||
|
rx_roi (can be done if there;s condition support?)
|
||||||
|
ratecorr (can be done if there's condition support?)
|
||||||
|
burstmode (very special)
|
||||||
|
vetostream
|
||||||
|
counters
|
||||||
|
gaincaps (has for loop and condition)
|
||||||
|
samples (ask Dhanya if it is okay to change the order of calling the ctb functions in PUT)
|
||||||
|
slowadc (has for loop)
|
||||||
|
rx_dbitlist (very special)
|
||||||
|
rx_jsonaddheader (very special)
|
||||||
|
execcommand (has for loop)
|
||||||
|
thresholdnotb
|
||||||
|
# notes
|
||||||
|
# ReceiverStatus error on put is not done
|
||||||
|
# ask about burstmode function
|
@ -71,7 +71,6 @@ class Detector {
|
|||||||
/** Gets shared memory ID */
|
/** Gets shared memory ID */
|
||||||
int getShmId() const;
|
int getShmId() const;
|
||||||
|
|
||||||
/** package git branch */
|
|
||||||
std::string getPackageVersion() const;
|
std::string getPackageVersion() const;
|
||||||
|
|
||||||
std::string getClientVersion() const;
|
std::string getClientVersion() const;
|
||||||
@ -99,7 +98,7 @@ class Detector {
|
|||||||
Result<std::string> getReceiverVersion(Positions pos = {}) const;
|
Result<std::string> getReceiverVersion(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2,
|
/** Options: EIGER, JUNGFRAU, GOTTHARD, MOENCH, MYTHEN3, GOTTHARD2,
|
||||||
* CHIPTESTBOARD */
|
* CHIPTESTBOARD, XILINX_CHIPTESTBOARD */
|
||||||
Result<defs::detectorType> getDetectorType(Positions pos = {}) const;
|
Result<defs::detectorType> getDetectorType(Positions pos = {}) const;
|
||||||
|
|
||||||
/** Gets the total number of modules in shared memory */
|
/** Gets the total number of modules in shared memory */
|
||||||
|
18260
slsDetectorSoftware/src/Caller.cpp
Normal file
18260
slsDetectorSoftware/src/Caller.cpp
Normal file
File diff suppressed because it is too large
Load Diff
878
slsDetectorSoftware/src/Caller.h
Normal file
878
slsDetectorSoftware/src/Caller.h
Normal file
@ -0,0 +1,878 @@
|
|||||||
|
// This file is used as input to generate the caller class
|
||||||
|
|
||||||
|
#include "CmdParser.h"
|
||||||
|
#include "HelpDacs.h"
|
||||||
|
#include "sls/Detector.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
namespace sls {
|
||||||
|
|
||||||
|
class Caller {
|
||||||
|
public:
|
||||||
|
Caller(Detector *ptr) : det(ptr) {}
|
||||||
|
void call(const std::string &command,
|
||||||
|
const std::vector<std::string> &arguments, int detector_id,
|
||||||
|
int action, std::ostream &os = std::cout, int receiver_id = -1);
|
||||||
|
|
||||||
|
IpAddr getDstIpFromAuto();
|
||||||
|
IpAddr getSrcIpFromAuto();
|
||||||
|
UdpDestination getUdpEntry();
|
||||||
|
void GetLevelAndUpdateArgIndex(int action,
|
||||||
|
std::string levelSeparatedCommand,
|
||||||
|
int &level, int &iArg, size_t nGetArgs,
|
||||||
|
size_t nPutArgs);
|
||||||
|
void WrongNumberOfParameters(size_t expected);
|
||||||
|
|
||||||
|
template <typename V> std::string OutStringHex(const V &value) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToStringHex(value.front());
|
||||||
|
return ToStringHex(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutStringHex(const V &value, int width) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToStringHex(value.front(), width);
|
||||||
|
return ToStringHex(value, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutString(const Result<V> &value) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToString(value.front());
|
||||||
|
return ToString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V> std::string OutString(const V &value) {
|
||||||
|
return ToString(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename V>
|
||||||
|
std::string OutString(const V &value, const std::string &unit) {
|
||||||
|
if (value.equal())
|
||||||
|
return ToString(value.front(), unit);
|
||||||
|
return ToString(value, unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> getAllCommands();
|
||||||
|
std::string list(int action);
|
||||||
|
|
||||||
|
std::string acquire(int action);
|
||||||
|
std::string activate(int action);
|
||||||
|
std::string adcclk(int action);
|
||||||
|
std::string adcenable(int action);
|
||||||
|
std::string adcenable10g(int action);
|
||||||
|
std::string adcindex(int action);
|
||||||
|
std::string adcinvert(int action);
|
||||||
|
std::string adclist(int action);
|
||||||
|
std::string adcname(int action);
|
||||||
|
std::string adcphase(int action);
|
||||||
|
std::string adcpipeline(int action);
|
||||||
|
std::string adcreg(int action);
|
||||||
|
std::string adcvpp(int action);
|
||||||
|
std::string apulse(int action);
|
||||||
|
std::string asamples(int action);
|
||||||
|
std::string autocompdisable(int action);
|
||||||
|
std::string badchannels(int action);
|
||||||
|
std::string blockingtrigger(int action);
|
||||||
|
std::string burstmode(int action);
|
||||||
|
std::string burstperiod(int action);
|
||||||
|
std::string bursts(int action);
|
||||||
|
std::string burstsl(int action);
|
||||||
|
std::string bustest(int action);
|
||||||
|
std::string cdsgain(int action);
|
||||||
|
std::string chipversion(int action);
|
||||||
|
std::string clearbit(int action);
|
||||||
|
std::string clearbusy(int action);
|
||||||
|
std::string clearroi(int action);
|
||||||
|
std::string clientversion(int action);
|
||||||
|
std::string clkdiv(int action);
|
||||||
|
std::string clkfreq(int action);
|
||||||
|
std::string clkphase(int action);
|
||||||
|
std::string column(int action);
|
||||||
|
std::string compdisabletime(int action);
|
||||||
|
std::string confadc(int action);
|
||||||
|
std::string config(int action);
|
||||||
|
std::string counters(int action);
|
||||||
|
std::string currentsource(int action);
|
||||||
|
std::string dac(int action);
|
||||||
|
std::string dacindex(int action);
|
||||||
|
std::string daclist(int action);
|
||||||
|
std::string dacname(int action);
|
||||||
|
std::string dacvalues(int action);
|
||||||
|
std::string datastream(int action);
|
||||||
|
std::string dbitclk(int action);
|
||||||
|
std::string dbitphase(int action);
|
||||||
|
std::string dbitpipeline(int action);
|
||||||
|
std::string defaultdac(int action);
|
||||||
|
std::string defaultpattern(int action);
|
||||||
|
std::string delay(int action);
|
||||||
|
std::string delayl(int action);
|
||||||
|
std::string detectorserverversion(int action);
|
||||||
|
std::string detsize(int action);
|
||||||
|
std::string diodelay(int action);
|
||||||
|
std::string dpulse(int action);
|
||||||
|
std::string dr(int action);
|
||||||
|
std::string drlist(int action);
|
||||||
|
std::string dsamples(int action);
|
||||||
|
std::string execcommand(int action);
|
||||||
|
std::string exptime(int action);
|
||||||
|
std::string exptime1(int action);
|
||||||
|
std::string exptime2(int action);
|
||||||
|
std::string exptime3(int action);
|
||||||
|
std::string exptimel(int action);
|
||||||
|
std::string extrastoragecells(int action);
|
||||||
|
std::string extsampling(int action);
|
||||||
|
std::string extsamplingsrc(int action);
|
||||||
|
std::string extsig(int action);
|
||||||
|
std::string fformat(int action);
|
||||||
|
std::string filtercells(int action);
|
||||||
|
std::string filterresistor(int action);
|
||||||
|
std::string findex(int action);
|
||||||
|
std::string firmwaretest(int action);
|
||||||
|
std::string firmwareversion(int action);
|
||||||
|
std::string fliprows(int action);
|
||||||
|
std::string flowcontrol10g(int action);
|
||||||
|
std::string fmaster(int action);
|
||||||
|
std::string fname(int action);
|
||||||
|
std::string foverwrite(int action);
|
||||||
|
std::string fpath(int action);
|
||||||
|
std::string framecounter(int action);
|
||||||
|
std::string frames(int action);
|
||||||
|
std::string framesl(int action);
|
||||||
|
std::string frametime(int action);
|
||||||
|
std::string free(int action);
|
||||||
|
std::string fwrite(int action);
|
||||||
|
std::string gaincaps(int action);
|
||||||
|
std::string gainmode(int action);
|
||||||
|
std::string gappixels(int action);
|
||||||
|
std::string gatedelay(int action);
|
||||||
|
std::string gatedelay1(int action);
|
||||||
|
std::string gatedelay2(int action);
|
||||||
|
std::string gatedelay3(int action);
|
||||||
|
std::string gates(int action);
|
||||||
|
std::string getbit(int action);
|
||||||
|
std::string hardwareversion(int action);
|
||||||
|
std::string highvoltage(int action);
|
||||||
|
std::string hostname(int action);
|
||||||
|
std::string im_a(int action);
|
||||||
|
std::string im_b(int action);
|
||||||
|
std::string im_c(int action);
|
||||||
|
std::string im_d(int action);
|
||||||
|
std::string im_io(int action);
|
||||||
|
std::string imagetest(int action);
|
||||||
|
std::string initialchecks(int action);
|
||||||
|
std::string inj_ch(int action);
|
||||||
|
std::string interpolation(int action);
|
||||||
|
std::string interruptsubframe(int action);
|
||||||
|
std::string kernelversion(int action);
|
||||||
|
std::string lastclient(int action);
|
||||||
|
std::string led(int action);
|
||||||
|
std::string lock(int action);
|
||||||
|
std::string master(int action);
|
||||||
|
std::string maxadcphaseshift(int action);
|
||||||
|
std::string maxclkphaseshift(int action);
|
||||||
|
std::string maxdbitphaseshift(int action);
|
||||||
|
std::string measuredperiod(int action);
|
||||||
|
std::string measuredsubperiod(int action);
|
||||||
|
std::string moduleid(int action);
|
||||||
|
std::string nextframenumber(int action);
|
||||||
|
std::string nmod(int action);
|
||||||
|
std::string numinterfaces(int action);
|
||||||
|
std::string overflow(int action);
|
||||||
|
std::string packageversion(int action);
|
||||||
|
std::string parallel(int action);
|
||||||
|
std::string parameters(int action);
|
||||||
|
std::string partialreset(int action);
|
||||||
|
std::string patfname(int action);
|
||||||
|
std::string patioctrl(int action);
|
||||||
|
std::string patlimits(int action);
|
||||||
|
std::string patloop(int action);
|
||||||
|
std::string patloop0(int action);
|
||||||
|
std::string patloop1(int action);
|
||||||
|
std::string patloop2(int action);
|
||||||
|
std::string patmask(int action);
|
||||||
|
std::string patnloop(int action);
|
||||||
|
std::string patnloop0(int action);
|
||||||
|
std::string patnloop1(int action);
|
||||||
|
std::string patnloop2(int action);
|
||||||
|
std::string patsetbit(int action);
|
||||||
|
std::string pattern(int action);
|
||||||
|
std::string patternstart(int action);
|
||||||
|
std::string patwait(int action);
|
||||||
|
std::string patwait0(int action);
|
||||||
|
std::string patwait1(int action);
|
||||||
|
std::string patwait2(int action);
|
||||||
|
std::string patwaittime(int action);
|
||||||
|
std::string patwaittime0(int action);
|
||||||
|
std::string patwaittime1(int action);
|
||||||
|
std::string patwaittime2(int action);
|
||||||
|
std::string patword(int action);
|
||||||
|
std::string pedestalmode(int action);
|
||||||
|
std::string period(int action);
|
||||||
|
std::string periodl(int action);
|
||||||
|
std::string polarity(int action);
|
||||||
|
std::string port(int action);
|
||||||
|
std::string powerchip(int action);
|
||||||
|
std::string powerindex(int action);
|
||||||
|
std::string powerlist(int action);
|
||||||
|
std::string powername(int action);
|
||||||
|
std::string powervalues(int action);
|
||||||
|
std::string programfpga(int action);
|
||||||
|
std::string pulse(int action);
|
||||||
|
std::string pulsechip(int action);
|
||||||
|
std::string pulsenmove(int action);
|
||||||
|
std::string pumpprobe(int action);
|
||||||
|
std::string quad(int action);
|
||||||
|
std::string ratecorr(int action);
|
||||||
|
std::string readnrows(int action);
|
||||||
|
std::string readout(int action);
|
||||||
|
std::string readoutspeed(int action);
|
||||||
|
std::string readoutspeedlist(int action);
|
||||||
|
std::string rebootcontroller(int action);
|
||||||
|
std::string reg(int action);
|
||||||
|
std::string resetdacs(int action);
|
||||||
|
std::string resetfpga(int action);
|
||||||
|
std::string roi(int action);
|
||||||
|
std::string romode(int action);
|
||||||
|
std::string row(int action);
|
||||||
|
std::string runclk(int action);
|
||||||
|
std::string runtime(int action);
|
||||||
|
std::string rx_arping(int action);
|
||||||
|
std::string rx_clearroi(int action);
|
||||||
|
std::string rx_dbitlist(int action);
|
||||||
|
std::string rx_dbitoffset(int action);
|
||||||
|
std::string rx_discardpolicy(int action);
|
||||||
|
std::string rx_fifodepth(int action);
|
||||||
|
std::string rx_frameindex(int action);
|
||||||
|
std::string rx_framescaught(int action);
|
||||||
|
std::string rx_framesperfile(int action);
|
||||||
|
std::string rx_hostname(int action);
|
||||||
|
std::string rx_jsonaddheader(int action);
|
||||||
|
std::string rx_jsonpara(int action);
|
||||||
|
std::string rx_lastclient(int action);
|
||||||
|
std::string rx_lock(int action);
|
||||||
|
std::string rx_missingpackets(int action);
|
||||||
|
std::string rx_padding(int action);
|
||||||
|
std::string rx_printconfig(int action);
|
||||||
|
std::string rx_realudpsocksize(int action);
|
||||||
|
std::string rx_roi(int action);
|
||||||
|
std::string rx_silent(int action);
|
||||||
|
std::string rx_start(int action);
|
||||||
|
std::string rx_status(int action);
|
||||||
|
std::string rx_stop(int action);
|
||||||
|
std::string rx_tcpport(int action);
|
||||||
|
std::string rx_threads(int action);
|
||||||
|
std::string rx_udpsocksize(int action);
|
||||||
|
std::string rx_version(int action);
|
||||||
|
std::string rx_zmqfreq(int action);
|
||||||
|
std::string rx_zmqhwm(int action);
|
||||||
|
std::string rx_zmqip(int action);
|
||||||
|
std::string rx_zmqport(int action);
|
||||||
|
std::string rx_zmqstartfnum(int action);
|
||||||
|
std::string rx_zmqstream(int action);
|
||||||
|
std::string samples(int action);
|
||||||
|
std::string savepattern(int action);
|
||||||
|
std::string scan(int action);
|
||||||
|
std::string scanerrmsg(int action);
|
||||||
|
std::string selinterface(int action);
|
||||||
|
std::string serialnumber(int action);
|
||||||
|
std::string setbit(int action);
|
||||||
|
std::string settings(int action);
|
||||||
|
std::string settingslist(int action);
|
||||||
|
std::string settingspath(int action);
|
||||||
|
std::string signalindex(int action);
|
||||||
|
std::string signallist(int action);
|
||||||
|
std::string signalname(int action);
|
||||||
|
std::string slowadc(int action);
|
||||||
|
std::string slowadcindex(int action);
|
||||||
|
std::string slowadclist(int action);
|
||||||
|
std::string slowadcname(int action);
|
||||||
|
std::string slowadcvalues(int action);
|
||||||
|
std::string start(int action);
|
||||||
|
std::string status(int action);
|
||||||
|
std::string stop(int action);
|
||||||
|
std::string stopport(int action);
|
||||||
|
std::string storagecell_delay(int action);
|
||||||
|
std::string storagecell_start(int action);
|
||||||
|
std::string subdeadtime(int action);
|
||||||
|
std::string subexptime(int action);
|
||||||
|
std::string sync(int action);
|
||||||
|
std::string syncclk(int action);
|
||||||
|
std::string temp_10ge(int action);
|
||||||
|
std::string temp_adc(int action);
|
||||||
|
std::string temp_control(int action);
|
||||||
|
std::string temp_dcdc(int action);
|
||||||
|
std::string temp_event(int action);
|
||||||
|
std::string temp_fpga(int action);
|
||||||
|
std::string temp_fpgaext(int action);
|
||||||
|
std::string temp_fpgafl(int action);
|
||||||
|
std::string temp_fpgafr(int action);
|
||||||
|
std::string temp_slowadc(int action);
|
||||||
|
std::string temp_sodl(int action);
|
||||||
|
std::string temp_sodr(int action);
|
||||||
|
std::string temp_threshold(int action);
|
||||||
|
std::string templist(int action);
|
||||||
|
std::string tempvalues(int action);
|
||||||
|
std::string tengiga(int action);
|
||||||
|
std::string threshold(int action);
|
||||||
|
std::string timing(int action);
|
||||||
|
std::string timinglist(int action);
|
||||||
|
std::string timingsource(int action);
|
||||||
|
std::string top(int action);
|
||||||
|
std::string transceiverenable(int action);
|
||||||
|
std::string trigger(int action);
|
||||||
|
std::string triggers(int action);
|
||||||
|
std::string triggersl(int action);
|
||||||
|
std::string trimbits(int action);
|
||||||
|
std::string trimen(int action);
|
||||||
|
std::string trimval(int action);
|
||||||
|
std::string tsamples(int action);
|
||||||
|
std::string txdelay(int action);
|
||||||
|
std::string txdelay_frame(int action);
|
||||||
|
std::string txdelay_left(int action);
|
||||||
|
std::string txdelay_right(int action);
|
||||||
|
std::string type(int action);
|
||||||
|
std::string udp_cleardst(int action);
|
||||||
|
std::string udp_dstip(int action);
|
||||||
|
std::string udp_dstip2(int action);
|
||||||
|
std::string udp_dstlist(int action);
|
||||||
|
std::string udp_dstmac(int action);
|
||||||
|
std::string udp_dstmac2(int action);
|
||||||
|
std::string udp_dstport(int action);
|
||||||
|
std::string udp_dstport2(int action);
|
||||||
|
std::string udp_firstdst(int action);
|
||||||
|
std::string udp_numdst(int action);
|
||||||
|
std::string udp_reconfigure(int action);
|
||||||
|
std::string udp_srcip(int action);
|
||||||
|
std::string udp_srcip2(int action);
|
||||||
|
std::string udp_srcmac(int action);
|
||||||
|
std::string udp_srcmac2(int action);
|
||||||
|
std::string udp_validate(int action);
|
||||||
|
std::string update(int action);
|
||||||
|
std::string updatedetectorserver(int action);
|
||||||
|
std::string updatekernel(int action);
|
||||||
|
std::string updatemode(int action);
|
||||||
|
std::string user(int action);
|
||||||
|
std::string v_a(int action);
|
||||||
|
std::string v_b(int action);
|
||||||
|
std::string v_c(int action);
|
||||||
|
std::string v_chip(int action);
|
||||||
|
std::string v_d(int action);
|
||||||
|
std::string v_io(int action);
|
||||||
|
std::string v_limit(int action);
|
||||||
|
std::string vchip_comp_adc(int action);
|
||||||
|
std::string vchip_comp_fe(int action);
|
||||||
|
std::string vchip_cs(int action);
|
||||||
|
std::string vchip_opa_1st(int action);
|
||||||
|
std::string vchip_opa_fd(int action);
|
||||||
|
std::string vchip_ref_comp_fe(int action);
|
||||||
|
std::string versions(int action);
|
||||||
|
std::string veto(int action);
|
||||||
|
std::string vetoalg(int action);
|
||||||
|
std::string vetofile(int action);
|
||||||
|
std::string vetophoton(int action);
|
||||||
|
std::string vetoref(int action);
|
||||||
|
std::string vetostream(int action);
|
||||||
|
std::string virtualFunction(int action);
|
||||||
|
std::string vm_a(int action);
|
||||||
|
std::string vm_b(int action);
|
||||||
|
std::string vm_c(int action);
|
||||||
|
std::string vm_d(int action);
|
||||||
|
std::string vm_io(int action);
|
||||||
|
std::string zmqhwm(int action);
|
||||||
|
std::string zmqip(int action);
|
||||||
|
std::string zmqport(int action);
|
||||||
|
|
||||||
|
std::vector<std::string> args;
|
||||||
|
std::string cmd;
|
||||||
|
Detector *det;
|
||||||
|
int det_id{-1};
|
||||||
|
int rx_id{-1};
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool ReplaceIfDepreciated(std::string &command);
|
||||||
|
using FunctionMap = std::map<std::string, std::string (Caller::*)(int)>;
|
||||||
|
using StringMap = std::map<std::string, std::string>;
|
||||||
|
Detector *ptr; // pointer to the detector that executes the command
|
||||||
|
|
||||||
|
FunctionMap functions{
|
||||||
|
{"list", &Caller::list},
|
||||||
|
|
||||||
|
{"acquire", &Caller::acquire},
|
||||||
|
{"activate", &Caller::activate},
|
||||||
|
{"adcclk", &Caller::adcclk},
|
||||||
|
{"adcenable", &Caller::adcenable},
|
||||||
|
{"adcenable10g", &Caller::adcenable10g},
|
||||||
|
{"adcindex", &Caller::adcindex},
|
||||||
|
{"adcinvert", &Caller::adcinvert},
|
||||||
|
{"adclist", &Caller::adclist},
|
||||||
|
{"adcname", &Caller::adcname},
|
||||||
|
{"adcphase", &Caller::adcphase},
|
||||||
|
{"adcpipeline", &Caller::adcpipeline},
|
||||||
|
{"adcreg", &Caller::adcreg},
|
||||||
|
{"adcvpp", &Caller::adcvpp},
|
||||||
|
{"apulse", &Caller::apulse},
|
||||||
|
{"asamples", &Caller::asamples},
|
||||||
|
{"autocompdisable", &Caller::autocompdisable},
|
||||||
|
{"badchannels", &Caller::badchannels},
|
||||||
|
{"blockingtrigger", &Caller::blockingtrigger},
|
||||||
|
{"burstmode", &Caller::burstmode},
|
||||||
|
{"burstperiod", &Caller::burstperiod},
|
||||||
|
{"bursts", &Caller::bursts},
|
||||||
|
{"burstsl", &Caller::burstsl},
|
||||||
|
{"bustest", &Caller::bustest},
|
||||||
|
{"cdsgain", &Caller::cdsgain},
|
||||||
|
{"chipversion", &Caller::chipversion},
|
||||||
|
{"clearbit", &Caller::clearbit},
|
||||||
|
{"clearbusy", &Caller::clearbusy},
|
||||||
|
{"clearroi", &Caller::clearroi},
|
||||||
|
{"clientversion", &Caller::clientversion},
|
||||||
|
{"clkdiv", &Caller::clkdiv},
|
||||||
|
{"clkfreq", &Caller::clkfreq},
|
||||||
|
{"clkphase", &Caller::clkphase},
|
||||||
|
{"column", &Caller::column},
|
||||||
|
{"compdisabletime", &Caller::compdisabletime},
|
||||||
|
{"confadc", &Caller::confadc},
|
||||||
|
{"config", &Caller::config},
|
||||||
|
{"counters", &Caller::counters},
|
||||||
|
{"currentsource", &Caller::currentsource},
|
||||||
|
{"dac", &Caller::dac},
|
||||||
|
{"dacindex", &Caller::dacindex},
|
||||||
|
{"daclist", &Caller::daclist},
|
||||||
|
{"dacname", &Caller::dacname},
|
||||||
|
{"dacvalues", &Caller::dacvalues},
|
||||||
|
{"datastream", &Caller::datastream},
|
||||||
|
{"dbitclk", &Caller::dbitclk},
|
||||||
|
{"dbitphase", &Caller::dbitphase},
|
||||||
|
{"dbitpipeline", &Caller::dbitpipeline},
|
||||||
|
{"defaultdac", &Caller::defaultdac},
|
||||||
|
{"defaultpattern", &Caller::defaultpattern},
|
||||||
|
{"delay", &Caller::delay},
|
||||||
|
{"delayl", &Caller::delayl},
|
||||||
|
{"detectorserverversion", &Caller::detectorserverversion},
|
||||||
|
{"detsize", &Caller::detsize},
|
||||||
|
{"diodelay", &Caller::diodelay},
|
||||||
|
{"dpulse", &Caller::dpulse},
|
||||||
|
{"dr", &Caller::dr},
|
||||||
|
{"drlist", &Caller::drlist},
|
||||||
|
{"dsamples", &Caller::dsamples},
|
||||||
|
{"execcommand", &Caller::execcommand},
|
||||||
|
{"exptime", &Caller::exptime},
|
||||||
|
{"exptime1", &Caller::exptime1},
|
||||||
|
{"exptime2", &Caller::exptime2},
|
||||||
|
{"exptime3", &Caller::exptime3},
|
||||||
|
{"exptimel", &Caller::exptimel},
|
||||||
|
{"extrastoragecells", &Caller::extrastoragecells},
|
||||||
|
{"extsampling", &Caller::extsampling},
|
||||||
|
{"extsamplingsrc", &Caller::extsamplingsrc},
|
||||||
|
{"extsig", &Caller::extsig},
|
||||||
|
{"fformat", &Caller::fformat},
|
||||||
|
{"filtercells", &Caller::filtercells},
|
||||||
|
{"filterresistor", &Caller::filterresistor},
|
||||||
|
{"findex", &Caller::findex},
|
||||||
|
{"firmwaretest", &Caller::firmwaretest},
|
||||||
|
{"firmwareversion", &Caller::firmwareversion},
|
||||||
|
{"fliprows", &Caller::fliprows},
|
||||||
|
{"flowcontrol10g", &Caller::flowcontrol10g},
|
||||||
|
{"fmaster", &Caller::fmaster},
|
||||||
|
{"fname", &Caller::fname},
|
||||||
|
{"foverwrite", &Caller::foverwrite},
|
||||||
|
{"fpath", &Caller::fpath},
|
||||||
|
{"framecounter", &Caller::framecounter},
|
||||||
|
{"frames", &Caller::frames},
|
||||||
|
{"framesl", &Caller::framesl},
|
||||||
|
{"frametime", &Caller::frametime},
|
||||||
|
{"free", &Caller::free},
|
||||||
|
{"fwrite", &Caller::fwrite},
|
||||||
|
{"gaincaps", &Caller::gaincaps},
|
||||||
|
{"gainmode", &Caller::gainmode},
|
||||||
|
{"gappixels", &Caller::gappixels},
|
||||||
|
{"gatedelay", &Caller::gatedelay},
|
||||||
|
{"gatedelay1", &Caller::gatedelay1},
|
||||||
|
{"gatedelay2", &Caller::gatedelay2},
|
||||||
|
{"gatedelay3", &Caller::gatedelay3},
|
||||||
|
{"gates", &Caller::gates},
|
||||||
|
{"getbit", &Caller::getbit},
|
||||||
|
{"hardwareversion", &Caller::hardwareversion},
|
||||||
|
{"highvoltage", &Caller::highvoltage},
|
||||||
|
{"hostname", &Caller::hostname},
|
||||||
|
{"im_a", &Caller::im_a},
|
||||||
|
{"im_b", &Caller::im_b},
|
||||||
|
{"im_c", &Caller::im_c},
|
||||||
|
{"im_d", &Caller::im_d},
|
||||||
|
{"im_io", &Caller::im_io},
|
||||||
|
{"imagetest", &Caller::imagetest},
|
||||||
|
{"initialchecks", &Caller::initialchecks},
|
||||||
|
{"inj_ch", &Caller::inj_ch},
|
||||||
|
{"interpolation", &Caller::interpolation},
|
||||||
|
{"interruptsubframe", &Caller::interruptsubframe},
|
||||||
|
{"kernelversion", &Caller::kernelversion},
|
||||||
|
{"lastclient", &Caller::lastclient},
|
||||||
|
{"led", &Caller::led},
|
||||||
|
{"lock", &Caller::lock},
|
||||||
|
{"master", &Caller::master},
|
||||||
|
{"maxadcphaseshift", &Caller::maxadcphaseshift},
|
||||||
|
{"maxclkphaseshift", &Caller::maxclkphaseshift},
|
||||||
|
{"maxdbitphaseshift", &Caller::maxdbitphaseshift},
|
||||||
|
{"measuredperiod", &Caller::measuredperiod},
|
||||||
|
{"measuredsubperiod", &Caller::measuredsubperiod},
|
||||||
|
{"moduleid", &Caller::moduleid},
|
||||||
|
{"nextframenumber", &Caller::nextframenumber},
|
||||||
|
{"nmod", &Caller::nmod},
|
||||||
|
{"numinterfaces", &Caller::numinterfaces},
|
||||||
|
{"overflow", &Caller::overflow},
|
||||||
|
{"packageversion", &Caller::packageversion},
|
||||||
|
{"parallel", &Caller::parallel},
|
||||||
|
{"parameters", &Caller::parameters},
|
||||||
|
{"partialreset", &Caller::partialreset},
|
||||||
|
{"patfname", &Caller::patfname},
|
||||||
|
{"patioctrl", &Caller::patioctrl},
|
||||||
|
{"patlimits", &Caller::patlimits},
|
||||||
|
{"patloop", &Caller::patloop},
|
||||||
|
{"patloop0", &Caller::patloop0},
|
||||||
|
{"patloop1", &Caller::patloop1},
|
||||||
|
{"patloop2", &Caller::patloop2},
|
||||||
|
{"patmask", &Caller::patmask},
|
||||||
|
{"patnloop", &Caller::patnloop},
|
||||||
|
{"patnloop0", &Caller::patnloop0},
|
||||||
|
{"patnloop1", &Caller::patnloop1},
|
||||||
|
{"patnloop2", &Caller::patnloop2},
|
||||||
|
{"patsetbit", &Caller::patsetbit},
|
||||||
|
{"patternX", &Caller::pattern},
|
||||||
|
{"patternstart", &Caller::patternstart},
|
||||||
|
{"patwait", &Caller::patwait},
|
||||||
|
{"patwait0", &Caller::patwait0},
|
||||||
|
{"patwait1", &Caller::patwait1},
|
||||||
|
{"patwait2", &Caller::patwait2},
|
||||||
|
{"patwaittime", &Caller::patwaittime},
|
||||||
|
{"patwaittime0", &Caller::patwaittime0},
|
||||||
|
{"patwaittime1", &Caller::patwaittime1},
|
||||||
|
{"patwaittime2", &Caller::patwaittime2},
|
||||||
|
{"patword", &Caller::patword},
|
||||||
|
{"pedestalmode", &Caller::pedestalmode},
|
||||||
|
{"period", &Caller::period},
|
||||||
|
{"periodl", &Caller::periodl},
|
||||||
|
{"polarity", &Caller::polarity},
|
||||||
|
{"port", &Caller::port},
|
||||||
|
{"powerchip", &Caller::powerchip},
|
||||||
|
{"powerindex", &Caller::powerindex},
|
||||||
|
{"powerlist", &Caller::powerlist},
|
||||||
|
{"powername", &Caller::powername},
|
||||||
|
{"powervalues", &Caller::powervalues},
|
||||||
|
{"programfpga", &Caller::programfpga},
|
||||||
|
{"pulse", &Caller::pulse},
|
||||||
|
{"pulsechip", &Caller::pulsechip},
|
||||||
|
{"pulsenmove", &Caller::pulsenmove},
|
||||||
|
{"pumpprobe", &Caller::pumpprobe},
|
||||||
|
{"quad", &Caller::quad},
|
||||||
|
{"ratecorr", &Caller::ratecorr},
|
||||||
|
{"readnrows", &Caller::readnrows},
|
||||||
|
{"readout", &Caller::readout},
|
||||||
|
{"readoutspeed", &Caller::readoutspeed},
|
||||||
|
{"readoutspeedlist", &Caller::readoutspeedlist},
|
||||||
|
{"rebootcontroller", &Caller::rebootcontroller},
|
||||||
|
{"reg", &Caller::reg},
|
||||||
|
{"resetdacs", &Caller::resetdacs},
|
||||||
|
{"resetfpga", &Caller::resetfpga},
|
||||||
|
{"roi", &Caller::roi},
|
||||||
|
{"romode", &Caller::romode},
|
||||||
|
{"row", &Caller::row},
|
||||||
|
{"runclk", &Caller::runclk},
|
||||||
|
{"runtime", &Caller::runtime},
|
||||||
|
{"rx_arping", &Caller::rx_arping},
|
||||||
|
{"rx_clearroi", &Caller::rx_clearroi},
|
||||||
|
{"rx_dbitlist", &Caller::rx_dbitlist},
|
||||||
|
{"rx_dbitoffset", &Caller::rx_dbitoffset},
|
||||||
|
{"rx_discardpolicy", &Caller::rx_discardpolicy},
|
||||||
|
{"rx_fifodepth", &Caller::rx_fifodepth},
|
||||||
|
{"rx_frameindex", &Caller::rx_frameindex},
|
||||||
|
{"rx_framescaught", &Caller::rx_framescaught},
|
||||||
|
{"rx_framesperfile", &Caller::rx_framesperfile},
|
||||||
|
{"rx_hostname", &Caller::rx_hostname},
|
||||||
|
{"rx_jsonaddheader", &Caller::rx_jsonaddheader},
|
||||||
|
{"rx_jsonpara", &Caller::rx_jsonpara},
|
||||||
|
{"rx_lastclient", &Caller::rx_lastclient},
|
||||||
|
{"rx_lock", &Caller::rx_lock},
|
||||||
|
{"rx_missingpackets", &Caller::rx_missingpackets},
|
||||||
|
{"rx_padding", &Caller::rx_padding},
|
||||||
|
{"rx_printconfig", &Caller::rx_printconfig},
|
||||||
|
{"rx_realudpsocksize", &Caller::rx_realudpsocksize},
|
||||||
|
{"rx_roi", &Caller::rx_roi},
|
||||||
|
{"rx_silent", &Caller::rx_silent},
|
||||||
|
{"rx_start", &Caller::rx_start},
|
||||||
|
{"rx_status", &Caller::rx_status},
|
||||||
|
{"rx_stop", &Caller::rx_stop},
|
||||||
|
{"rx_tcpport", &Caller::rx_tcpport},
|
||||||
|
{"rx_threads", &Caller::rx_threads},
|
||||||
|
{"rx_udpsocksize", &Caller::rx_udpsocksize},
|
||||||
|
{"rx_version", &Caller::rx_version},
|
||||||
|
{"rx_zmqfreq", &Caller::rx_zmqfreq},
|
||||||
|
{"rx_zmqhwm", &Caller::rx_zmqhwm},
|
||||||
|
{"rx_zmqip", &Caller::rx_zmqip},
|
||||||
|
{"rx_zmqport", &Caller::rx_zmqport},
|
||||||
|
{"rx_zmqstartfnum", &Caller::rx_zmqstartfnum},
|
||||||
|
{"rx_zmqstream", &Caller::rx_zmqstream},
|
||||||
|
{"samples", &Caller::samples},
|
||||||
|
{"savepattern", &Caller::savepattern},
|
||||||
|
{"scan", &Caller::scan},
|
||||||
|
{"scanerrmsg", &Caller::scanerrmsg},
|
||||||
|
{"selinterface", &Caller::selinterface},
|
||||||
|
{"serialnumber", &Caller::serialnumber},
|
||||||
|
{"setbit", &Caller::setbit},
|
||||||
|
{"settings", &Caller::settings},
|
||||||
|
{"settingslist", &Caller::settingslist},
|
||||||
|
{"settingspath", &Caller::settingspath},
|
||||||
|
{"signalindex", &Caller::signalindex},
|
||||||
|
{"signallist", &Caller::signallist},
|
||||||
|
{"signalname", &Caller::signalname},
|
||||||
|
{"slowadc", &Caller::slowadc},
|
||||||
|
{"slowadcindex", &Caller::slowadcindex},
|
||||||
|
{"slowadclist", &Caller::slowadclist},
|
||||||
|
{"slowadcname", &Caller::slowadcname},
|
||||||
|
{"slowadcvalues", &Caller::slowadcvalues},
|
||||||
|
{"start", &Caller::start},
|
||||||
|
{"status", &Caller::status},
|
||||||
|
{"stop", &Caller::stop},
|
||||||
|
{"stopport", &Caller::stopport},
|
||||||
|
{"storagecell_delay", &Caller::storagecell_delay},
|
||||||
|
{"storagecell_start", &Caller::storagecell_start},
|
||||||
|
{"subdeadtime", &Caller::subdeadtime},
|
||||||
|
{"subexptime", &Caller::subexptime},
|
||||||
|
{"sync", &Caller::sync},
|
||||||
|
{"syncclk", &Caller::syncclk},
|
||||||
|
{"temp_10ge", &Caller::temp_10ge},
|
||||||
|
{"temp_adc", &Caller::temp_adc},
|
||||||
|
{"temp_control", &Caller::temp_control},
|
||||||
|
{"temp_dcdc", &Caller::temp_dcdc},
|
||||||
|
{"temp_event", &Caller::temp_event},
|
||||||
|
{"temp_fpga", &Caller::temp_fpga},
|
||||||
|
{"temp_fpgaext", &Caller::temp_fpgaext},
|
||||||
|
{"temp_fpgafl", &Caller::temp_fpgafl},
|
||||||
|
{"temp_fpgafr", &Caller::temp_fpgafr},
|
||||||
|
{"temp_slowadc", &Caller::temp_slowadc},
|
||||||
|
{"temp_sodl", &Caller::temp_sodl},
|
||||||
|
{"temp_sodr", &Caller::temp_sodr},
|
||||||
|
{"temp_threshold", &Caller::temp_threshold},
|
||||||
|
{"templist", &Caller::templist},
|
||||||
|
{"tempvalues", &Caller::tempvalues},
|
||||||
|
{"tengiga", &Caller::tengiga},
|
||||||
|
{"threshold", &Caller::threshold},
|
||||||
|
{"thresholdnotb", &Caller::threshold},
|
||||||
|
{"timing", &Caller::timing},
|
||||||
|
{"timinglist", &Caller::timinglist},
|
||||||
|
{"timingsource", &Caller::timingsource},
|
||||||
|
{"top", &Caller::top},
|
||||||
|
{"transceiverenable", &Caller::transceiverenable},
|
||||||
|
{"trigger", &Caller::trigger},
|
||||||
|
{"triggers", &Caller::triggers},
|
||||||
|
{"triggersl", &Caller::triggersl},
|
||||||
|
{"trimbits", &Caller::trimbits},
|
||||||
|
{"trimen", &Caller::trimen},
|
||||||
|
{"trimval", &Caller::trimval},
|
||||||
|
{"tsamples", &Caller::tsamples},
|
||||||
|
{"txdelay", &Caller::txdelay},
|
||||||
|
{"txdelay_frame", &Caller::txdelay_frame},
|
||||||
|
{"txdelay_left", &Caller::txdelay_left},
|
||||||
|
{"txdelay_right", &Caller::txdelay_right},
|
||||||
|
{"type", &Caller::type},
|
||||||
|
{"udp_cleardst", &Caller::udp_cleardst},
|
||||||
|
{"udp_dstip", &Caller::udp_dstip},
|
||||||
|
{"udp_dstip2", &Caller::udp_dstip2},
|
||||||
|
{"udp_dstlist", &Caller::udp_dstlist},
|
||||||
|
{"udp_dstmac", &Caller::udp_dstmac},
|
||||||
|
{"udp_dstmac2", &Caller::udp_dstmac2},
|
||||||
|
{"udp_dstport", &Caller::udp_dstport},
|
||||||
|
{"udp_dstport2", &Caller::udp_dstport2},
|
||||||
|
{"udp_firstdst", &Caller::udp_firstdst},
|
||||||
|
{"udp_numdst", &Caller::udp_numdst},
|
||||||
|
{"udp_reconfigure", &Caller::udp_reconfigure},
|
||||||
|
{"udp_srcip", &Caller::udp_srcip},
|
||||||
|
{"udp_srcip2", &Caller::udp_srcip2},
|
||||||
|
{"udp_srcmac", &Caller::udp_srcmac},
|
||||||
|
{"udp_srcmac2", &Caller::udp_srcmac2},
|
||||||
|
{"udp_validate", &Caller::udp_validate},
|
||||||
|
{"update", &Caller::update},
|
||||||
|
{"updatedetectorserver", &Caller::updatedetectorserver},
|
||||||
|
{"updatekernel", &Caller::updatekernel},
|
||||||
|
{"updatemode", &Caller::updatemode},
|
||||||
|
{"user", &Caller::user},
|
||||||
|
{"v_a", &Caller::v_a},
|
||||||
|
{"v_b", &Caller::v_b},
|
||||||
|
{"v_c", &Caller::v_c},
|
||||||
|
{"v_chip", &Caller::v_chip},
|
||||||
|
{"v_d", &Caller::v_d},
|
||||||
|
{"v_io", &Caller::v_io},
|
||||||
|
{"v_limit", &Caller::v_limit},
|
||||||
|
{"vchip_comp_adc", &Caller::vchip_comp_adc},
|
||||||
|
{"vchip_comp_fe", &Caller::vchip_comp_fe},
|
||||||
|
{"vchip_cs", &Caller::vchip_cs},
|
||||||
|
{"vchip_opa_1st", &Caller::vchip_opa_1st},
|
||||||
|
{"vchip_opa_fd", &Caller::vchip_opa_fd},
|
||||||
|
{"vchip_ref_comp_fe", &Caller::vchip_ref_comp_fe},
|
||||||
|
{"versions", &Caller::versions},
|
||||||
|
{"veto", &Caller::veto},
|
||||||
|
{"vetoalg", &Caller::vetoalg},
|
||||||
|
{"vetofile", &Caller::vetofile},
|
||||||
|
{"vetophoton", &Caller::vetophoton},
|
||||||
|
{"vetoref", &Caller::vetoref},
|
||||||
|
{"vetostream", &Caller::vetostream},
|
||||||
|
{"virtual", &Caller::virtualFunction},
|
||||||
|
{"vm_a", &Caller::vm_a},
|
||||||
|
{"vm_b", &Caller::vm_b},
|
||||||
|
{"vm_c", &Caller::vm_c},
|
||||||
|
{"vm_d", &Caller::vm_d},
|
||||||
|
{"vm_io", &Caller::vm_io},
|
||||||
|
{"zmqhwm", &Caller::zmqhwm},
|
||||||
|
{"zmqip", &Caller::zmqip},
|
||||||
|
{"zmqport", &Caller::zmqport}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
StringMap depreciated_functions{
|
||||||
|
|
||||||
|
{"detectorversion", "firmwareversion"},
|
||||||
|
{"softwareversion", "detectorserverversion"},
|
||||||
|
{"receiverversion", "rx_version"},
|
||||||
|
{"detectornumber", "serialnumber"},
|
||||||
|
{"thisversion", "clientversion"},
|
||||||
|
{"detsizechan", "detsize"},
|
||||||
|
{"trimdir", "settingspath"},
|
||||||
|
{"settingsdir", "settingspath"},
|
||||||
|
{"flippeddatax", "fliprows"},
|
||||||
|
{"cycles", "triggers"},
|
||||||
|
{"cyclesl", "triggersl"},
|
||||||
|
{"clkdivider", "readoutspeed"},
|
||||||
|
{"speed", "readoutspeed"},
|
||||||
|
{"vhighvoltage", "highvoltage"},
|
||||||
|
{"digitest", "imagetest"},
|
||||||
|
{"filter", "filterresistor"},
|
||||||
|
{"readnlines", "readnrows"},
|
||||||
|
{"vtr", "vtrim"},
|
||||||
|
{"vrf", "vrpreamp"},
|
||||||
|
{"vrs", "vrshaper"},
|
||||||
|
{"vcall", "vcal"},
|
||||||
|
{"vis", "vishaper"},
|
||||||
|
{"vshaper", "vrshaper"},
|
||||||
|
{"vpreamp", "vrpreamp"},
|
||||||
|
{"vshaperneg", "vrshaper_n"},
|
||||||
|
{"viinsh", "vishaper"},
|
||||||
|
{"vpl", "vcal_n"},
|
||||||
|
{"vph", "vcal_p"},
|
||||||
|
{"vthreshold", "dac"},
|
||||||
|
{"vsvp", "dac"},
|
||||||
|
{"vsvn", "dac"},
|
||||||
|
{"vtrim", "dac"},
|
||||||
|
{"vrpreamp", "dac"},
|
||||||
|
{"vrshaper", "dac"},
|
||||||
|
{"vtgstv", "dac"},
|
||||||
|
{"vcmp_ll", "dac"},
|
||||||
|
{"vcmp_lr", "dac"},
|
||||||
|
{"vcal", "dac"},
|
||||||
|
{"vcmp_rl", "dac"},
|
||||||
|
{"vcmp_rr", "dac"},
|
||||||
|
{"rxb_rb", "dac"},
|
||||||
|
{"rxb_lb", "dac"},
|
||||||
|
{"vcp", "dac"},
|
||||||
|
{"vcn", "dac"},
|
||||||
|
{"vishaper", "dac"},
|
||||||
|
{"iodelay", "dac"},
|
||||||
|
{"vref_ds", "dac"},
|
||||||
|
{"vcascn_pb", "dac"},
|
||||||
|
{"vcascp_pb", "dac"},
|
||||||
|
{"vout_cm", "dac"},
|
||||||
|
{"vcasc_out", "dac"},
|
||||||
|
{"vin_cm", "dac"},
|
||||||
|
{"vref_comp", "dac"},
|
||||||
|
{"ib_test_c", "dac"},
|
||||||
|
{"vrshaper_n", "dac"},
|
||||||
|
{"vipre", "dac"},
|
||||||
|
{"vdcsh", "dac"},
|
||||||
|
{"vth1", "dac"},
|
||||||
|
{"vth2", "dac"},
|
||||||
|
{"vth3", "dac"},
|
||||||
|
{"vcal_n", "dac"},
|
||||||
|
{"vcal_p", "dac"},
|
||||||
|
{"vcassh", "dac"},
|
||||||
|
{"vcas", "dac"},
|
||||||
|
{"vicin", "dac"},
|
||||||
|
{"vipre_out", "dac"},
|
||||||
|
{"vref_h_adc", "dac"},
|
||||||
|
{"vb_comp_fe", "dac"},
|
||||||
|
{"vb_comp_adc", "dac"},
|
||||||
|
{"vcom_cds", "dac"},
|
||||||
|
{"vref_rstore", "dac"},
|
||||||
|
{"vb_opa_1st", "dac"},
|
||||||
|
{"vref_comp_fe", "dac"},
|
||||||
|
{"vcom_adc1", "dac"},
|
||||||
|
{"vref_prech", "dac"},
|
||||||
|
{"vref_l_adc", "dac"},
|
||||||
|
{"vref_cds", "dac"},
|
||||||
|
{"vb_cs", "dac"},
|
||||||
|
{"vb_opa_fd", "dac"},
|
||||||
|
{"vcom_adc2", "dac"},
|
||||||
|
{"vb_ds", "dac"},
|
||||||
|
{"vb_comp", "dac"},
|
||||||
|
{"vb_pixbuf", "dac"},
|
||||||
|
{"vin_com", "dac"},
|
||||||
|
{"vdd_prot", "dac"},
|
||||||
|
{"vbp_colbuf", "dac"},
|
||||||
|
{"vb_sda", "dac"},
|
||||||
|
{"vcasc_sfp", "dac"},
|
||||||
|
{"vipre_cds", "dac"},
|
||||||
|
{"ibias_sfp", "dac"},
|
||||||
|
{"defaultdacs", "resetdacs"},
|
||||||
|
{"busy", "clearbusy"},
|
||||||
|
{"receiver", "rx_status"},
|
||||||
|
{"framescaught", "rx_framescaught"},
|
||||||
|
{"startingfnum", "nextframenumber"},
|
||||||
|
{"detectorip", "udp_srcip"},
|
||||||
|
{"detectorip2", "udp_srcip2"},
|
||||||
|
{"detectormac", "udp_srcmac"},
|
||||||
|
{"detectormac2", "udp_srcmac2"},
|
||||||
|
{"rx_udpip", "udp_dstip"},
|
||||||
|
{"rx_udpip2", "udp_dstip2"},
|
||||||
|
{"rx_udpmac", "udp_dstmac"},
|
||||||
|
{"rx_udpmac2", "udp_dstmac2"},
|
||||||
|
{"rx_udpport", "udp_dstport"},
|
||||||
|
{"rx_udpport2", "udp_dstport2"},
|
||||||
|
{"flowcontrol_10g", "flowcontrol10g"},
|
||||||
|
{"txndelay_frame", "txdelay_frame"},
|
||||||
|
{"txndelay_left", "txdelay_left"},
|
||||||
|
{"txndelay_right", "txdelay_right"},
|
||||||
|
{"r_silent", "rx_silent"},
|
||||||
|
{"r_discardpolicy", "rx_discardpolicy"},
|
||||||
|
{"r_padding", "rx_padding"},
|
||||||
|
{"r_lock", "rx_lock"},
|
||||||
|
{"r_lastclient", "rx_lastclient"},
|
||||||
|
{"fileformat", "fformat"},
|
||||||
|
{"outdir", "fpath"},
|
||||||
|
{"index", "findex"},
|
||||||
|
{"enablefwrite", "fwrite"},
|
||||||
|
{"masterfile", "fmaster"},
|
||||||
|
{"overwrite", "foverwrite"},
|
||||||
|
{"r_framesperfile", "rx_framesperfile"},
|
||||||
|
{"r_readfreq", "rx_zmqfreq"},
|
||||||
|
{"rx_readfreq", "rx_zmqfreq"},
|
||||||
|
{"rx_datastream", "rx_zmqstream"},
|
||||||
|
{"resmat", "partialreset"},
|
||||||
|
{"storagecells", "extrastoragecells"},
|
||||||
|
{"auto_comp_disable", "autocompdisable"},
|
||||||
|
{"comp_disable_time", "compdisabletime"},
|
||||||
|
{"adc", "slowadc"},
|
||||||
|
{"flags", "romode"},
|
||||||
|
{"i_a", "im_a"},
|
||||||
|
{"i_b", "im_b"},
|
||||||
|
{"i_c", "im_c"},
|
||||||
|
{"i_d", "im_d"},
|
||||||
|
{"i_io", "im_io"},
|
||||||
|
{"copydetectorserver", "updatedetectorserver"},
|
||||||
|
{"nframes", "framecounter"},
|
||||||
|
{"now", "runtime"},
|
||||||
|
{"timestamp", "frametime"},
|
||||||
|
{"frameindex", "rx_frameindex"},
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sls
|
1154
slsDetectorSoftware/src/CallerSpecial.cpp
Normal file
1154
slsDetectorSoftware/src/CallerSpecial.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,22 +1,12 @@
|
|||||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
#include "Caller.h"
|
||||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
||||||
|
|
||||||
/*
|
|
||||||
This file is used to generate the command line binaries
|
|
||||||
(sls_detector_get/put/acquire/help). By defines in CMake
|
|
||||||
we get the different files.
|
|
||||||
|
|
||||||
*/
|
|
||||||
#include "sls/Detector.h"
|
|
||||||
|
|
||||||
#include "CmdParser.h"
|
#include "CmdParser.h"
|
||||||
#include "CmdProxy.h"
|
#include "inferAction.h"
|
||||||
#include "sls/sls_detector_defs.h"
|
#include "sls/Detector.h"
|
||||||
|
#include "sls/logger.h"
|
||||||
#include "sls/versionAPI.h"
|
#include "sls/versionAPI.h"
|
||||||
#include <cstring> //strcmp
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// To genereate sepereate binaries for put, get, acquire and help
|
// To genereate sepereate binaries for put, get, acquire and help
|
||||||
#ifdef PUT
|
#ifdef PUT
|
||||||
int action = slsDetectorDefs::PUT_ACTION;
|
int action = slsDetectorDefs::PUT_ACTION;
|
||||||
@ -30,13 +20,12 @@ int main(int argc, char *argv[]) {
|
|||||||
int action = slsDetectorDefs::READOUT_ACTION;
|
int action = slsDetectorDefs::READOUT_ACTION;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef READOUTZMQ
|
|
||||||
int action = slsDetectorDefs::READOUT_ZMQ_ACTION;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HELP
|
#ifdef HELP
|
||||||
int action = slsDetectorDefs::HELP_ACTION;
|
int action = slsDetectorDefs::HELP_ACTION;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef INFER
|
||||||
|
int action = -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check for --version in the arguments
|
// Check for --version in the arguments
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
@ -49,15 +38,12 @@ int main(int argc, char *argv[]) {
|
|||||||
sls::CmdParser parser;
|
sls::CmdParser parser;
|
||||||
parser.Parse(argc, argv);
|
parser.Parse(argc, argv);
|
||||||
|
|
||||||
// If we called sls_detector_acquire, add the acquire command
|
if (action == slsDetectorDefs::READOUT_ACTION)
|
||||||
if (action == slsDetectorDefs::READOUT_ACTION ||
|
|
||||||
action == slsDetectorDefs::READOUT_ZMQ_ACTION)
|
|
||||||
parser.setCommand("acquire");
|
parser.setCommand("acquire");
|
||||||
|
|
||||||
if (parser.isHelp())
|
if (parser.isHelp())
|
||||||
action = slsDetectorDefs::HELP_ACTION;
|
action = slsDetectorDefs::HELP_ACTION;
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// Free shared memory should work also without a detector
|
// Free shared memory should work also without a detector
|
||||||
// if we have an option for verify in the detector constructor
|
// if we have an option for verify in the detector constructor
|
||||||
// we could avoid this but clutter the code
|
// we could avoid this but clutter the code
|
||||||
@ -70,22 +56,30 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent mem size check
|
|
||||||
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
|
if (parser.command() == "config" && action == slsDetectorDefs::PUT_ACTION) {
|
||||||
sls::freeSharedMemory(parser.multi_id());
|
sls::freeSharedMemory(parser.multi_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sls::InferAction inferAction = sls::InferAction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::unique_ptr<sls::Detector> det{nullptr};
|
if (action == -1) {
|
||||||
if (action != slsDetectorDefs::HELP_ACTION) {
|
action = inferAction.infer(parser);
|
||||||
det = sls::make_unique<sls::Detector>(parser.multi_id());
|
std::string actionString =
|
||||||
|
(action == slsDetectorDefs::GET_ACTION) ? "GET" : "PUT";
|
||||||
|
std::cout << "inferred action: " << actionString << std::endl;
|
||||||
}
|
}
|
||||||
sls::CmdProxy proxy(det.get());
|
|
||||||
proxy.Call(parser.command(), parser.arguments(), parser.detector_id(),
|
std::unique_ptr<sls::Detector> d{nullptr};
|
||||||
action, std::cout, parser.receiver_id());
|
if (action != slsDetectorDefs::HELP_ACTION) {
|
||||||
} catch (const sls::RuntimeError &e) {
|
d = sls::make_unique<sls::Detector>(parser.multi_id());
|
||||||
|
}
|
||||||
|
sls::Caller c(d.get());
|
||||||
|
|
||||||
|
c.call(parser.command(), parser.arguments(), parser.detector_id(),
|
||||||
|
action, std::cout, parser.receiver_id());
|
||||||
|
} catch (sls::RuntimeError &e) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
@ -20,7 +20,6 @@ reason that the header file is not exposed.
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
|
||||||
class CmdParser {
|
class CmdParser {
|
||||||
public:
|
public:
|
||||||
void Parse(int argc, const char *const argv[]);
|
void Parse(int argc, const char *const argv[]);
|
||||||
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user