// TODO: Put strings into the resources. // bool P_Signal(ITriggerSignalProperties signalProps, Func <ITriggerSignalProperties, TriggerSignalState, TriggerSignalState> condition) { signalProps.EnsureNotNull(nameof(signalProps)); signalProps.Trigger.ArgProp($"{nameof(signalProps)}.{nameof(signalProps.Trigger)}").EnsureIs(operand: this); condition.EnsureNotNull(nameof(condition)); // TriggerSignalEventArgs signalEventArgs = default; for (; P_CanSignal();) { var inState = itrlck.Get(ref _signalState); var outState = condition(arg1: signalProps, arg2: inState); if (ReferenceEquals(inState, outState)) { return(false); } else if (outState.SignalCounter < (inState?.SignalCounter ?? 0L)) { throw new EonException(message: $"Не выполняется условие '{nameof(inState)}.{nameof(inState.SignalCounter)} <= {nameof(outState)}.{nameof(outState.SignalCounter)}.'"); } else if (itrlck.UpdateBool(location: ref _signalState, value: outState, comparand: inState)) { if (P_CanSignal() && (inState?.SignalCounter ?? 0L) != outState.SignalCounter) { itrlck.SetNull(location: ref _nextSignalAwaitable)?.TrySetResult(result: signalEventArgs = signalEventArgs ?? new TriggerSignalEventArgs(signalProps: signalProps)); return(true); } else { return(false); } } } return(false); }
protected override void SignalCondition(ITriggerSignalProperties signalProps, TriggerSignalState inState, out TriggerSignalState outState) { signalProps.EnsureNotNull(nameof(signalProps)); // if ((inState is null) || inState.SignalCounter == 0 || signalProps.Timestamp.Subtract(inState.LastSignalTimestamp) > _signalFrequencyLimit) { base.SignalCondition(signalProps: signalProps, inState: inState, outState: out outState); }
public TriggerSignalProperties(ITrigger trigger, ITriggerSignalProperties source, ArgumentPlaceholder <DateTimeOffset> timestamp = default) { trigger.EnsureNotNull(nameof(trigger)); source.EnsureNotNull(nameof(source)); // _trigger = trigger; _source = source; _timestamp = timestamp.Substitute(value: source.Timestamp); _correlationId = source.CorrelationId; _explicitlyDefinedProps = timestamp.HasExplicitValue ? ExplicitlyDefinedProps.Timestamp : ExplicitlyDefinedProps.None; }
// TODO: Put strings into the resources. // void P_ResetTrigger_OnSignal(ITriggerSignalProperties signalProps, IDisposable subscription) { signalProps.EnsureNotNull(nameof(signalProps)); subscription.EnsureNotNull(nameof(subscription)); // var resetTrigger = TryReadDA(ref _resetTrigger); var resetTriggerSubscription = TryReadDA(ref _resetTriggerSignalSubscription, considerDisposeRequest: true); if (ReferenceEquals(resetTrigger, signalProps.Trigger) && ReferenceEquals(resetTriggerSubscription, subscription)) { try { if (signalProps.Trigger.IsDisabled) { return; } } catch (ObjectDisposedException) { return; } if (IsActive) { TaskUtilities.RunOnDefaultScheduler(factory: () => resetComponentAsync(locTriggerSignalProps: signalProps)); } } // async Task resetComponentAsync(ITriggerSignalProperties locTriggerSignalProps) { try { using (var localCtx = ContextUtilities.Create(fullCorrelationId: signalProps.CorrelationId)) await P_ResetComponentAsync(triggerSignalProps : locTriggerSignalProps, doFailureResponse : true, ctx : localCtx).ConfigureAwait(false); } catch (Exception exception) { if (!((exception is ObjectDisposedException && IsDisposeRequested) || exception.HasSingleBaseExceptionOf <OperationCanceledException>() || exception.IsObserved())) { #if !DO_NOT_USE_EON_LOGGING_API this .IssueError( message: $"Сбой установки (замены) компонента, инициированной триггером.{Environment.NewLine}\tСобытие-инициатор:{locTriggerSignalProps.FmtStr().GNLI2()}", error: exception, includeErrorInIssueFaultException: true, severityLevel: exception.GetMostHighSeverityLevel(baseLevel: SeverityLevel.Medium)); #endif } } } }
public static ITriggerSignalProperties GetOriginator(this ITriggerSignalProperties signalProps) { signalProps.EnsureNotNull(nameof(signalProps)); // var source = signalProps; for (; ;) { var nextSource = source.Source; if (nextSource is null) { return(source); } else { source = nextSource; } } }
protected virtual void SignalCondition(ITriggerSignalProperties signalProps, TriggerSignalState inState, out TriggerSignalState outState) { signalProps.EnsureNotNull(nameof(signalProps)); // if (inState is null) { outState = new TriggerSignalState(signalCounter: 1L, lastSignalTimestamp: signalProps.Timestamp); } else { switch (inState.SignalCounter) { case long.MaxValue: outState = inState; break; default: outState = new TriggerSignalState(signalCounter: inState.SignalCounter + 1L, lastSignalTimestamp: signalProps.Timestamp); break; } } }
public TriggerSignalEventArgs(ITriggerSignalProperties signalProps) { signalProps.EnsureNotNull(nameof(signalProps)); // _signalProperties = signalProps; }