# Server for Remote Models (UgServer)

## Getting Started with RemoteModel (Interactive Post Processing of CAE Models)

The prerequisites for the CAE server can be found in Supported Platforms.

Overview of the Remote Model architecture:

1. Download and extract HOOPS Envision for Web distribution archive from the Tech Soft 3D Developer Zone: https://developer.techsoft3d.com/

2. Specify your license, either by modifying server/UgServer/Main.js to specify your license code:

       ugServer.setLicenseCode(myCode);

   or by copying the hoops_license.h file downloaded from the developer zone into the server/UgServer folder, or by specifying the CEW_TECH_SOFT_LICENSE_FILE environment variable to point to the hoops_license.h.

3. With a terminal prompt, go to the ‘server/UgServer’ folder inside the distribution.

4. Execute the following command to fetch UgServer’s single dependency, Sockets.io.

       > npm install

5. Start the server using npm:

   Start the server with the appropriate command for your platform:

       > npm run startLinux
       > npm run startWin
       > npm run startMac

   Note: If you want to use the ‘CeeUgServer_noImportCae.node’ add-on, set the CEW_UG_DISABLE_IMPORT_CAE to 1 (e.g. export CEW_UG_DISABLE_IMPORT_CAE=1). This will load the CeeUgServer_noImportCae.node which do not have a dependency to e.g. Abaqus libraries.

   Node will then run Main.js, and the server will start on port 8998. The port can easily be changed in Main.js or by setting the PORT environment variable.

   You can verify that the server is running by opening http://localhost:8998 in a browser. You should then see a message like this

       Ceetron Cloud Server is alive
       Server ver: 2.2.0-5d8ff466 (add-on: 2.2.0-5d8ff466)
       Node.js ver: v18.17.0 (linux|x64)

6. We have included a simple http server for hosting the example web apps. To start the http server, go to the Examples/HttpServer folder and run:

       > npm install

   Then start the server by running:

       > npm start

   This will start the server on port 8000. This can be changed by the PORT environment variable or editing the HttpServer.js file.

   Open http://localhost:8000 in your browser and you should see a welcome page for the example web apps.

   You can also run the web apps by opening the corresponding index.html page (e.g. Examples/CloudPost/index.html).

   If you are running the example apps and the UgServer on two different machines, you will have to modify the example app code to use the correct IP address for the UgServer server. Just replace vizServerUrl with the full URL to the UgServer in the line below:

       var mySocket = io(vizServerUrl, {reconnection:false});

   You might want to modify the modelFileFromKey() method in the Main.js file to provide proper model key to file path translation.

7. Please refer to the documentation to learn more about HOOPS Envision for Web. The central classes are:

   - `CloudSession`: Applications will typically create a single instance of CloudSession for managing viewers. It also handles the animationFrameCallback which is essential for Envision to update and control animations.
   - `Viewer`: Handles user interaction (pan/rotate/zoom), picking and other view related functions.
   - `RemoteModel`: The main class for interacting with the remote CAE model. Handles result selection, part settings and all feature extractions (cut/iso/particle trace). RemoteModel requires the presence of a running UgServer.
   - `GeometryModel`: Implements a client-side model that can handle a large number of parts efficiently.

## Logging in UgServer

The `RemoteModel` server (UgServer) supports logging to console and file in two different formats: Standard (more human readable) and JSON (for easy processing or consumption by e.g. Logstash).

The logging output of the `RemoteModel` server (UgServer) can be controlled via the following environment variables:

- CEW_UG_LOG_CONSOLE_OUTPUT_TYPE: Format for console log. Possible values: “standard”, “json”, “none”. Default: “standard”.
- CEW_UG_LOG_FILE_OUTPUT_TYPE: Format for console log. Possible values: “standard”, “json”, “none”. Default: “json”.
- CEW_UG_LOG_FILENAME: If file output type is not NONE, use this to specify the name of the log file. Default: “c3_ug_server.log”.
- CEW_UG_LOG_LEVEL: Specify what to log. Possible values: 1: Error, 2: Warning, 3: Info, 4: Debug, 5: Full debug. A 3 will log Error, Info and Warning, but not any debug messages. This is default.

It is also possible to add {key,value} pairs to the log on the server side from the client. This could be useful to trace operations through your web app. See `RemoteModel.setServerLogContextKeyValueArr()` for more info.

On linux, logging of segmentation faults is now also added to help debugging situations where the server crashes.

## Reconnection in UgServer

The UgServer supports automatic reconnection if the connection is lost. This is done by setting the environment variable CEW_UG_MAX_DISCONNECT_DURATION_MS to a value in milliseconds. The default is 30000 (30 seconds). If the connection to the server is lost, for example because of network issues or sudden connection interrupt, the client will try to reconnect and the open session will be restored. This means that the user can continue working with the model without losing any data or having to reload the model.

The client’s state must remain intact, the session will be in any case lost upon a page reload or if the client is closed. All websocket packets sent during the disconnect period will be queued and sent to the server once the connection is restored.

To disable the reconnection feature, set the environment variable CEW_UG_MAX_DISCONNECT_DURATION_MS to 0. In that case, the server will clean up all resources immediately on every disconnect.

Note: The socket.io client needs to be configured to allow reconnections, when instantiating it for the RemoteModel. This is on by default and requires no action but make sure that reconnection is not disabled. To test the reconnection feature, see the Examples/ReconnectionUg example app in the distribution.

## Examples

The example apps in the HOOPS Envision for Web distribution can be tested online at: http://envision.ceetron.com/

For a more complete example of an app powered by HOOPS Envision for Web, feel free to try Envision Analyzer Cloud (https://analyzer.ceetron.com). Although still a work-in-progress, it offers many features that demonstrate the capabilities of HOOPS Envision for Web.

The CAE Sharing portal uses HOOPS Envision for Web technology: https://cloud.ceetron.com

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your Docs generative AI assistant. Ask me anything about HOOPS Envision for Web or choose a sample question below to start a conversation:

What is HOOPS Envision for Web?
What are the latest release notes for HOOPS Envision for Web?
How do I start evaluating HOOPS Envision for Web?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...