Пример #1
0
        /// <summary>
        /// Stop the CQG adapter
        /// </summary>
        protected override void DoStop()
        {
            try
            {
                driverLog.Info("DoStop:enter");
                setSubscriptionsStatus(KaiTrade.Interfaces.Status.closed);
                if (m_GWStatus == eConnectionStatus.csConnectionUp)
                {
                    m_CQGHostForm.CQGApp.Shutdown();
                }
                m_CQGHostForm.Close();
                m_CQGHostForm = null;

                // Report that we are stopped - this will show in the adapter view
                // in the dashboard
                this.SendStatusMessage(KaiTrade.Interfaces.Status.closed, "KTCQG adapter is closed");

                // clear maps
                m_SubscribedProducts.Clear();
                //m_Clients.Clear();

                m_SubscribedProducts.Clear();

                m_TSSets.Clear();
                _clOrdIDOrderMap.Clear();
                m_GUID2CQGOrder.Clear();

                driverLog.Info("DoStop:exit");
            }
            catch (Exception myE)
            {
                log.Error("DoStop", myE);
            }
        }
Пример #2
0
        /// <summary>
        /// Start the CQG Adapter
        /// </summary>
        /// <param name="myState"></param>
        protected override void DoStart(string myState)
        {
            try
            {
                driverLog.Info("KTACQG doStart");

                // open the CQG Host form
                m_CQGHostForm = new CQGFrm();
                m_CQGHostForm.Adapter = this;
                m_CQGHostForm.Show();
                if (base._state.HideDriverUI)
                {
                        //CQGHostForm.Hide();
                }
                // Read the configuration data
                try
                {
                    using (StreamReader sr = new StreamReader(_configPath + "CQGConfig.xml"))
                    {
                        _config = JsonConvert.DeserializeObject<CQGConfig>(sr.ReadToEnd());
                    }

                    // process config file
                    processConfig(_config);
                }
                catch(Exception e)
                {
                    // not consider an issue if not found
                    driverLog.Error("error processing config", e);
                }

                // do any property processing
                try
                {
                    string orTicks = Facade.GetUserProfileProperty("*", m_ID + "::" + "RequiredORIntervalTicks");
                    string useOEThrottle = Facade.GetUserProfileProperty("*", m_ID + "::" + "UseOEThrottle");

                    if (useOEThrottle.ToLower() == "true")
                    {
                        UseOEThrottle = true;
                    }
                    else
                    {
                        UseOEThrottle = false;
                    }

                    if (long.Parse(orTicks) >= 0)
                    {
                        RequiredORIntervalTicks = long.Parse(orTicks);
                    }
                }
                catch (Exception myE)
                {
                    driverLog.Error("property processing", myE);
                }

                m_tickCount = 0;
                m_TimeWarningCount = 0;

                //m_CQGHostForm.Hide();

                // Start connection to CQG
                InitializeCQGCEL();

                // Report that we are open - this will show in the adapter view
                // in the dashboard
                this.SendStatusMessage(KaiTrade.Interfaces.Status.open, "KTCQG adapter is open");
                driverLog.Info("KTCQG adapter is open");
            }
            catch (Exception myE)
            {
                this.SendStatusMessage(KaiTrade.Interfaces.Status.error, "KTCQG is not working");
            }
        }