Project
Loading...
Searching...
No Matches
DevicesManager.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
14#include "Framework/Logger.h"
16
17namespace o2::framework
18{
19
20void DevicesManager::queueMessage(char const* target, char const* message)
21{
22 for (int di = 0; di < specs.size(); ++di) {
23 if (specs[di].id == target) {
24 messages.push_back({di, message});
25 }
26 }
27}
28
30{
31 static bool notifiedUnavailable = false;
32 static bool notifiedAvailable = false;
33 for (auto& handle : messages) {
34 auto controller = controls[handle.ref.index].controller;
35 // Device might not be started yet, by the time we write to it.
36 if (!controller) {
37 if (!notifiedUnavailable) {
38 LOGP(info, "Controller for {} not yet available.", specs[handle.ref.index].id);
39 notifiedUnavailable = true;
40 }
41 continue;
42 }
43 if (notifiedUnavailable && !notifiedAvailable) {
44 LOGP(info, "Controller for {} now available.", specs[handle.ref.index].id);
45 notifiedAvailable = true;
46 }
47 controller->write(handle.message.c_str(), handle.message.size());
48 }
49
50 auto checkIfController = [this](DeviceMessageHandle const& handle) {
51 return this->controls[handle.ref.index].controller != nullptr;
52 };
53 auto it = std::remove_if(messages.begin(), messages.end(), checkIfController);
54 auto r = std::distance(it, messages.end());
55 messages.erase(it, messages.end());
56}
57
58} // namespace o2::framework
GLenum target
Definition glcorearb.h:1641
GLuint GLsizei const GLchar * message
Definition glcorearb.h:2517
GLboolean r
Definition glcorearb.h:1233
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DeviceMessageHandle > messages
std::vector< DeviceControl > & controls
void queueMessage(char const *receiver, char const *msg)
std::vector< DeviceSpec > & specs