AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
RemoteSolver.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
18#ifndef AGX_REMOTESOLVER_H
19#define AGX_REMOTESOLVER_H
20
21#include <agx/config/AGX_USE_WEBSOCKETS.h>
22#include <agx/Component.h>
23#include <agxNet/Socket.h>
24#include <agxNet/WebSocket.h>
27
28#if AGX_USE_WEBSOCKETS()
29
30#include <agxData/Frame.h>
31
32namespace agxSDK { class Simulation; }
33
35
36namespace agx
37{
38 AGX_DECLARE_POINTER_TYPES(RemoteSolver);
39 class AGXPHYSICS_EXPORT RemoteSolver : public Referenced
40 {
41
42 public:
43 RemoteSolver(UInt16 tcpSocketPort = 1906, UInt16 webSocketPort = 1907);
44
45
46 void execute();
47
48 agx::UInt16 getWebPort() const { return m_webPort; }
49 agx::UInt16 getTcpPort() const { return m_tcpPort; }
50 agxSDK::SimulationFrameReader *getSimulationReader() { return m_simulationReader; }
51 agxSDK::SimulationFrameWriter *getSimulationWriter() { return m_simulationWriter; }
52
53 protected:
54 virtual ~RemoteSolver();
55
56 private:
57 friend class agxSDK::Simulation;
58 void init(agxSDK::Simulation *simulation);
59
60 private:
61 void clientConnected(agxNet::WebSocket* client);
62 void clientConnected(agxNet::TCPSocket* client);
63 void clientDisconnected(agxNet::WebSocket* client);
64 void clientDisconnected(agxNet::TCPSocket* client);
65 void messageReceived(agx::UInt8* payload, size_t size);
66
67 void waitForClient();
68 void someClientDisconnected();
69 bool writeReadCycle(agxData::Frame* frame);
70
71 private:
72 agx::UInt16 m_tcpPort;
73 agx::UInt16 m_webPort;
74 agxSDK::Simulation *m_simulation;
75
76 agxSDK::SimulationFrameReaderRef m_simulationReader;
77 agxSDK::SimulationFrameWriterRef m_simulationWriter;
78
79 agxNet::TCPServerSocketRef m_tcpSocketServer;
80 agxNet::TCPSocketRef m_tcpSocketClient;
81
82 agxNet::WebSocketServerRef m_webSocketServer;
83 agxNet::WebSocketRef m_webSocketClient;
84
85 agxData::FrameChannelRef m_frameChannel;
86
87 agxData::FrameRef m_solverResult;
88 };
89
90}
92
93#endif
94#endif /* AGX_REMOTESOLVER_H */
#define AGX_DECLARE_POINTER_TYPES(type)
Definition Referenced.h:254
#define AGXPHYSICS_EXPORT
Simulation is a class that bridges the collision space agxCollide::Space and the dynamic simulation s...
Definition Simulation.h:126
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
The agxSDK namespace contain classes to bridge the collision detection system and the dynamical simul...
Definition Constraint.h:31
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
uint16_t UInt16
Definition Integer.h:31
uint8_t UInt8
Definition Integer.h:30
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.