Skip to main content

Post-processing tools 2023 R2

ensight.proto

Last update: 17.04.2023
1 // *****************************************
2 // Copyright 2020-2022 ANSYS, Inc.
3 // All Rights Reserved.
4 //
5 // Restricted Rights Legend
6 //
7 // Use, duplication, or disclosure of this
8 // software and its documentation by the
9 // Government is subject to restrictions as
10 // set forth in subdivision [(b)(3)(ii)] of
11 // the Rights in Technical Data and Computer
12 // Software clause at 52.227-7013.
13 // *****************************************
14 
15 syntax = "proto3";
16 
17 //@ingroup grpc
18 // gRPC service definition for the EnSight Application
19 
20 package ensightservice;
21 
22 //@defgroup EnSightService EnSightService
23 //@ingroup grpc
24 //@brief The core EnSight gRPC service
25 //
26 // The remote EnSight command and control functions provided by the EnSight core.
27 // They provide access to the EnSight Python interpreter, scene geometry (via glTF blobs),
28 // the generated image stream and the internal event queue. Custom, special purpose
29 // interfaces exist for other applications. Most of these calls require the complete
30 // attention of the EnSight core to perform their operations and thus will block until
31 // the EnSight core becomes available. Calls that do not block in this fashion are
32 // marked "(non-blocking)" in their description.
34 service EnSightService {
35  //@addtogroup EnSightService
37 
38  // Run a Python command string in the EnSight Python interpreter
39  // @return PythonReply the result of the string
40  rpc RunPython (PythonRequest) returns (PythonReply) {}
41 
42  // Render an image of the current scene
43  // @return RenderReply the rendered image
45 
46  // Return current scene geometry representation
47  // @return GeometryReply the current scene geometry in glTF format
49 
50  // Shutdown EnSight session
51  // @return ExitReply an acknowledgment from the EnSight server
52  rpc Exit (ExitRequest) returns (ExitReply) {}
53 
54  // Enable a filtered stream of callback events from the EnSight session (non-blocking)
55  //
56  // EnSight supports a callback registration system that can associate a callback with
57  // with any attribute change in the client. This is the ensight.objs.addcallback()
58  // Python call. For example:
59  // ~~~~~~~~~~~~~~~{.py}
60  // ensight.objs.addcallback(ensight.objs.core, None, prefix+"PARTLIST_CHANGED",
61  // attrs=['PARTS'], flags=ensight.objs.EVENTMAP_FLAG_COMP_GLOBAL)
62  // ~~~~~~~~~~~~~~~
63  // will register a callback event associated with any changes in the ensight.objs.core.PARTS
64  // attribute. When this happens, EnSight will emit an event with the string
65  // "prefix+'PARTLIST_CHANGED'". The gRPC interface enables a stream of these event strings
66  // to be returned to the calling application in EventReply messages. It also provides a
67  // simple prefix filter, so that only messages that start with the specific prefix will be
68  // returned on the event stream. This prefix is passed in the EventStreamRequest message.
69  // @return EventReply a stream of EventReply messages for each emitted event
70  rpc GetEventStream (EventStreamRequest) returns (stream EventReply) {}
71 
72  // Subscribe to the EnSight event stream via reverse gRPC connection (non-blocking)
73  //
74  // Some gRPC clients have demonstrated problems maintaining a continuous EventReply
75  // stream. For these clients, it is possible for the client to reverse the gRPC
76  // connection so EnSight will make gRPC calls back to the client. In this case,
77  // the client application will start an \ref EnSightSubscription service and inform
78  // EnSight of how to connect to it via SubscribeEventOptions. EnSight will then
79  // make PublishEvent calls with the EventReply messages
80  // it would have used in the GetEventStream() configuration.
82 
83  // Subscribe to the EnSight image stream via reverse gRPC connection (non-blocking)
84  //
85  // Some gRPC clients have demonstrated problems maintaining a continuous ImageReply
86  // stream. For these clients, it is possible for the client to reverse the gRPC
87  // connection so EnSight will make gRPC calls back to the client. In this case,
88  // the client application will start an \ref EnSightSubscription service and inform
89  // EnSight of how to connect to it via SubscribeImageOptions. EnSight will then
90  // make PublishImage calls with a short lived (single image frame) ImageReply message
91  // stream it would have used in the GetEventStream() configuration. EnSight will
92  // make a separate PublishImage call for every frame of imagery it generates.
94 
95  // Discontinue a previous established stream subscription (non-blocking)
96  //
97  // This call will cause EnSight to stop making gRPC calls to the client gRPC server
98  // associated with the prefix string. It can be used to stop a SubscribeEvents() or
99  // SubscribeImages() call.
100  rpc Unsubscribe (Prefix) returns (GenericResponse) {}
101 
102  // Enable a stream of rendered images from the EnSight session (non-blocking)
103  //
104  // A stream of the images rendered by EnSight.
105  // @return ImageReply a stream of ImageReply messages for each image rendered
106  rpc GetImageStream (ImageStreamRequest) returns (stream ImageReply) {}
107 
108  // An interface to save an image or animation
109  // @return AnimSaveReply
111 
112  // An interface to query the progress an animation being saved
113  // @return AnimQueryProgressReply describing progress toward completion
115 
117 }
119 
120 //@defgroup EnSightSubscription EnSightSubscription
121 //@ingroup grpc
122 //@brief Client-side, reverse gRPC service
123 //
124 // Definition of the client-side, reverse gRPC service that EnSight
125 // will connect to in response to a stream subscription request.
127 service EnSightSubscription {
128  //@addtogroup EnSightSubscription
130 
131  // Publish a single image (possibly in chucks) to the remote server
132  // @param ImageReply The stream of ImageReply objects
133  // @return GenericResponse
134  rpc PublishImage(stream ImageReply) returns (GenericResponse) {}
135 
136  // Publish an event to the remote server
137  // @return GenericResponse
138  rpc PublishEvent(EventReply) returns (GenericResponse) {}
139 
141 }
143 
144 
145 // The generic return value for an EnSightSubscription rpc call
146 message GenericResponse {
147  string str = 1; // Generic return string
148 }
149 
150 // The prefix to be Unsubscribe
151 message Prefix {
152  string prefix = 1; // The subscription prefix passed in SubscribeEventOptions or SubscribeImageOptions
153 }
154 
155 
156 // The event subscription options
157 message SubscribeEventOptions {
158  // @brief Subscription channel type
159  // Presently, only image subscriptions are supported
160  enum ChannelType {
161  GRPC = 0; // EnSight should use gRPC PublishEvent() to send the events back to the client
162  }
163  string prefix = 1; // A unique prefix string (perhaps a GUID) used to identify this stream (used by Unsubscribe())
164  ChannelType type = 2; // The EventReply transport mechanism (GRPC)
165  // @brief various type specific options
166  //
167  // For type=ChannelType::GRPC, 'uri' map key contains the URI for the server launched by the client (required). 'num_retries' map
168  // key is the number of times EnSight should attempt to connect before failing the operation. 'shared_secret' map
169  // key is the shared secret that the client gRPC server is expecting to see to authenticate a connection.
170  map<string, string> options = 3;
171 }
172 
173 
174 // The image subscription options
175 message SubscribeImageOptions {
176  // @brief Image channel type
177  // The image subscription can be via gRPC protocol or via shared memory transport
178  enum ChannelType {
179  GRPC = 0; // EnSight should use gRPC PublishImage() calls to send images back to the client
180  SHARED_MEM = 1; // EnSight should use a \ref SharedMemoryImageStream to send images back to the client
181  }
182  string prefix = 1; // A unique prefix string (perhaps a GUID) used to identify this stream (used by Unsubscribe())
183  ChannelType type = 2; // Select GRPC or SHARED_MEM transport
184  bool flip_vertical = 3; // If true, flip the image over the X axis before sending the image
185  bool chunk = 4; // Set to send images in 1MB chunks to speed up large (>1MB) image transfers (see ImageStreamRequest and ImageReply)
186  // @brief various type specific options
187  //
188  // For type=GRPC, 'uri' map key contains the URI for the server launched by the client (required). 'num_retries' map
189  // key is the number of times EnSight should attempt to connect before failing the operation. 'shared_secret' map
190  // key is the shared secret that the client gRPC server is expecting to see to authenticate a connection.
191  //
192  // For type=SHARED_MEM, 'filename' map key contains the name of local file to be used
193  // as the memory mapped shared memory block (required).
194  map<string, string> options = 5;
195 }
196 
197 // A string to execute in the EnSight Python interpreter and execution options
198 message PythonRequest {
199  // @brief Specify the execution type and return value for the Python command
200  enum CmdType {
201  EXEC_NO_RESULT = 0; // Run the command with exec() with no return value
202  EXEC_RETURN_PYTHON = 1; // Run the string using eval() and return the resulting Python object via Python repr()
203  EXEC_RETURN_JSON = 2; // Run the string using eval() and return the resulting Python object encoded via json
204  }
205  CmdType type = 1; // Specify how the string should be executed and what the return value should be
206  string command = 2; // UTF8 encoded string to be exec() or eval() by the EnSight Python interpreter
207 }
208 
209 // The result of executing a Python string in EnSight
210 message PythonReply {
211  string value = 1; // UTF8 encoded string, the repr() or json representation of the evaluated expression depending on the PythonRequest::CmdType specified
212  int32 error = 2; // If error < 0 an error occurred
213 }
214 
215 // Control options for a single image render request
216 message RenderRequest {
217  // @brief Specify the return type of the rendering request
218  enum RenderType {
219  IMAGE_PNG = 0; // The returned image will be encoded into the PNG image file format and returned as an array of bytes.
220  IMAGE_RAW = 1; // The returned value be in raw binary bytes: RGBRGBRGB... width*height*3 bytes total
221  }
222  RenderType type = 1; // Select the format the returned image should be in.
223  int32 image_width = 2; // The desired image width in pixels
224  int32 image_height = 3; // The desired image height in pixels
225  int32 image_aa_passes = 4; // The number of anti-aliasing passes to be applied
226  bool include_highlighting = 5; // If true, any dynamic overlay will be included in the rendered image
227 }
228 
229 // The returned, rendered image
230 message RenderReply {
231  bytes value = 1; // An array of byte representing the image. See RenderRequest::RenderType for the specific format.
232 }
233 
234 
235 // Request that an image or animation be saved.
236 // If saving an animation, and format is an image format like png, save multiple images
237 // and insert an index like "_0003" into the file name before the extension.
238 // If saving one frame in an animation format, a one-frame movie will be written.
239 // Valid anim formats: .mp4, .avi, .mov
240 // Valid image formats: .png, .tif/.tiff, .jpg/.jpeg, .ppm
241 //
242 // Format Option name Value Notes
243 // mp4: Quality Best|High|Medium|Low default: High
244 // Type 0|1 default: 1 1 for H.264, 0 for non-H.264
245 // avi: Compression MJPEG|RAW|MPEG4V2 default: MPEG4V2
246 // BitRate (a value between 0 and 80000) default: 20000 kbits/sec
247 // mov: BitRate (a value between 0 and 80000) default: 20000 kbits/sec
248 // png: Compression None|Fast|Best|Default default: Default (zlib compression setting)
249 // tif: Compression None|PackBits|Deflate default: PackBits
250 // jpg: Quality (a value between 0 and 100) default: 75
251 // ppm: Format Binary|Ascii default: Binary
252 message AnimSaveRequest {
253  string id = 1; // Handle used to query progress or cancel a save. Any unique string, provided by the caller.
254  string filename = 2; // Name of file to save. Format determined from file extension. Defaults to .mp4 or .png with no file extension. UTF8 encoding. Existing files are overwritten.
255  map<string, string> format_options = 3; // Options specific to certain formats, as (option_name, value) pairs
256  uint32 width = 4; // Image width. 0 means current window width.
257  uint32 height = 5; // Image height. 0 means current window height.
258  uint32 aa_passes = 6; // Num anti-aliasing passes. 0 uses EnSight default 4-pass antialiasing.
259  bool white_background = 7; // If True, set background to white, and change text and misc colors to black as necessary. Restore all, after save. If False, leave all colors as they are.
260  int32 start_frame = 8; // First frame to save. 0-based. -1 special value that means the current timestep
261  int32 num_frames = 9; // Num frames to save. -1 special value that means all timesteps. num_frames > num timesteps allows multiple cycles through time.
262  float fps = 10; // Frames/sec. Ignored if saving an image.
263 }
264 // Reply to request to save an image or animation
265 message AnimSaveReply {
266 }
267 
268 // Query the progress of an animation being saved. This can be called while AnimSaveRequest is in progress
269 message AnimQueryProgressRequest {
270  string id = 1; // Handle for the save operation, same as in the request
271  bool cancel = 2; // If True, request cancellation of the save.
272 }
273 // Reply to query of animation progress
274 message AnimQueryProgressReply {
275  // @brief The current status of the animation rendering operation
276  enum Status {
277  IN_PROGRESS = 0; // Saving
278  COMPLETE = 1; // Successfully completed.
279  CANCEL_REQUESTED = 2; // Cancellation requested, but not yet cancelled
280  CANCELLED = 3; // Cancellation completed
281  WRITE_ERROR = 4; // Animation could not be saved - file not writable, output size too big, ...
282  }
283  string id = 1; // Handle for the save operation, same as in the request
284  uint32 num_frames_finished = 2; // Is 0 at first, will be equal to num_frames when finished.
285  uint32 num_frames = 3; // Same as num_frames in request, unless num_frames in request == -1.
286  Status status = 4; // If 'cancel' is True in the request, but the anim had already completed or errored out, returned status is COMPLETE or ERROR
287  string error_msg = 5; // If the status==WRITE_ERROR, the error message
288 }
289 
290 
291 // Control options for a geometry pull request
293  // @brief select the format of the geometry reqquest
294  enum GeometryType {
295  GEOMETRY_GLB = 0; // The returned geometry is returned as an in-memory glTF encoded file
296  }
297  GeometryType type = 1; // The format the geometry data should be returned in.
298 }
299 
300 // The returned geometry request payload
301 message GeometryReply {
302  bytes value = 1; // a binary array containing the geometry in the format specified by GeometryRequest::GeometryType
303 }
304 
305 // Request that the EnSight server shut down
306 message ExitRequest {
307 }
308 
309 // The value returned by an ExitRequest rpc call
310 // Note: it is not uncommon for the ExitRequest call to return a gRPC error due to shutdown race conditions.
311 message ExitReply {
312 }
313 
314 // @brief Request the start of an image stream
315 //
316 // This message dictates the form of the ImageReply messages. One can have the images flipped vertically
317 // and can optionally chunk an entire image frame into multiple ImageReply messages. Empirical measurements
318 // demonstrate that gRPC can transfer smaller blocks of pixels faster that larger blocks. If the chunk option
319 // is enabled, the ImageReply messages will contain 1MB of pixel data maximum. The client must
320 // concatenate the pixel data from consecutive ImageReply messages until it receives a message
321 // with the final flag set. At that point, all of the pixel data for a complete image frame has
322 // been received.
323 message ImageStreamRequest {
324  bool flip_vertical = 1; // If true, flip the image over the X axis before sending the image
325  bool chunk = 2; // Set to send images in 1MB chunks to speed up large (>1MB) image transfers
326 }
327 
328 // @brief An image frame message
329 //
330 // These messages can contain the pixel data for an entire image or some portion of the image. An
331 // image frame can be broken up into multiple ImageReply messages. If the client receives an
332 // ImageReply message with the final flag set to false, it must continue reading messages,
333 // concatenating the pixels data until it receives an ImageReply with the final flag set to
334 // true.
335 message ImageReply {
336  int32 width = 1; // The width of the image in pixels
337  int32 height = 2; // The height of the image in pixels
338  // @brief the pixel compression, if any
339  enum CompressionType {
340  NONE = 0; // The data are in raw-binary uncompressed format
341  }
342  CompressionType compression = 3; // The compression scheme used for the pixel data payload
343  bytes pixels = 4; // The pixel data in RGBRGBRGB... form, width*height*3 bytes
344  bool final = 5; // If the ImageStreamRequest chunk is true, this is the final message in an image frame
345 }
346 
347 // Specify the prefix that should be used to set the filter prefix
349  string prefix = 1; // Specify that only the events that begin with this prefix should be included in the event stream
350 }
351 
352 // A filtered event
353 message EventReply {
354  string tag = 1; // The string associated with the EnSight event callback. It will begin with the prefix passed in the EventStreamRequest message
355 }
rpc AnimQueryProgress(AnimQueryProgressRequest animqueryprogressrequest) returns(AnimQueryProgressReply)
Definition: ensight.proto:114
rpc SubscribeImages(SubscribeImageOptions subscribeimageoptions) returns(GenericResponse)
Definition: ensight.proto:93
rpc RunPython(PythonRequest pythonrequest) returns(PythonReply)
Definition: ensight.proto:40
rpc Unsubscribe(Prefix prefix) returns(GenericResponse)
Definition: ensight.proto:100
rpc AnimSave(AnimSaveRequest animsaverequest) returns(AnimSaveReply)
Definition: ensight.proto:110
rpc Exit(ExitRequest exitrequest) returns(ExitReply)
Definition: ensight.proto:52
rpc SubscribeEvents(SubscribeEventOptions subscribeeventoptions) returns(GenericResponse)
Definition: ensight.proto:81
rpc GetEventStream(EventStreamRequest eventstreamrequest) returns(stream EventReply)
Definition: ensight.proto:70
rpc RenderImage(RenderRequest renderrequest) returns(RenderReply)
Definition: ensight.proto:44
rpc GetImageStream(ImageStreamRequest imagestreamrequest) returns(stream ImageReply)
Definition: ensight.proto:106
rpc GetGeometry(GeometryRequest geometryrequest) returns(GeometryReply)
Definition: ensight.proto:48
rpc PublishImage(stream ImageReply) returns(GenericResponse)
Definition: ensight.proto:136
rpc PublishEvent(EventReply eventreply) returns(GenericResponse)
Definition: ensight.proto:140
Status
The current status of the animation rendering operation.
Definition: ensight.proto:284
An image frame message.
Definition: ensight.proto:343
Request the start of an image stream.
Definition: ensight.proto:331
CmdType
Specify the execution type and return value for the Python command.
Definition: ensight.proto:205
ChannelType
Subscription channel type Presently, only image subscriptions are supported.
Definition: ensight.proto:162
ChannelType
Image channel type The image subscription can be via gRPC protocol or via shared memory transport.
Definition: ensight.proto:181