public void onShutdown() { Debug.WriteLine("main_window: onShutdown() stage=" + LuckyMe.testStageString()); haggleStatusLabel.Text = "Waiting for Haggle to exit"; numDataObjectsGenLabel.Text = LuckyMe.getNumDataObjectsGenerated() + " data objects generated"; this.Refresh(); }
public void onNeighborUpdate() { Debug.WriteLine("main_window: onNeighborUpdate() stage=" + LuckyMe.testStageString()); numNeighborsLabel.Text = LuckyMeLib.getNumberOfNeighbors() + " neighbors"; ShowWindow(this.Handle, SW_SHOW); this.Refresh(); }
public void onNewDataObject() { Debug.WriteLine("main_window: onNewDataObject stage=" + LuckyMe.testStageString()); numDataObjectsLabel.Text = LuckyMeLib.getNumberOfDOsReceived() + " data objects received"; ShowWindow(this.Handle, SW_SHOW); this.Refresh(); }
private void button_start_Click(object sender, EventArgs e) { switch (LuckyMe.getTestStage()) { case LuckyMe.TestStage.NOT_RUNNING: menuBack.Text = ""; start_button.Enabled = false; start_haggle_button.Enabled = false; this.Refresh(); if (LuckyMe.startTest()) { statusMsgLabel.Text = ""; } else { start_button.Enabled = true; menuBack.Text = "Back"; statusMsgLabel.Text = "Could not start test"; } this.Refresh(); break; case LuckyMe.TestStage.STARTING: break; case LuckyMe.TestStage.RUNNING: break; case LuckyMe.TestStage.STOPPING: default: break; } Debug.WriteLine("Start button done"); }
public void onStatusUpdate() { Debug.WriteLine("main_window: onStatusUpdate stage=" + LuckyMe.testStageString()); /* * onNeighborUpdate(); * onNewDataObject(); */ updateWindowStatus(); }
private void button_start_Haggle_Click(object sender, EventArgs e) { statusMsgLabel.Text = "Starting Haggle..."; start_haggle_button.Enabled = false; start_button.Enabled = false; shutdown_button.Enabled = false; progressBar.Visible = true; this.Refresh(); LuckyMe.startHaggle(); }
private void menuBack_Click(object sender, EventArgs e) { this.Activate(); if (LuckyMe.getTestStage() == LuckyMe.TestStage.NOT_RUNNING || LuckyMe.getTestStage() == LuckyMe.TestStage.RUNNING) { this.DialogResult = DialogResult.OK; this.Close(); } }
private void button_shutdown_Click(object sender, EventArgs e) { shutdown_button.Enabled = false; start_button.Enabled = false; stop_button.Enabled = false; this.Refresh(); if (LuckyMe.shutdown()) { Application.Exit(); } }
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(); }
private void button_stop_Click(object sender, EventArgs e) { switch (LuckyMe.getTestStage()) { case LuckyMe.TestStage.NOT_RUNNING: case LuckyMe.TestStage.STARTING: statusMsgLabel.Text = "Could not stop, test not running"; this.Refresh(); break; case LuckyMe.TestStage.RUNNING: stop_button.Enabled = false; menuBack.Text = ""; this.Refresh(); if (LuckyMe.stopTest()) { statusMsgLabel.Text = ""; } else { stop_button.Enabled = true; menuBack.Text = "Back"; statusMsgLabel.Text = "Could not stop test"; } this.Refresh(); break; case LuckyMe.TestStage.STOPPING: statusMsgLabel.Text = "Test is already stopping"; this.Refresh(); break; case LuckyMe.TestStage.SHUTDOWN: statusMsgLabel.Text = "Shutting down..."; this.Refresh(); break; } }
public static void eventCallback(LuckyMeLib.EventType eventType) { bool exitApplication = false; DialogResult res; // Make sure we execute the callbacks in the Window thread switch (eventType) { case LuckyMeLib.EventType.EVENT_TYPE_ERROR: Debug.WriteLine("main_window: got error event"); res = MessageBox.Show("An error occurred in LuckyMe. Exit LuckyMe?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (res == DialogResult.Yes) { exitApplication = true; if (LuckyMeLib.isLuckyMeRunning()) { LuckyMeLib.stopLuckyMe(0); } } break; case LuckyMeLib.EventType.EVENT_TYPE_SHUTDOWN: Debug.WriteLine("callback: Haggle was shutdown"); LuckyMeLib.stopLuckyMe(0); if (LuckyMe.getTestStage() == LuckyMe.TestStage.SHUTDOWN) { Debug.WriteLine("main_window: calling Application.Exit()"); exitApplication = true; } else { Debug.WriteLine("main_window: got shutdown event, but is not in shutdown stage"); res = MessageBox.Show("Haggle was shutdown. Exit LuckyMe?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (res == DialogResult.Yes) { exitApplication = true; } } main_window.BeginInvoke(new myDelegate(main_window.onShutdown)); testcontrol_window.BeginInvoke(new myDelegate(testcontrol_window.onShutdown)); uint n = 0; // Wait for Haggle to shutdown while (LuckyMeLib.isHaggleRunning() && n++ < 120) { Debug.WriteLine("Waiting for Haggle to exit..."); Thread.Sleep(1000); } Debug.WriteLine("Saving log files"); setTestStage(TestStage.SAVING_LOGS); archiveHaggleFiles(true); setTestStage(TestStage.NOT_RUNNING); Debug.WriteLine("Log files saved"); break; case LuckyMeLib.EventType.EVENT_TYPE_NEIGHBOR_UPDATE: Debug.WriteLine("callback neighbor update"); main_window.BeginInvoke(new myDelegate(main_window.onNeighborUpdate)); neighbor_window.BeginInvoke(new myDelegate(neighbor_window.onNeighborUpdate)); break; case LuckyMeLib.EventType.EVENT_TYPE_NEW_DATAOBJECT: Debug.WriteLine("callback new data object"); main_window.BeginInvoke(new myDelegate(main_window.onNewDataObject)); break; case LuckyMeLib.EventType.EVENT_TYPE_DATA_OBJECT_GENERATED: Debug.WriteLine("callback data object generated"); numDataObjectsGenerated++; main_window.BeginInvoke(new myDelegate(main_window.onDataObjectGenerated)); break; case LuckyMeLib.EventType.EVENT_TYPE_STATUS_UPDATE: Debug.WriteLine("callback status update"); main_window.BeginInvoke(new myDelegate(main_window.onStatusUpdate)); break; } if (exitApplication) { Application.Exit(); } }
public void onDataObjectGenerated() { Debug.WriteLine("main_window: onDataObjectGenerated stage=" + LuckyMe.testStageString()); numDataObjectsGenLabel.Text = LuckyMe.getNumDataObjectsGenerated() + " data objects generated"; this.Refresh(); }
public void updateWindowStatus() { bool haggleIsRunning = false; statusMsgLabel.Text = ""; testStageLabel.Text = "Test stage: " + LuckyMe.testStageString(); if (LuckyMeLib.isHaggleRunning()) { start_haggle_button.Enabled = false; statusMsgLabel.Text = "Haggle is running"; haggleIsRunning = true; } else { start_haggle_button.Enabled = true; } switch (LuckyMe.getTestStage()) { case LuckyMe.TestStage.NOT_RUNNING: start_button.Text = "Start test"; start_button.Enabled = true; stop_button.Text = "Stop test"; stop_button.Enabled = false; shutdown_button.Enabled = true; menuBack.Text = "Back"; updateStartupProgressBar(-1); progressBar.Visible = false; break; case LuckyMe.TestStage.STARTING: start_button.Text = "Please wait..."; start_button.Enabled = false; statusMsgLabel.Text = "Starting test, please wait..."; stop_button.Text = "Stop test"; stop_button.Enabled = false; shutdown_button.Enabled = false; start_haggle_button.Enabled = false; menuBack.Text = ""; if (!haggleIsRunning) { progressBar.Visible = true; } break; case LuckyMe.TestStage.RUNNING: start_button.Text = "Start test"; start_button.Enabled = false; stop_button.Text = "Stop test"; stop_button.Enabled = true; shutdown_button.Enabled = true; menuBack.Text = "Back"; updateStartupProgressBar(-1); progressBar.Visible = false; start_haggle_button.Enabled = false; break; case LuckyMe.TestStage.STOPPING: statusMsgLabel.Text = "Stopping test, please wait..."; start_button.Text = "Start test"; start_button.Enabled = false; stop_button.Enabled = false; stop_button.Text = "Please wait..."; shutdown_button.Enabled = false; menuBack.Text = ""; updateStartupProgressBar(-1); progressBar.Visible = false; start_haggle_button.Enabled = false; break; case LuckyMe.TestStage.SAVING_LOGS: statusMsgLabel.Text = "Saving log files, please wait..."; start_button.Enabled = false; stop_button.Enabled = false; stop_button.Text = "Please wait..."; shutdown_button.Enabled = false; start_haggle_button.Enabled = false; menuBack.Text = ""; break; case LuckyMe.TestStage.SHUTDOWN: progressBar.Visible = false; statusMsgLabel.Text = "Shutting down..."; start_haggle_button.Enabled = false; break; } this.Refresh(); }