vtkLiveInsituLink.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
26 #ifndef vtkLiveInsituLink_h
27 #define vtkLiveInsituLink_h
28 
29 #include "vtkRemotingLiveModule.h" //needed for exports
30 
31 #include "vtkSMObject.h"
32 #include "vtkSmartPointer.h" // Needed for Smart pointer
33 #include "vtkWeakPointer.h" // Needed for Weak pointer
34 
37 class vtkPVXMLElement;
38 class vtkPVSessionBase;
39 class vtkTrivialProducer;
41 
43 {
44 public:
45  static vtkLiveInsituLink* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
50 
54  vtkSetMacro(InsituPort, int);
55  vtkGetMacro(InsituPort, int);
57 
59 
62  vtkSetStringMacro(Hostname);
63  vtkGetStringMacro(Hostname);
65 
67 
71  enum
72  {
73  LIVE = 0,
74  INSITU = 1
75  };
76  vtkSetClampMacro(ProcessType, int, LIVE, INSITU);
77  vtkGetMacro(ProcessType, int);
79 
81 
87  vtkSetMacro(ProxyId, unsigned int);
88  vtkGetMacro(ProxyId, unsigned int);
90 
92 
96  vtkGetMacro(SimulationPaused, int);
97  void SetSimulationPaused(int paused);
99 
104  bool Initialize() { return this->Initialize(nullptr); }
105  bool Initialize(vtkSMSessionProxyManager*);
106 
107  // **************************************************************************
108  // *** API to be used from the insitu library ***
109 
119  void InsituUpdate(double time, vtkIdType timeStep);
120 
128  void InsituPostProcess(double time, vtkIdType timeStep);
129 
131 
137  int WaitForLiveChange();
139  void OnLiveChanged();
141 
142  // **************************************************************************
143 
144  // **************************************************************************
145  // API to be used from the LIVE side.
146  // Register/unregister a producer for an extract.
147  void RegisterExtract(
148  vtkTrivialProducer* producer, const char* groupname, const char* proxyname, int portnumber);
149  void UnRegisterExtract(vtkTrivialProducer* producer);
150 
151  void OnInsituUpdate(double time, vtkIdType timeStep);
152  void OnInsituPostProcess(double time, vtkIdType timeStep);
158  void LiveChanged();
159  // **************************************************************************
160 
162  {
163  CONNECTED = 1200,
164  NEXT_TIMESTEP_AVAILABLE = 1201,
165  DISCONNECTED = 1202
166  };
167 
168  void UpdateInsituXMLState(const char* txt);
169 
174  static bool FilterXMLState(vtkPVXMLElement* xmlState);
175 
176  // ***************************************************************
177  // Internal methods, public for callbacks.
178  void InsituConnect(vtkMultiProcessController* proc0NodesController);
179 
183  void DropLiveInsituConnection();
184 
185 protected:
187  ~vtkLiveInsituLink() override;
188 
189  enum RMITags
190  {
191  UPDATE_RMI_TAG = 8800,
192  POSTPROCESS_RMI_TAG = 8801,
193  INITIALIZE_CONNECTION = 8802,
194  DROP_CAT2PV_CONNECTION = 8803,
195  // Message from LIVE, sent when simulation is paused,
196  // signalling a change. INSITU wakes up and checks for new
197  // simulation state, changed extracts or if it should continue the
198  // simulation
199  LIVE_CHANGED = 8804
200  };
201 
205  void InitializeLive();
206 
211  bool InitializeInsitu();
212 
216  void OnConnectionCreatedEvent();
217 
222  void OnConnectionClosedEvent(vtkObject*, unsigned long eventid, void* calldata);
223 
224  char* Hostname;
227  unsigned int ProxyId;
228 
232 
241 
242 private:
243  vtkLiveInsituLink(const vtkLiveInsituLink&) = delete;
244  void operator=(const vtkLiveInsituLink&) = delete;
245 
246  vtkWeakPointer<vtkSMSessionProxyManager> InsituProxyManager;
247 
248  vtkSetStringMacro(URL);
249  char* URL;
250 
251  vtkSetStringMacro(InsituXMLState);
252 
253  class vtkInternals;
254  vtkInternals* Internals;
255 };
256 
257 #endif
#define VTKREMOTINGLIVE_EXPORT
int vtkIdType
superclass for most server manager classes
Definition: vtkSMObject.h:17
time
The vtkSMSessionProxyManager is esponsible for creating and managing proxies for a given session...
static vtkSMObject * New()
Abstract class used to provide the main implementation of the ParaView session methods for the follow...
This is used by vtkPVXMLParser to represent an XML document starting at the root element.
void PrintSelf(ostream &os, vtkIndent indent) override