Interface ISimulationController
- Namespace
- Scaleout.Modules.DigitalTwin.Abstractions
- Assembly
- Scaleout.Modules.DigitalTwin.Abstractions.dll
The methods of this interface allow user to control all aspects of digital twin's model simulation process.
public interface ISimulationController
Properties
SimulationStartTime
Returns the simulation start time in UTC.
DateTimeOffset SimulationStartTime { get; }
Property Value
- DateTimeOffset
The simulation start time.
Methods
CreateTwinAsync(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.
Task CreateTwinAsync(string modelName, string twinId, object newInstance)
Parameters
modelNamestringDigital twin model name.
twinIdstringDigital twin identifier.
newInstanceobjectDigital 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
- Task
The task object representing the asynchronous operation.
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.
CreateTwinFromPersistenceStoreAsync(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.
Task CreateTwinFromPersistenceStoreAsync(string modelName, string twinId)
Parameters
Returns
- Task
The task object representing the asynchronous operation.
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.
CreateTwinFromPersistenceStoreAsync(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.
Task CreateTwinFromPersistenceStoreAsync(string modelName, string twinId, object defaultInstance)
Parameters
modelNamestringDigital twin model name.
twinIdstringDigital twin identifier.
defaultInstanceobjectDigital 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
- Task
The task object representing the asynchronous operation.
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.
void Delay(TimeSpan delay)
Parameters
Exceptions
- ModelSimulationException
The exception is thrown if the current digital twin model does not support simulation.
DelayIndefinitely()
Delays calling the ProcessModelAsync(ProcessingContext<TDigitalTwin>, TDigitalTwin, DateTimeOffset) method for this instance forever. Users can interrupt this infinite delay later by calling RunThisTwin() for this instance within the ProcessMessageAsync(ProcessingContext<TDigitalTwin>, TDigitalTwin, byte[]) method call.
void DelayIndefinitely()
Exceptions
- ModelSimulationException
The exception is thrown if the current digital twin model does not support simulation.
DeleteThisTwinAsync()
Delete this simulation twin instance (itself).
Task DeleteThisTwinAsync()
Returns
- Task
The task object representing the asynchronous operation.
Exceptions
- ModelSimulationException
The exception is thrown if the current digital twin model does not support simulation.
DeleteTwinAsync(string, string)
Delete a digital twin instance of the specified simulation modelName.
Task DeleteTwinAsync(string modelName, string twinId)
Parameters
Returns
- Task
The task object representing the asynchronous operation.
Exceptions
- ModelSimulationException
The exception is thrown if the current digital twin model does not support simulation.
EmitTelemetryAsync(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.
Task EmitTelemetryAsync(string modelName, byte[] message)
Parameters
modelNamestringReal-time digital twin model name.
messagebyte[]The JSON-serialized message to send.
Returns
- Task
The task object representing the asynchronous operation.
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
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 ProcessModelAsync(ProcessingContext<TDigitalTwin>, TDigitalTwin, DateTimeOffset) method for it at the current simulation time.
void RunThisTwin()
StopSimulation()
Stop the currently running simulation.
void StopSimulation()