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
12
#include "
Framework/DevicesManager.h
"
13
#include "
Framework/RuntimeError.h
"
14
#include "
Framework/Logger.h
"
15
#include "
Framework/DeviceController.h
"
16
#include "
Framework/Signpost.h
"
17
18
O2_DECLARE_DYNAMIC_LOG
(devices_manager);
19
20
namespace
o2::framework
21
{
22
23
void
DevicesManager::queueMessage
(
char
const
*
target
,
char
const
*
message
)
24
{
25
O2_SIGNPOST_ID_GENERATE
(sid, devices_manager);
26
O2_SIGNPOST_EVENT_EMIT
(devices_manager, sid,
"queue"
,
27
"Queuing message for %{public}s: %{public}s"
,
28
target
,
message
);
29
for
(
int
di
= 0;
di
<
specs
.size(); ++
di
) {
30
if
(
specs
[
di
].
id
==
target
) {
31
messages
.push_back({
di
,
message
});
32
}
33
}
34
}
35
36
void
DevicesManager::flush
()
37
{
38
static
bool
notifiedUnavailable =
false
;
39
static
bool
notifiedAvailable =
false
;
40
for
(
auto
&
handle
:
messages
) {
41
auto
controller =
controls
[
handle
.ref.index].controller;
42
// Device might not be started yet, by the time we write to it.
43
if
(!controller) {
44
if
(!notifiedUnavailable) {
45
LOGP(info,
"Controller for {} not yet available."
,
specs
[
handle
.ref.index].id);
46
notifiedUnavailable =
true
;
47
}
48
continue
;
49
}
50
if
(notifiedUnavailable && !notifiedAvailable) {
51
LOGP(info,
"Controller for {} now available."
,
specs
[
handle
.ref.index].id);
52
notifiedAvailable =
true
;
53
}
54
O2_SIGNPOST_ID_GENERATE
(sid, devices_manager);
55
O2_SIGNPOST_EVENT_EMIT
(devices_manager, sid,
"flush"
,
56
"Flushing message to %{public}s: %{public}s"
,
57
specs
[
handle
.ref.index].id.c_str(),
handle
.message.c_str());
58
controller->write(
handle
.message.c_str(),
handle
.message.size());
59
}
60
61
auto
checkIfController = [
this
](
DeviceMessageHandle
const
&
handle
) {
62
return
this->
controls
[
handle
.ref.index].controller !=
nullptr
;
63
};
64
auto
it = std::remove_if(
messages
.begin(),
messages
.end(), checkIfController);
65
auto
r
= std::distance(it,
messages
.end());
66
messages
.erase(it,
messages
.end());
67
}
68
69
}
// namespace o2::framework
DeviceController.h
DevicesManager.h
handle
CURL * handle
Definition
HttpByteSource.cxx:40
Logger.h
RuntimeError.h
Signpost.h
O2_DECLARE_DYNAMIC_LOG
#define O2_DECLARE_DYNAMIC_LOG(name)
Definition
Signpost.h:490
O2_SIGNPOST_ID_GENERATE
#define O2_SIGNPOST_ID_GENERATE(name, log)
Definition
Signpost.h:507
O2_SIGNPOST_EVENT_EMIT
#define O2_SIGNPOST_EVENT_EMIT(log, id, name, format,...)
Definition
Signpost.h:523
unsigned char
unsigned int
message
GLuint GLsizei const GLchar * message
Definition
glcorearb.h:2517
o2::framework
Defining ITS Vertex explicitly as messageable.
Definition
Cartesian.h:288
o2::framework::DeviceMessageHandle
Definition
DevicesManager.h:29
o2::framework::DevicesManager::messages
std::vector< DeviceMessageHandle > messages
Definition
DevicesManager.h:41
o2::framework::DevicesManager::controls
std::vector< DeviceControl > & controls
Definition
DevicesManager.h:38
o2::framework::DevicesManager::queueMessage
void queueMessage(char const *receiver, char const *msg)
Definition
DevicesManager.cxx:23
o2::framework::DevicesManager::specs
std::vector< DeviceSpec > & specs
Definition
DevicesManager.h:40
o2::framework::DevicesManager::flush
void flush()
Definition
DevicesManager.cxx:36
di
int di
Definition
test_ctf_io_itsmft.cxx:134
Framework
Core
src
DevicesManager.cxx
Generated on Fri Nov 13 2026 07:45:40 for Project by
1.9.8