Пример #1
0
 public void AttemptConnectReaders()
 {
     try {
         InstrumentReaders.AdviseAll();
         InstrumentReaders.AssignEventHandlers();
         lastChangeReaders = Environment.TickCount;
     } catch (Exception e) {
         log.Error(e);
     }
 }
Пример #2
0
        private void Initialize()
        {
            m_ComMgr            = null;
            m_ComMgr            = new MBTCOMLib.MbtComMgrClass();
            m_ComMgr.SilentMode = true;
            m_ComMgr.EnableSplash(false);

            m_OrderClient            = m_ComMgr.OrderClient;
            m_OrderClient.SilentMode = true;

            m_Quotes = m_ComMgr.Quotes;

            AssignEventHandlers();
            InstrumentReaders = new InstrumentReaders(receiver, m_OrderClient, m_Quotes);
        }
Пример #3
0
 public void m_Quotes_OnLogonSucceed()
 {
     try {
         TryRetryEnd();
         if (debug)
         {
             log.Debug("Quote Server Connected");
         }
         AttemptConnectReaders();
         InstrumentReaders.UpdateLastConnectTime();
         lastChangeQuotes = 0;
     } catch (Exception e) {
         log.Error(e);
     }
 }
Пример #4
0
 public void LogoutInternal()
 {
     log.Info("MBTInterface Logout");
     closePending = true;
     if (monitorThread != null)
     {
         monitorThread.Join();
     }
     if (m_Quotes.ConnectionState != enumConnectionState.csDisconnected)
     {
         m_Quotes.Disconnect();
     }
     if (m_OrderClient.IsConnected())
     {
         m_OrderClient.Disconnect();
     }
     InstrumentReaders.Close();
     RemoveEventHandlers();
 }
Пример #5
0
        private void CheckQuotesHealth()
        {
            bool retryQuotes = Environment.TickCount - lastChangeQuotes > retryTime;

            if (retryQuotes && quotesHealth != enumConnectionState.csLoggedIn)
            {
                if (debug)
                {
                    log.Debug("Reconnect Quotes");
                }
                TryRetryStart(retryTime);
                m_Quotes.Connect();
                if (debug)
                {
                    log.Debug("Returned from Quotes.Connect");
                }
                lastChangeQuotes = Environment.TickCount;
                return;
            }

            // If Quotes logged in check the readers to make sure they're staying current.
            if (retryQuotes && quotesHealth == enumConnectionState.csLoggedIn)
            {
                bool retryReaders = Environment.TickCount - lastChangeReaders > retryTime;
                // Update the last readers time.
                lastChangeReaders = InstrumentReaders.GetLastChangeTime();
                // Is it still longer than the retry time?
                int currentTime = Environment.TickCount;
                retryReaders = currentTime - lastChangeReaders > timeoutTime;
                if (retryReaders)
                {
                    log.Info("Reconnect Connect {Readers timed out}");
                    m_Quotes.Disconnect();
                    if (debug)
                    {
                        log.Debug("Returned from Quotes.Connect {Readers Timeout}");
                    }
                }
            }
        }
Пример #6
0
 public void ReadersDisconnect()
 {
     InstrumentReaders.UnadviseAll();
 }