protected override void OnStateMachineStateChanged(StateMachine stateMachine, StateMachineStateChangedEventArgs eventArgs, TimeSpan previousStateDuration) { JsonObject startData = CreateDataPackage(stateMachine.Id, EventType.OutputActuatorStateChanged); startData.SetNamedValue("state", JsonValue.CreateStringValue(eventArgs.NewValue)); startData.SetNamedValue("kind", JsonValue.CreateStringValue("Start")); Task.Run(() => SendToAzureEventHubAsync(startData)); JsonObject endData = CreateDataPackage(stateMachine.Id, EventType.OutputActuatorStateChanged); endData.SetNamedValue("state", JsonValue.CreateStringValue(eventArgs.OldValue)); endData.SetNamedValue("kind", JsonValue.CreateStringValue("End")); endData.SetNamedValue("duration", JsonValue.CreateNumberValue(previousStateDuration.TotalSeconds)); Task.Run(() => SendToAzureEventHubAsync(endData)); }
protected virtual void OnStateMachineStateChanged(StateMachine stateMachine, StateMachineStateChangedEventArgs eventArgs, TimeSpan previousStateDuration) { }