public IOBinSemaforoUI(IOManager ioManager, ushort port) { InitializeComponent(); //initialize colors Red = IR.Fill; Yello = IA.Fill; Green = IV.Fill; Black = new SolidColorBrush(Color.FromRgb(0, 0, 0)); _active = true; _ioManager = ioManager; LightsOff(); portNumber.Content = "0x" + UnitConverter.IntToHex(port, defaultWidth: 3); // initialize IO Device semaforo = new IOBinSemaforo(port); //add function to delegate semaforo.GotBinContent += UpdateSemaforo; // try to add to IO Manager // exception wil be thrown if invalid port is selected _ioManager.AddIODevice(port, semaforo); try { MouseDown += delegate { DragMove(); }; } catch (Exception) { } }
public void IOBinSemaforoTests_WriteFromMicro_Success() { VirtualMemory vm = new VirtualMemory(new string[] { "a806", "ff07", "0000", "0102", "0203", "c940", "a812", "1a04", "a816", "1904", "0b08", "a816" }); IOManager manager = new IOManager(100); MicroSimulator micro = new MicroSimulator(vm, manager); Console.WriteLine("Initial State:"); Console.Write(vm); Console.WriteLine(manager); Console.WriteLine(micro); IOBinSemaforo semaforo = new IOBinSemaforo(4, "#Debug"); manager.AddIODevice(4, semaforo); Console.WriteLine("\nAfter adding IO Hex Keyboard:"); Console.WriteLine(manager); for (int i = 0; i < 7; i++) { micro.NextInstruction(); } foreach (char c in semaforo.BitContent) { Assert.AreEqual('1', c); } Console.WriteLine(semaforo); }
public void IOBinSemaforoTests_ExecuteOneInstruction_Success() { IOBinSemaforo semaforo = new IOBinSemaforo(4, "#Debug"); Assert.AreEqual(false, semaforo.HasData); foreach (char c in semaforo.BitContent) { Assert.AreEqual('0', c); } semaforo.WriteInPort(4, "FF"); foreach (char c in semaforo.BitContent) { Assert.AreEqual('1', c); } Console.WriteLine(semaforo); }