Interface SimulationController


public interface SimulationController
The SimulationController interface is used to interact with the running DigitalTwin simulation.
  • Method Details

    • getSimulationTimeIncrement

      Duration getSimulationTimeIncrement()

      Retrieves the current simulation time increment.

      Returns:
      the simulation time increment.
    • getSimulationStartTime

      Date getSimulationStartTime()

      Retrieves the simulation start time.

      Returns:
      the simulation start time.
    • delay

      void delay(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. if the delay was not processed.
    • delayIndefinitely

      void delayIndefinitely()

      Delay simulation processing for this DigitalTwin instance, indefinitely.

      Simulation processing will be delayed until this instance is run with runThisInstance().

      if the delay was not processed.
    • emitTelemetry

      CompletableFuture<SendingResult> emitTelemetry(String modelName, byte[] telemetryMessage)

      Asynchronously send a JSON serialized message to a DigitalTwin instance that will be processed by the DigitalTwin models MessageProcessor.processMessage(ProcessingContext, DigitalTwinBase, byte[]) method.

      Parameters:
      modelName - the model to send the messages too.
      telemetryMessage - a blob representing a JSON serialized messages.
      Returns:
      SendingResult.Handled if the messages were processed, SendingResult.Enqueued if the messages are in process of being handled, or SendingResult.NotHandled if the delay was not processed.
    • createInstance

      <T extends DigitalTwinBase<T>> CompletableFuture<CreateResult> createInstance(String modelName, 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.Handled if the instance was created, SendingResult.Enqueued if the instance is in process of being created, or SendingResult.NotHandled if the instance could not be created.
    • deleteInstance

      CompletableFuture<DeleteResult> deleteInstance(String modelName, String instanceId)
      Delete and remove a digital twin instance from simulation processing.
      Parameters:
      modelName - the model name.
      instanceId - the instance id.
      Returns:
      SendingResult.Handled if the instance was deleted, SendingResult.Enqueued if the instance is in process of being deleted, or SendingResult.NotHandled if the instance could not be deleted.
    • deleteThisInstance

      CompletableFuture<DeleteResult> 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 models SimulationProcessor.processModel(ProcessingContext, DigitalTwinBase, Date) implementation. This will cause the simulation sub-system to run this instance during the current simulation step.
    • stopSimulation

      SimulationStatus stopSimulation()
      Stop the simulation.
      Returns:
      a SimulationStatus.InstanceRequestedStop.