PLCnext API Documentation 23.6.0.37
TraceController.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Commons/Logging.h"
9#include "Arp/System/Core/Singleton.hxx"
10#include "Arp/System/Commons/Logging.h"
11#include "Arp/System/Commons/Runtime/SharedLibrary.hpp"
12#include "Arp/System/Commons/Chrono/Timer.hpp"
13
14#include <list>
15
16namespace Arp { namespace System { namespace Ve
17{
18class ITraceControllerService;
19}}};
20
21namespace Arp { namespace System { namespace Commons { namespace Diagnostics
22{
23
25using namespace Arp::System::Commons::Chrono;
26
52class TraceController : public Singleton<TraceController>, private Loggable<TraceController>
53{
54
55 friend class Singleton<TraceController>;
56
57public: // typedefs
58
59 typedef std::list<Arp::String> SessionList;
60
61public: // operations
62
72 bool IsSessionDaemonAlive(void) const;
73
84
95
129 bool LoadSessionConfiguration(const Arp::String& session, const Arp::String& config);
130
136 SessionList ListSessions(void);
137
159 bool StartSession(const Arp::String& session);
160
178 bool StopSession(const Arp::String& session);
179
193 bool DestroySession(const Arp::String& session);
194
222 bool TriggerSavingTraceOutputs(const bool& stopTriggerSession);
223
244
256 bool IsSessionEnabled(const Arp::String& session);
257
266 bool IsSessionLoaded(const Arp::String& session);
267
268public: // getter/setter operations
269
277 void SetTracesSavingConfigs(const Arp::String& triggerSession, const Arp::String& outPath, const Arp::uint32& maxDirectorySize, const Arp::uint32& savingDelayTimeout);
278
279private: // construction/destruction
280
282 TraceController(void);
283
285 TraceController(const TraceController& arg) = delete;
286
288 TraceController& operator=(const TraceController& arg) = delete;
289
291 ~TraceController(void);
292
293private: // methods
294 void RunTraceSavingTimer(void);
295
296 bool RecordSessionSnapshot(const Arp::String& session);
297
298private: // typedefs/usings
299
300 using ITraceControllerService = Arp::System::Ve::ITraceControllerService;
301
302private: // fields
303
304 ITraceControllerService *pInstance;
305
306 SharedLibrary pTracingLibrary;
307
308 // Traces Saving Configs
309 Arp::uint32 savingDelayTimeout;
310 Arp::String triggerSession;
311 Arp::String savingOutputPath;
312 Arp::uint32 maxDirectorySize;
313
314 // Saving Delay Timer
315 Timer savingDelayTimer;
316
317 bool stopSession;
318 std::atomic_flag triggerSavingWorking = ATOMIC_FLAG_INIT;
319
320 bool tracepointLibLoaded;
321};
322
324// inline methods of class TraceController
325
326}}}} // end of namespace Arp::System::Commons::Diagnostics
327
This class implements the singleton pattern.
Definition: Singleton.hxx:25
High resolution timer for interval based executions.
Definition: Timer.hpp:54
This Singleton class provides an Interface to manage and control the LTTng tracing on the PLCnext con...
Definition: TraceController.hpp:53
bool IsSessionInSnapshotMode(const Arp::String &session)
Checks if a tracing session is in Snapshot Mode.
bool StopSession(const Arp::String &session)
Stops a LTTng tracing session.
bool IsSessionDaemonAlive(void) const
Checks if the LTTng session daemon for tracing is alive.
bool IsSessionLoaded(const Arp::String &session)
Checks if a trace session is already loaded.
void SetTracesSavingConfigs(const Arp::String &triggerSession, const Arp::String &outPath, const Arp::uint32 &maxDirectorySize, const Arp::uint32 &savingDelayTimeout)
Sets the configuration of the trigger saving function
bool IsSessionEnabled(const Arp::String &session)
Checks if a tracing session is already enabled/started.
void UnloadTracepointLibrary(void)
Unloads the userspace Tracepoint library.
SessionList ListSessions(void)
Queries a list of all loaded (both started and stopped sessions) LTTng tracing sessions.
bool TriggerSavingTraceOutputs(const bool &stopTriggerSession)
Triggers the recording/saving all outputs of a configured session. Saving will be performed by anothe...
bool DestroySession(const Arp::String &session)
Destroys/Unloads a LTTng tracing session.
bool LoadSessionConfiguration(const Arp::String &session, const Arp::String &config)
Tries to loads a tracing session from a given configuration file.
void LoadTracepointLibrary(void)
Loads the PLCnext userspace Tracepoint library.
bool StartSession(const Arp::String &session)
Starts a LTTng tracing session.
High level API to enable work with dynamically loadable shared libraries.
Definition: SharedLibrary.hpp:20
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:36
@ System
System components used by the System, Device, Plc or Io domains.
Namespace for time related classes
Definition: Duration.hpp:13
Root namespace for the PLCnext API