ChimeraTK-ApplicationCore  04.01.00
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 
8 namespace ChimeraTK {
9 
10  class DeviceModule;
11 
47  ScriptedInitHandler(ModuleGroup* owner, const std::string& name, const std::string& description,
48  std::string command, DeviceModule& deviceModule, std::string outputName = "initScriptOutput",
49  unsigned int errorGracePeriod = 10);
50  void mainLoop() override {
51  } // no main loop needed. doInit() is called from the DeviceModule thread as initialisation handler
52  void doInit();
53 
54  protected:
55  bool _lastFailed{false};
56  std::string _command;
57  std::string _deviceAlias;
58  std::string _outputName;
59  unsigned int _errorGracePeriod; // additional sleep time before a retry after an error
60  //_scriptOutput must be in this file after _outputName so the latter can be used as constructor parameter
62  RegisterPath("/Devices") / Utilities::escapeName(_deviceAlias, false) / _outputName, "",
63  "stdout+stderr of init script"};
64  };
65 
66 } // namespace ChimeraTK
ChimeraTK::ScriptedInitHandler::_deviceAlias
std::string _deviceAlias
Definition: ScriptedInitialisationHandler.h:57
ChimeraTK::ScriptedInitHandler
Initialisation handler which calls an external application (usually a script), captures its output (b...
Definition: ScriptedInitialisationHandler.h:34
ChimeraTK::ScriptedInitHandler::_scriptOutput
ScalarOutput< std::string > _scriptOutput
Definition: ScriptedInitialisationHandler.h:61
ChimeraTK::ModuleGroup
Definition: ModuleGroup.h:16
ChimeraTK::ScriptedInitHandler::ScriptedInitHandler
ScriptedInitHandler(ModuleGroup *owner, const std::string &name, const std::string &description, std::string command, DeviceModule &deviceModule, std::string outputName="initScriptOutput", unsigned int errorGracePeriod=10)
Constructor.
Definition: ScriptedInitialisationHandler.cc:17
ChimeraTK::DeviceModule
Definition: DeviceModule.h:20
ChimeraTK::ScriptedInitHandler::_outputName
std::string _outputName
Definition: ScriptedInitialisationHandler.h:58
ChimeraTK::ApplicationModule
Definition: ApplicationModule.h:24
ChimeraTK::ScriptedInitHandler::doInit
void doInit()
Definition: ScriptedInitialisationHandler.cc:26
ChimeraTK::Utilities::escapeName
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:44
ChimeraTK::ScriptedInitHandler::_command
std::string _command
Definition: ScriptedInitialisationHandler.h:56
ChimeraTK::ScriptedInitHandler::_errorGracePeriod
unsigned int _errorGracePeriod
Definition: ScriptedInitialisationHandler.h:59
ScalarAccessor.h
ApplicationModule.h
ChimeraTK::ScriptedInitHandler::mainLoop
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...
Definition: ScriptedInitialisationHandler.h:50
ChimeraTK
InvalidityTracer application module.
Definition: spec_dataValidityPropagation.dox:2
ChimeraTK::ScalarOutput< std::string >
ChimeraTK::ScriptedInitHandler::_lastFailed
bool _lastFailed
Definition: ScriptedInitialisationHandler.h:55