Example #1
0
 private ModelTime Min(ModelTime mt1, ModelTime mt2, ModelTime mt3)
 {
     return(new ModelTime()
     {
         Time = Math.Min(Math.Min(mt1.Time, mt2.Time), mt3.Time)
     });
 }
Example #2
0
 public Server(ref ModelTime time,
               AbstractGenerator aTypeGenerator,
               AbstractGenerator bTypeGenerator)
 {
     _time           = time;
     _aTypeGenerator = aTypeGenerator;
     _bTypeGenerator = bTypeGenerator;
     IsFree          = true;
 }
Example #3
0
 public void Enter(Transact transact)
 {
     transact.AddLog(new TransactLog(_time, EventTypeEnum.EnterServer));
     IsFree           = false;
     _currentTransact = transact;
     NextReleaseTime  = new ModelTime()
     {
         Time = _time.Time + (_currentTransact.Type == TransactTypeEnum.Atype ? _aTypeGenerator.Next() : _bTypeGenerator.Next())
     };
 }
Example #4
0
        public Model(
            AbstractGenerator sourceAGenerator,
            AbstractGenerator sourceBGenerator,
            AbstractGenerator serverAGenerator,
            AbstractGenerator serverBGenerator,
            ModelTime maxTime)
        {
            _time   = new ModelTime();
            MaxTime = maxTime;

            Source = new Source(ref _time, sourceAGenerator, sourceBGenerator);
            Drain  = new Drain(ref _time);

            Queue  = new Queue(ref _time);
            Server = new Server(ref _time, serverAGenerator, serverBGenerator);
        }
Example #5
0
        public Source(ref ModelTime time,
                      AbstractGenerator aTypeGenerator,
                      AbstractGenerator bTypeGenerator)
        {
            _time           = time;
            _aTypeGenerator = aTypeGenerator;
            _bTypeGenerator = bTypeGenerator;

            NextAGenerationTime = new ModelTime()
            {
                Time = _time.Time + _aTypeGenerator.Next()
            };
            NextBGenerationTime = new ModelTime()
            {
                Time = _time.Time + _bTypeGenerator.Next()
            };
        }
Example #6
0
        public Transact Get()
        {
            Transact transact = null;

            if (NextAGenerationTime == _time)
            {
                NextAGenerationTime = new ModelTime()
                {
                    Time = _time.Time + _aTypeGenerator.Next()
                };
                transact = new Transact(++idCounter, TransactTypeEnum.Atype);
            }
            if (NextBGenerationTime == _time)
            {
                NextBGenerationTime = new ModelTime()
                {
                    Time = _time.Time + _bTypeGenerator.Next()
                };
                transact = new Transact(++idCounter, TransactTypeEnum.Btype);
            }

            transact?.AddLog(new TransactLog(_time, EventTypeEnum.Born));
            return(transact);
        }
Example #7
0
 public Queue(ref ModelTime time)
 {
     _time = time;
 }
Example #8
0
 public Drain(ref ModelTime time)
 {
     _time            = time;
     DrainedTransacts = new List <Transact>();
 }