Class ProcessingContext<TDigitalTwin>
- Namespace
- Scaleout.Modules.DigitalTwin.Abstractions
- Assembly
- Scaleout.Modules.DigitalTwin.Abstractions.dll
Message processing context for currently processing messages. It allows sending messages back to a data source where the messages are originated from.
public abstract class ProcessingContext<TDigitalTwin> where TDigitalTwin : DigitalTwinBase<TDigitalTwin>
Type Parameters
TDigitalTwin
- Inheritance
-
ProcessingContext<TDigitalTwin>
- Inherited Members
Properties
AnomalyDetectionProviders
Returns the collection of registered anomaly detection providers the model has access to.
public abstract Dictionary<string, IAnomalyDetectionProvider> AnomalyDetectionProviders { get; }
Property Value
AzureDigitalTwinsProvider
Returns a reference to registered AzureDigitalTwins provider the model is using. Azure Digital Twins must be configured as a persistence provider in the ScaleOut Digital Twins service, and the model must be configured to use it in appsettings.json.
public abstract IAzureDigitalTwinsProvider AzureDigitalTwinsProvider { get; }
Property Value
- IAzureDigitalTwinsProvider
The AzureDigitalTwins provider used by the model.
DigitalTwinModel
Digital twin model name.
public abstract string DigitalTwinModel { get; }
Property Value
SharedGlobalData
Gets an ISharedData instance for accessing objects that are shared globally between all models.
public abstract ISharedData SharedGlobalData { get; }
Property Value
SharedModelData
Gets an ISharedData instance for accessing shared objects that are associated with the model being processed.
public abstract ISharedData SharedModelData { get; }
Property Value
SimulationController
Returns the ISimulationController interface to control all aspects of model simulation.
public abstract ISimulationController SimulationController { get; }
Property Value
- ISimulationController
Get the ISimulationController interface.
Methods
GetCurrentTime()
Returns the current time in UTC. If model simulation is active the method returns the current simulation time, otherwise it returns the current UTC time.
public abstract DateTimeOffset GetCurrentTime()
Returns
- DateTimeOffset
The current time - either the current system time or the current simulation time if simulation process is active.
LogMessageAsync(LogSeverity, string)
Logs a message that is visible in the ScaleOut Digital Twins UI.
public abstract Task LogMessageAsync(LogSeverity severity, string message)
Parameters
severityLogSeverityThe severity level for the specified message.
messagestringThe user message to log.
Returns
- Task
The task object representing the asynchronous operation.
RemoveRealTimeTwinAsync(string, string)
Deletes a real-time twin instance.
public abstract Task<DeleteResult> RemoveRealTimeTwinAsync(string targetTwinModel, string targetTwinId)
Parameters
Returns
- Task<DeleteResult>
DeleteResult indicating the result of the delete operation.
SendAlertAsync(AlertMessage)
Sends an alert using the alerting provider that is associated with the digital twin model.
public abstract Task SendAlertAsync(AlertMessage alertMessage)
Parameters
alertMessageAlertMessageThe provided object contains information about the alert data, as well as the provider to target.
Returns
- Task
The task object representing the asynchronous operation.
SendToDataSourceAsync(byte[])
Sends a message back to a data source origination point (e.g. IoT device). When sending a message to the ScaleOut Messaging REST service as a data source, the message content must be JSON encoded.
public abstract Task SendToDataSourceAsync(byte[] message)
Parameters
messagebyte[]JSON encoded message as byte[].
Returns
- Task
The task object representing the asynchronous operation.
SendToDataSourceAsync(IEnumerable<byte[]>)
Sends a list of messages back to a data source origination point (e.g. IoT device). When sending messages to the ScaleOut Messaging REST service as a data source, each message must be JSON encoded.
public abstract Task SendToDataSourceAsync(IEnumerable<byte[]> messages)
Parameters
messagesIEnumerable<byte[]>JSON encoded messages as a list of byte[].
Returns
- Task
The task object representing the asynchronous operation.
SendToTwinAsync(string, string, byte[])
Sends message to a different digital twin in twin's hierarchy.
public abstract Task SendToTwinAsync(string targetTwinModel, string targetTwinId, byte[] message)
Parameters
targetTwinModelstringDigital twin model name.
targetTwinIdstringDigital twin identifier.
messagebyte[]JSON encoded message as byte[].
Returns
- Task
The task object representing the asynchronous operation.
SendToTwinAsync(string, string, IEnumerable<byte[]>)
Sends a list of messages to a different digital twin in twin's hierarchy.
public abstract Task SendToTwinAsync(string targetTwinModel, string targetTwinId, IEnumerable<byte[]> messages)
Parameters
targetTwinModelstringDigital twin model name.
targetTwinIdstringDigital twin identifier.
messagesIEnumerable<byte[]>JSON encoded messages as a list of byte[].
Returns
- Task
The task object representing the asynchronous operation.
StartTimerAsync(string, TimeSpan, TimerType, TimerAsyncHandler<TDigitalTwin>)
Starts a new timer for the digital twin whose message is currently being processed.
public abstract Task<TimerActionResult> StartTimerAsync(string timerName, TimeSpan interval, TimerType type, TimerAsyncHandler<TDigitalTwin> timerCallback)
Parameters
timerNamestringThe timer name.
intervalTimeSpanThe timer interval.
typeTimerTypeThe type of the timer.
timerCallbackTimerAsyncHandler<TDigitalTwin>A function representing a user-defined timer callback method to be executed.
Returns
- Task<TimerActionResult>
Success if the timer was started successfully, otherwise one of the following error codes is returned: FailedTooManyTimers when the maximum number of timers is reached or FailedInternalError if an error occurred during the method call.
StopTimerAsync(string)
Stops the specified timer.
public abstract Task<TimerActionResult> StopTimerAsync(string timerName)
Parameters
timerNamestringThe timer name.
Returns
- Task<TimerActionResult>
Success if the timer was stopped successfully, otherwise one of the following error codes is returned: FailedNoSuchTimer when the specified timer was not found or FailedInternalError if an error occurred during the method call.