Class ProcessingContext
- All Implemented Interfaces:
Serializable
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Date
Retrieves the current time.abstract String
Retrieve the unique Identifier for a DataSource (matches the Device/Datasource/Real-time twin ID)abstract String
Retrieve the model for a DigitalTwin (matches the model of a Device/Datasource/real-time twin)abstract PersistenceProvider
Returns the configured persistence provider or null if no persistence provider configuration can be found.abstract SimulationController
Retrieve the runningSimulationController
or null if no simulation is running.abstract void
logMessage
(Level severity, String message) Logs a message to the real-time digital twin cloud service.abstract SendingResult
sendAlert
(String alertingProviderName, AlertMessage alert) This method sends an alert message to supported systems.abstract SendingResult
sendToDataSource
(byte[] payload) Sends a message to a data source.abstract SendingResult
sendToDataSource
(Object jsonSerializableMessage) Sends a message to a data source.abstract SendingResult
sendToDataSource
(List<Object> jsonSerializableMessages) Sends a list of messages to a data source.abstract SendingResult
sendToDigitalTwin
(String model, String id, byte[] payload) This method sends a serialized JSON message to a real-time digital twinabstract SendingResult
sendToDigitalTwin
(String model, String id, Object jsonSerializableMessage) This method sends a serialized JSON message to a real-time digital twinabstract SendingResult
sendToDigitalTwin
(String model, String id, String payload) This method sends a JSON message to a real-time digital twinabstract SendingResult
sendToDigitalTwin
(String model, String id, List<byte[]> payload) This method sends a list of serialized JSON message to a real-time digital twinabstract <T extends DigitalTwinBase>
TimerActionResultstartTimer
(String timerName, Duration interval, TimerType timerType, TimerHandler<T> timerHandler) Starts a new timer for the digital twinabstract TimerActionResult
Stops the specified timer.
-
Constructor Details
-
ProcessingContext
public ProcessingContext()
-
-
Method Details
-
sendToDataSource
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
-
sendToDataSource
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:
jsonSerializableMessage
- a JSON serializable message.- Returns:
- the sending result
-
sendToDataSource
Sends a list of messages 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.processMessages(ProcessingContext, DigitalTwinBase, Iterable)
.- Parameters:
jsonSerializableMessages
- a list of JSON serializable messages.- Returns:
- the sending result
-
sendToDigitalTwin
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 twinid
- the id of the digital twinpayload
- the serialized JSON message- Returns:
- the sending result
-
sendToDigitalTwin
public abstract SendingResult sendToDigitalTwin(String model, String id, Object jsonSerializableMessage) 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 twinid
- the id of the digital twinjsonSerializableMessage
- a JSON serializable message object- Returns:
- the sending result
-
sendToDigitalTwin
This method sends a 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 twinid
- the id of the digital twinpayload
- the JSON message- Returns:
- the sending result
-
sendToDigitalTwin
This method sends a list of 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 twinid
- the id of the digital twinpayload
- the JSON message- Returns:
- the sending result
-
sendAlert
This method sends an alert message to supported systems. See "TODO: Link to docs" for more details on supported systems.
When a model is deployed, an optional alerting provider configuration can be supplied. The provider name corresponds to the name of the configured alerting provider. For example, if an alerting provider configuration is called "SREPod1", then the processing context will send an alert message to the alerting provider configured with the name "SREPod1".
If the message cannot be sent then
SendingResult.NotHandled
will be returned. If the message is sent and in process of sending thenSendingResult.Enqueued
will be returned. Once the message is successfully sent then the returned enum will be changed toSendingResult.Handled
.- Parameters:
alertingProviderName
- the alerting provider name. Note, must match a valid configuration.alert
- the alert message.- Returns:
- the sending result.
-
getPersistenceProvider
Returns the configured persistence provider or null if no persistence provider configuration can be found.- Returns:
- a PersistenceProvider .
-
getDataSourceId
Retrieve the unique Identifier for a DataSource (matches the Device/Datasource/Real-time twin ID)- Returns:
- the digital twin id
-
getDigitalTwinModel
Retrieve the model for a DigitalTwin (matches the model of a Device/Datasource/real-time twin)- Returns:
- the digital twin model
-
logMessage
Logs a message to the real-time digital twin cloud service. Note: the only supported severity levels are: INFO, WARN, and SEVERE- Parameters:
severity
- the severity of the log messagemessage
- the message to log
-
startTimer
public abstract <T extends DigitalTwinBase> TimerActionResult startTimer(String timerName, Duration interval, TimerType timerType, TimerHandler<T> timerHandler) Starts a new timer for the digital twin- Type Parameters:
T
- the type of the digital twin- Parameters:
timerName
- the timer nameinterval
- the timer intervaltimerType
- the timer typetimerHandler
- the time handler callback- Returns:
- returns
TimerActionResult.Success
if the timer was started,TimerActionResult.FailedTooManyTimers
if too many timers exist, orTimerActionResult.FailedInternalError
if an unexpected error occurs.
-
stopTimer
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, orTimerActionResult.FailedInternalError
if an unexpected error occurs.
-
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
Retrieve the runningSimulationController
or null if no simulation is running.- Returns:
- the
SimulationController
or null if no simulation is running.
-