|
14 | 14 | #include <string> |
15 | 15 | #include "TFile.h" |
16 | 16 | #include "CCDB/CcdbApi.h" |
| 17 | +#include "CommonUtils/StringUtils.h" |
17 | 18 | #include "DetectorsDCS/AliasExpander.h" |
18 | 19 | #include "DetectorsDCS/DeliveryType.h" |
19 | 20 | #include "DetectorsDCS/DataPointIdentifier.h" |
|
24 | 25 | #include <chrono> |
25 | 26 |
|
26 | 27 | using DPID = o2::dcs::DataPointIdentifier; |
| 28 | +using namespace o2::utils; |
27 | 29 |
|
28 | 30 | /// macro to populate CCDB for TPC with the configuration for DCS |
29 | | -int makeTPCCCDBEntryForDCS(const std::string url = "http://localhost:8080") |
| 31 | +int makeTPCCCDBEntryForDCS(const std::string url = "http://localhost:8080", std::string comment = "") |
30 | 32 | { |
31 | 33 |
|
32 | 34 | std::unordered_map<DPID, std::string> dpid2DataDesc; |
@@ -64,9 +66,23 @@ int makeTPCCCDBEntryForDCS(const std::string url = "http://localhost:8080") |
64 | 66 |
|
65 | 67 | o2::ccdb::CcdbApi api; |
66 | 68 | api.init(url); // or http://localhost:8080 for a local installation |
67 | | - std::map<std::string, std::string> md; |
| 69 | + std::map<std::string, std::string> meta; |
| 70 | + |
| 71 | + auto toKeyValPairs = [&meta](std::vector<std::string> const& tokens) { |
| 72 | + for (auto& token : tokens) { |
| 73 | + auto keyval = Str::tokenize(token, '=', false); |
| 74 | + if (keyval.size() != 2) { |
| 75 | + LOG(error) << "Illegal command-line key/value string: " << token; |
| 76 | + continue; |
| 77 | + } |
| 78 | + Str::trim(keyval[1]); |
| 79 | + meta[keyval[0]] = keyval[1]; |
| 80 | + } |
| 81 | + }; |
| 82 | + toKeyValPairs(Str::tokenize(comment, ';', true)); |
| 83 | + |
68 | 84 | long ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); |
69 | | - api.storeAsTFileAny(&dpid2DataDesc, "TPC/Config/DCSDPconfig", md, ts, 99999999999999); |
| 85 | + api.storeAsTFileAny(&dpid2DataDesc, "TPC/Config/DCSDPconfig", meta, ts, 99999999999999); |
70 | 86 |
|
71 | 87 | return 0; |
72 | 88 | } |
0 commit comments