AGX Dynamics  2.37.2.0
WebPlot.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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
9 having been advised so by Algoryx Simulation AB for a time limited evaluation,
10 or having purchased a 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 #pragma once
18 
19 #include <agx/config/AGX_USE_WEBPLOT.h>
20 
21 #if AGX_USE_WEBPLOT()
22 
23 #include <agxPlot/Output.h>
24 #include <agxNet/WebSocket.h>
25 
26 namespace agxPlot
27 {
29 
30  class AGXPHYSICS_EXPORT WebPlot : public agxPlot::Output
31  {
32  public:
33  WebPlot(bool openBrowser = false, bool useDefaultPorts = true);
34 
35  agx::UInt16 getPort() const;
36 
37  virtual void handlePacket(DataPacket *packet) override;
38  virtual void handlePacket(DescriptionPacket *packet) override;
39  virtual void handlePacket(TimePacket *packet) override;
40  virtual bool isReady() override;
41  virtual void closeOutput() override;
42 
43  void removeCurve(CurveID curveID);
44 
45  protected:
46  virtual ~WebPlot();
47 
48  private:
49  void clientConnected(agxNet::WebSocket* client);
50  void clientDisconnected(agxNet::WebSocket* client);
51 
52  agxNet::StructuredMessage *createMessage(DataPacket *packet);
53  agxNet::StructuredMessage *createMessage(DescriptionPacket *packet);
54  agxNet::StructuredMessage *createMessage(TimePacket *packet);
55  private:
56  agxNet::WebSocketServerRef m_socketServer;
57  DescriptionPacketRef m_currentDescription;
58  agx::Vector<DataPacketRef> m_dataHistory;
59  };
60 }
61 
62 
63 // End AGX_USE_WEBPLOT()
64 #endif
Namespace contains functionality related to plotting.
#define AGXPHYSICS_EXPORT
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::ref_ptr< DescriptionPacket > DescriptionPacketRef
Templated vector class.
Definition: Vector.h:52
uint16_t UInt16
Definition: Integer.h:39
agx::UInt CurveID
Definition: Curve.h:30