AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
System.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agxPlot/Window.h>
20#include <agxPlot/Output.h>
21#include <agxPlot/Queue.h>
22#include <agxPlot/DataSeries.h>
23
24#include <agx/Thread.h>
26#include <agx/Timer.h>
27
28#include <agxSDK/Simulation.h>
29
30namespace agxPlot
31{
32 class Output;
34
39 {
40 public:
42
43
52
62 void setTimeStep(agx::Real timeStep);
63
68 bool shouldUpdate() const;
69
75 void add(agxPlot::Output* output);
76
83 void remove(agxPlot::Output* output);
84
89
93 void refresh();
94
103
104
109
112
116 bool hasAnyWindow() const;
117
126 void getDescription(agxJson::Value& root, bool includeData) const;
132 void setFromDescription(const agxJson::Value& root);
133
138 void save() const;
143 void load();
144
150
155
160
163
165 static void disableAllPlotting();
166 static bool plottingDisabled();
167
168 public:
169 /***************************************/
170 /* HELPER FUNCTIONS FOR CREATING PLOTS */
171 /***************************************/
172 protected:
174 private:
175 void updatedRepresentation();
181 void add(Window* window);
182
183 bool hasData() const;
184
185 void simulationTickCallback(agx::Clock *clock);
186
188
189 private:
190 friend class agxSDK::Simulation;
191 void setSimulation(agxSDK::Simulation* simulation);
192
193 private:
194 agxPlot::DataSeriesRefVector m_dataSeries;
195 agx::Clock::TickEvent::CallbackType m_simulationTickCallback;
196 WindowRefVector m_windows;
198 OutputRefVector m_outputs;
199 OutputThreadRef m_outputThread;
200 bool m_loadingJournal;
201
202 bool m_updatedRepresentation;
203 agx::Real m_plotTimeStep;
204 agx::Real m_lastPlotTime;
205
206 agx::Event::CallbackType m_windowRepresentationChangedCallback;
207 private:
208 friend class OutputThread;
209 agx::Mutex m_outputMutex;
210 };
212
213
215
220 {
221 public:
222 OutputThread(System *system, agx::Real frequency = 30);
223
224 void setFrequency(agx::Real frequency);
226
227 protected:
228 virtual ~OutputThread();
229
230 private:
231 virtual void run();
232
233 void start();
234 void stop();
235 void updateOutputs();
236
237 private:
238 System *m_system;
239 bool m_running;
240 agx::Block m_startBlock;
241 agx::Timer m_timer;
242 agx::Real m_frequency;
243 };
244}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXPHYSICS_EXPORT
Class that encapsulates data to be plotted, including methods for accessing the data,...
Definition DataSeries.h:45
THis class wraps the description of data that should be plotted.
Definition Output.h:35
OutputThread(System *system, agx::Real frequency=30)
void setFrequency(agx::Real frequency)
agx::Real getFrequency() const
System that manages the plotting system.
Definition System.h:39
void getDescription(agxJson::Value &root, bool includeData) const
Retrieve the description as follows.
void add(agxPlot::Output *output)
Add an output to listen to the System.
void save() const
Store the current description in an attached RECORD journal.
bool addDataSeries(agxPlot::DataSeries *dataSeries)
Add a data series to be updated.
void setFromDescription(const agxJson::Value &root)
INTERNAL.
bool hasAnyWindow() const
Returns true if the system has any windows.
void clearDataSeries()
Clear all old data from DataSeries.
void disableWindows()
Sets all windows in the system to disabled.
void closeOutputs()
Tell all outputs attached that no more data will be coming.
static void disableAllPlotting()
Disable all plotting.
void setTimeStep(agx::Real timeStep)
When automatically generating values, this is the rate which the plot system tries to hold.
void refresh()
Check for new data and push it to all plot outputs.
void generateData()
Update all series after a time step.
agxPlot::DataSeries * getDataSeries(agx::UInt id) const
Get a dataseries from the ID it holds.
static bool plottingDisabled()
OutputAddedEvent outputAdded
Definition System.h:162
agxPlot::Window * getOrCreateWindow(const agx::String &windowId="")
Get the default plot associated to the system.
const OutputRefVector & getOutputs() const
void load()
Load from an attach PLAYBACK journal.
agx::Event1< agxPlot::Output * > OutputAddedEvent
Definition System.h:161
void remove(agxPlot::Output *output)
INTERNAL.
bool shouldUpdate() const
Check if it is time for a new plot frame.
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
Basic wrapper class aroud std::thread.
Definition Thread.h:83
Block synchronization primitive.
Generalized callback, using std::function.
Definition Callback.h:54
Clock class keeps representation of virtual/simulated time.
Definition Clock.h:38
An event with one argument.
Definition Event.h:103
T CallbackType
Definition Event.h:37
Base class providing referencing counted objects.
Definition Referenced.h:120
The Timer class permits timing execution speed with the same refinement as the built in hardware cloc...
Definition Timer.h:75
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Namespace contains functionality related to plotting.
std::mutex Mutex
Definition Referenced.h:99
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42