[Quantproject-developers] QuantProject/b4_Business/a05_Timing Timer.cs, 1.1, 1.2
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-11-20 20:44:20
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30975/b4_Business/a05_Timing Modified Files: Timer.cs Log Message: - a new property has been added: public bool IsDone - some bugs have been fixed Index: Timer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/Timer.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Timer.cs 29 Sep 2008 21:02:41 -0000 1.1 --- Timer.cs 20 Nov 2008 20:44:14 -0000 1.2 *************** *** 38,51 **** public event NewDateTimeEventHandler NewDateTime; ! protected bool isActive; // true iff the timer is started and not stopped protected DateTime currentDateTime; ! public bool IsActive { ! get { return this.isActive; } } public Timer() { } --- 38,60 ---- public event NewDateTimeEventHandler NewDateTime; ! private bool hasTheTimerBeenStarted; ! private bool hasTheTimerBeenStopped; // true iff the timer was stop protected DateTime currentDateTime; ! #region IsDone ! protected abstract bool isDone(); ! /// <summary> ! /// true iif all DateTime(s) have been thrown out by this timer ! /// </summary> ! public bool IsDone { ! get { return this.isDone(); } } + #endregion IsDone public Timer() { + this.hasTheTimerBeenStarted = false; + this.hasTheTimerBeenStopped = false; } *************** *** 59,65 **** public virtual DateTime GetCurrentDateTime() { ! if ( !this.isActive ) throw new Exception( - "Either Start() has not been invoked yet, or " + "Stop() has already been invoked" ); return this.currentDateTime; --- 68,76 ---- public virtual DateTime GetCurrentDateTime() { ! if ( !this.hasTheTimerBeenStarted ) ! throw new Exception( ! "Start() has not been invoked yet" ); ! if ( this.hasTheTimerBeenStopped ) throw new Exception( "Stop() has already been invoked" ); return this.currentDateTime; *************** *** 72,76 **** { this.initializeTimer(); ! this.isActive = true; } #endregion activateTimer --- 83,87 ---- { this.initializeTimer(); ! this.hasTheTimerBeenStarted = true; } #endregion activateTimer *************** *** 91,107 **** this.currentDateTime.Minute , this.currentDateTime.Second ) ); ! ! // if ( ( this.MarketOpen != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.MarketOpen ) ) ! // this.MarketOpen( this , new EndOfDayTimingEventArgs( this.currentTime ) ); ! // if ( ( this.FiveMinutesBeforeMarketClose != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ) ) ! // this.FiveMinutesBeforeMarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); ! // if ( ( this.MarketClose != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.MarketClose ) ) ! // this.MarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); ! // if ( ( this.OneHourAfterMarketClose != null ) && ( this.currentTime.EndOfDaySpecificTime == ! // EndOfDaySpecificTime.OneHourAfterMarketClose ) ) ! // this.OneHourAfterMarketClose( this , new EndOfDayTimingEventArgs( this.currentTime ) ); } /// <summary> --- 102,111 ---- this.currentDateTime.Minute , this.currentDateTime.Second ) ); ! } ! private void moveNextIfPossible() ! { ! if ( !this.IsDone ) ! // there is at least one more bar to be thrown out, yet ! this.moveNext(); } /// <summary> *************** *** 111,118 **** { this.activateTimer(); ! while ( this.isActive ) { this.callEvents(); ! this.moveNext(); } } --- 115,122 ---- { this.activateTimer(); ! while ( !this.hasTheTimerBeenStopped && !this.IsDone ) { this.callEvents(); ! this.moveNextIfPossible(); } } *************** *** 124,128 **** public void Stop() { ! this.isActive = false; } } --- 128,132 ---- public void Stop() { ! this.hasTheTimerBeenStopped = true; } } |