[Quantproject-developers] QuantDownloader/Downloader/OpenTickDownloader/OTManagement OTManager.cs,
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2009-02-04 20:01:56
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv573/OpenTickDownloader/OTManagement Modified Files: OTManager.cs Log Message: - some static OTManager's methods have been changed and are instance method now - intervalValueInSeconds is properly computed, now Index: OTManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement/OTManager.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OTManager.cs 29 Jan 2009 19:45:12 -0000 1.5 --- OTManager.cs 4 Feb 2009 20:01:49 -0000 1.6 *************** *** 48,52 **** { public event OnErrorEventHandler OnError; ! public static OnLoginEventHandler OnLogin; public event OnNoDataEventHandler OnNoData; public event OnEndOfDataEventHandler OnEndOfData; --- 48,52 ---- { public event OnErrorEventHandler OnError; ! public event OnLoginEventHandler OnLogin; public event OnNoDataEventHandler OnNoData; public event OnEndOfDataEventHandler OnEndOfData; *************** *** 67,93 **** // private string logFileName; ! private static OTClient oTClient; ! static OTManager() ! { ! OTManager.oTClient = new OTClient(); ! OTManager.oTClient.onLogin += new OTLoginEvent( ! OTManager.onLoginEventHandler ); ! OTManager.oTClient.onStatusChanged += new OTStatusChangedEvent( ! OTManager.onStatusChangedEventHandler ); ! } ! private static void onLoginEventHandler() { ! if ( OTManager.OnLogin != null ) ! OTManager.OnLogin(); } ! private static void onStatusChangedEventHandler( int status ) { string currentStatusHasChangedTo = ! OTStatus.GetName( ! typeof( OTStatus ) , status ); string message = "Current status has changed to: " + currentStatusHasChangedTo; ! // this.riseNewMessageEvent( message ); } --- 67,93 ---- // private string logFileName; ! private static OTClient staticOTClient; ! private OTClient oTClient; ! // static OTManager() ! // { ! // OTManager.oTClient = new OTClient(); ! // OTManager.oTClient.onLogin += new OTLoginEvent( ! // OTManager.onLoginEventHandler ); ! // OTManager.oTClient.onStatusChanged += new OTStatusChangedEvent( ! // OTManager.onStatusChangedEventHandler ); ! // } ! private void onLoginEventHandler() { ! if ( this.OnLogin != null ) ! this.OnLogin(); } ! private void onStatusChangedEventHandler( int status ) { string currentStatusHasChangedTo = ! OTStatus.GetName( typeof( OTStatus ) , status ); string message = "Current status has changed to: " + currentStatusHasChangedTo; ! this.riseNewMessageEvent( message ); } *************** *** 103,106 **** --- 103,119 ---- #region commonInitialization + private void set_oTClient() + { + if ( OTManager.staticOTClient == null ) + { + // this is the first OTManager's instance created + this.oTClient = new OTClient(); + OTManager.staticOTClient = this.oTClient; + } + else + // this is not the first OTManager's instance created + this.oTClient = OTManager.staticOTClient; + } + #region setOTCLientEventHandlers private bool wasThisRequestSubmittedByThisOTManagerInstance( int requestId ) *************** *** 139,143 **** "Type: " + error.Type; OTDataEntity oTDataEntity = ! OTManager.oTClient.getEntityById( error.RequestId ); if ( oTDataEntity != null ) // RequestId was refered to a OTDataEntity --- 152,156 ---- "Type: " + error.Type; OTDataEntity oTDataEntity = ! this.oTClient.getEntityById( error.RequestId ); if ( oTDataEntity != null ) // RequestId was refered to a OTDataEntity *************** *** 188,192 **** "RequestId: " + oTMessage.RequestId; OTDataEntity oTDataEntity = ! OTManager.oTClient.getEntityById( oTMessage.RequestId ); if ( oTDataEntity != null ) // RequestId was refered to a OTDataEntity --- 201,205 ---- "RequestId: " + oTMessage.RequestId; OTDataEntity oTDataEntity = ! this.oTClient.getEntityById( oTMessage.RequestId ); if ( oTDataEntity != null ) // RequestId was refered to a OTDataEntity *************** *** 231,235 **** { OTDataEntity oTDataEntity = ! OTManager.oTClient.getEntityById( ohlc.RequestId ); string message = String.Format( "OHLC({7}):time={0} o={1,-6} h={2,-6} " + --- 244,248 ---- { OTDataEntity oTDataEntity = ! this.oTClient.getEntityById( ohlc.RequestId ); string message = String.Format( "OHLC({7}):time={0} o={1,-6} h={2,-6} " + *************** *** 268,281 **** private void setOTClientEventHandlers() { ! OTManager.oTClient.onError += new OTErrorEvent( this.onOTClientError ); ! OTManager.oTClient.onMessage += new OTMessageEvent( ! this.onMessageEventHandler ); ! OTManager.oTClient.onHistoricalOHLC += new OTOHLCEvent( this.onHistoricalOHLC ); } #endregion setOTCLientEventHandlers ! private void commonInitialization() { this.pendingBarRequests = new Hashtable(); this.setOTClientEventHandlers(); --- 281,298 ---- private void setOTClientEventHandlers() { ! this.oTClient.onLogin += new OTLoginEvent( ! this.onLoginEventHandler ); ! this.oTClient.onStatusChanged += new OTStatusChangedEvent( ! this.onStatusChangedEventHandler ); ! this.oTClient.onError += new OTErrorEvent( this.onOTClientError ); ! this.oTClient.onMessage += new OTMessageEvent( this.onMessageEventHandler ); ! this.oTClient.onHistoricalOHLC += new OTOHLCEvent( this.onHistoricalOHLC ); } #endregion setOTCLientEventHandlers ! private void commonInitialization() { + this.set_oTClient(); this.pendingBarRequests = new Hashtable(); this.setOTClientEventHandlers(); *************** *** 286,295 **** ! public static void SubmitLogin( string openTickUser , string openTickPassword ) { ! OTManager.oTClient.addHost( "feed1.opentick.com" , 10010 ); ! //OTManager.oTClient.addHost( "delayed1.opentick.com" , 10010 ); ! OTManager.oTClient.login( openTickUser , openTickPassword ); } --- 303,312 ---- ! public void SubmitLogin( string openTickUser , string openTickPassword ) { ! // this.oTClient.addHost( "feed1.opentick.com" , 10010 ); ! this.oTClient.addHost( "delayed1.opentick.com" , 10015 ); ! this.oTClient.login( openTickUser , openTickPassword ); } *************** *** 342,346 **** OTDataEntity oTDataEntity = new OTDataEntity( exchange , symbol ); ! int requestId = OTManager.oTClient.requestHistData( oTDataEntity , startingDateInUTC , endingDateInUTC , oTHistoricalType , intervalValue ); --- 359,363 ---- OTDataEntity oTDataEntity = new OTDataEntity( exchange , symbol ); ! int requestId = this.oTClient.requestHistData( oTDataEntity , startingDateInUTC , endingDateInUTC , oTHistoricalType , intervalValue ); *************** *** 356,359 **** --- 373,379 ---- short intervalValue) { + int intervalValueInSeconds = + intervalValue * + OTIntervalValueCalculator.GetIntervalValueInSeconds( oTHistoricalType ); BarRequest barRequest = new BarRequest( *************** *** 361,365 **** symbol , startingDateInUTC , ! intervalValue ); lock ( this.pendingBarRequests ) { --- 381,385 ---- symbol , startingDateInUTC , ! intervalValueInSeconds ); lock ( this.pendingBarRequests ) { |