public void HandelTermiantionTrigger(ITerminatorTrigger trigger)
        {
            //_logger.LogMessage( LogLevel.Informational, "HandelTermiantionTrigger "+ trigger.ToString());
            var timeTerminationTrigger = trigger as TimeTerminationTrigger;

            if (timeTerminationTrigger != null)
            {
                _lastTimeTerminationTrigger = timeTerminationTrigger;
                if (timeTerminationTrigger.TimerUpdateVO.TimePassed >= (_duration * 1000))
                {
                    _logger.LogMessage(LogLevel.Informational,
                                       "Exercise time is up (" + timeTerminationTrigger.TimerUpdateVO.TimePassed + ")");
                    _timeIsUp = true;
                }
            }
            else
            {
                var stateTerminationTrigger = trigger as StateTerminationTrigger;
                if (stateTerminationTrigger?.IsRoundFinished == true && _timeIsUp)
                {
                    _logger.LogMessage(LogLevel.Informational, string.Concat("Exercise terminated"));
                    OnTerminate?.Invoke(new TimerBasedTerminationVO(_lastTimeTerminationTrigger.TimerUpdateVO));
                }
            }
        }
 void IAsyncProcessHandleSetter.Error(Exception ex)
 {
     Exception    = ex;
     IsTerminated = true;
     OnTerminate?.Invoke();
     _tcs.SetException(ex);
 }
 void IAsyncProcessHandleSetter.Complete(object result)
 {
     Result       = result;
     IsTerminated = true;
     OnTerminate?.Invoke();
     _tcs.SetResult(result);
 }
Exemple #4
0
        /// <summary>
        /// Se mueve a la próxima iteración
        /// </summary>
        public bool MoveNext()
        {
            bool ret = BaseEnumerator.MoveNext();

            if (!ret)
            {
                OnTerminate?.Invoke(this, EventArgs.Empty);
            }
            return(ret);
        }
 public void HandelTermiantionTrigger(ITerminatorTrigger trigger)
 {
     if (trigger is TotalBadRunsUpdateVO && ((TotalBadRunsUpdateVO)trigger).CurrentValue >= _initVO.NumBadRuns)
     {
         _waitForShowWrong = true;
     }
     else if (_waitForShowWrong && trigger is StateTerminationTrigger && ((StateTerminationTrigger)trigger).IsRoundFinished)
     {
         //Todo verify conditional logic
         _logger.LogMessage(LogLevel.Informational, "Terminate by SurvivorTerminator");
         OnTerminate?.Invoke(new SurvivorTerminationVO());
     }
 }
    public virtual void Dispose()
    {
        SessionInterface?.Dispose();
        _network.OnDisconnectedFromSession -= OnDisconnectFromSession;

        if (LOG)
#pragma warning disable CS0162 // Unreachable code detected
        {
            Log.Info("Online interface terminating");
        }
#pragma warning restore CS0162 // Unreachable code detected

        OnTerminate?.Invoke();
    }
Exemple #7
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    OnTerminate?.Invoke();
                    container?.Stop();
                    container?.Remove();
                    container?.Dispose();
                    watcher?.Dispose();
                    container = null;
                }

                // TODO: free unmanaged resources (unmanaged objects) and override finalizer
                // TODO: set large fields to null
                disposedValue = true;
            }
        }
Exemple #8
0
        /// <summary>
        /// raw Terminate interface called by simulator, release COM object write a debug message
        /// </summary>
        public virtual void Terminate()
        {
            CasterLogger.Debug("Terminate");
            Debug.WriteLine("Terminate");
            OnTerminate?.Invoke(this, EventArgs.Empty);

            CasterLogger.Debug("Start Release COM object");
            if (simulationContext != null && simulationContext.GetType().IsCOMObject)
            {
                Marshal.FinalReleaseComObject(simulationContext);
            }

            foreach (var port in Ports)
            {
                ((CapeUnitPortBase)port.Value).Disconnect();
                ((CapeUnitPortBase)port.Value).Dispose();
            }

            CasterLogger.Debug("Terminate Done.");
            Debug.WriteLine("Terminate Done.");
        }
Exemple #9
0
    public virtual void Dispose()
    {
        Disposed = true;

        OnTerminate?.Invoke();

        _networkInterface.OnDisconnect -= InterfaceOnDisconnect;
        _networkInterface.OnConnect    -= Interface_OnConnect;

        _outgoingDataTransfers.ForEach((x) => { if (x.IsRunning)
                                                {
                                                    x.TerminateWithAbnormalFailure();
                                                }
                                       });
        _incomingDataTransfers.ForEach((x) => { if (x.IsRunning)
                                                {
                                                    x.TerminateWithAbnormalFailure();
                                                }
                                       });
        _outgoingDataTransfers.Clear();
        _incomingDataTransfers.Clear();
    }
Exemple #10
0
        private void ProcessTrigger(ITerminatorTrigger trigger)
        {
            switch (trigger)
            {
            case TotalGoodRunsUpdateVO _:
                exerciseState.CountRun(true);
                break;

            case TotalBadRunsUpdateVO _:
                exerciseState.CountRun(false);
                break;

            case StateTerminationTrigger terminationTrigger:
                if (terminationTrigger.IsRoundFinished && exerciseState.IsFinished)
                {
                    OnTerminate?.Invoke(null);
                }
                break;

            case TimeTerminationTrigger timeoutTrigger:
                exerciseState.HandleTimeOut(timeoutTrigger.TimerUpdateVO.TimePassed);
                break;
            }
        }