Class ProcessingContext<T extends DigitalTwinBase<T>>

java.lang.Object
com.scaleoutsoftware.digitaltwin.abstractions.ProcessingContext<T>
Type Parameters:
T - the type of the digital twin
All Implemented Interfaces:
Serializable

public abstract class ProcessingContext<T extends DigitalTwinBase<T>> extends Object implements Serializable
Context object that allows the user to send a message to a DataSource.
See Also:
  • Constructor Details

    • ProcessingContext

      public ProcessingContext()
      Default constructor.
  • Method Details

    • sendToDataSource

      public abstract CompletableFuture<SendingResult> sendToDataSource(byte[] payload)

      Sends a message to a data source. This will route messages through the connector back to the data source.

      if the datasource is simulation instance, then the message will be sent to the simulation model's implementation of the MessageProcessor.

      Parameters:
      payload - the message (as a serialized JSON string)
      Returns:
      the sending result
    • sendToDigitalTwin

      public abstract CompletableFuture<SendingResult> sendToDigitalTwin(String model, String id, byte[] payload)

      This method sends a serialized JSON message to a real-time digital twin

      Note, the message contents must be serialized so that the registered message type of the digital twin model will be sufficient to deserialize the message.

      Parameters:
      model - the model of the digital twin
      id - the id of the digital twin
      payload - the serialized JSON message
      Returns:
      the sending result
    • sendAlert

      public abstract CompletableFuture<Void> sendAlert(AlertMessage alert)

      This method sends an alert message to configured systems.

      If the message cannot be sent then the returned CompletableFuture will complete exceptionally.

      Parameters:
      alert - the alert message.
      Returns:
      the sending result.
    • getAzureDigitalTwinsProvider

      public abstract AzureDigitalTwinsProvider getAzureDigitalTwinsProvider()
      Returns an AzureDigitalTwinsProvider or null if no AzureDigitalTwinsProvider configuration can be found.
      Returns:
      a AzureDigitalTwinsProvider or null.
    • getDataSourceId

      public abstract String getDataSourceId()
      Retrieve the unique Identifier for a DataSource (matches the Device/Datasource/Real-time twin ID)
      Returns:
      the digital twin id
    • getDigitalTwinModel

      public abstract String getDigitalTwinModel()
      Retrieve the model for a DigitalTwin (matches the model of a Device/Datasource/real-time twin)
      Returns:
      the digital twin model
    • logMessage

      public abstract CompletableFuture<Void> logMessage(Level severity, String message)
      Log a message to the real-time digital twin UI. Note: the only supported severity levels are: INFO, WARN, and SEVERE
      Parameters:
      severity - the severity of the log message
      message - the message to log
      Returns:
      A future that will complete successfully with no result or exceptionally.
    • removeRealTimeTwin

      public abstract CompletableFuture<DeleteResult> removeRealTimeTwin(String targetTwinModel, String targetTwinId)
      Delete the target real-time twin instance.
      Parameters:
      targetTwinModel - the model of the real-time twin instance
      targetTwinId - the id of the real-time twin instance
      Returns:
      a completable future that will complete with a DeleteResult indicating the status of the operation, or exceptionally indicating that an error occurred.
    • startTimer

      public abstract TimerActionResult startTimer(String timerName, Duration interval, TimerType timerType, TimerHandler<T> timerHandler, Class<? extends TimerHandler<T>> timerHandlerClass)
      Starts a new timer for the digital twin
      Parameters:
      timerName - the timer name
      interval - the timer interval
      timerType - the timer type
      timerHandler - the time handler callback
      timerHandlerClass - the timer handler callback class
      Returns:
      returns TimerActionResult.Success if the timer was started, TimerActionResult.FailedTooManyTimers if too many timers exist, or TimerActionResult.FailedInternalError if an unexpected error occurs.
    • stopTimer

      public abstract TimerActionResult stopTimer(String timerName)
      Stops the specified timer.
      Parameters:
      timerName - the timer name.
      Returns:
      returns TimerActionResult.Success if the timer was stopped, TimerActionResult.FailedNoSuchTimer if no timer exists with that name, or TimerActionResult.FailedInternalError if an unexpected error occurs.
    • getCurrentTime

      public abstract Date getCurrentTime()
      Retrieves the current time. If the model (simulation or real-time) is running inside of a simulation then the simulation time will be returned.
      Returns:
      The current time (real time, or simulation if running under simulation).
    • getSimulationController

      public abstract SimulationController getSimulationController()
      Retrieve the running SimulationController or null if no simulation is running.
      Returns:
      the SimulationController or null if no simulation is running.
    • getSharedModelData

      public abstract SharedData getSharedModelData()
      Retrieve a SharedData accessor for this model's shared data.
      Returns:
      a SharedData instance.
    • getSharedGlobalData

      public abstract SharedData getSharedGlobalData()
      Retrieve a SharedData accessor for globally shared data.
      Returns:
      a SharedData instance.