Class TransitionOptions
(experimental) Properties for options of state transition.
Inheritance
Implements
Namespace: Amazon.CDK.AWS.IoTEvents
Assembly: Amazon.CDK.AWS.IoTEvents.dll
Syntax (csharp)
public class TransitionOptions : Object, ITransitionOptions
Syntax (vb)
Public Class TransitionOptions
Inherits Object
Implements ITransitionOptions
Remarks
Stability: Experimental
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.IoTEvents;
using Amazon.CDK.AWS.IoTEvents.Actions;
using Amazon.CDK.AWS.Lambda;
IFunction func;
var input = new Input(this, "MyInput", new InputProps {
InputName = "my_input", // optional
AttributeJsonPaths = new [] { "payload.deviceId", "payload.temperature" }
});
var warmState = new State(new StateProps {
StateName = "warm",
OnEnter = new [] { new Event {
EventName = "test-enter-event",
Condition = Expression.CurrentInput(input),
Actions = new [] { new LambdaInvokeAction(func) }
} },
OnInput = new [] { new Event { // optional
EventName = "test-input-event",
Actions = new [] { new LambdaInvokeAction(func) } } },
OnExit = new [] { new Event { // optional
EventName = "test-exit-event",
Actions = new [] { new LambdaInvokeAction(func) } } }
});
var coldState = new State(new StateProps {
StateName = "cold"
});
// transit to coldState when temperature is less than 15
warmState.TransitionTo(coldState, new TransitionOptions {
EventName = "to_coldState", // optional property, default by combining the names of the States
When = Expression.Lt(Expression.InputAttribute(input, "payload.temperature"), Expression.FromString("15")),
Executing = new [] { new LambdaInvokeAction(func) }
});
// transit to warmState when temperature is greater than or equal to 15
coldState.TransitionTo(warmState, new TransitionOptions {
When = Expression.Gte(Expression.InputAttribute(input, "payload.temperature"), Expression.FromString("15"))
});
new DetectorModel(this, "MyDetectorModel", new DetectorModelProps {
DetectorModelName = "test-detector-model", // optional
Description = "test-detector-model-description", // optional property, default is none
EvaluationMethod = EventEvaluation.SERIAL, // optional property, default is iotevents.EventEvaluation.BATCH
DetectorKey = "payload.deviceId", // optional property, default is none and single detector instance will be created and all inputs will be routed to it
InitialState = warmState
});
Synopsis
Constructors
TransitionOptions() |
Properties
EventName | (experimental) The name of the event. |
Executing | (experimental) The actions to be performed with the transition. |
When | (experimental) The condition that is used to determine to cause the state transition and the actions. |
Constructors
TransitionOptions()
public TransitionOptions()
Properties
EventName
(experimental) The name of the event.
public string EventName { get; set; }
Property Value
System.String
Remarks
Default: string combining the names of the States as ${originStateName}_to_${targetStateName}
Stability: Experimental
Executing
(experimental) The actions to be performed with the transition.
public IAction[] Executing { get; set; }
Property Value
IAction[]
Remarks
Default: - no actions will be performed
Stability: Experimental
When
(experimental) The condition that is used to determine to cause the state transition and the actions.
public Expression When { get; set; }
Property Value
Remarks
When this was evaluated to true
, the state transition and the actions are triggered.
Stability: Experimental