Simulator

public class Simulator

Constructors

Simulator

protected Simulator(APIClient client, long objectId)

Internal constructor

Methods

addListener

public void addListener(io.cocotec.coco.platform.coco.SimulatorListener listener)

Adds a listener that will receive callbacks about events in this Session. The caller is responsible for ensuring that the SessionListener remains valid whilst the session is active: the session does not take ownership of the SessionListener at all.

behaviour

public io.cocotec.coco.platform.coco.Behaviour behaviour()

The behaviour that leads to the current state. This can only be called during a callback from one of the listener methods.

choices

public java.util.ArrayList<io.cocotec.coco.platform.coco.Event> choices()

The events that are available to be chosen from in the current state. This can only be called during a callback from one of the listener methods. After calling this, behaviour() is updated to reflect the extra state.

currentState

public io.cocotec.coco.platform.coco.InstanceNetworkState currentState()

The current execution state. This can only be called during a callback from one of the listener methods.

finalize

protected void finalize()

focusInstance

public io.cocotec.coco.platform.coco.BehaviouralInstance focusInstance()

The instance out of stepped_instances that should be focused on in a UI. This may be null.

getObjectId

public long getObjectId()

Internal method

getOrCreate

public static Simulator getOrCreate(APIClient client, long objectId)

Internal method

lastStopReason

public io.cocotec.coco.platform.coco.SimulatorStopReason lastStopReason()

The reason the simulator is currently stopped, if it is.

leafInstances

public java.util.ArrayList<io.cocotec.coco.platform.coco.BehaviouralInstance> leafInstances()

reset

public void reset(int stateIndex)

Resets the simulator to the state given by the index.

Parameters:
  • stateIndex – The index of the state (in behaviour().states()) that should become the new current state. This continues asynchronously in the background.

resolveChoice

public void resolveChoice(int choiceIndex)

If the current state has choices, then the index of the choice to proceed with.

step

public void step(io.cocotec.coco.platform.coco.SimulatorStepMode mode)

Steps according to the given mode.

steppedInstances

public java.util.ArrayList<io.cocotec.coco.platform.coco.BehaviouralInstance> steppedInstances()

The list of threads that have changed state since the last callback. This can only be called during a callback from one of the listener methods.

stopped

public boolean stopped()

Is the simulator currently paused?

toTrace

public String toTrace(io.cocotec.coco.platform.coco.TraceLevel level)

Converts the current behaviour This can only be called during a callback from one of the listener methods.

topLevelInstances

public java.util.ArrayList<io.cocotec.coco.platform.coco.Value> topLevelInstances()

The top-level instances that are active in this counterexample. Each behavioural instance may consist of several other instances.