Exemplo n.º 1
0
        public void updateWindowStatus()
        {
            Debug.WriteLine("main_window: updating status");

            testStatusLabel.Text = "Test stage: " + LuckyMe.testStageString();

            LuckyMeLib.HaggleStatus status = LuckyMeLib.getHaggleStatus();

            switch (status)
            {
            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_CRASHED:
                haggleStatusLabel.Text = "Haggle has crashed";
                break;

            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_ERROR:
                haggleStatusLabel.Text = "Haggle status error...";
                break;

            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_NOT_RUNNING:
                haggleStatusLabel.Text = "Haggle is not running";
                break;

            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_RUNNING:
                haggleStatusLabel.Text = "Haggle is running";
                break;
            }

            updateLockStatus();

            if (LuckyMeLib.isLuckyMeRunning())
            {
                if (LuckyMeLib.isTestRunning())
                {
                    luckyMeStatusLabel.Text = "LuckyMe and test is running";
                }
                else
                {
                    luckyMeStatusLabel.Text = "LuckyMe is running, but not test";
                }
                Debug.WriteLine("main_window: LuckyMe is running");
            }
            else
            {
                luckyMeStatusLabel.Text = "LuckyMe is not running";
                Debug.WriteLine("main_window: LuckyMe is not running");
            }

            numDataObjectsGenLabel.Text = LuckyMe.getNumDataObjectsGenerated() + " data objects generated";

            this.Refresh();
        }
Exemplo n.º 2
0
        public static void onTimerStatusCheck(object state)
        {
            Debug.WriteLine("Timer status check: Checking if Haggle is still running");

            LuckyMeLib.HaggleStatus status = LuckyMeLib.getHaggleStatus();

            switch (status)
            {
            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_NOT_RUNNING:
                Debug.WriteLine("status check: Haggle is NOT running");

                if (getTestStage() == TestStage.RUNNING)
                {
                    main_window.BeginInvoke(new myDelegate(main_window.updateWindowStatus));
                }
                stopTest();
                break;

            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_CRASHED:
                Debug.WriteLine("status check: Haggle daemon crashed");
                main_window.BeginInvoke(new myDelegate(main_window.updateWindowStatus));

                stopTest();

                DialogResult res = MessageBox.Show("Haggle crashed! Exit LuckyMe?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);


                if (res == DialogResult.Yes)
                {
                    Application.Exit();
                }
                break;

            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_ERROR:
                Debug.WriteLine("status check: Haggle daemon error");
                break;

            case LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_RUNNING:
                Debug.WriteLine("status check: Haggle daemon running");
                break;

            default:
                Debug.WriteLine("status check: Unknown status=" + status);
                break;
            }
        }
Exemplo n.º 3
0
        public static bool startHaggle()
        {
            // Check Haggle status
            LuckyMeLib.HaggleStatus status = LuckyMeLib.getHaggleStatus();

            if (status != LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_RUNNING)
            {
                Debug.WriteLine("Deleting old Haggle files");
                // Make sure we delete old haggle files.
                archiveHaggleFiles(false);

                int res = LuckyMeLib.startHaggle(mSpawnCallback);

                if (res < 0)
                {
                    Debug.WriteLine("startTest: startHaggle returned res=" + res);
                    return(false);
                }

                status = LuckyMeLib.getHaggleStatus();

                if (status != LuckyMeLib.HaggleStatus.HAGGLE_DAEMON_RUNNING)
                {
                    Debug.WriteLine("startTest: Haggle deamon is not running");
                    return(false);
                }
                // Let Haggle do its thing for a while before we try to connect
                Thread.Sleep(5000);
            }

            // Start status check timer
            mCallTimer.Change(1000, 8000);

            updateWindowStatus();

            return(true);
        }