AGX Dynamics  2.35.0.1
JournalReader.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_JOURNAL_READER_H
18 #define AGX_JOURNAL_READER_H
19 
20 #include <agx/config/AGX_USE_WEBSOCKETS.h>
21 
22 #if AGX_USE_WEBSOCKETS()
23 
24 #include <agx/Journal.h>
25 #include <agx/ConfigSingleton.h>
26 #include <agxData/FrameTranspose.h>
27 #include <agxData/FileTrack.h>
28 #include <agxIO/ArgumentParser.h>
30 #include <agxNet/WebSocketTrack.h>
31 
32 namespace agx
33 {
34  AGX_DECLARE_POINTER_TYPES(JournalReader);
35  class AGXPHYSICS_EXPORT JournalReader : public Referenced
36  {
37  public:
38  JournalReader( const agx::String& journalSearchPath, agxNet::WebSocket::ControlChannel *controlChannel, agx::JournalRef& journal);
39 
40  // bool httpListJournals(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
41  // bool httpLoadJournal(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
42  // bool httpListSessions(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
43  // bool httpInspectSession(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
44  // bool httpAttachRemoteViewer(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
45  // bool httpSelectBuffer(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
46  //
47  // bool httpQuit(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
48  // bool httpGetControlChannel(agxIO::RemoteCommandServer* server, mg_connection* connection, const agxIO::RemoteCommandServer::QueryArgumentTable& arguments);
49 
50  void blockUntilDone();
51 
52  bool loadSession(const agx::String& journalPath, const agx::String& sessionName);
53  // void setJournal(agx::Journal *journal) { m_journal = journal; }
54 
55  bool checkAndResetPlotSavedState();
56 
57  protected:
58  virtual ~JournalReader() {}
59  JournalReader& operator=(const JournalReader&) { agxAbort(); return *this; }
60 
61  private:
62  void mirrorFrame( agxData::Frame* source, agxJson::Value& destination );
63  void addChildren( agx::Component* source, agxJson::Value& destination, const agx::String& path );
64  void addDispatch( agx::Object* source, agxJson::Value& destination, const agx::String& path );
65  void add( agx::Component* source, agxJson::Value& destination, const agx::String& path );
66  void add( agxData::Buffer* source, agxJson::Value& destination, const agx::String& path );
67  void add( agxData::Value* source, agxJson::Value& destination, const agx::String& path );
68  void add( agxData::Frame::EntityStorage* source, agxJson::Value& destination, const agx::String& path );
69  agxJson::Value& createArrayElement( agxJson::Value& eParent, const char* groupName );
70  void ccGetPlotData( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
71  void ccSavePlot( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
72  void ccAllPlotsSaved( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
73  void ccRemovePlot( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
74  void ccGetSavedPlots( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
75  void ccGetPlotList( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
76  void ccRequestSimulationTrack( agxNet::WebSocket::ControlChannel* /*channel*/, agxNet::WebSocket* /*socket*/, agxNet::StructuredMessage* message);
77  void ccGetTreeStructure( agxNet::WebSocket::ControlChannel* channel, agxNet::WebSocket* socket, agxNet::StructuredMessage* message);
78  void ccGetBuffer( agxNet::WebSocket::ControlChannel* channel, agxNet::WebSocket* socket, agxNet::StructuredMessage* message);
79 
80  private:
81  agx::String m_journalSearchPath;
82  agx::JournalRef& m_journal;
83  bool m_plotSaved;
84 
85  agxNet::WebSocketFrameWriterRef m_frameSocket;
86  agxNet::WebSocket::ControlChannelRef m_controlChannel;
87  bool m_running;
88  };
89 
90 }
91 
92 #endif
93 
94 #endif
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
#define AGXPHYSICS_EXPORT
Abstract representation of a data buffer.
Definition: Buffer.h:56
Abstract representation of a value.
Definition: Value.h:43
A component is an object containing other objects, enabling hierarchical structuring.
Definition: Component.h:39
agx::Object is a refcounted object with a name.
Definition: Object.h:60
#define agxAbort()
Definition: debug.h:164
The agx namespace contains the dynamics/math part of the AGX Dynamics API.