Table of Contents

Interface ISimulationController

Namespace
Scaleout.Streaming.DigitalTwin.Core
Assembly
ScaleOut.Streaming.DigitalTwin.Core.dll

The methods of this interface allow user to control all aspects of digital twin's model simulation process.

public interface ISimulationController

Methods

CreateTwin(string, string, object)

Create a new digital twin instance of the specified simulation modelName. This method forces to use the specified object instance over the one that could be found in the persistence store if it is enabled.

SendingResult CreateTwin(string modelName, string twinId, object newInstance)

Parameters

modelName string

Digital twin model name.

twinId string

Digital twin identifier.

newInstance object

Digital twin instance to create. It could be an object of a real digital twin model type or simply an anonymous object with a set of digital twin model's properties and their initial values.

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DigitalTwinInstantiationException

An error occurred while creating a new digital twin instance.

CreateTwinFromPersistenceStore(string, string)

Create a new digital twin instance of the specified simulation modelName. This method assumes that persistence store is enabled for the modelName and twin instance with the specified twinId exists there. In this case, a new twin instance is created and initialized from the persistence store.

SendingResult CreateTwinFromPersistenceStore(string modelName, string twinId)

Parameters

modelName string

Digital twin model name.

twinId string

Digital twin identifier.

Returns

SendingResult

Handled in case of success, otherwise the method throws DigitalTwinInstantiationException with the error details.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DigitalTwinInstantiationException

An error occurred while creating a new digital twin instance.

CreateTwinFromPersistenceStore(string, string, object)

Create a new digital twin instance of the specified simulation modelName. This method first tries to create a new twin instance from a persistence store if it is enabled. If a persistence store is not enabled or if the twin instance is not found there, then the property values of the specified fallback defaultInstance are used to create and initialize a new twin instance.

SendingResult CreateTwinFromPersistenceStore(string modelName, string twinId, object defaultInstance)

Parameters

modelName string

Digital twin model name.

twinId string

Digital twin identifier.

defaultInstance object

Digital twin instance to create. It could an object of a real digital twin model type or simply an anonymous object with a set of digital twin model's properties and their initial values.

Returns

SendingResult

Handled in case of success, otherwise the method throws DigitalTwinInstantiationException with the error details.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DigitalTwinInstantiationException

An error occurred while creating a new digital twin instance.

Delay(TimeSpan)

Delays the wake-up for the current instance for the specified delay.

SendingResult Delay(TimeSpan delay)

Parameters

delay TimeSpan

TimeSpan for simulation time delay.

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DelayIndefinitely()

Delays calling the ProcessModel(ProcessingContext, TDigitalTwin, DateTimeOffset) method for this instance forever. Users can interrupt this infinite delay later by calling RunThisTwin() for this instance within the ProcessMessages(ProcessingContext, TDigitalTwin, IEnumerable<TMessage>) method call.

SendingResult DelayIndefinitely()

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DeleteThisTwin()

Delete this simulation twin instance (itself).

SendingResult DeleteThisTwin()

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DeleteTwin(string, string)

Delete a digital twin instance of the specified simulation modelName.

SendingResult DeleteTwin(string modelName, string twinId)

Parameters

modelName string

Digital twin model name.

twinId string

Digital twin identifier.

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

EmitTelemetry(string, byte[])

Sends a telemetry message to the corresponding real-time digital twin instance. The twin ids for both, sending digital twin in a simulation model and the receiving twin in the real-time model are the same.

SendingResult EmitTelemetry(string modelName, byte[] message)

Parameters

modelName string

Real-time digital twin model name.

message byte[]

The JSON-serialized message to send.

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DigitalTwinProcessingException

An error occurred while processing the message by digital twin.

EmitTelemetry(string, object)

Sends a telemetry message to the corresponding real-time digital twin instance. The twin ids for both, sending digital twin in a simulation model and the receiving twin in the real-time model are the same.

SendingResult EmitTelemetry(string modelName, object message)

Parameters

modelName string

Real-time digital twin model name.

message object

The message to serialize and send.

Returns

SendingResult

Handled in case of success, otherwise the method returns NotHandled.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

DigitalTwinProcessingException

An error occurred while processing the message by digital twin.

GetSimulationTimeIncrement()

Get a simulation time increment.

TimeSpan GetSimulationTimeIncrement()

Returns

TimeSpan

TimeSpan for the simulation time increment.

Exceptions

ModelSimulationException

The exception is thrown if the current digital twin model does not support simulation.

RunThisTwin()

Adds this simulation twin instance (itself) to the end of the priority queue for running the ProcessModel(ProcessingContext, TDigitalTwin, DateTimeOffset) method for it at the current simulation time.

void RunThisTwin()

StopSimulation()

Stop the currently running simulation.

void StopSimulation()