• No results found

The Scenario Runtime Engine

In document Pacis (Page 106-110)

FROM.SCENARIOS 26

11. USING SCENARIOS DURING SIMULATION

11.2 The Scenario Runtime Engine

The scenario runtime engine is the component of the Equipment Simulator which is responsible for the execution of scenarios.

Scenarios which are attached to device objects or are currently running are managed by the runtime engine.

11.2.1 Status of Scenarios

The scenario runtime engine manages a state for every scenario. This state controls how a scenario is handled by the runtime engine.

Every scenario is in one of the following states:

Waiting

The scenario is currently not running but is waiting for execution. This state is used for scenarios which contain event handlers. This scenario is started if an event for which the scenario has a handler defined is processed.

Ready

The scenario is currently not running but is already scheduled for the next start. This state is only applicable for scenarios which are executed periodically. After the runtime engine has determined the next start time from the periodic execution settings, the scenario is moved into the ready state waiting for the start time to be reached.

Ready + Waiting

The ready and waiting states can be combined if the scenario is both waiting for events and should be executed periodically.

Running

The scenario runtime engine is currently executing the scenario. This is normally the result of a periodic start or the start of an event handler.

Running + Waiting

An instance of the scenario is currently running but the scenario is still ready for further starts. This state combination is used for scenarios which contain event handler where one event handler is currently executing and the scenario is ready for further events.

Finished

The scenario has been terminated. This can be the result of manually stopping the scenario, a runtime error or the termination of periodic execution.

The status of a scenario is displayed in the scenario status view (see "Scenario Status View").

11.2.2 Execution of Scenarios

An execution interval is used to run scenarios. This interval is given in milliseconds and controls the time the Equipment Simulator waits between the execution of two consecutive statements in the scenario code.

For example if the execution interval is 20 milliseconds, the runtime engine executes statement by statement with a break of 20 milliseconds between the statements. The interval controls only the break after a statement is finished until the next statement is started. The duration needed to execute a statement must be added to calculate the total time needed by a statement. This time may vary depending on the type of statement executed. For example a UCA2 operation like a direct control operation takes longer than a simple assignment because network communication is necessary.

The real execution interval may also vary with the current workload which for example depends on other applications running on the system or the number of scenarios started.

The execution interval can be seen as a minimum break between two consecutive statements in a scenario.

The execution interval can be configured (see "Configuration"). Larger execution intervals execute scenarios slower, smaller execution intervals execute scenarios faster.

If the runtime engine is executing multiple scenarios at the same time all scenarios are handled with the same priority.

11.2.3 Runtime Errors

If the runtime engine discovers a runtime error during the execution of a scenario, the scenario is terminated.

Runtime errors can occur if the scenario code is incorrect, a UCA2 server is not answering or the UCA2 Agency returns an error.

Examples for runtime errors are: Division by zero, data type mismatch in an expression or assignment, timeout in an UCA2 operations, etc.

If a scenario is terminated the reason is displayed in the scenario status window and in the execution history of the scenario (see "Scenario Status View" ).

If a scenario is executed periodically or contains event handler, only the affected instance of the scenario is terminated. The scenario remains ready for further periodic executions if necessary or waits for UCA2 events to be handled. Because the reason for the runtime error may be temporary (e.g. a server is not responding) it does not make sense to fully terminate the scenario.

11.2.4 Configuration

Some details of the behavior of the scenario runtime engine can be configured by choosing Tools - Options....

The Equipment Simulator offers some general and some client and server session specific configuration settings.

Select the Scenarios - General category to modify the execution interval used to run scenarios.

Using this interval you can influence the speed scenarios are executed with. A smaller value means higher speed, a higher value means slower speed. The execution interval is the time the Equipment Simulator waits between the execution of two consecutive statements in a scenario. If you set this value to 0, scenarios are executed at maximum speed.

Select the Scenarios - Server Session category to modify settings used if the Equipment Simulator is simulating a server.

The only setting in this category is if the Equipment Simulator should automatically call ODSDirectControlDone() and ODSSboSelectDone() if the appropriate handler has not called DirectControlDone() or SboSelectDone(). When a scenario finishes its event handler the Equipment Simulator checks if DirectControlDone() or SboSelectDone() has been called. If not and this option is enabled, ODSDirectControlDone() or ODSSboSelectDone() is called automatically.

NOTE: This setting is used for all simulated servers. It is not possible to configure the automatic call of ODSDirectControlDone() and ODSSboSelectDone() differently for each server.

Select the Scenarios - Client Session category to modify settings used when the Equipment Simulator is acting in client mode and connects to a server.

For client sessions you can define under which circumstances the Equipment Simulator reads data leaf values from servers if referenced in scenarios. If you enable Always read data leaf values from server if simulating a client, data leaves are always read. If you do not enable this option, data leaf values are read only once from the server, stored in the local device database and fetched from this database when the leaf is next accessed. If you enable this option you can reduce the network communication between client and server if the data leaf value does not change on the server or is always reported by the server when modified.

If you disable this option and enable Do not read data leaf values from server if they are part of a report, the Equipment Simulator checks if the data leaf is part of a report and does not read the leaf in this case. The Equipment Simulator assumes that the local device database is always up to date because all changes on the server are reported to the client.

By configuring the timeouts on this configuration page you can define how long the Equipment Simulator waits for a response from the server before an operation is classified as faulty. If the server does not respond within the specified time the scenario which issued the statement is terminated by the runtime engine.

Furthermore you can configure the default origin and operator name used when direct control, SBO select or SBO deselect operations are done from the client. If the appropriate statements are issued without operator or origin in a scenario the default values configured here are used.

If you enable Use currently logged on user as default operator name in control operations, the runtime engine determines the name of the currently logged on user and uses this name for the operator name. If you disable the option you can provide any name by entering a value in the Default operator name edit box.

If you enable Use computer name as default origin in control operations, the runtime engine determines the name of the computer and uses this name as origin. If you disable the option you can provide any name by entering a value in the Default origin edit box.

In document Pacis (Page 106-110)