7#include <THttpServer.h>
12#include <fmt/format.h>
20 L_(info) <<
"Starting Server with port " <<
fS.
port;
24 L_(info) <<
"Not filtering on sensor";
27 fServer =
new THttpServer(fmt::format(
"http:{}",
fS.
port).c_str());
31 fServer->SetJSROOT(
"https://jsroot.gsi.de/7.1.0/");
42 fServer->SetItemField(
"/",
"_layout",
"grid3x3");
44 fServer->RegisterCommand(
"/NextTS",
"/server/->RequestNextTS()");
45 fServer->SetItemField(
"/NextTS",
"_title",
"Next Timeslice");
47 if (
fS.
archive ==
nullptr)
throw std::runtime_error(
"Archive must not be null");
48 if (
fS.
histograms ==
nullptr)
throw std::runtime_error(
"Histograms must not be null");
51 if (
fS.
archive2 ==
nullptr)
throw std::runtime_error(
"Archive2 must not be null");
52 if (
fS.
histograms2 ==
nullptr)
throw std::runtime_error(
"Histograms2 must not be null");
57 fServer->CreateItem(folder.path.c_str(), folder.name.c_str());
58 fServer->SetItemField(folder.path.c_str(),
"_kind",
"Folder");
63 fServer->Register(path.c_str(), histo);
73 L_(info) <<
"Starting event loop";
78 nRequests =
fServer->ProcessRequests();
79 if (nRequests > 0)
L_(info) <<
"Processed " << nRequests <<
" requests";
86 }
while (nRequests > 0);
99 L_(info) <<
"Fetching next Timeslice...";
103 L_(info) <<
"End of archive reached";
115 if (
fS.
archive2->eos())
throw std::runtime_error(
"End of archive2 reached too early");
117 fill = {.data = recoResults.get(), .sensor =
fS.
sensor};
119 L_(info) <<
"Dividing histograms";
123 L_(info) <<
"Finished Timeslice";
Server(Settings settings)
static constexpr int SleepPerTick_ms
std::shared_ptr< HistogramCollection > histograms2
std::shared_ptr< HistogramCollection > histograms
std::shared_ptr< algo::RecoResultsInputArchive > archive
std::optional< uint32_t > sensor
std::shared_ptr< algo::RecoResultsInputArchive > archive2