Example #1
0
 protected ActivatableXAppScopeInstanceBase(IXAppScopeInstance scope, TDescription description)
     : base(scope: scope, description: description)
 {
     //
     _isAutoActivationEnabled            = description.IsAutoActivationEnabled();
     _hasDeactivatedBeforeInitialization = false;
 }
Example #2
0
 public ResetServant(IXAppScopeInstance scope, TDescription description)
     : base(scope: scope, description: description)
 {
     // TODO_HIGH: Implement lock naming — $"{nameof(ResetServant<TDescription>)}.{nameof(_resetLock)}".
     //
     _resetLock    = new SemaphoreSlim(initialCount: 1, maxCount: 1);
     _resetCounter = -1L;
 }
Example #3
0
 public FrequencyLimitTrigger(IXAppScopeInstance scope, TDescription description)
     : base(scope: scope, description: description)
 {
     _signalFrequencyLimit = description.SignalFrequencyLimit;
 }
Example #4
0
 public XAppLocalPublisher(IXAppScopeInstance scope, TDescription description)
     : base(scope: scope, description: description)
 {
 }
Example #5
0
 public PeriodTrigger(IXAppScopeInstance scope, TDescription description)
     : base(scope, description)
 {
     _period         = description.Period;
     _periodVariance = description.PeriodVariance;
 }
Example #6
0
 public ActivationList(IXAppScopeInstance scope, TDescription description)
     : base(scope: scope, description: description)
 {
 }
Example #7
0
        async Task P_DoActivateAsync(IRunControlAttemptState state, Func <IRunControlAttemptState, Task> continuation, bool componentDisability)
        {
            state.EnsureNotNull(nameof(state));
            continuation.EnsureNotNull(nameof(continuation));
            //
            if (componentDisability)
            {
                await continuation(arg : state).ConfigureAwait(false);
            }
            else
            {
                var resetTrigger             = ReadIA(ref _resetTrigger, isNotRequired: true, locationName: nameof(_resetTrigger));
                IXAppScopeInstance component = default;
                IDisposable        resetTriggerSubscription = default;
                try {
                    component =
                        await
                        P_ResetComponentAsync(breakCondition : breakCondition, doFailureResponse : false)
                        .ConfigureAwait(false);
                    await continuation(arg : state).ConfigureAwait(false);

                    if (resetTrigger != null)
                    {
                        WriteDA(
                            location: ref _resetTriggerSignalSubscription,
                            value: resetTriggerSubscription = TriggerUtilities.SubscribeToSignal(trigger: resetTrigger, onSignal: P_ResetTrigger_OnSignal));
                        await resetTrigger.ActivateControl.StartAsync().ConfigureAwait(false);
                    }
                }
                catch (Exception exception) {
                    var caughtExceptions = new List <Exception>()
                    {
                        exception
                    };
                    if (resetTriggerSubscription != null)
                    {
                        itrlck.SetNullBool(ref _resetTriggerSignalSubscription, resetTriggerSubscription);
                        try { resetTriggerSubscription.Dispose(); }
                        catch (Exception secondException) { caughtExceptions.Add(secondException); }
                    }
                    if (component != null)
                    {
                        try {
                            await OnFreeComponentAsync(component : component).ConfigureAwait(false);

                            itrlck.SetNullBool(ref _component, component);
                        }
                        catch (Exception secondException) {
                            caughtExceptions.Add(secondException);
                        }
                    }
                    if (caughtExceptions.Count > 1)
                    {
                        throw new AggregateException(innerExceptions: caughtExceptions);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            //
            bool breakCondition(IContext locCtx)
            {
                locCtx.ThrowIfCancellationRequested();
                return(state.RunControl.HasStopRequested || HasDeactivationRequested);
            }
        }
Example #8
0
 public static Task <IList <ITriggerXInstance> > CreateInitializeAsync(ArgumentUtilitiesHandle <IEnumerable <ITriggerDescription> > descriptions, IXAppScopeInstance scope, IContext ctx = default)
 => XInstanceFactoryUtilities.CreateInitializeAppScopeInstanceAsync <ITriggerXInstance>(scope: scope, ctx: ctx, descriptions: descriptions.AsBase <IEnumerable <ITriggerDescription>, IEnumerable <IDescription> >());
Example #9
0
 protected TriggerBase(IXAppScopeInstance scope, TDescription description)
     : base(scope: scope, description: description)
 {
     //
     _isDisabled = description.IsDisabled;
 }