Skip to content
Snippets Groups Projects
Commit b172645e authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

extend interface for more advanced tests (timeout, write to flash etc.)

parent bb963f0d
No related branches found
No related tags found
No related merge requests found
......@@ -10,21 +10,41 @@ struct TecDummy : ChimeraTK::DummyBackend {
TecDummy(std::string mapFileName) : DummyBackend(mapFileName) {}
~TecDummy() override {}
// getter and setter functions for parameters
int getInt(TecFrame::TecParameter param) { return rawValues[param]; }
float getFloat(TecFrame::TecParameter param) { return *(reinterpret_cast<float*>(&(rawValues[param]))); }
void set(TecFrame::TecParameter param, int value) { rawValues[param] = value; }
void set(TecFrame::TecParameter param, float value) { rawValues[param] = *(reinterpret_cast<int*>(&value)); }
// returns whether the last write operation for the given parameter was stored in flash or not. Will return false
// if the parameter has not been yet at all.
bool getLastWriteToFlash(TecFrame::TecParameter param) { return lastWriteToFlash[param]; }
// flag whether timeouts should be simulated. This simulates e.g. a broken UART connection between FPGA and TEC device
bool simulateSerialTimeout{false};
// Number of read operations on the LOOP_DONE register required before the communication is simulated and LOOP_DONE is
// set to 1. If this value is 0, it will happen on the first read operation. A value of 1 requires one additional read
// before. After each communication cycle, this value will end up to be 0. A test needs hence to set this value every
// time again.
size_t loopDoneDelay{0};
protected:
// hardcoded addresses used by the dummy, need to match addresses of map file
constexpr static uint8_t TecDummy_bar{0};
constexpr static uint32_t TecDummy_address_loopDone{8};
// Maps contining the values of the TEC parameters. These maps will be filled / read by the dummy during the
// Map containing the values of the TEC parameters. These map will be filled / read by the dummy during the
// communication with the TEC library. It can also be used by tests to read / change values in the dummy.
// If a value is not in the map, it means the value has not yet been written / read.
// For accessing the values within unit tests, use the getter/setter functions below.
// For accessing the values within unit tests, use the getter/setter functions above.
std::map<TecFrame::TecParameter, int32_t> rawValues;
// getter and setter functions for parameters
int getInt(TecFrame::TecParameter param) { return rawValues[param]; }
float getFloat(TecFrame::TecParameter param) { return *(reinterpret_cast<float*>(&(rawValues[param]))); }
void set(TecFrame::TecParameter param, int value) { rawValues[param] = value; }
void set(TecFrame::TecParameter param, float value) { rawValues[param] = *(reinterpret_cast<int*>(&value)); }
// Map containing the flags whether the last write of a TEC parameter was to flash.
std::map<TecFrame::TecParameter, bool> lastWriteToFlash;
// Flag whether writes currently go to flash or not.
bool currentWritesToFlash{false}; // TODO: Verify default value from TEC hardware documentation!
// Accessors for the registers
ChimeraTK::DummyRegisterAccessor<uint32_t> reg_loopStart{this, "UNIO0", "BIT_TEC1091_CMD_LOOP_START"};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment