Calculation Service: Difference between revisions
No edit summary |
No edit summary |
||
Line 39: | Line 39: | ||
Default Formatter Plugin is called '''SMathFileType''' and it has GUID '''8ec52daf-bcdb-4e5c-8e07-fade44a14e50'''. In order to prepare input data in '''SMathFileType''' format perform the following steps: | Default Formatter Plugin is called '''SMathFileType''' and it has GUID '''8ec52daf-bcdb-4e5c-8e07-fade44a14e50'''. In order to prepare input data in '''SMathFileType''' format perform the following steps: | ||
# Open your calculation in [[SMath Studio]]: | # Open your calculation in [[SMath Studio]]: | ||
#: [[File: | #: [[File:En_SMathViewer - Calculation.png|600px|frameless]] | ||
# Use '''Tools -> Preview''' in [[SMath Viewer]] menu item. | # Use '''Tools -> Preview''' in [[SMath Viewer]] menu item. | ||
#: [[File: | #: [[File:En_SMathViewer - Calling Button.png|600px|frameless]] | ||
# Make sure opened [[SMath Viewer]] shows all expected calculation input parameters. | # Make sure opened [[SMath Viewer]] shows all expected calculation input parameters. | ||
# Press [[SMath Viewer]] '''Save''' button and specify where you want to save resulting XML file. This XML file may be used as an input for [[Calculation Service]]. | # Press [[SMath Viewer]] '''Save''' button and specify where you want to save resulting XML file. This XML file may be used as an input for [[Calculation Service]]. | ||
#: [[File: | #: [[File:En_SMathViewer - Save Button.png|600px|frameless]] | ||
==Examples== | ==Examples== |
Latest revision as of 12:31, 12 September 2024
Introduction
Calculation Service is a process that can be started by the external application to immediately perform calculations via SMath Studio. It is important to understand that Calculation Service is not registered in the operating system as a service, and its full lifecycle completely depends on the calling application. Calculation Service is delivered as a separate executable module, available in the main SMath Studio Enterprise folder:
SMath.UI.Service.exe
List of commands, supported by the current version may be taken by standard -? or -help command call:
SMath.UI.Service.exe -help
Limited Access
Calculation Service is an optional component of SMath infrastructure available only with a proper licensed SMath Studio Enterprise installation for our commercial customers.
Calculation Service API
To ensure maximum ease of interaction with Calculation Service for third-party developers, along with SMath Studio Enterprise a convenient API is supplied in the form of a file in the program installation directory:
SMath.UI.Service.Api.dll
When running on Windows, the Calculation Service API library is registered to interact with COM on SMath Studio Enterprise installation, which makes it possible to implement integration with SMath Studio Enterprise to almost any external application.
Calculation Service API Lifecycle
Working with Calculation Service is performed as follows:
- Start Calculation Service. Optionally it is possible to specify the port to use or it will be allocated dynamically otherwise. API may be used to get an allocated port then.
- Started Calculation Service loads the application components. It may take a few seconds, depending on your hardware and installed add-ons amount in SMath Studio Plugins.
- Calculation Service may be started manually in a command line, or you may initiate new service instance via API call.
- Request connection to the service started in the previous item. You will need a port to be used.
- Prepare .sm file to calculate and format input data.
- Initially the service was created for internal use and it caused using internal XML based format. In order to simplify input/output data handling special Formatter plugin type was introduced.
- Request to calculate .sm file(s) indicating initial data and returning calculation results format.
- Calculation occurs as quickly as possible, because application components are already loaded in memory and ready to make requests.
- Close connection(s) to the service and terminate the Calculation Service process.
- After Calculation Service process is completed, its process is unloaded from memory and no longer available for any external applications interaction.
Calculation Service API Commands
Calculation Service does not implement all functionality by itself. It just wraps what is performed by SMath Studio Enterprise engine. It is why the full list of the commands supported by API may be taken from SMath Studio:
SMathStudio_Desktop.exe -help
Formatter Plugins
In order to simplify formatting input/output data passed to/received from API several Plugins have been developed. All of them implement specific interface IPluginDataInputOutput. Each of these Plugins has a unique GUID identifier. Namely this GUID identifier to be passed into API call in order to instruct the Calculation Service what data format to be used. Our examples demonstrate how it to be performed. GUID of custom Plugins may be found in our sources repository. It is ProjectGuid property in appropriate project file.
Default Formatter Plugins
Default Formatter Plugin is called SMathFileType and it has GUID 8ec52daf-bcdb-4e5c-8e07-fade44a14e50. In order to prepare input data in SMathFileType format perform the following steps:
- Open your calculation in SMath Studio:
- Use Tools -> Preview in SMath Viewer menu item.
- Make sure opened SMath Viewer shows all expected calculation input parameters.
- Press SMath Viewer Save button and specify where you want to save resulting XML file. This XML file may be used as an input for Calculation Service.
Examples
In order to simplify developer's introduction into how to work with Calculation Service several examples have been developed and made available in our public sources repository under https://smath.com/svn/public/integration
At the moment .NET based and Delphi based examples are available. More environments will be covered later.