Esempio n. 1
0
        private static void StartIterations(Action.Action cropCycle, Action.Action goHome,
                                            Action.Action rescureInvalidState, int iterations)
        {
            StreamWriter fs = GetFileStream();

            try
            {
                goHome.ExecuteAll(fs);
                for (int i = 0; i < iterations; i++)
                {
                    try
                    {
                        LogToFileAndConsole(fs, Environment.NewLine + "Executing iteration " + (i + 1));

                        cropCycle.ExecuteAll(fs);
                    }
                    catch (InvalidStateException ise)
                    {
                        LogToFileAndConsole(fs, Environment.NewLine + Environment.NewLine + "invalid state Exception: " + Environment.NewLine + ise);
                        rescureInvalidState.ExecuteAll(fs);
                    }
                }
            }
            catch (Exception e)
            {
                LogToFileAndConsole(fs, "Error mitigation failed\n" + e);
            }
            finally
            {
                fs.Flush();
                fs.Close();
            }
        }
Esempio n. 2
0
        ////TODO
        //@"C:\Users\Achu\Pictures\SiloCloseButton.png"

        static void Main(string[] args)
        {
            AutoHotkey.ThreadFromText("");
            CropCycleConfiguration hdc = new CropCycleConfiguration();

            Action.Action cropCycle           = hdc.GenerateSeedHarvestAndSell();
            Action.Action goHome              = hdc.GenerateGoHome();
            Action.Action rescureInvalidState = hdc.GetRescueInvalidState();
            Console.WriteLine("How many iterations to execute?");
            int iterations = 99999;

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("Starting in:" + (i + 1));
                Thread.Sleep(1000);
            }
            StartIterations(cropCycle, goHome, rescureInvalidState, iterations);
            Console.WriteLine("Press key to exit");
            Console.ReadKey();
        }