Skip to content

Commit

Permalink
Add local vats
Browse files Browse the repository at this point in the history
  • Loading branch information
awegrzyn committed Aug 30, 2023
1 parent 824e2ad commit 8072f7b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions examples/15-ODC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ std::mutex gMapAccess;
struct OdcStats {
int EpnCount;
int FailedTasks;
int RecoTasks;
int CalibTasks;
std::unordered_map<std::string, int> TasksPerCalib;
std::unordered_map<std::string, int> FailedTasksPerCalib;
unsigned int RecoTasks;
unsigned int CalibTasks;
std::unordered_map<std::string, unsigned int> TasksPerCalib;
std::unordered_map<std::string, unsigned int> FailedTasksPerCalib;
std::string State;
};

Expand Down Expand Up @@ -112,7 +112,6 @@ void httpServer(tcp::acceptor& acceptor, tcp::socket& socket) {
}
}
calibTasksJson += "]";
std::cout << calibTasksJson << std::endl;
beast::ostream(response.body()) << jsonPrefix << calibTasksJson << jsonSuffix << '\n';
});
connection->start();
Expand Down Expand Up @@ -157,8 +156,8 @@ class OdcClient {
unsigned int failedCount = 0;
std::unordered_set<std::string> uniqueEpns{};
std::unordered_set<std::string> calibCollections{};
stats.TasksPerCalib.clear();
stats.FailedTasksPerCalib.clear();
unsigned int recoTasks = 0;
unsigned int calibTasks = 0;
std::regex rReco("_reco[0-9]+_");
std::regex rCalib("_calib[0-9]+_");
for (int i = 0; i < reply.devices_size(); i++) {
Expand All @@ -167,10 +166,10 @@ class OdcClient {
}
uniqueEpns.insert(reply.devices(i).host());
if (std::regex_search(reply.devices(i).path(), rReco)) {
stats.RecoTasks++;
recoTasks++;
}
if (std::regex_search(reply.devices(i).path(), rCalib)) {
stats.CalibTasks++;
calibTasks++;
auto calibIdx = reply.devices(i).path().find("_calib");
auto calib = reply.devices(i).path().substr(calibIdx + 1, reply.devices(i).path().size()-calibIdx-3);
auto it = stats.TasksPerCalib.find(calib);
Expand All @@ -191,6 +190,9 @@ class OdcClient {
}
}
}
const std::lock_guard<std::mutex> lock(gMapAccess);
stats.RecoTasks = recoTasks;
stats.CalibTasks = calibTasks;
stats.EpnCount = uniqueEpns.size();
stats.FailedTasks = failedCount;
} else {
Expand Down

0 comments on commit 8072f7b

Please sign in to comment.