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

167 lines
5.4 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
#include "Readers.h"
#include "sls/ToString.h"
#include "sls/sls_detector_defs.h"
#include <rapidjson/document.h>
namespace sls::test::master_file {
using ns = std::chrono::nanoseconds;
/* --scalar reads-- */
template <> struct Reader<JsonContext, int> {
static int read(const JsonContext &ctx, const std::string &name,
AccessType access) {
return ctx.doc[name.c_str()].GetInt();
}
};
template <> struct Reader<JsonContext, uint32_t> {
static uint32_t read(const JsonContext &ctx, const std::string &name,
AccessType access) {
return ctx.doc[name.c_str()].GetUint();
}
};
template <> struct Reader<JsonContext, uint64_t> {
static uint64_t read(const JsonContext &ctx, const std::string &name,
AccessType access) {
return ctx.doc[name.c_str()].GetUint64();
}
};
template <> struct Reader<JsonContext, double> {
static double read(const JsonContext &ctx, const std::string &name,
AccessType access) {
return ctx.doc[name.c_str()].GetDouble();
}
};
template <> struct Reader<JsonContext, std::string> {
static std::string read(const JsonContext &ctx, const std::string &name,
AccessType access) {
return ctx.doc[name.c_str()].GetString();
}
};
/** complex types */
template <> struct Reader<JsonContext, defs::xy> {
static defs::xy read(const JsonContext &ctx, const std::string &name,
AccessType access) {
defs::xy out{};
out.x = ctx.doc[name.c_str()]["x"].GetInt();
out.y = ctx.doc[name.c_str()]["y"].GetInt();
return out;
}
};
template <> struct Reader<JsonContext, std::vector<defs::ROI>> {
static std::vector<defs::ROI>
read(const JsonContext &ctx, const std::string &name, AccessType access) {
std::vector<defs::ROI> out{};
for (const auto &item : ctx.doc[name.c_str()].GetArray()) {
defs::ROI r{};
r.xmin = item["xmin"].GetInt();
r.xmax = item["xmax"].GetInt();
r.ymin = item["ymin"].GetInt();
r.ymax = item["ymax"].GetInt();
out.push_back(r);
}
return out;
}
};
template <> struct Reader<JsonContext, defs::scanParameters> {
static defs::scanParameters
read(const JsonContext &ctx, const std::string &name, AccessType access) {
defs::scanParameters out{};
const auto &s = ctx.doc[name.c_str()].GetObject();
out.enable = s["enable"].GetInt();
out.dacInd = static_cast<defs::dacIndex>(s["dacInd"].GetInt());
out.startOffset = s["start offset"].GetInt();
out.stopOffset = s["stop offset"].GetInt();
out.stepSize = s["step size"].GetInt();
out.dacSettleTime_ns = s["dac settle time ns"].GetInt64();
return out;
}
};
/** arrays/vectors/maps */
template <> struct Reader<JsonContext, std::array<int, 3UL>> {
static std::array<int, 3UL>
read(const JsonContext &ctx, const std::string &name, AccessType access) {
const auto &arr = ctx.doc[name.c_str()].GetArray();
check_size(arr.Size(), 3, name, "JSON");
std::array<int, 3UL> out{};
for (size_t i = 0; i < 3; ++i) {
out[i] = arr[i].GetInt();
}
return out;
}
};
template <> struct Reader<JsonContext, std::array<ns, 3UL>> {
static std::array<ns, 3UL>
read(const JsonContext &ctx, const std::string &name, AccessType access) {
const auto &arr = ctx.doc[name.c_str()].GetArray();
check_size(arr.Size(), 3, name, "JSON");
std::array<ns, 3UL> out{};
for (size_t i = 0; i < 3; ++i) {
std::string sval = arr[i].GetString();
out[i] = StringTo<ns>(sval);
}
return out;
}
};
template <> struct Reader<JsonContext, std::vector<int>> {
static std::vector<int> read(const JsonContext &ctx,
const std::string &name, AccessType access) {
std::vector<int> out{};
for (const auto &item : ctx.doc[name.c_str()].GetArray()) {
out.push_back(item.GetInt());
}
return out;
}
};
template <> struct Reader<JsonContext, std::vector<int64_t>> {
static std::vector<int64_t>
read(const JsonContext &ctx, const std::string &name, AccessType access) {
std::vector<int64_t> out{};
for (const auto &item : ctx.doc[name.c_str()].GetArray()) {
out.push_back(item.GetInt64());
}
return out;
}
};
template <> struct Reader<JsonContext, std::vector<std::string>> {
static std::vector<std::string>
read(const JsonContext &ctx, const std::string &name, AccessType access) {
std::vector<std::string> out{};
for (const auto &item : ctx.doc[name.c_str()].GetArray()) {
out.push_back(item.GetString());
}
return out;
}
};
template <> struct Reader<JsonContext, std::map<std::string, std::string>> {
static std::map<std::string, std::string>
read(const JsonContext &ctx, const std::string &name, AccessType access) {
std::map<std::string, std::string> out{};
for (const auto &m : ctx.doc[name.c_str()].GetObject()) {
out[m.name.GetString()] = m.value.GetString();
}
return out;
}
};
} // namespace sls::test::master_file