mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-21 08:51:41 +01:00
Dev/define cmd (#1312)
* basic ctb config api for register and bit names * tests for define and definelist pass. yet to implement using them for reg, setbit, clearbit and getbit * improved autocomplete for getbit,setbit, clearbit * validate autocomplete * definelist has no put * updating help * converting char array+int in runtimeerror compiles but throws at runtime.Fixed.Tested for it. Also check if string or int before using getregisterdefinitonbyvalue to see if it threw to call the other function. because both of it can throw and we should differentiate the issues for both * removed std::vector<std::pair<string,int> to std::map<string, int> for defiitions list * Dev/define cmd tie bit to reg (#1328) * strong type * moved everythign to bit_utils class * pybindings * added tests for python * removed duplicates * removed bit names in reg * changed BitPosition to BitAddress * Using define reg/bit from python (#1344) * define_bit, define_addr in python. * setBit/clearBit takes int or addr * added example using bits * split define into 2 commands define_reg and define_bit, definelist into 2: definelist_reg and definelist_bit * allow string for register and bit names in c++ api * refactor from github comments * naming refactoring (getRegisterDefnition to retunr name and address specifically * added marker for 8 cmd tests connected to define, changed macro to static constexpr * changed bitPosition from int to uint32_t * got rid of setbitposition and setaddress, instead overloaded constructor to take in strings so that the conversion from string to bit address members, takes place within the class for easy maintainance in case type changes * Removing implicit conversions: RegisterAddresss and RegisterValue: Removed the implicit conversions. RegisterAddress: Changed member name from address_ to value_ and method as well to value(). RegisterValue: Also added | operator to be able to concatenate with uint32_t. Same in python bindings (but could not find the tests to modify * Allowed concatenation with other RegisterValue, made them all constexpr * fix a ctbConfig test * Maponstack works with integration tests, but need unit tests * tests on mapstack * fixed ctb tests and FixedString being initialized with gibberish * removing parsing from string inside the class RegisterAddress, BitAddress and RegisterValue * updated python bindings * fixed bit utils test * renaming getRegisterDefintiionAddress/Name=>getRegisterAddress/Name and similary for getBitDefinitionAddress/Name * updated python bindings * fix tests (format) * a few python tests added and python bindings corrected * replaceing str with __str__ for bit.cpp * repr reimplemented for bit.cpp * removed make with registerAddress etc * starting server for tests per session and nor module * killprocess throws if no process found-> github runs fails, changed to pkill and not throw * clean shm shouldnt raise, in ci binary not found * ignoring these tests for CI, which fail on CI because simulators are not generated in CI. This is in another PR, where it should work --------- Co-authored-by: Erik Fröjdh <erik.frojdh@gmail.com> Co-authored-by: froejdh_e <erik.frojdh@psi.ch>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
#include "sls/Pattern.h"
|
||||
#include "sls/Result.h"
|
||||
#include "sls/bit_utils.h"
|
||||
#include "sls/network_utils.h"
|
||||
#include "sls/sls_detector_defs.h"
|
||||
#include <chrono>
|
||||
@@ -1837,6 +1838,64 @@ class Detector {
|
||||
/** [CTB][Xilinx CTB] */
|
||||
std::string getSlowADCName(const defs::dacIndex i) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
int getRegisterDefinitionsCount() const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
void setRegisterDefinition(const std::string &name, RegisterAddress addr);
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
bool hasRegisterDefinition(const std::string &name) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
bool hasRegisterDefinition(RegisterAddress addr) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
RegisterAddress getRegisterAddress(const std::string &name) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
std::string getRegisterName(RegisterAddress addr) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
void clearRegisterDefinitions();
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
void
|
||||
setRegisterDefinitions(const std::map<std::string, RegisterAddress> &list);
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
std::map<std::string, RegisterAddress> getRegisterDefinitions() const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
int getBitDefinitionsCount() const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
void setBitDefinition(const std::string &name, BitAddress addr);
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
bool hasBitDefinition(const std::string &name) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
bool hasBitDefinition(BitAddress addr) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
std::string toRegisterNameBitString(BitAddress addr) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] returns bit position and address */
|
||||
BitAddress getBitAddress(const std::string &name) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
std::string getBitName(BitAddress addr) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
void clearBitDefinitions();
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
void setBitDefinitions(const std::map<std::string, BitAddress> &list);
|
||||
|
||||
/** [CTB][Xilinx CTB] */
|
||||
std::map<std::string, BitAddress> getBitDefinitions() const;
|
||||
|
||||
///@}
|
||||
|
||||
/** @name Xilinx CTB Specific */
|
||||
@@ -2045,26 +2104,71 @@ class Detector {
|
||||
/** Advanced user Function! \n
|
||||
* Goes to stop server. Hence, can be called while calling blocking
|
||||
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only
|
||||
* right. */
|
||||
Result<uint32_t> readRegister(uint32_t addr, Positions pos = {}) const;
|
||||
* right.*/
|
||||
Result<RegisterValue> readRegister(RegisterAddress addr,
|
||||
Positions pos = {}) const;
|
||||
|
||||
/** Advanced user Function! \n
|
||||
* Goes to stop server. Hence, can be called while calling blocking
|
||||
* acquire(). \n [Eiger] Address is +0x100 for only left, +0x200 for only
|
||||
* right. */
|
||||
void writeRegister(uint32_t addr, uint32_t val, bool validate = false,
|
||||
Positions pos = {});
|
||||
* right.*/
|
||||
void writeRegister(RegisterAddress addr, RegisterValue val,
|
||||
bool validate = false, Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
void setBit(uint32_t addr, int bitnr, bool validate = false,
|
||||
/** Advanced user Function! */
|
||||
void setBit(BitAddress addr, bool validate = false, Positions pos = {});
|
||||
|
||||
/** Advanced user Function!*/
|
||||
void clearBit(BitAddress addr, bool validate = false, Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
Result<int> getBit(BitAddress addr, Positions pos = {}) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] Advanced user Function! */
|
||||
Result<RegisterValue> readRegister(const std::string ®_name,
|
||||
Positions pos = {}) const;
|
||||
|
||||
/** [CTB][Xilinx CTB] Advanced user Function! */
|
||||
void writeRegister(const std::string ®_name, RegisterValue val,
|
||||
bool validate = false, Positions pos = {});
|
||||
|
||||
/** [CTB][Xilinx CTB] Advanced user Function! */
|
||||
void setBit(const std::string &bit_name, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
void clearBit(uint32_t addr, int bitnr, bool validate = false,
|
||||
/** [CTB][Xilinx CTB] Advanced user Function! */
|
||||
void clearBit(const std::string &bit_name, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Advanced user Function! */
|
||||
Result<int> getBit(uint32_t addr, int bitnr, Positions pos = {});
|
||||
/** [CTB][Xilinx CTB] Advanced user Function! */
|
||||
Result<int> getBit(const std::string &bit_name, Positions pos = {}) const;
|
||||
|
||||
/** Deprecated Advanced user Function! */
|
||||
[[deprecated("Use the overload taking RegisterAddress instead of "
|
||||
"uint32_t")]] Result<uint32_t>
|
||||
readRegister(uint32_t addr, Positions pos = {}) const;
|
||||
|
||||
/** Deprecated Advanced user Function! */
|
||||
[[deprecated("Use the overload taking RegisterAddress and RegisterValue "
|
||||
"instead of uint32_t")]] void
|
||||
writeRegister(uint32_t addr, uint32_t val, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Deprecated Advanced user Function! */
|
||||
[[deprecated("Use the overload taking BitAddress instead of uint32_t and "
|
||||
"int")]] void
|
||||
setBit(uint32_t addr, int bitnr, bool validate = false, Positions pos = {});
|
||||
|
||||
/** Deprecated Advanced user Function! */
|
||||
[[deprecated("Use the overload taking BitAddress instead of uint32_t and "
|
||||
"int")]] void
|
||||
clearBit(uint32_t addr, int bitnr, bool validate = false,
|
||||
Positions pos = {});
|
||||
|
||||
/** Deprecated Advanced user Function! */
|
||||
[[deprecated("Use the overload taking BitAddress instead of uint32_t and "
|
||||
"int")]] Result<int>
|
||||
getBit(uint32_t addr, int bitnr, Positions pos = {}) const;
|
||||
|
||||
/** [Jungfrau][Moench][Mythen3][Gotthard2][CTB] Advanced user
|
||||
* Function! */
|
||||
|
||||
Reference in New Issue
Block a user