ChimeraTK-ApplicationCore 04.08.00
Loading...
Searching...
No Matches
ScriptedInitialisationHandler.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2// SPDX-License-Identifier: LGPL-3.0-or-later
3#pragma once
4
5#include "ApplicationModule.h"
6#include "ScalarAccessor.h"
7
8namespace ChimeraTK {
9
10 class DeviceModule;
11
49 ScriptedInitHandler(ModuleGroup* owner, const std::string& name, const std::string& description,
50 std::string command, DeviceModule& deviceModule, std::string outputName = "initScriptOutput",
51 std::string exitCodeName = "initScriptExitCode", unsigned int errorGracePeriod = 10);
52
53 // Alternative constructor signature for backwards compatibility
54 ScriptedInitHandler(ModuleGroup* owner, const std::string& name, const std::string& description,
55 std::string command, DeviceModule& deviceModule, std::string outputName, unsigned int errorGracePeriod);
56
57 void mainLoop() override {
58 } // no main loop needed. doInit() is called from the DeviceModule thread as initialisation handler
59 void doInit();
60
61 protected:
62 bool _lastFailed{false};
63 std::string _command;
64 std::string _deviceAlias;
65 std::string _outputName;
66 std::string _exitCodeName;
67 unsigned int _errorGracePeriod; // additional sleep time before a retry after an error
68
70 RegisterPath("/Devices") / Utilities::escapeName(_deviceAlias, false) / _outputName, "",
71 "stdout+stderr of init script"};
72
74 RegisterPath("/Devices") / Utilities::escapeName(_deviceAlias, false) / _exitCodeName, "",
75 "exit code of init script"};
76 };
77
78} // namespace ChimeraTK
Convenience class for output scalar accessors (always UpdateMode::push)
std::string escapeName(const std::string &name, bool allowDotsAndSlashes)
Convert all characters which are not allowed in variable or module names into underscores followed by...
Definition Utilities.cc:45
InvalidityTracer application module.
Initialisation handler which calls an external application (usually a script), captures its output (b...
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...