REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
drivers.cpp
Go to the documentation of this file.
1#include "run/manager.h"
2#include "mode/counters.h"
3
4#include <Arduino.h>
5#include <cmath>
6#include <cstdlib>
7
8#include <daq/daq.h>
9#include <utils/logging.h>
10
11#include "run/registry.h"
12#include "run/handlers.h"
13#include "run/native/drivers.h"
14
15void run::drivers::SimulatedRun::run() {
16 LOG_ALWAYS("run::drivers::SimulatedRun::run not yet implemented");
17 throw 7711;
18 // or is there any reason to behave as if we set OP/IC and do data aquisition
19 // without having any simulator behind it?
20}
21
22void run::drivers::DummyDemoRun::run() {
23 LOG_ALWAYS("run::drivers::DummyDemoRun starting, for testing protocol code infrastructure");
24
25 LOGMEV("IC TIME: %lld", config.ic_time);
26 LOGMEV("OP TIME: %lld", config.op_time);
27
28 if(state_change_handler)
29 state_change_handler->handle(to(RunState::IC, 0), *this);
30 else
31 LOG_ALWAYS("No state change handler");
32
33 if(data_handler)
34 data_handler->init();
35
36 auto &perf = mode::PerformanceCounter::get();
37 perf.add(mode::Mode::IC, config.ic_time / 1000);
38 perf.add(mode::Mode::OP, config.op_time / 1000);
39 perf.increase_run();
40
41 if(state_change_handler) state_change_handler->handle(to(RunState::OP, config.ic_time), *this);
42
43 constexpr const size_t outer = 100, inner = 100;
44
45 auto *data32 = new uint32_t[outer*inner];
46 auto *data16 = new uint16_t[outer*inner];
47
48 // dummy data
49 for(size_t j=0; j<outer*inner; j++) {
50 data32[j] = j; data16[j] = j;
51 }
52
53 if(data_handler)
54 data_handler->handle(data32, 100, 100, *this);
55 else
56 LOG_ALWAYS("No data handler");
57
58 if(alt_data_handler)
59 alt_data_handler->handle(data16, 100, 100, *this);
60 else
61 LOG_ALWAYS("No alt data handler");
62
63 if(state_change_handler) state_change_handler->handle(to(RunState::DONE, config.ic_time+config.op_time), *this);
64
65}
uint32_t
Definition flasher.cpp:195