コード例 #1
0
        public EventPar <TEvent> GetEventPar()
        {
            ActivationType = ActivationType.None;
            var newPar = new EventPar <TEvent>(this, Parameters);

            Parameters = null;
            return(newPar);
        }
コード例 #2
0
        public virtual void RunSimulation()
        {
            EventPar <TEvent> promotedEvent = null;
            EventPar <TEvent> eventPar      = null;

            //Inicijalizacija pre pokretanja simulacije
            PreInitialize();

            while (FEL.Count > 0 || promotedEvent != null)
            {
                //Preuzimanje sledeceg event-a
                if (promotedEvent != null)
                {
                    eventPar      = promotedEvent;
                    promotedEvent = null;
                }
                else
                {
                    eventPar = FEL.Remove();
                }
                CurrentEventPar = eventPar;

                //Trenutak aktivacije event-a
                Time = eventPar.Time;

                //Uslov za zavrsetak simulacije, trajanje simulacije
                if (Time >= SimulationEndTime)
                {
                    break;
                }

                //Aktivacija event-a
                var nextEvent = eventPar.Event;
                nextEvent.ActivateEvent(eventPar.Parameters);

                //Prolazak kroz sve otocne grane posmatranog event-a, ako je
                //uslov zadovoljen odgovarajuci skup parametara za aktivaciju
                //event-a se postavlja na FEL.
                foreach (var eventEdge in EventGraph.OutEdges(nextEvent))
                {
                    switch (eventEdge.ActivationType)
                    {
                    case ActivationType.Normal:
                    {
                        FEL.Insert(eventEdge.GetEventPar());
                    }
                    break;

                    case ActivationType.Immediate:
                    {
                        if (promotedEvent != null)
                        {
                            throw new Exception("Only single immediate event can be triggered from current event.");
                        }

                        promotedEvent = eventEdge.GetEventPar();
                    }
                    break;
                    }
                }
            }

            //Inicijalizacija nakon zavrsetka simulacije
            PostInitialize();
        }
コード例 #3
0
ファイル: EventPar.cs プロジェクト: jasaleja/SDD_projekat
 public int CompareTo(EventPar <TEvent> other)
 {
     return(Time.CompareTo(other.Time));
 }