Project
Loading...
Searching...
No Matches
DIMessages.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#include "DIMessages.h"
12#include "rapidjson/document.h"
13#include "rapidjson/writer.h"
14#include "rapidjson/stringbuffer.h"
15#include <fairlogger/Logger.h>
16
17using namespace rapidjson;
18
20{
21 Document doc;
22 doc.SetObject();
23 auto& alloc = doc.GetAllocator();
24
25 doc.AddMember("binding", Value(input.binding.c_str(), alloc), alloc);
26 doc.AddMember("sourceChannel", Value(input.sourceChannel.c_str(), alloc), alloc);
27 doc.AddMember("timeslice", Value((uint64_t)input.timeslice), alloc);
28
29 if (input.origin.has_value()) {
30 doc.AddMember("origin", Value(input.origin.value().c_str(), alloc), alloc);
31 }
32 if (input.description.has_value()) {
33 doc.AddMember("description", Value(input.description.value().c_str(), alloc), alloc);
34 }
35 if (input.subSpec.has_value()) {
36 doc.AddMember("subSpec", Value(input.subSpec.value()), alloc);
37 }
38
39 return doc;
40}
41
43{
44 Document doc;
45 doc.SetObject();
46 auto& alloc = doc.GetAllocator();
47
48 doc.AddMember("binding", Value(output.binding.c_str(), alloc), alloc);
49 doc.AddMember("channel", Value(output.channel.c_str(), alloc), alloc);
50 doc.AddMember("timeslice", Value((uint64_t)output.timeslice), alloc);
51 doc.AddMember("maxTimeslices", Value((uint64_t)output.maxTimeslices), alloc);
52
53 doc.AddMember("origin", Value(output.origin.c_str(), alloc), alloc);
54 doc.AddMember("description", Value(output.description.c_str(), alloc), alloc);
55 if (output.subSpec.has_value()) {
56 doc.AddMember("subSpec", Value(output.subSpec.value()), alloc);
57 }
58
59 return doc;
60}
61
63{
64 Document doc;
65 doc.SetObject();
66 auto& alloc = doc.GetAllocator();
67
68 doc.AddMember("binding", Value(forward.binding.c_str(), alloc), alloc);
69 doc.AddMember("channel", Value(forward.channel.c_str(), alloc), alloc);
70 doc.AddMember("timeslice", Value((uint64_t)forward.timeslice), alloc);
71 doc.AddMember("maxTimeslices", Value((uint64_t)forward.maxTimeslices), alloc);
72
73 if (forward.origin.has_value()) {
74 doc.AddMember("origin", Value(forward.origin.value().c_str(), alloc), alloc);
75 }
76 if (forward.description.has_value()) {
77 doc.AddMember("description", Value(forward.description.value().c_str(), alloc), alloc);
78 }
79 if (forward.subSpec.has_value()) {
80 doc.AddMember("subSpec", Value(forward.subSpec.value()), alloc);
81 }
82
83 return doc;
84}
85
87{
88 Document doc;
89 doc.SetObject();
90 auto& alloc = doc.GetAllocator();
91
92 doc.AddMember("rank", Value((uint64_t)specs.rank), alloc);
93 doc.AddMember("nSlots", Value((uint64_t)specs.nSlots), alloc);
94 doc.AddMember("inputTimesliceId", Value((uint64_t)specs.inputTimesliceId), alloc);
95 doc.AddMember("maxInputTimeslices", Value((uint64_t)specs.maxInputTimeslices), alloc);
96
97 Value inputsArray;
98 inputsArray.SetArray();
99 for (auto& input : specs.inputs) {
100 Value inputValue;
101 inputValue.CopyFrom(toJson(input), alloc);
102 inputsArray.PushBack(inputValue, alloc);
103 }
104 doc.AddMember("inputs", inputsArray, alloc);
105
106 Value outputsArray;
107 outputsArray.SetArray();
108 for (auto& output : specs.outputs) {
109 Value outputValue;
110 outputValue.CopyFrom(toJson(output), alloc);
111 outputsArray.PushBack(outputValue, alloc);
112 }
113 doc.AddMember("outputs", outputsArray, alloc);
114
115 Value forwardsArray;
116 forwardsArray.SetArray();
117 for (auto& forward : specs.forwards) {
118 Value forwardValue;
119 forwardValue.CopyFrom(toJson(forward), alloc);
120 forwardsArray.PushBack(forwardValue, alloc);
121 }
122 doc.AddMember("forwards", forwardsArray, alloc);
123
124 return doc;
125}
126
128{
129 Document doc;
130 doc.SetObject();
131 auto& alloc = doc.GetAllocator();
132
133 doc.AddMember("name", Value(name.c_str(), alloc), alloc);
134 doc.AddMember("runId", Value(runId.c_str(), alloc), alloc);
135
136 Value specsValue;
137 specsValue.CopyFrom(specToJson(specs), alloc);
138 doc.AddMember("specs", specsValue, alloc);
139
140 StringBuffer buffer;
141 Writer<StringBuffer> writer(buffer);
142 doc.Accept(writer);
143
144 return {buffer.GetString(), buffer.GetSize()};
145}
o2::monitoring::tags::Value Value
Document toJson(const DIMessages::RegisterDevice::Specs::Input &input)
Document specToJson(const DIMessages::RegisterDevice::Specs &specs)
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
GLuint buffer
Definition glcorearb.h:655
GLuint const GLchar * name
Definition glcorearb.h:781
boost::optional< std::string > origin
Definition DIMessages.h:50
boost::optional< std::string > description
Definition DIMessages.h:51
boost::optional< uint32_t > subSpec
Definition DIMessages.h:52
boost::optional< std::string > description
Definition DIMessages.h:29
boost::optional< uint32_t > subSpec
Definition DIMessages.h:30
boost::optional< std::string > origin
Definition DIMessages.h:28
std::vector< Output > outputs
Definition DIMessages.h:56
std::vector< Input > inputs
Definition DIMessages.h:55
std::vector< Forward > forwards
Definition DIMessages.h:57