Пример #1
0
 protected override void OnClosing(CancelEventArgs e)
 {
     // remove IO from IO Manager
     if (SegmentDisplay != null)
     {
         _ioManager?.RemoveIODevice(SegmentDisplay.IOPort);
         SegmentDisplay = null;
     }
     base.OnClosing(e);
 }
Пример #2
0
        public void SevenSegmentTestsTests_ExecuteOneInstruction_Success()
        {
            var display = new IOSevenSegmentDisplay(4);

            Assert.AreEqual(false, display.HasData);
            Assert.AreEqual(string.Empty, display.Data);

            display.WriteInPort(4, "F6");

            Assert.AreEqual("11110110", display.Data);

            Console.WriteLine(display);
        }
Пример #3
0
        public void SevenSegmentTestsTests_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);

            IOSevenSegmentDisplay segment = new IOSevenSegmentDisplay(9);

            manager.AddIODevice(9, segment);

            Console.WriteLine("\nAfter adding IO Hex Keyboard:");
            Console.WriteLine(manager);

            for (int i = 0; i < 7; i++)
            {
                micro.NextInstruction();
            }

            foreach (char c in segment.Data)
            {
                Assert.AreEqual("11110110", segment.Data);
            }

            Console.WriteLine(segment);
        }
Пример #4
0
        public SevenSegmentWindow(IOManager ioManager, ushort port)
        {
            InitializeComponent();

            _ioManager = ioManager;

            portNumber.Content = "0x" + UnitConverter.IntToHex(port, defaultWidth: 3);

            // initialize IO Device
            SegmentDisplay = new IOSevenSegmentDisplay(port);

            SegmentDisplay.UpdateGui += UpdateDisplay;

            // try to add to IO Manager
            // exception wil be thrown if invalid port is selected
            _ioManager.AddIODevice(port, SegmentDisplay);

            try
            {
                MouseDown += delegate { DragMove(); };
            }
            catch (Exception) { }
        }