3 #include "ChimeraTK/MappedImage.h"
7 #include <doocs/EqCall.h>
9 const std::vector<std::string>
IGNORE_PATTERNS = {
".HIST",
".FILT",
"._FILT",
".EGU",
".DESC",
".HSTAT",
"._HSTAT",
10 "._HIST",
".LIST",
".SAVE",
".COMMENT",
".XEGU",
".POLYPARA",
"MESSAGE.TICKER"};
17 fillCatalogue(serverAddress_, nSlashes);
19 bool isCatalogueComplete = not(isCancelled() || locationLookupError_ || catalogue_.getNumberOfRegisters() == 0);
21 return {std::move(catalogue_), isCatalogueComplete};
26 void CatalogueFetcher::fillCatalogue(std::string fixedComponents,
long level) {
30 doocs::EqData src, propList;
31 ea.adr(fixedComponents +
"/*");
32 int rc = eq.names(&ea, &propList);
36 std::cout <<
"DoocsBackend::CatalogueFetcher: Failed to query names for " + fixedComponents
37 <<
": \"" + propList.get_string() +
"\"" << std::endl;
39 locationLookupError_ =
true;
45 for(
int i = 0; i < propList.array_length() && (isCancelled() ==
false); ++i) {
47 auto u = propList.get_ustr(i);
48 std::string name(u->str_data.str_data_val);
49 name = name.substr(0, name.find_first_of(
" "));
54 fillCatalogue(fixedComponents +
"/" + name, level + 1);
65 std::string fqn = fixedComponents +
"/" + name;
68 rc = eq.get(&ea, &src, &dst);
74 else if(rc && dst.error()) {
78 std::cout <<
"DoocsBackend::CatalogueFetcher: Failed to query shape information for " + fqn
79 <<
": \"" + dst.get_string() +
"\" (" + std::to_string(dst.error()) +
")" << std::endl;
80 locationLookupError_ =
true;
84 auto regPath = fqn.substr(std::string(serverAddress_).length());
85 auto length = dst.array_length();
86 auto doocsTypeId = dst.type();
88 ChimeraTK::AccessModeFlags flags{};
89 if(checkZmqAvailability(fqn)) {
90 flags.add(ChimeraTK::AccessMode::wait_for_new_data);
92 if(doocsTypeId == DATA_IMAGE) {
95 length +=
sizeof(ChimeraTK::ImgHeader);
97 catalogue_.
addProperty(regPath, length, doocsTypeId, flags);
104 bool CatalogueFetcher::checkZmqAvailability(
const std::string& fullQualifiedName)
const {
105 auto lastSlash = fullQualifiedName.find_last_of(
'/');
106 assert(lastSlash != std::string::npos && lastSlash > 0);
107 auto fullLocationPath = fullQualifiedName.substr(0, lastSlash);
108 auto propertyName = fullQualifiedName.substr(lastSlash + 1);
121 ea.adr(fullLocationPath +
"/SPN");
124 dat.set(1, 0.0f, 0.0f, time_t{0}, propertyName, 0);
127 rc = eq.get(&ea, &dat, &dst);
132 rc = dst.get_ustr(&portp, &f1, &f2, &tm, &sp, 0);
133 if(rc && !portp && !
static_cast<int>(f1 + f2)) rc = 0;
136 dst.get_ustr(&portp, &f1, &f2, &tm, &sp, 0);
138 rc = eq.set(&ea, &dat, &dst);
144 if(dst.type() == DATA_INT) {
145 portp = dst.get_int();
148 dst.get_ustr(&portp, &f1, &f2, &tm, &sp, 0);