public TargetTestBoard() { TestBoard = null; foreach (var dev in SignTest.Enumerate()) { try { TestBoard = new SignTest(dev); break; } catch { } } if (TestBoard == null) { throw new Exception("Unable to attach to a Sign Test board."); } SignComponent[] c = new SignComponent[1]; c[0] = new SignComponent() { X = 0, Y = 0, Width = 32, Height = 32 }; CurrentConfig = new SignConfiguration(c); // Initialize test board. TestBoard.SetMode(SignTest.DeviceMode.On); TestBoard.SetMode(SignTest.DeviceMode.FpgaActive); }
void Reset() { Dev.SetMode(SignTest.DeviceMode.Off); LastPrintedStatus = false; LastLineLength = 0; RecentStatus = new Queue <SignTestStatus>(); CurrentState = TestState.WaitForDevice; }
public void Run() { Dev = new SignTest(SignTest.Enumerate().First()); Reset(); while (true) { if (System.Diagnostics.Debugger.IsAttached) { // Run without exception handling in the debugger. Loop(); } else { try { Loop(); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("Exception!"); Console.WriteLine(ex.ToString()); try { Dev.SetLed(false, true); } catch { } Thread.Sleep(2000); Console.WriteLine("Restarting..."); Reset(); } } // Check for some control characters if (Console.KeyAvailable) { ConsoleKeyInfo k = Console.ReadKey(true); switch (char.ToLower(k.KeyChar)) { case '?': case 'h': WriteText("Special keys: 'x' Exit, 'r' Reprogram test board, <space> reprogram current board."); break; case 'x': // Clean up and exit WriteText("'x' pressed, exiting."); Reset(); return; case 'r': WriteText("'r' pressed, putting test board into reprogramming mode."); Reset(); Dev.Reprogram(); return; case ' ': WriteText("<Space> pressed, resetting test system state."); Reset(); break; case 'f': WriteText("'f' pressed, restarting FPGA"); try { Dev.SetMode(SignTest.DeviceMode.FpgaActive); // Restarts FPGA. } catch (Exception ex) { WriteText(ex.ToString()); } break; case 'c': WriteText("Going into a cycle of power on/off"); int count = 0; string statusText = ""; while (true) { if (count == 0) { statusText = "Power On"; Dev.SetLed(true, false); Dev.SetMode(SignTest.DeviceMode.On); try { Dev.SetMode(SignTest.DeviceMode.FpgaActive); } catch { } } if (count == 40) { statusText = "Power Off"; Dev.SetLed(false, false); Dev.SetMode(SignTest.DeviceMode.Off); } count++; if (count == 80) { count = 0; } UpdateStatus(statusText); Thread.Sleep(100); } } } Thread.Sleep(100); } }