Example #1
1
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            m_Playing = true;
            m_Engine = new Engine.Engine();

            if (RadioButtonWebcam.IsChecked.Value)
            {
                m_Capture = new Capture(0);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, 1280);
                m_Capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, 720);
            }
            else
            {
                m_Capture = new Capture(System.IO.Path.GetFullPath(".\\..\\Videos\\vidD.mp4"));
            }

            m_Timer = new Timer(ExpectedFrameUpdate, null, 0, 1000 / 15);

            m_DisplayFrames = new Thread(ShowFrames);
            m_DisplayFrames.Start();
        }
Example #2
0
        static void Main(string[] args)
        {
            Engine.Engine engine = new Engine.Engine();
            engine.Start();

            Console.ReadKey();

            engine.Stop();
        }
Example #3
0
        /// <summary>
        /// Overridden from the base Game.Initialize. Once the GraphicsDevice is setup,
        /// we'll use the viewport to initialize some values.
        /// </summary>
        protected override void Initialize()
        {
            engine = new Engine.Engine ();
            //pakmak = new Player.Player ();

            //map = new Map.Map (Constants.MAP_SIZE_HEIGHT, Constants.MAP_SIZE_WIDTH);
            playerMoveSpeed = Constants.PLAYER_MOVE_SPEED;

            base.Initialize ();
        }
        public Service1()
        {
            this.mEngine = new Engine.Engine();
            this.mEngine.Start();

            //mTimer = new Timer(OnTimer);
            //mMonitor = new ProgramMonitor();

            //mTimer.Change(1000, 1000);
            InitializeComponent();
        }
        /// <summary>
        /// The main method of the Console UI of the game.
        /// </summary>
        public static void Main()
        {
            var printer = new Printer();

            var reader = new Reader();

            var gameInitializator = new GameInitializer.GameInitializer(printer, reader);

            var game = gameInitializator.Initialize();

            var scoreboard = new Scoreboard();

            var commandManager = new CommandManager();

            var boardHistory = new BoardHistory();

            EngineTemplate engine = new Engine.Engine(game, scoreboard, printer, reader, commandManager, boardHistory);

            engine.Run();
        }
Example #6
0
        private void ButtonGo_Click(object sender, RoutedEventArgs e)
        {
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            m_Engine = new Engine.Engine();
            m_Engine.BoardImagePath = System.IO.Path.GetFullPath(".\\..\\Images\\MyBoards\\Board01.jpg");
            m_Engine.Process();

            sw.Stop();
            TextBlockTimeTaken.Text = sw.ElapsedMilliseconds.ToString() + "ms";

            OrigImage.Source = BitmapSourceConvert.ToBitmapSource(m_Engine.Board.BoardImage);
            OrigImageWithQuads.Source = BitmapSourceConvert.ToBitmapSource(m_Engine.Board.BoardImageWithBoxes);
            ShowPieceImage();
            //GrayImage.Source = BitmapSourceConvert.ToBitmapSource(engine.Board.GrayImage);
            //CannyImage.Source = BitmapSourceConvert.ToBitmapSource(engine.Board.CannyImage);
            //LinesImage.Source = BitmapSourceConvert.ToBitmapSource(engine.Board.LinesImage);
            WarpedImage.Source = BitmapSourceConvert.ToBitmapSource(m_Engine.Board.WarpedImage);
            WarpedCannyImage.Source = BitmapSourceConvert.ToBitmapSource(m_Engine.Board.WarpedCannyImage);
            WarpedLinesImage.Source = BitmapSourceConvert.ToBitmapSource(m_Engine.Board.WarpedLinesImage);
            GridBoxesImage.Source = BitmapSourceConvert.ToBitmapSource(m_Engine.Board.GridQuadsImage);
        }
Example #7
0
        static void Main(string[] args)
        {
            //Initialize:
            string mode = "RELEASE";
#if DEBUG
            mode = "DEBUG";
#endif
            if (Config.Get("environment") == "backtesting-desktop")
            {
                Application.EnableVisualStyles();
                Thread thread = new Thread(RunLeanEngineWinForm);
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join(); 
            }
            else
            {
                Log.LogHandler = Composer.Instance.GetExportedValueByTypeName<ILogHandler>(Config.Get("log-handler", "CompositeLogHandler"));

                var liveMode = Config.GetBool("live-mode");
                Log.DebuggingEnabled = Config.GetBool("debug-mode");
            //Name thread for the profiler:
            Thread.CurrentThread.Name = "Algorithm Analysis Thread";
            Log.Trace("Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v" + Globals.Version + " Mode: " + mode);
            Log.Trace("Engine.Main(): Started " + DateTime.Now.ToShortTimeString());
            Log.Trace("Engine.Main(): Memory " + OS.ApplicationMemoryUsed + "Mb-App  " + +OS.TotalPhysicalMemoryUsed + "Mb-Used  " + OS.TotalPhysicalMemory + "Mb-Total");

            //Import external libraries specific to physical server location (cloud/local)
            LeanEngineSystemHandlers leanEngineSystemHandlers;
            try
            {
                leanEngineSystemHandlers = LeanEngineSystemHandlers.FromConfiguration(Composer.Instance);
            }
            catch (CompositionException compositionException)
            {
                Log.Error("Engine.Main(): Failed to load library: " + compositionException);
                throw;
            }

            //Setup packeting, queue and controls system: These don't do much locally.
            leanEngineSystemHandlers.Initialize();

            //-> Pull job from QuantConnect job queue, or, pull local build:
            string assemblyPath;
            var job = leanEngineSystemHandlers.JobQueue.NextJob(out assemblyPath);

            if (job == null)
            {
                throw new Exception("Engine.Main(): Job was null.");
            }

            LeanEngineAlgorithmHandlers leanEngineAlgorithmHandlers;
            try
            {
                leanEngineAlgorithmHandlers = LeanEngineAlgorithmHandlers.FromConfiguration(Composer.Instance);
            }
            catch (CompositionException compositionException)
            {
                Log.Error("Engine.Main(): Failed to load library: " + compositionException);
                throw;
            }

            // log the job endpoints
            Log.Trace("JOB HANDLERS: ");
            Log.Trace("         DataFeed:     " + leanEngineAlgorithmHandlers.DataFeed.GetType().FullName);
            Log.Trace("         Setup:        " + leanEngineAlgorithmHandlers.Setup.GetType().FullName);
            Log.Trace("         RealTime:     " + leanEngineAlgorithmHandlers.RealTime.GetType().FullName);
            Log.Trace("         Results:      " + leanEngineAlgorithmHandlers.Results.GetType().FullName);
            Log.Trace("         Transactions: " + leanEngineAlgorithmHandlers.Transactions.GetType().FullName);
            Log.Trace("         History:      " + leanEngineAlgorithmHandlers.HistoryProvider.GetType().FullName);
            Log.Trace("         Commands:     " + leanEngineAlgorithmHandlers.CommandQueue.GetType().FullName);
            if (job is LiveNodePacket) Log.Trace("         Brokerage:    " + ((LiveNodePacket)job).Brokerage);

            // if the job version doesn't match this instance version then we can't process it
            // we also don't want to reprocess redelivered jobs
            if (VersionHelper.IsNotEqualVersion(job.Version) || job.Redelivered)
            {
                Log.Error("Engine.Run(): Job Version: " + job.Version + "  Deployed Version: " + Globals.Version + " Redelivered: " + job.Redelivered);
                //Tiny chance there was an uncontrolled collapse of a server, resulting in an old user task circulating.
                //In this event kill the old algorithm and leave a message so the user can later review.
                leanEngineSystemHandlers.Api.SetAlgorithmStatus(job.AlgorithmId, AlgorithmStatus.RuntimeError, _collapseMessage);
                leanEngineSystemHandlers.Notify.SetAuthentication(job);
                leanEngineSystemHandlers.Notify.Send(new RuntimeErrorPacket(job.AlgorithmId, _collapseMessage));
                leanEngineSystemHandlers.JobQueue.AcknowledgeJob(job);
                return;
            }

            try
            {
                var engine = new Engine.Engine(leanEngineSystemHandlers, leanEngineAlgorithmHandlers, liveMode);
                engine.Run(job, assemblyPath);
            }
            finally
            {
                //Delete the message from the job queue:
                leanEngineSystemHandlers.JobQueue.AcknowledgeJob(job);
                Log.Trace("Engine.Main(): Packet removed from queue: " + job.AlgorithmId);

                // clean up resources
                leanEngineSystemHandlers.Dispose();
                leanEngineAlgorithmHandlers.Dispose();
                Log.LogHandler.Dispose();
            }
            }

        }