示例#1
0
        private void OnStepFinished(IProtocolStep step)
        {
            _logger.Write("OnStepFinished " + step);
            var handler = StepFinished;
            if (handler == null) return;

            _logger.Write("Raising event, handler not null");
            var stepFinishedEventArgs = new ProtocolStepFinishedEventArgs(step);
            _logger.Write("args prepared");
            try
            {
                handler(this, stepFinishedEventArgs);
                _logger.Write("handler was called, waiting for animations");
            }
            catch (Exception exception)
            {
                _logger.Write(string.Format("Something went wrong: {0}", exception.Message));
            }
            finally
            {
                stepFinishedEventArgs.Handle.WaitOne(2000);
            }

            _logger.Write("finish processing of OnStepFinished");
        }
示例#2
0
 private string GetState(IProtocolStep step, Random random)
 {
     return(step switch
     {
         AddReagent addReagent => new string( Enumerable.Range(0, 96).Select(_ => random.NextDouble() < ProbabilityOfAddReagentFailure ? 'F' : 'S').ToArray()),
         DistributeSample distribute => new string( Enumerable.Range(0, 96).Select(_ => random.NextDouble() < ProbabilityOfDistributeFailure ? 'F' : 'S').ToArray()),
         Incubate incubate => random.NextDouble() < ProbabilityOfIncubateFailure ? "F" : "S",
         Wash wash => random.NextDouble() < ProbabilityOfWashFailure ? "F" : "S",
         _ => throw new InvalidOperationException(),
     });
示例#3
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IProtocolStep stepsCasted = item.As <IProtocolStep>();

                if ((stepsCasted != null))
                {
                    this._parent.Steps.Add(stepsCasted);
                }
                IReagent reagentsCasted = item.As <IReagent>();

                if ((reagentsCasted != null))
                {
                    this._parent.Reagents.Add(reagentsCasted);
                }
            }
示例#4
0
        private void DoStep(IProtocolStep step)
        {
            _logger.Write(string.Format("Start DoStep with step {0}", step));
            _stepHandle.WaitOne(1000);
            _logger.Write("Handle granted, executing step");
            OnStepStarted(step);
            foreach (var nextStep in step.Execute(_environment).OrEmptyIfNull())
            {
                _logger.Write(string.Format("Next step in execution chain is {0}", nextStep));
                DoStep(nextStep);
                _logger.Write(string.Format("{0} executed successfully", nextStep));
            }

            _stepHandle.Reset();
            OnStepFinished(step);
            _logger.Write(string.Format("End DoStep of step {0}", step));
        }
示例#5
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                IProtocolStep protocolStepItem = item.As <IProtocolStep>();

                if (((protocolStepItem != null) &&
                     this._parent.Steps.Remove(protocolStepItem)))
                {
                    return(true);
                }
                IReagent reagentItem = item.As <IReagent>();

                if (((reagentItem != null) &&
                     this._parent.Reagents.Remove(reagentItem)))
                {
                    return(true);
                }
                return(false);
            }
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Next == null))
     {
         IProtocolStep nextCasted = item.As <IProtocolStep>();
         if ((nextCasted != null))
         {
             this._parent.Next = nextCasted;
             return;
         }
     }
     if ((this._parent.Previous == null))
     {
         IProtocolStep previousCasted = item.As <IProtocolStep>();
         if ((previousCasted != null))
         {
             this._parent.Previous = previousCasted;
             return;
         }
     }
 }
 public ProtocolStepFinishedEventArgs(IProtocolStep step)
 {
     Step = step;
     Handle = new AutoResetEvent(false);
 }
示例#8
0
        private void OnStepStarted(IProtocolStep step)
        {
            _logger.Write("OnStepStarted " + step);
            var handler = StepStarted;
            if (handler == null) return;

            _logger.Write("Raising event, handler not null");
            var stepStartedEventArgs = new ProtocolStepStartedEventArgs(step);
            handler(this, stepStartedEventArgs);
            stepStartedEventArgs.Handle.WaitOne(2000);
        }