pflib v3.9.4-7-gb2e7f4f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
ECON.h
1#ifndef PFLIB_ECON_H_INCLUDED
2#define PFLIB_ECON_H_INCLUDED
3
4#include <iostream>
5#include <map>
6#include <string>
7#include <vector>
8
9#include "pflib/Compile.h"
10#include "pflib/I2C.h"
11#include "pflib/logging/Logging.h"
12
13namespace pflib {
14
18class ECON {
19 public:
20 ECON(std::shared_ptr<I2C> i2c, uint8_t econ_base_addr,
21 const std::string& type_version);
22
23 const std::string& type() const { return type_; }
24 void setRunMode(bool active = true, int edgesel = -1, int fcmd_invert = -1);
25 int getPUSMRunValue();
26 int getPUSMStateValue();
27 bool isRunMode();
28
29 std::vector<uint8_t> getValues(int reg_addr, int nbytes);
30 void setValue(int reg_addr, uint64_t value, int nbytes);
31 void setValues(int reg_addr, const std::vector<uint8_t>& values);
32
33 void setRegisters(const std::map<int, std::map<int, uint8_t>>& registers);
34 void loadParameters(const std::string& file_path, bool prepend_defaults);
36 const std::map<int, std::map<int, uint8_t>>& selected);
39 void applyParameter(const std::string& page, const std::string& param,
40 const uint64_t& val);
41
44 bool print_values = true);
46 const std::string& file_path);
47 uint64_t readParameter(const std::string& page, const std::string& param,
48 bool print_values = false);
49
50 void dumpSettings(const std::string& filename, bool should_decompile);
51
53 std::map<int, std::map<int, uint8_t>> previous_registers_;
54 ECON& econ_;
55
56 public:
58 ECON& econ,
64 TestParameters& operator=(const TestParameters&) = delete;
66 class Builder {
68 ECON& econ_;
69
70 public:
72 Builder& add(const std::string& page, const std::string& param,
73 const uint64_t& val);
74 [[nodiscard]] TestParameters apply();
75 };
76 };
77
78 TestParameters::Builder testParameters();
79
80 private:
82 uint8_t econ_base_;
83 Compiler compiler_;
84 std::string type_;
85 std::map<uint16_t, size_t> econ_reg_nbytes_lut_;
86 mutable ::pflib::logging::logger the_log_{::pflib::logging::get("econ")};
87};
88
89} // namespace pflib
90
91#endif // PFLIB_ECON_H_INCLUDED
Definition of compiling and decompiling functions between page numbers, register numbers,...
The object that does the compiling.
Definition Compile.h:55
Build a TestParameters parameter by parameter.
Definition ECON.h:66
Definition ECON.h:52
~TestParameters()
applies the unset parameters to the ECON
Definition ECON.cxx:439
TestParameters(const TestParameters &)=delete
cannot copy or assign this lock
Definition ECON.h:18
std::map< int, std::map< int, uint8_t > > applyParameters(const std::map< std::string, std::map< std::string, uint64_t > > &parameters)
Definition ECON.cxx:276
void dumpSettings(const std::string &filename, bool should_decompile)
Definition ECON.cxx:373
void loadParameters(const std::string &file_path, bool prepend_defaults)
Definition ECON.cxx:315
static void econ(const std::string &cmd, Target *pft)
ECON menu commands.
Definition econ.cxx:147
logger get(const std::string &name)
Gets a logger with the input name for its channel.
Definition Logging.cxx:24
This version of the fast control code interfaces with the CMS Fast control library which can be contr...
Definition Backend.cxx:3