pflib v3.9.0-rc3-11-g2537d8f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
ROC.h
1#ifndef PFLIB_ROC_H_INCLUDED
2#define PFLIB_ROC_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 ROC {
19 static const int N_REGISTERS_PER_PAGE = 32;
20
21 public:
22 ROC(I2C& i2c, uint8_t roc_base_addr, const std::string& type_version);
23
24 void setRunMode(bool active = true);
25 bool isRunMode();
26 const std::string& type() const;
27
28 std::vector<uint8_t> readPage(int ipage, int len);
29 uint8_t getValue(int page, int offset);
30 void setValue(int page, int offset, uint8_t value);
31
32 std::vector<std::string> getDirectAccessParameters();
33 bool getDirectAccess(const std::string& name);
34 bool getDirectAccess(int reg, int bit);
35 void setDirectAccess(const std::string& name, bool val);
36 void setDirectAccess(int reg, int bit, bool val);
37
44 void setRegisters(const std::map<int, std::map<int, uint8_t>>& registers);
45
53 const std::map<int, std::map<int, uint8_t>>& selected = {});
54
62 void loadRegisters(const std::string& file_path);
63
70
81
94
103 void loadParameters(const std::string& file_path, bool prepend_defaults);
104
114 void applyParameter(const std::string& page, const std::string& param,
115 const uint64_t& val);
116
124 void dumpSettings(const std::string& filepath, bool decompile);
125
130 std::map<int, std::map<int, uint8_t>> previous_registers_;
131 ROC& roc_;
132
133 public:
141 ROC& roc,
147 TestParameters& operator=(const TestParameters&) = delete;
149 class Builder {
151 ROC& roc_;
152
153 public:
154 Builder(ROC& roc);
155 Builder& add(const std::string& page, const std::string& param,
156 const uint64_t& val);
157 Builder& add_all_channels(const std::string& param, const uint64_t& val);
158 [[nodiscard]] TestParameters apply();
159 };
160 };
161
183
184 private:
185 I2C& i2c_;
186 uint8_t roc_base_;
187 std::string type_version_;
188 Compiler compiler_;
189 mutable ::pflib::logging::logger the_log_{::pflib::logging::get("roc")};
190};
191
192} // namespace pflib
193
194#endif // PFLIB_ROC_H_INCLUDED
Definition of compiling and decompiling functions between page numbers, register numbers,...
The object that does the compiling.
Definition Compile.h:55
Base class which encapsulates the I2C interface, represents a single bus.
Definition I2C.h:18
Build a TestParameters parameter by parameter.
Definition ROC.h:149
test certain parameters before setting them back to old values
Definition ROC.h:129
TestParameters(const TestParameters &)=delete
cannot copy or assign this lock
~TestParameters()
applies the unset parameters to the ROC
Definition ROC.cxx:333
TestParameters(ROC &roc, std::map< std::string, std::map< std::string, uint64_t > > new_params)
Construct a set of test parameters.
Definition ROC.cxx:327
Definition ROC.h:18
void dumpSettings(const std::string &filepath, bool decompile)
Dump the settings of the HGCROC into the input filepath.
Definition ROC.cxx:278
std::map< int, std::map< int, uint8_t > > applyParameters(const std::map< std::string, std::map< std::string, uint64_t > > &parameters)
Apply the input parameter mapping onto the chip.
Definition ROC.cxx:217
void loadParameters(const std::string &file_path, bool prepend_defaults)
Load the input parameters onto the chip.
Definition ROC.cxx:249
std::map< std::string, uint64_t > getParameters(const std::string &page)
Get the parameters for the input page.
Definition ROC.cxx:191
TestParameters::Builder testParameters()
start a set of test parameters
Definition ROC.cxx:357
void setRegisters(const std::map< int, std::map< int, uint8_t > > &registers)
set registers on the HGCROC to specific values
Definition ROC.cxx:140
void loadRegisters(const std::string &file_path)
set registers on the HGCROC to specific values
Definition ROC.cxx:180
std::map< std::string, std::map< std::string, uint64_t > > defaults()
Retrieve all of the manual-documented defaults for all parameters.
Definition ROC.cxx:213
std::map< int, std::map< int, uint8_t > > getRegisters(const std::map< int, std::map< int, uint8_t > > &selected={})
get registers from the HGCROC
Definition ROC.cxx:148
void applyParameter(const std::string &page, const std::string &param, const uint64_t &val)
Short-hand for applying a single parameter.
Definition ROC.cxx:271
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
static void roc(const std::string &cmd, Target *pft)
ROC menu commands.
Definition roc.cxx:119