Class ProcessingContext
- Namespace
- Scaleout.Streaming.DigitalTwin.Core
- Assembly
- ScaleOut.Streaming.DigitalTwin.Core.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
- Inheritance
-
ProcessingContext
- 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
DataSourceId
Data source unique identifier, e.g. for IoT use case it is typically device Id, which is also used as a digital twin Id.
public abstract string DataSourceId { get; }
Property Value
DigitalTwinModel
Digital twin model type.
public abstract string DigitalTwinModel { get; }
Property Value
PersistenceProvider
Returns the reference to registered persistence provider the model is using. The name of the registered persistence provider should be specified in the model's appsettings.json file via the PersistenceProvider key. Only Azure Digital Twins Service provider is supported.
public abstract IPersistenceProvider PersistenceProvider { get; }
Property Value
- IPersistenceProvider
The registered IPersistenceProvider used by the model.
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.
LogMessage(LogSeverity, string)
Logs user message with the specified severity level.
public abstract void LogMessage(LogSeverity severity, string message)
Parameters
severity
LogSeverityThe severity level for the specified message.
message
stringThe user message to log.
SendAlert(string, AlertMessage)
Sends an alert to a given Alerting provider.
public abstract SendingResult SendAlert(string providerName, AlertMessage alertMessage)
Parameters
providerName
stringThe name of the configuration of an Alerting Provider to send the alert to.
alertMessage
AlertMessageThe provided object contains information about the alert data, as well as the provider to target.
Returns
SendToDataSource(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 SendingResult SendToDataSource(byte[] message)
Parameters
message
byte[]JSON encoded message as byte[].
Returns
- SendingResult
Enqueued when message was successfully enqueued, NotHandled otherwise.
SendToDataSource(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 SendingResult SendToDataSource(IEnumerable<byte[]> messages)
Parameters
messages
IEnumerable<byte[]>JSON encoded messages as a list of byte[].
Returns
- SendingResult
Enqueued when messages were successfully enqueued, NotHandled otherwise.
SendToDataSource(IEnumerable<object>)
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 SendingResult SendToDataSource(IEnumerable<object> messages)
Parameters
messages
IEnumerable<object>Message object to be encoded as JSON.
Returns
- SendingResult
Enqueued when messages were successfully enqueued, NotHandled otherwise.
SendToDataSource(object)
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 SendingResult SendToDataSource(object message)
Parameters
message
objectMessage object to be encoded as JSON.
Returns
- SendingResult
Enqueued when message was successfully enqueued, NotHandled otherwise.
SendToTwin(string, string, byte[])
Sends message to a different digital twin in twin's hierarchy.
public abstract SendingResult SendToTwin(string targetTwinModel, string targetTwinId, byte[] message)
Parameters
targetTwinModel
stringDigital twin model type.
targetTwinId
stringDigital twin identifier.
message
byte[]JSON encoded message as byte[].
Returns
- SendingResult
Enqueued when message was successfully enqueued, NotHandled otherwise.
SendToTwin(string, string, IEnumerable<byte[]>)
Sends a list of messages to a different digital twin in twin's hierarchy.
public abstract SendingResult SendToTwin(string targetTwinModel, string targetTwinId, IEnumerable<byte[]> messages)
Parameters
targetTwinModel
stringDigital twin model type.
targetTwinId
stringDigital twin identifier.
messages
IEnumerable<byte[]>JSON encoded messages as a list of byte[].
Returns
- SendingResult
Enqueued when messages were successfully enqueued, NotHandled otherwise.
SendToTwin(string, string, IEnumerable<object>)
Sends a list of messages to a different digital twin in twin's hierarchy.
public abstract SendingResult SendToTwin(string targetTwinModel, string targetTwinId, IEnumerable<object> messages)
Parameters
targetTwinModel
stringDigital twin model type.
targetTwinId
stringDigital twin identifier.
messages
IEnumerable<object>Messages to be encoded as JSON.
Returns
- SendingResult
Enqueued when messages were successfully enqueued, NotHandled otherwise.
SendToTwin(string, string, object)
Sends message to a different digital twin in twin's hierarchy.
public abstract SendingResult SendToTwin(string targetTwinModel, string targetTwinId, object message)
Parameters
targetTwinModel
stringDigital twin model type.
targetTwinId
stringDigital twin identifier.
message
objectMessage object to be encoded as JSON.
Returns
- SendingResult
Enqueued when message was successfully enqueued, NotHandled otherwise.
StartTimer(string, TimeSpan, TimerType, TimerHandler)
Starts a new timer for the digital twin DataSourceId.
public abstract TimerActionResult StartTimer(string timerName, TimeSpan interval, TimerType type, TimerHandler timerCallback)
Parameters
timerName
stringThe timer name.
interval
TimeSpanThe timer interval.
type
TimerTypeThe type of the timer.
timerCallback
TimerHandlerA delegate representing a user-defined timer callback static method to be executed.
Returns
- 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.
StopTimer(string)
Stops the specified timer.
public abstract TimerActionResult StopTimer(string timerName)
Parameters
timerName
stringThe timer name.
Returns
- 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.