News
Shop
Learn
Community
Ein Bild oder sowas
LUCIDAC Documentation
User Docs
Pybrid
Julia
C++
Firmware
REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
user_plugin_static.cpp
Go to the documentation of this file.
1
#include <proto/main.pb.h>
2
3
#include <plugin/static.h>
4
#include <run/run.h>
5
#include <protocol/protocol.h>
6
#include <protocol/protocol_oob.h>
7
8
constexpr
uint16_t
bufsize
= 300;
9
uint16_t *
results
=
nullptr
;
10
size_t
cur_run
= 0;
11
run::Run *
reprun
=
nullptr
;
12
13
void
tear_down
() {
14
delete
reprun
;
15
delete
results
;
16
cur_run
= 0;
17
}
18
19
/*
20
class MonteCarloHandler : public msg::handlers::MessageHandler {
21
public:
22
int handle(JsonObjectConst msg_in, utils::StreamingJson &msg_out) override {
23
if(msg_in.containsKey("run_delete"))
24
tear_down();
25
26
if(msg_in.containsKey("run_config")) {
27
auto run_config_json = msg_in["run_config"].as<JsonObjectConst>();
28
auto run_config = run::RunConfig::from_pb(run_config_json);
29
if(reprun)
30
tear_down();
31
32
33
reprun = new run::Run(
34
"monte_carlo",
35
run_config,
36
std::make_unique<client::RunStateChangeNotificationHandler>(msg_out.output),
37
std::make_unique<client::RunDataNotificationHandler>(msg_out.output),
38
daq::DAQConfig::silence()
39
);
40
}
41
42
return success;
43
}
44
};*/
45
46
void
static_plugin::setup() {
47
//msg::handlers::Registry::get().set("monte_carlo", new MonteCarloHandler(), net::auth::SecurityLevel::RequiresLogin);
48
}
49
50
void
static_plugin::loop() {
51
if
(!
reprun
)
return
;
52
53
if
(!
results
) {
54
results
=
new
uint16_t[
bufsize
];
// because RAM2 has more of leftover
55
}
56
57
// carry out the next run, not streaming any data during run.
58
// TODO: Add carrier reference to plugins and fix this call
59
auto
carrier
=
static_cast<
carrier::Carrier*
>
(
nullptr
);
60
reprun
->run(*
carrier
);
61
// sample exactly one channel at end of run.
62
results
[
cur_run
++] = daq::sample_raw()[0];
63
64
if
(
cur_run
<
bufsize
)
return
;
65
66
// stream out the results, reusing existing infrastructure.
67
//reprun->streaming_run_data_notification_handler->handle(results, bufsize, 1, *reprun);
68
cur_run
= 0;
69
}
carrier
Definition
daq.h:14
tear_down
void tear_down()
Definition
user_plugin_static.cpp:13
results
uint16_t * results
Definition
user_plugin_static.cpp:9
bufsize
constexpr uint16_t bufsize
Definition
user_plugin_static.cpp:8
reprun
run::Run * reprun
Definition
user_plugin_static.cpp:11
cur_run
size_t cur_run
Definition
user_plugin_static.cpp:10
src
user_plugin_static.cpp
Generated by
1.13.2