Interface SimulationController
-
public interface SimulationControllerThe SimulationController interface is used to interact with the running DigitalTwin simulation.
-
-
Method Summary
Modifier and Type Method Description <T extends DigitalTwinBase>
SendingResultcreateInstance(java.lang.String modelName, java.lang.String instanceId, T base)Create a new digital twin instance for simulation processing.SendingResultcreateInstanceFromPersistenceStore(java.lang.String model, java.lang.String id)Create a new digital twin instance for simulation processing from a persistence store.<T extends DigitalTwinBase>
SendingResultcreateInstanceFromPersistenceStore(java.lang.String model, java.lang.String id, T def)The twin instance will be loaded via model name and id from a persistence store.SendingResultdelay(java.time.Duration duration)Delay simulation processing for this DigitalTwin instance for a duration of time.SendingResultdelayIndefinitely()Delay simulation processing for this DigitalTwin instance, indefinitely.SendingResultdeleteInstance(java.lang.String modelName, java.lang.String instanceId)Delete and remove a digital twin instance from simulation processing.SendingResultdeleteThisInstance()Delete and remove this digital twin instance from simulation processing.SendingResultemitTelemetry(java.lang.String modelName, byte[] telemetryMessage)Asynchronously send a JSON serialized message to a DigitalTwin instance that will be processed by the DigitalTwin modelsMessageProcessor.processMessages(ProcessingContext, DigitalTwinBase, Iterable)method.SendingResultemitTelemetry(java.lang.String modelName, java.lang.Object jsonSerializableMessage)Asynchronously send a JSON serializable message to a DigitalTwin instance that will be processed by the DigitalTwin modelsMessageProcessor.processMessages(ProcessingContext, DigitalTwinBase, Iterable)method.java.util.DategetSimulationStartTime()Retrieves the simulation start time.java.time.DurationgetSimulationTimeIncrement()Retrieves the current simulation time increment.voidrunThisInstance()Run this instance during this simulation step.SimulationStatusstopSimulation()Stop the simulation.
-
-
-
Method Detail
-
getSimulationTimeIncrement
java.time.Duration getSimulationTimeIncrement()
Retrieves the current simulation time increment.
- Returns:
- the simulation time increment.
-
getSimulationStartTime
java.util.Date getSimulationStartTime()
Retrieves the simulation start time.
- Returns:
- the simulation start time.
-
delay
SendingResult delay(java.time.Duration duration)
Delay simulation processing for this DigitalTwin instance for a duration of time.
Simulation processing will be delayed for the duration specified relative to the current simulation time.
Examples:
at a current simulation time of 10, an interval of 20, and a delay of 40 -- the instance would skip one cycle of processing and be processed at simulation time 50.
at a current simulation time of 10, an interval of 20, and a delay of 30 -- the instance would skip one cycle of processing and be processed at simulation time 50.
at a current simulation time of 10, an interval of 20, and a delay of 50 -- the instance would skip two cycles of processing and be processed at simulation time 70.
- Parameters:
duration- the duration to delay.- Returns:
SendingResult.Handledif the delay was processed orSendingResult.NotHandledif the delay was not processed.
-
delayIndefinitely
SendingResult delayIndefinitely()
Delay simulation processing for this DigitalTwin instance, indefinitely.
Simulation processing will be delayed until this instance is run with
runThisInstance().- Returns:
SendingResult.Handledif the delay was processed orSendingResult.NotHandledif the delay was not processed.
-
emitTelemetry
SendingResult emitTelemetry(java.lang.String modelName, byte[] telemetryMessage)
Asynchronously send a JSON serialized message to a DigitalTwin instance that will be processed by the DigitalTwin models
MessageProcessor.processMessages(ProcessingContext, DigitalTwinBase, Iterable)method.- Parameters:
modelName- the model to send the messages too.telemetryMessage- a blob representing a JSON serialized messages.- Returns:
SendingResult.Handledif the messages were processed,SendingResult.Enqueuedif the messages are in process of being handled, orSendingResult.NotHandledif the delay was not processed.
-
emitTelemetry
SendingResult emitTelemetry(java.lang.String modelName, java.lang.Object jsonSerializableMessage)
Asynchronously send a JSON serializable message to a DigitalTwin instance that will be processed by the DigitalTwin models
MessageProcessor.processMessages(ProcessingContext, DigitalTwinBase, Iterable)method.- Parameters:
modelName- the model to send the messages too.jsonSerializableMessage- an object message that is JSON serializable.- Returns:
SendingResult.Handledif the messages were processed,SendingResult.Enqueuedif the messages are in process of being handled, orSendingResult.NotHandledif the delay was not processed.
-
createInstance
<T extends DigitalTwinBase> SendingResult createInstance(java.lang.String modelName, java.lang.String instanceId, T base)
Create a new digital twin instance for simulation processing.- Type Parameters:
T- the type of the digital twin to create.- Parameters:
modelName- the model name.instanceId- the instance id.base- the instance to create.- Returns:
SendingResult.Handledif the instance was created,SendingResult.Enqueuedif the instance is in process of being created, orSendingResult.NotHandledif the instance could not be created.
-
createInstanceFromPersistenceStore
SendingResult createInstanceFromPersistenceStore(java.lang.String model, java.lang.String id)
Create a new digital twin instance for simulation processing from a persistence store. The twin instance will be loaded via model name and id from a persistence store. If no instance can be found, then an exception will be thrown and no instance will be created.- Parameters:
model- The model name.id- the instance id.- Returns:
SendingResult.Handledif the instance was created,SendingResult.Enqueuedif the instance is in process of being created, orSendingResult.NotHandledif the instance could not be created.
-
createInstanceFromPersistenceStore
<T extends DigitalTwinBase> SendingResult createInstanceFromPersistenceStore(java.lang.String model, java.lang.String id, T def)
The twin instance will be loaded via model name and id from a persistence store. The twin instance will be loaded via model name and id from a persistence store. If no instance can be found, then the default parameter instance will be used.- Type Parameters:
T- the type of the digital twin to create.- Parameters:
model- the model name.id- the instance id.def- the default instance to create.- Returns:
SendingResult.Handledif the instance was created,SendingResult.Enqueuedif the instance * is in process of being created, orSendingResult.NotHandledif the instance could not be created.
-
deleteInstance
SendingResult deleteInstance(java.lang.String modelName, java.lang.String instanceId)
Delete and remove a digital twin instance from simulation processing.- Parameters:
modelName- the model name.instanceId- the instance id.- Returns:
SendingResult.Handledif the instance was deleted,SendingResult.Enqueuedif the instance is in process of being deleted, orSendingResult.NotHandledif the instance could not be deleted.
-
deleteThisInstance
SendingResult deleteThisInstance()
Delete and remove this digital twin instance from simulation processing.- Returns:
- this local request will always return
SendingResult.Handled.
-
runThisInstance
void runThisInstance()
Run this instance during this simulation step. The instance will be run using the modelsSimulationProcessor.processModel(ProcessingContext, DigitalTwinBase, Date)implementation. This will cause the simulation sub-system to run this instance regardless of the instances currentDigitalTwinBase.NextSimulationTime.
-
stopSimulation
SimulationStatus stopSimulation()
Stop the simulation.- Returns:
- a
SimulationStatus.InstanceRequestedStop.
-
-