File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,9 +19,22 @@ public Simulator(State state)
1919 #endregion
2020
2121 State = state ;
22- if ( State . InitEvents . Count == 0 ) throw new InitEventsNotFound ( ) ;
22+ // if (State.InitEvents.Count == 0) throw new InitEventsNotFound();
2323 foreach ( var evnt in State . InitEvents ) Schedule ( evnt , ClockTime ) ;
24- }
24+ }
25+ public bool HasFutureEvents { get { return FutureEventList . Count > 0 ; } }
26+ public DateTime HeadEventTime { get { return FutureEventList . Count > 0 ? FutureEventList . First ( ) . ScheduledTime : DateTime . MaxValue ; } }
27+ /// <summary>
28+ /// Reset simulation clock time, used for HLA federate initialization.
29+ /// </summary>
30+ public void ResetClockTime ( DateTime clockTime )
31+ {
32+ while ( ClockTime < clockTime )
33+ {
34+ FutureEventList . Remove ( FutureEventList . First ( ) ) ;
35+ ClockTime = FutureEventList . Count > 0 ? FutureEventList . First ( ) . ScheduledTime : clockTime ;
36+ }
37+ }
2538 internal protected void Schedule ( Event evnt , DateTime time )
2639 {
2740 if ( evnt . Simulator == null ) evnt . Simulator = this ;
@@ -46,6 +59,13 @@ protected bool ExecuteHeadEvent()
4659 head . Invoke ( ) ;
4760 return true ;
4861 }
62+ public virtual bool Run ( Event evnt )
63+ {
64+ if ( evnt . Simulator != null && ! evnt . Simulator . Equals ( this ) )
65+ return false ;
66+ Execute ( evnt ) ;
67+ return true ;
68+ }
4969 public virtual bool Run ( TimeSpan duration ) { return Run ( ClockTime . Add ( duration ) ) ; }
5070 public virtual bool Run ( DateTime terminate )
5171 {
You can’t perform that action at this time.
0 commit comments