Project
Loading...
Searching...
No Matches
ControlService.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.
17#include "Framework/Logger.h"
19#include <string>
20#include <string_view>
21#include <regex>
22#include <iostream>
23
24namespace o2::framework
25{
26
28 : mRegistry{registry},
29 mDeviceState{deviceState},
30 mDriverClient{registry.get<DriverClient>()}
31{
32}
33
34// This will send an end of stream to all the devices downstream.
36{
37 std::scoped_lock lock(mMutex);
38 mDeviceState.streaming = StreamingState::EndOfStreaming;
39}
40
41// All we do is to printout
43{
44 std::scoped_lock lock(mMutex);
45 if (mOnce == true) {
46 return;
47 }
48 mOnce = true;
49 switch (what) {
51 mDeviceState.quitRequested = true;
52 mDriverClient.tell("CONTROL_ACTION: READY_TO_QUIT_ALL");
53 break;
54 case QuitRequest::Me:
55 mDeviceState.quitRequested = true;
56 mDriverClient.tell("CONTROL_ACTION: READY_TO_QUIT_ME");
57 break;
58 }
59}
60
62{
63 std::scoped_lock lock(mMutex);
64 switch (state) {
66 mDriverClient.tell("CONTROL_ACTION: NOTIFY_STREAMING_STATE IDLE");
67 break;
69 mDriverClient.tell("CONTROL_ACTION: NOTIFY_STREAMING_STATE STREAMING");
70 break;
72 mDriverClient.tell("CONTROL_ACTION: NOTIFY_STREAMING_STATE EOS");
73 break;
74 default:
75 throw std::runtime_error("Unknown streaming state");
76 }
77}
78
79void ControlService::push(std::string_view key, std::string_view value, int64_t timestamp)
80{
81 std::scoped_lock lock(mMutex);
82 mDriverClient.tell(fmt::format("CONTROL_ACTION: PUT {} {} {}", key, timestamp, value), true);
83}
84
85void ControlService::notifyDeviceState(std::string currentState)
86{
87 std::scoped_lock lock(mMutex);
88 mDriverClient.tell(fmt::format("CONTROL_ACTION: NOTIFY_DEVICE_STATE {}", currentState));
89 mDriverClient.flushPending(mRegistry);
90}
91
92} // namespace o2::framework
benchmark::State & state
StringRef key
void readyToQuit(bool all)
Compatibility with old API.
ControlService(ServiceRegistryRef registry, DeviceState &deviceState)
void notifyStreamingState(StreamingState state)
Report the current streaming state of a given device.
void push(std::string_view key, std::string_view value, int64_t timestamp)
Push a generic key/value pair to the driver.
void endOfStream()
Signal that we are done with the current stream.
void notifyDeviceState(std::string state)
Report the current FairMQ state of a given device.
A service API to communicate with the driver.
GLsizei const GLfloat * value
Definition glcorearb.h:819
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
@ EndOfStreaming
End of streaming requested, but not notified.
@ Streaming
Data is being processed.
@ Idle
End of streaming notified.
QuitRequest
Kind of request we want to issue to control.
@ Me
Only quit this data processor.
@ All
Quit all data processor, regardless of their state.
Running state information of a given device.
Definition DeviceState.h:34