ChimeraTK-ApplicationCore 04.06.00
Loading...
Searching...
No Matches
Status Monitor

To monitor a status of a varaible in an appplicaiton this group of modules provides different possiblites. It includes

  • MaxMonitor to monitor a value depending upon two MAX thresholds for warning and fault.
  • MinMonitor to monitor a value depending upon two MIN thresholds for warning and fault.
  • RangeMonitor to monitor a value depending upon two ranges of thresholds for warning and fault.
  • ExactMonitor to monitor a value which should be exactly same as required value. Depending upon the value and condition on of the four states are reported.
  • OFF, OK, WARNING, FAULT.

Checkout the status monitor example to see in detail how it works.

// SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
// SPDX-License-Identifier: LGPL-3.0-or-later
#include <ChimeraTK/ApplicationCore/ApplicationCore.h>
#include <ChimeraTK/ApplicationCore/EnableXMLGenerator.h>
#include <ChimeraTK/ApplicationCore/ModuleGroup.h>
#include <ChimeraTK/ApplicationCore/StatusMonitor.h>
namespace ctk = ChimeraTK;
// Just simulate a temperature going up and down
using ctk::ApplicationModule::ApplicationModule;
ctk::ScalarOutput<double> temperature{this, "temperature", "degC", "simulated temperature"};
void mainLoop() override {
double direction = 1;
while(true) {
// go down with the temperature if too hot
if(temperature > 50) {
direction = -1;
}
// go up with the temperature if too cold
if(temperature < -50) {
direction = 1;
}
temperature += direction * 1; // one dregree steps
setCurrentVersionNumber({}); // We generate data without trigger or other input.
// So we must update the version number manually.
// This automatically updates the time stamp as well.
usleep(100000);
}
}
};
struct ExampleApp : public ctk::Application {
ExampleApp() : Application("exampleApp") {}
~ExampleApp() override { shutdown(); }
// Create an instance of the simulation module. We name it "Simulation".
// There will be a variable /Simulation/temperature from this.
SimulationModule simulation{this, "Simulation", "temperature simulation"};
// Now we place a monitor next to the temperature variable. First we create a module group, also with the name
// "Simulation". Everything in it will be placed next to the variables from the simulation module.
struct : ctk::ModuleGroup {
using ctk::ModuleGroup::ModuleGroup;
// Inside the module group we place the monitor. In the constructor it gets the name of the variable to monitor, and
// the name of the output variable. The monitor automatically connects to the input variable that is in the same
// hierarchy level. We add output and parameter tags (STATUS and CONFIG, respectively) for easier connetion of the
// variables.
// ctk::RangeMonitor<double> temperatureMonitor{this, "TemperatureMonitor", "monitor for the simulated temperature",
// "temperature", "temperatureStatus", ctk::HierarchyModifier::none, {"STATUS"}, {"CONFIG"}, {}};
ctk::RangeMonitor<double> temperatureMonitor{this, "/TemperatureMonitor/temperature",
"/TemperatureMonitor/temperatureStatus", "/TemperatureMonitor", "monitor for the simulated temperature",
ctk::TAGS{"MON_OUTPUT"}, ctk::TAGS{"MON_PARAMS"}};
} simulationGroup{this, "Simulation", ""};
ctk::ConfigReader config{this, "Config", "demoStatusMonitor_config.xml"};
};
void shutdown() override
This will remove the global pointer to the instance and allows creating another instance afterwards.
void setCurrentVersionNumber(VersionNumber versionNumber) override
Set the current version number.
Generic module to read an XML config file and provide the defined values as constant variables.
friend class Application
Definition ModuleGroup.h:47
bool write(ChimeraTK::VersionNumber versionNumber)=delete
[Snippet: Class Definition Start]
Definition ExampleApp.h:27
~ExampleApp() override
[Snippet: Destructor]
Definition ExampleApp.cc:18
ctk::RangeMonitor< double > temperatureMonitor
SimulationModule simulation
ctk::ConfigReader config
ExampleApp theExampleApp
InvalidityTracer application module.
const std::unordered_set< std::string > TAGS
Convenience type definition which can optionally be used as a shortcut for the type which defines a l...
Definition EntityOwner.h:27
Module for status monitoring depending on range of threshold values.
Convenience class for output scalar accessors (always UpdateMode::push)
Example to simulate the working and usage of StatusMonitor.
ctk::ScalarOutput< double > temperature
The value to be monitored.
void mainLoop() override
To be implemented by the user: function called in a separate thread executing the main loop of the mo...