Model Run Engine Related System Attributes

From Planimate Knowledge Base
Jump to navigation Jump to search

Model Run Engine Related System Attributes

These system attributes provide information to assist you in how to respond to activities and events in the Model during a Run.


Name

Read / Write

Description



ActiveBroadcastIndex

R

Run Engine system attribute returns label index of the currently active broadcast or 0 if none active.


AnimationStartingMessage

R/W

Gives the modeller access to the option for whether "Animation Starting" messages will be presented to the user.


AutomaticRestartAfterError

R/W

This is an Experimental Feature

If the model sets this attribute to 1 during a run AND the "Restart When Model Stops" option is enabled, then PL will attempt to restart the model if a model error occurs.

This is intended for special cases where model errors in some runs are unavoidable (eg: a modeller managing multiple runs of a network directly rather than using PL's inbuilt mechanism).

It is not to be used for general modelling or catching file errors.

It will not work if the "Friendly Errors" dialog is enabled or any other dialog appears, apart from the standard "model error" dialog appears.

When an error occurs, the model error dialog appears for 10 seconds. If the user clicks/closes the dialog then the restart will not occur, otherwise the dialog closes and the model restarts.

The modeller should check and act on the "last stop reason" system attribute (if they are relying on restarts a handler for this should already be there).

Upon a restart this attribute gets reset to 0.

The modeller should only set it non zero after the code that proceeds it has been proven robust.

BackgroundRun

R

???


ContinueRun

R/W

Sets continue mode so a user event broadcast (eg: portal click) can continue the run.

Equivalent to the user button "continue" option.


DisableUndo

R/W

s.DisableUndo (Run Engine) enables the modeller to disable the undo/revert mechanism that normally occurs when a routine is executed during lookahead (before the item actually moves).

Setting this non zero will cause attributes and tables altered during lookahead to retain whatever is done to them after the lookahead is complete.

The modeller must set this value back to zero before the routine finishes or an error will be reported.

This is intended for advanced users who are hooking into Planimate's lookahead mechanism, for example in routing trains.

Attributes modified while DisableUndo is set do not initiate unblocks on dependent objects/views.

DoingTrackCheckNext

R

By testing this system attribute the modeller can give a controlled response to the CheckNext tests that the track network propagates.

Using this flag a modeller can tell the track system whether a portal is safe to consider moving towards, even if the train is some distance back and not directly "TestEntering".


HandlingBroadcastOnly

R

Set to non zero if the current run is being performed as result of a broadcast without initialisation.

This enables a model to catch when a broadcast button has been clicked *during* a run vs. when clicking it initiates the run.


HaveCurrentPendingEvents

R

Returns true if the FEC has any events scheduled to occur at exactly the current time - meaning that there is some unfinished activity at the current epoch which has not yet occurred - either because the user has paused the model or as a side effect of activity in the current thread (eg: unblocking).

This is intended to enable modellers to check whether other 0-time activity is in progress when a new broadcast is initiated by the user interacting with the model.

The modeller may want to prevent this second broadcast from proceeding in such circumstances.


LastRunStopReason

R

This returns a numeric code describing why the run/engine stopped LAST time.

This can be very useful in handling error recovery and may make handling "just loaded" situations easier than using the "_model loaded" broadcast (but that BC is still available).

Also very useful in handling restart dispatchers since the model can easily know that a "control" item will be present.

The current codes are as follows:

0   Loaded/No Previous Run no previous run, model just loaded or created

1   User Stopped Run user selected stop from menu/keyboard

2   Model Stopped Run model self stopped (exit, posted stop message)

3   Platform Required platform stopped run (closing, load/save model/scenario, editing time ref)

4   Error In Model/Engine error in model or runtime engine

5   Broadcast Option broadcast set to stop

6   UI/Portal Click Option user interaction: portal clicks,

7   Restart Dispatcher restart dispatcher restarted the run (item preserved)

A label list names these codes.


ModelNeedsSaving

R

The modeller can set/reset this to control whether PL will prompt to save the model upon exit.

This is only useful for models used by editors, obviously a standalone EXE isn't going to be saving any models.

MultipleRunCount

R

is 0 for normal runs is the # of multiple runs for a multiple-run session


RandomSeedImmediate

R/W

Enables reinitialisation of random seed without having to restart the engine.


RandomSeedOnRestart

R/W

This enables the initial random seed for the NEXT run to be set when a run restart dispatcher is used.

It also enables the random seed for the current run (single or multiple) to be read (unless the modeller has set it prior to a run/restart).

Note: its OK to use incrementing seeds, internally Planimate® scrambles the initial seed to ensure the streams for the successive runs don’t trivially correlate.

The seed value must be an integer between 1 and 32767 (inclusive) and a hard clamp has been introduced to ensure this.


RealTimeTickEnable

R/W

Run Engine System Attribute to control fine timer tick option on/off.


RoutineInLookahead

R

Reading this allows a Routine to control the flow of operations based on whether the execution of the routine is happening during a Lookahead as opposed to a Move.

Useful when calling DLL’s.

This will also be set for messages sent from a routine in lookahead.

RunNumber

R

Is the number that is appended to the Log files produced by Planimate®.


UserMode

R/W

This is set non zero if the editing tools are unavailable (ie: the system is in user mode or a standalone EXE).

This enables a model to adapt its UI/operation for a developer or an end user