Exemplo n.º 1
0
        //private TTApiService m_TTService;

        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public Form2()
        {
            InitializeComponent();

            typeof(Ambre.TTServices.Markets.MarketTTAPI).ToString();                        // force this needed assembly to load.
            AppServices appServices = AppServices.GetInstance("AutoStackingTracker", true); // Set application information - do this before hubs are instantiated.

            appServices.Info.RequestShutdownAddHandler(new EventHandler(this.RequestShutdownHandler));
            appServices.LoadServicesFromFile("AutoStackingConfig.txt");     // Creates all services.

            // Attach event handlers to events this GUI is interested in.
            foreach (IService service in AppServices.GetInstance().GetServices())
            {
                if (service is OrderHub)
                {
                    OrderHub hub = (OrderHub)service;
                    hub.BookCreated += new EventHandler(OrderHub_BookCreated);
                    hub.BookChanged += new EventHandler(OrderHub_BookChanged);
                    //hub.BookDeleted += new EventHandler(OrderHub_BookCreated);
                }
            }

            // Can use this to monitor xTrader
            //System.Diagnostics.Process[] procs2 = System.Diagnostics.Process.GetProcesses();
            //System.Diagnostics.Process[] procs = System.Diagnostics.Process.GetProcessesByName("x_trader");



            //
            appServices.Start();                                            // Start thread hubs.
            appServices.Connect();
        }
Exemplo n.º 2
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        /// <summary>
        /// Default Constructor called by the gui thread to start our data hub.
        /// </summary>
        public DataHub()
            : base("DataHub", UV.Lib.Application.AppInfo.GetInstance().LogPath, true, LogLevel.ShowAllMessages)
        {
            Log.AllowedMessages = LogLevel.ShowAllMessages;
            m_AppServices       = UV.Lib.Application.AppServices.GetInstance();             // find our AppServices

            m_AppServices.TryLoadServicesFromFile("UVDataConfig.txt");                      // load our needed services from our config.
            IService service = null;

            if (m_AppServices.TryGetService("MarketTTAPI", out service))                    // find the TTAPI market, but cast it as a generic MarketHub.
            {
                m_Market = (UV.Lib.MarketHubs.MarketHub)service;
                m_Market.Log.AllowedMessages = LogLevel.ShowAllMessages;
                Hub hub = (Hub)service;
                hub.Log.IsViewActive = true;
                //
                Log.NewEntry(LogLevel.Major, "ConnectToServices: Found market {0}. Subscribing to events.", m_Market.ServiceName);
                m_Market.FoundResource       += new EventHandler(HubEventEnqueue);
                m_Market.MarketStatusChanged += new EventHandler(HubEventEnqueue);
                m_Market.ServiceStateChanged += new EventHandler(HubEventEnqueue);
            }

            //
            // Rename our app services
            //
            FrontEnds.FrontEndServices frontEnd = FrontEnds.FrontEndServices.GetInstance();
            frontEnd.AppName = "Data Recorder";
            frontEnd.RunName = FrontEnds.FrontEndServices.RunNameType.Sim1;

            m_AppServices.Connect();                                                        // tells all of our services to connect.
            m_AppServices.Start();                                                          // tells all of our services to start.
        }
Exemplo n.º 3
0
        // Internal application variables.
        //private bool m_IsShuttingDown = false;
        //private bool m_ServiceConnectionRequested = false;              // guarentees we start services only once.



        #endregion// members


        #region Constructors
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        public Form1()
        {
            InitializeComponent();                                                          // windows form stuff

            AppServices appServices = AppServices.GetInstance("AutoStackingTracker", true); // Set application information - do this before hubs are instantiated.

            appServices.Info.RequestShutdownAddHandler(new EventHandler(this.RequestShutdown));
            appServices.LoadServicesFromFile("AutoStackingConfig.txt");     // Creates all services.
            CreateOrderHubControls();                                       // Create services we will need.
            appServices.Start();
            appServices.Connect();
        }//constructor
Exemplo n.º 4
0
        // *****************************************************************
        // ****                     Constructors                        ****
        // *****************************************************************
        //
        //
        //
        public SpreadViewer()
        {
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(FormClosedByUser);

            // Create the needed services.
            typeof(MarketTTAPI).ToString();
            AppServices appServices = AppServices.GetInstance("SpreadPriceGenerator");

            appServices.Info.RequestShutdownAddHandler(new EventHandler(this.RequestShutdown));
            appServices.ServiceStopped += new EventHandler(Service_ServiceStopped);

            // Write service names to config gile if it does not exist.
            string configPath = string.Format("{0}{1}", appServices.Info.UserConfigPath, m_ConfigFileName);

            if (!System.IO.File.Exists(configPath))
            {
                DialogResult result = System.Windows.Forms.DialogResult.Abort;
                result = MessageBox.Show(string.Format("Config file does not exist! \r\nFile: {0}\r\nDir: {1}\r\nShould I create an empty one?", m_ConfigFileName, appServices.Info.UserConfigPath), "Config file not found", MessageBoxButtons.YesNo);
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    using (System.IO.StreamWriter writer = new System.IO.StreamWriter(configPath, false))
                    {
                        writer.WriteLine("<Ambre.TTServices.Markets.MarketTTAPI/>");
                        writer.WriteLine("<Ambre.TTServices.TTApiService FollowXTrader=True/>");
                        writer.Close();
                    }
                }
            }

            // Create logs.
            bool isLogViewerVisible = true;

            Log = new LogHub("SpreadProjectLogs", AppInfo.GetInstance().LogPath, isLogViewerVisible, LogLevel.ShowAllMessages);

            // Load the services from config file and start services.
            appServices.LoadServicesFromFile(m_ConfigFileName);
            foreach (IService service in appServices.GetServices())
            {
                this.AddService(service);
            }
            string filePath = AppServices.GetInstance().Info.UserPath;

            filePath = string.Format("{0}ProductSpreadInfo.csv", filePath);
            SpreadInfoReader.TryReadSpreadInfoTable(filePath, Log, out m_CSVSpreadInfoReader);

            // Get the market tt api service.
            IService iService = null;

            if (!appServices.TryGetService("MarketTTAPI", out iService))
            {
                Log.NewEntry(LogLevel.Warning, "Failed to find the market tt api service.");
                return;
            }
            m_MarketTTAPI = (MarketTTAPI)iService;

            // Set market reading timer.
            m_MarketReadTimer          = new System.Timers.Timer();
            m_MarketReadTimer.Interval = 2000;
            m_MarketReadTimer.Elapsed += new System.Timers.ElapsedEventHandler(MarketReadingTimer_Elapsed);
            m_MarketReadTimer.Start();

            // Start and connect all the services.
            appServices.Start();
            appServices.Connect();
        }//SpreadViewer()