REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
run_manager.cpp
Go to the documentation of this file.
1#include "run/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// This is an interim hacky solution to introduce another kind of RunDataHandler
12#include <protocol/protocol_oob.h>
13
14void run::Run::run(carrier::Carrier &carrier_) {
15 state_change_handler->handle(to(RunState::TAKE_OFF, millis()), *this);
16 state_change_handler->handle(to(RunState::IC, millis()), *this);
17 state_change_handler->handle(to(RunState::OP, millis()), *this);
18
19 uint32_t num_channels = daq_config.get_num_channels();
20 uint32_t count = 64 * num_channels;
21 uint16_t data[count];
22
23 constexpr auto max = 6550.57976809;
24 for (auto idx = 0; idx < 64; ++idx) {
25 for (auto channel = 0; channel < num_channels; ++channel) {
26 double x = 2 * M_PI * idx / 64.0;
27 double value = channel % 2 == 0 ? std::sin(x) : std::cos(x);
28 data[idx * num_channels + channel] = static_cast<uint16_t>(8188.22471011 - max * value);
29 }
30 }
31
32 data_handler->prepare(*this, num_channels);
33 data_handler->handle(*this, data, 64);
34 std::array<std::array<float, 8>, 6> data_op_end;
35 data_handler->handle_op_end(*this, data_op_end);
36 state_change_handler->handle(to(RunState::OP_END, millis()), *this);
37 state_change_handler->handle(to(RunState::DONE, millis()), *this);
38}
uint32_t
Definition flasher.cpp:195