Getting the status of a simulation engine
                This endpoint enables you to get the status of the simulation engine.
The response provides an XML file according to orca2.xsd (see ORCA2.xsd).
In the response, 3 elements can be detected:
- The status of the engine.
 - The status of a simulation.
 - The status of a simulation group.
 
Status of the engine
The status of the simulation engine is reported in the XML tag <Action>:
| Action | Description | 
|---|---|
| 
                                 Waiting  | 
                            
                                 The engine is ready to receive a request.  | 
                        
| 
                                 Working  | 
                            
                                 The engine is waiting to get free resources to run the request.  | 
                        
| 
                                 Closing  | 
                            
                                 The engine is releasing the resource after a shutdown request.  | 
                        
| 
                                 ImportingNetworkData  | 
                            
                                 The engine is loading the network data; it is not ready to receive a run request.  | 
                        
| 
                                 ImportingRealTimeData  | 
                            
                                 The engine is updating real time data.  | 
                        
| 
                                 ExportingData  | 
                            
                                 The engine is exporting the result of the run request.  | 
                        
| 
                                 PerformingSimulation  | 
                            
                                 The engine is running the simulation.  | 
                        
| 
                                 PerformingDTA  | 
                            
                                 The engine is computing the route search in DTA.  | 
                        
Status of the simulation
The status of the simulation is stored in the attribute status of the XML tag <simulation>.
| Status | Description | 
|---|---|
| 
                                 0  | 
                            
                                 Ready. The request is in the queue, waiting to be run.  | 
                        
| 
                                 1  | 
                            
                                 Completed. The simulation has been completed.  | 
                        
| 
                                 2  | 
                            
                                 InProgress. The simulation is started but not completed.  | 
                        
| 
                                 3  | 
                            
                                 CalculatingKPI. The simulation is completed and the KPI computations are started but not completed.  | 
                        
| 
                                 4  | 
                            
                                 CompletedKPI. The KPI has been calculated and is available to be analyzed.  | 
                        
| 
                                 5  | 
                            
                                 ErrorKPI. Error during the KPI computation.  | 
                        
| 
                                 6  | 
                            
                                 Cancelled. The request has been canceled by the user.  | 
                        
| 
                                 7  | 
                            
                                 Failed. The request has failed.  | 
                        
Status of the simulation group
The status of the simulation group is stored in the attribute status of the XML tag <simulationGroup>.
| Status | Description | 
|---|---|
| 0 | 
                                 Ready The simulation group is ready to be run and the engine can take it in charge as soon as its computing resources are free.  | 
                        
| 
                                 1  | 
                            
                                 Completed All the simulations of the simulation group are completed.  | 
                        
| 
                                 2  | 
                            
                                 InProgress The first simulation the simulation group has started.  | 
                        
| 
                                 6  | 
                            
                                 Cancelled The execution was canceled by the user.  | 
                        
| 
                                 7  | 
                            
                                 Failed An error occurred during the execution.  | 
                        
Configuration of ISO 8601 date format
You can get a response including a timestamp:
- 
                        
In the ISO 8601 date format, with the Universal Time Coordinated (UTC) time offset
 - 
                        
In legacy format.
 
The option is handled through a string parameter associated with the tag <configuration>/<api-date-format> of the file /opt/ptv-optima-as/standalone/configuration/optima/optima-configuration.xml.
| 
                                 Property  | 
                            
                                 Type  | 
                            
                                 Description  | 
                        
|---|---|---|
| 
                                 api-date-format  | 
                            
                                 String  | 
                            
                                 It determines the timestamp format: 
 Important: If api-date-format is not present in the optima-configuration.xml file, the legacy timestamp is enabled.  | 
                        
Example
If api-date-format=iso, the result is:
<simt>2023-02-14T14:20:40+01:00</simt>
<sday>2023-02-14T00:00:00+01:00</sday>
If api-date-format=legacy, the result is:
<simt>2023-02-14 14:20:40 (+01:00)</simt>
<sday>14/02/2023 00:00:00</sday>
Authentication phase
Before using the endpoint, you must run the authentication phase (→ Login).
After the authentication, a session opens and a valid session token persists until:
- The end of the session time-out, that is set through the parameter sessionTimeout (→ OptimaWSI configuration > OptimaAuth section).
 - An explicit Logout call (→ Logout).
 
Request
GET
                
https://<OPTIMA_HOST_IP_ADDRESS>:<PORT_NUMBER>/datex-interface/simulation/engine/{appname}
                        The parameter appname must be specified with the value TRE_tattico (that is also the default value).
Important: For legacy reasons and backward compatibility, STF is associated with the string TRE_tattico.
Request parameters
Not applicable.
Request content-type
Not applicable.
Request body (payload)
Not applicable.
Response status
| HTTP status | Description | 
|---|---|
| 
                                         200 OK  | 
                                    
                                         The engine is able to answer; the XML message provides valid details on the current status of the engine.  | 
                                
| 
                                         401 Unauthorized  | 
                                    
                                         The requested resource is restricted and requires authentication. Please see → Login (deprecated).  | 
                                
Response content-type
application/xml
Response output
XML message containing information on the Short Term Forecast (STF) simulation engine.
In the XML message, the <status> tag indicates the processing status of the request:
- status = 0: the request is well formed and has been accounted with success.
 - status = 1: internal error or wrong request (failed request).
 
Request
https://<OPTIMA_HOST_IP_ADDRESS>:<PORT_NUMBER>/datex-interface/simulation/engine/TRE_tattico
                        Response status
| HTTP status | Description | 
|---|---|
| 
                                         200 OK  | 
                                    
                                         Result of the processed request.  | 
                                
Response output
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Orca2Model xmlns="http://sistemaits.com/orca2/1" xmlns:ns2="http://datex2.eu/schema/2/2_0">    
    <exchange>
        <provider>PTV-OPTIMA</provider>
    </exchange>
    <payloadPublication xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="SimulationPayload">
        <engine appName="TRE_TATTICO">
        <status>0</status>
        <ServiceException/>
        <Message>0</Message>
        <TimeToNextSim>00:08:48</TimeToNextSim>
        <init>53100</init>
        <lastDay>-1</lastDay>
        <Action>Waiting</Action>
        <ends>0</ends>
        <simt>2020-03-18T14:59:30+01:00</simt>
        <Progress>0.0</Progress>
        <sday>2020-03-18T00:00:00+01:00</sday>
        <simulationGroup idno="3" publicVisibility="true" description="Testing a road closure" status="2" timestamp="2020-03-06T10:44:53.027">
            <simulation idno="7" description="Base" base="true" simulationStart="2020-03-06T10:44:53.027" simulationPeriodStart="2020-03-06T10:30:00" simulationPeriodEnd="2020-03-06T11:45:00" applicationName="TRE_tattico" simulationGroup="3" status="2"/>
            <simulation idno="6" description="Case1 road closed" base="false" simulationGroup="3">
                <scenario idno="6"/>
            </simulation>
        </simulationGroup>
    </payloadPublication>
</Orca2Model>