12#include <fmt/format.h>
21template <
class Clock,
class Duration>
22double MakeTimestamp(std::chrono::time_point<Clock, Duration>
const& ts) {
23 using Seconds = std::chrono::duration<double, std::ratio<1>>;
24 return std::chrono::time_point_cast<Seconds>(ts).time_since_epoch().count();
27template <
class Clock,
class Duration>
28void MakeTimepoint(std::chrono::time_point<Clock, Duration>& ts,
double time) {
29 using Seconds = std::chrono::duration<double, std::ratio<1>>;
30 ts = std::chrono::time_point<Clock, Duration>(
31 std::chrono::duration_cast<Duration>(Seconds(time)));
38 j = nlohmann::json{{
"id", p.
id},
44 {
"timestamp", MakeTimestamp(p.
timestamp)}};
49 j = nlohmann::json{{
"category", p.
id.
category},
52 {
"timestamp", MakeTimestamp(p.
timestamp)}};
57 j = nlohmann::json{{
"state", p.
state}};
66 {
"creationTime", std::chrono::nanoseconds(p.
creation_time.time_since_epoch()).count()},
71 {
"keywords", std::move(kws)},
83 j = nlohmann::json{{
"name", p.
name}, {
"rrUri", p.
rr_uri}};
88 if (std::holds_alternative<fits::KeywordVector>(p.
Part())) {
91 j = nlohmann::json::object(
92 {{
"type",
"fitsKeywords"}, {
"sourceName", p.
SourceName()}, {
"keywords", std::move(kws)}});
93 }
else if (std::holds_alternative<std::string>(p.
Part())) {
94 auto const& path = std::get<std::string>(p.
Part());
95 j = nlohmann::json::object(
96 {{
"type",
"fitsFile"}, {
"sourceName", p.
SourceName()}, {
"location", path}});
102 j.at(
"id").get_to(p.
id);
103 j.at(
"fileId").get_to(p.
file_id);
104 j.at(
"state").get_to(p.
state);
105 j.at(
"alerts").get_to(p.
alerts);
107 j.at(
"result").get_to(p.
result);
109 j.at(
"timestamp").get_to(ts);
116 j.at(
"key").get_to(p.
id.
key);
119 j.at(
"timestamp").get_to(ts);
125 j.at(
"state").get_to(p.
state);
130 j.at(
"id").get_to(p.
id);
131 j.at(
"fileId").get_to(p.
file_id);
137 j.at(
"awaitInterval").get_to(interval);
139 j.at(
"dpParts").get_to(p.
results);
141 int64_t time_since_epoch_ns;
142 j.at(
"creationTime").get_to(time_since_epoch_ns);
143 using Time = std::chrono::system_clock::time_point;
144 p.
creation_time = Time(std::chrono::nanoseconds(time_since_epoch_ns));
146 if (j.contains(
"specification")) {
153 j.at(
"name").get_to(p.
name);
154 j.at(
"rrUri").get_to(p.
rr_uri);
161 j.at(
"type").get_to(type);
164 if (type ==
"fitsKeywords") {
166 }
else if (type ==
"fitsFile") {
168 j.at(
"location").get_to(path);
171 throw std::invalid_argument(fmt::format(
"Invalid type: {}", type));
Provides information of the location and source of a FITS file or keywords produced by a data acquisi...
auto Part() const noexcept -> PartTypes const &
Holds a std::string path [[user]@host:]path or FITS keywords.
auto SourceName() const noexcept -> std::string const &
Source name of the part.
Declares JSON support for serialization.
Contains data structure for FITS keywords.
Contains declaration of daq::Context.
nlohmann::json SerializeJsonKeywords(std::vector< KeywordVariant > const &keywords)
SerializeJsons keyword to JSON.
std::vector< KeywordVariant > ParseJsonKeywords(char const *keywords)
Parse and return FITS keywords.
StartDaqV2Spec ParseStartDaqV2Spec(nlohmann::json const &json)
Parse StartDaqSpec.
std::string key
Unique key for each alert.
void from_json(nlohmann::json const &j, Status &p)
std::string category
Standardized category.
void to_json(nlohmann::json &j, Status const &p)
Describes an active Data Acquisition alert.
Contains declaration for Status and ObservableStatus.
Structure carrying context needed to start a Data Acquisition and construct a Data Product Specificat...
std::vector< Source > meta_sources
DpParts results
Results from Data Acquisition (FITS files and keywords).
std::string process_name
User defined process name.
std::vector< daq::fits::KeywordVariant > keywords
Keyword list provided by OCM to Data Product.
std::vector< Source > prim_sources
std::chrono::milliseconds await_interval
Interval (and thus duration) of the requests sent to primary sources to await end of recording.
std::optional< json::StartDaqV2Spec > specification
Optional specification, if DAQ was started using StartDaqV2.
std::string file_id
Data Product FileId as specified by OLAS ICD.
std::string dp_name_prefix
Data product file name prefix.
std::chrono::system_clock::time_point creation_time
Time when DAQ was created.
std::string id
DAQ identfier, possibly provided by user.
Persistent status for receiver delivery.
Non observable status object that keeps stores status of data acquisition.
std::string result
Path to resulting data product.
std::map< std::size_t, ReceiverStatus > receivers
Receiver processing (e.g.
std::vector< Alert > alerts
Active alerts.
TimePoint timestamp
Timestamp of last update.