Files
maliakal_dandGitHub c3ad3d2e73
Build and Deploy on local RHEL9 / build (push) Successful in 2m13s
Build on RHEL9 docker image / build (push) Successful in 3m53s
Build and Deploy on local RHEL8 / build (push) Successful in 4m58s
Build on RHEL8 docker image / build (push) Successful in 5m47s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m55s
Run Simulator Tests on local RHEL8 / build (push) Successful in 22m26s
Dev/rx disable datastream port (#1448)
- changed 
   - command from `datastream` to `udp_datastream` to be more specific
   - Detector API:
      - setNumberofUDPInterfaces(pos) =>setNumberofUDPInterfaces() # no position anymore
      - getDataStream(portPosition, pos) =>getUDPDataStream(portPosition, pos)
      - setDataStream(portPosition, pos) => setUDPDataStream(portPosition) # no position anymore
      
   - modified the dataprocessing thread: 
      - if gui or call back, start zmq processing (connecting sockets) before starting receiver (disabled ports sends dummy that the client zmq sockets are not ready for)
      - if only progress, starting progress processing thread after startReceiver
      -


- added
   - Detector API:
      - getRxDisabledUDPPortIndices()
      - getPortPositionList()  
   - allow disabling/enabling udp interface in receiver for Jungfrua/Moench when both udp interfaces is enabled  (This is to go fast, where only one half of the module matters)
   - write ports type and disabled ports to master file (tests for it as well)
   - tests for python commands as well
   - datastream command to deprecated commands
   - refactored tests to make the new parameters fit

* first draft of disabling data port at the receiver side. Todo: master file and stream for gui to use

* updated help in command

* formatting

* md5 unchanged

* fix test, check port position for detector type

* wip, udp port enable metadata in client, to:receiver, zmq streaming

* wip, master attributes

* wip, imple=> save only disabled ports with port index, 1 interface, is empty

* works in file. still needs refactoring

* updated writer versions

* udp ports type pass, disabled with api yet

* fixed disabled ports meta data as well

* fixed in developer via other PR

* renamed.more intuitive

* fix in gui that wont wait for disabled ports

* added tests for master file

* extra tests

* move the master fiel tests into its own tests with the disable marker for github tests

* refactoring

* python test

* more intuitive and doc

* release notes

* example for python

* back to before

* minor documentation fix and sending nports unnecessarily for getRxUDPPortDisableMetadata

* doc

* review fixes, 1. using std::array instead of vector, 2. moving udp_datastream command testing with different values into master attributes testing file because we test the master file

* minor

* review: update help

* progress printed before assigned

* try catch inside hdf5

* auto generated code for CLI and formatting

* missing packets should not be checked at github workflow level

* formatting

* improved python doc for udp_datastream help

* indent doc python done
2026-07-13 14:58:25 +02:00

148 lines
5.2 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include "sls/Detector.h"
#include "sls/logger.h"
#include <cstdint>
#include <optional>
#include <vector>
namespace sls::test::acquire {
struct CTBState {
defs::readoutMode readout_mode;
int num_adc_samples;
int num_dbit_samples;
int num_trans_samples;
bool ten_giga;
uint32_t adc_enable_1g;
uint32_t adc_enable_10g;
int dbit_offset;
std::vector<int> dbit_list;
bool dbit_reorder;
uint32_t transceiver_mask;
};
/** an example of CTB config */
inline CTBState
default_ctb_state(const defs::detectorType &detType = defs::GENERIC) {
if (detType == defs::GENERIC) {
throw sls::RuntimeError(
"Cannot determine default CTB state for generic detector type.");
}
auto isAltera = (detType == defs::CHIPTESTBOARD);
return {defs::ANALOG_AND_DIGITAL, 5000, 6000, 288,
isAltera ? false : true, 0xFFFFFF00, 0xFF00FFFF, 0,
{0, 12, 2, 43}, false, 0x3};
}
inline CTBState get_ctb_state(const Detector &det) {
auto isAltera =
(det.getDetectorType().squash(defs::GENERIC) == defs::CHIPTESTBOARD);
return CTBState{
det.getReadoutMode().tsquash("Inconsistent readout mode"),
det.getNumberOfAnalogSamples().tsquash(
"Inconsistent number of analog samples"),
det.getNumberOfDigitalSamples().tsquash(
"Inconsistent number of digital samples"),
det.getNumberOfTransceiverSamples().tsquash(
"Inconsistent number of transceiver samples"),
isAltera ? det.getTenGiga().tsquash("Inconsisten ten giga enable")
: true,
isAltera
? det.getADCEnableMask().tsquash("Inconsistent adc enable mask")
: 0,
det.getTenGigaADCEnableMask().tsquash(
"Inconsistent ten giga adc enable mask"),
det.getRxDbitOffset().tsquash("Inconsistent rx dbit offset"),
det.getRxDbitList().tsquash("Inconsistent rx dbit list"),
det.getRxDbitReorder().tsquash("Inconsistent rx dbit reorder"),
det.getTransceiverEnableMask().tsquash(
"Inconsistent transceiver mask")};
}
inline void set_ctb_state(Detector &det, const CTBState &s) {
auto isAltera =
(det.getDetectorType().squash(defs::GENERIC) == defs::CHIPTESTBOARD);
det.setReadoutMode(s.readout_mode);
if (isAltera) {
det.setTenGiga(s.ten_giga);
det.setADCEnableMask(s.adc_enable_1g);
}
det.setNumberOfAnalogSamples(s.num_adc_samples);
det.setNumberOfDigitalSamples(s.num_dbit_samples);
det.setNumberOfTransceiverSamples(s.num_trans_samples);
det.setTenGigaADCEnableMask(s.adc_enable_10g);
det.setRxDbitOffset(s.dbit_offset);
det.setRxDbitList(s.dbit_list);
det.setRxDbitReorder(s.dbit_reorder);
det.setTransceiverEnableMask(s.transceiver_mask);
}
inline std::ostream &operator<<(std::ostream &os, const CTBState &s) {
os << "CTB State:"
<< "\n Readout Mode: " << ToString(s.readout_mode)
<< "\n Num ADC Samples: " << s.num_adc_samples
<< "\n Num DBIT Samples: " << s.num_dbit_samples
<< "\n Num Trans Samples: " << s.num_trans_samples
<< "\n Ten Giga: " << s.ten_giga
<< "\n ADC Enable 1G: " << ToStringHex(s.adc_enable_1g)
<< "\n ADC Enable 10G: " << ToStringHex(s.adc_enable_10g)
<< "\n DBIT Offset: " << s.dbit_offset
<< "\n DBIT List: " << ToString(s.dbit_list)
<< "\n DBIT Reorder: " << s.dbit_reorder
<< "\n Transceiver Mask: " << ToStringHex(s.transceiver_mask);
return os;
}
inline void print_current_ctb_state(const Detector &det) {
auto ctb_state = get_ctb_state(det);
LOG(logINFO) << ctb_state;
}
/**
* @brief RAII guard for restoring the existing ctb configuration after a test.
*
* The constructor saves the current ctb config and sets a new config, while the
* destructor restores the original config.
*/
class CTBStateGuard {
public:
explicit CTBStateGuard(Detector &det,
std::optional<CTBState> new_state = std::nullopt)
: det(det) {
auto type = det.getDetectorType().squash(defs::GENERIC);
if (type == defs::CHIPTESTBOARD || type == defs::XILINX_CHIPTESTBOARD) {
active = true;
if (!new_state.has_value()) {
throw sls::RuntimeError(
"New CTB state must be provided for CTBStateGuard.");
}
saved_ = get_ctb_state(det);
set_ctb_state(det, new_state.value());
}
}
~CTBStateGuard() {
if (active)
set_ctb_state(det, saved_);
}
private:
Detector &det;
bool active{false};
CTBState saved_;
};
/**
* @brief
* @param test_info current CTB state
* @param isXilinxCtb if the detector type is Xilinx CTB
* @return std::pair<uint64_t, int> pair of image size in bytes and number of
* channels in dimension X (Currently only analog channels)
*/
std::pair<uint64_t, int> calculate_ctb_image_size(const CTBState &test_info,
bool isXilinxCtb);
} // namespace sls::test::acquire