pflib v3.9.0-rc3-11-g2537d8f
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(I2C& i2c, uint8_t econ_base_addr, const std::string& type_version);
21
22 const std::string& type() const { return type_; }
23 void setRunMode(bool active = true, int edgesel = -1, int fcmd_invert = -1);
24 int getPUSMRunValue();
25 int getPUSMStateValue();
26 bool isRunMode();
27
28 std::vector<uint8_t> getValues(int reg_addr, int nbytes);
29 void setValue(int reg_addr, uint64_t value, int nbytes);
30 void setValues(int reg_addr, const std::vector<uint8_t>& values);
31
32 void setRegisters(const std::map<int, std::map<int, uint8_t>>& registers);
33 void loadParameters(const std::string& file_path, bool prepend_defaults);
35 const std::map<int, std::map<int, uint8_t>>& selected);
38 void applyParameter(const std::string& page, const std::string& param,
39 const uint64_t& val);
40
43 bool print_values = true);
45 const std::string& file_path);
46 uint64_t readParameter(const std::string& page, const std::string& param,
47 bool print_values = false);
48
49 void dumpSettings(const std::string& filename, bool should_decompile);
50
52 std::map<int, std::map<int, uint8_t>> previous_registers_;
53 ECON& econ_;
54
55 public:
57 ECON& econ,
63 TestParameters& operator=(const TestParameters&) = delete;
65 class Builder {
67 ECON& econ_;
68
69 public:
71 Builder& add(const std::string& page, const std::string& param,
72 const uint64_t& val);
73 [[nodiscard]] TestParameters apply();
74 };
75 };
76
77 TestParameters::Builder testParameters();
78
79 private:
80 I2C& i2c_;
81 uint8_t econ_base_;
82 Compiler compiler_;
83 std::string type_;
84 std::map<uint16_t, size_t> econ_reg_nbytes_lut_;
85 mutable ::pflib::logging::logger the_log_{::pflib::logging::get("econ")};
86};
87
88} // namespace pflib
89
90#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:65
Definition ECON.h:51
~TestParameters()
applies the unset parameters to the ECON
Definition ECON.cxx:438
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:275
void dumpSettings(const std::string &filename, bool should_decompile)
Definition ECON.cxx:372
void loadParameters(const std::string &file_path, bool prepend_defaults)
Definition ECON.cxx:314
Base class which encapsulates the I2C interface, represents a single bus.
Definition I2C.h:18
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