Example #1
0
        /// <summary>
        /// Setups this hardware device driver
        /// </summary>
        /// <returns></returns>
        public override bool Setup(IHardwareResources hardwareResources)
        {
            this.hardwareResources = hardwareResources;
            base.name = "AMDPCNet_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X");

            ioProm1 = hardwareResources.GetIOPort(0, 0x0);
            ioProm4 = hardwareResources.GetIOPort(0, 0x4);
            rdp     = hardwareResources.GetIOPort(0, 0x10);
            rap     = hardwareResources.GetIOPort(0, 0x14);
            bdp     = hardwareResources.GetIOPort(0, 0x1C);

            initBlock    = hardwareResources.GetMemory(0);
            txDescriptor = hardwareResources.GetMemory(1);
            rxDescriptor = hardwareResources.GetMemory(2);
            buffers      = hardwareResources.GetMemory(3);

            bufferSize = 2048;
            uint len = (ushort)(~bufferSize);

            len = (len + 1) & 0x0FFF | 0x8000F000;

            physicalBufferAddress = HAL.GetPhysicalAddress(buffers);

            for (uint index = 0; index < 16; index++)
            {
                uint offset = index * 4;
                rxDescriptor.Write32((offset + 1) * 4, len);
                rxDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * index));
                txDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * (index + 16)));
            }

            nextTXDesc = 0;

            return(true);
        }
Example #2
0
        protected override void Initialize()
        {
            Device.Name = "AMDPCNet_0x" + Device.Resources.GetIOPortRegion(0).BaseIOPort.ToString("X");

            ioProm1 = Device.Resources.GetIOPortReadWrite(0, 0x0);
            ioProm4 = Device.Resources.GetIOPortReadWrite(0, 0x4);
            rdp     = Device.Resources.GetIOPortReadWrite(0, 0x10);
            rap     = Device.Resources.GetIOPortReadWrite(0, 0x14);
            bdp     = Device.Resources.GetIOPortReadWrite(0, 0x1C);

            initBlock    = Device.Resources.GetMemory(0);
            txDescriptor = Device.Resources.GetMemory(1);
            rxDescriptor = Device.Resources.GetMemory(2);
            buffers      = Device.Resources.GetMemory(3);

            bufferSize = 2048;
            uint len = (ushort)(~bufferSize);

            len = ((len + 1) & 0x0FFF) | 0x8000F000;

            physicalBufferAddress = HAL.GetPhysicalAddress(buffers);

            for (uint index = 0; index < 16; index++)
            {
                uint offset = index * 4;
                rxDescriptor.Write32((offset + 1) * 4, len);
                rxDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * index));
                txDescriptor.Write32((offset + 2) * 4, physicalBufferAddress + (bufferSize * (index + 16)));
            }

            nextTXDesc = 0;
        }
Example #3
0
        public void Test1()
        {
            var result = HAL.Builder()
                         .WithState(new { Name = "Masoud", Familty = "Bahrami", Age = 25 })
                         .WithSelfLink("/person/20", HttpVerbs.GET, false)
                         .WithFirstLink("/person/first", HttpVerbs.GET, false)
                         .WithLastLink("/person/last", HttpVerbs.GET, false)
                         .WithLink(new LinkObject("test")
            {
                Links = new List <Link>
                {
                    Link.New("asd").WithQueryParameter(ScalarQueryParameter.NewBoolean("has", 2))
                    .WithQueryParameter(ScalarQueryParameter.NewNumber("age", 1))
                }
            })
                         .WithEmbedded(new Embedded("ed:orders")
                                       .WithResource(EmbeddedResource.New(masoud)
                                                     .WithSelfLink("/orders/123", HttpVerbs.GET)
                                                     .WithLinkObject("basket", "/orders/123", HttpVerbs.GET))
                                       )
                         .WithEmbedded(new Embedded("ed:saba")
                                       .WithResource(EmbeddedResource.New(masoud)
                                                     .WithSelfLink("/orders/123", HttpVerbs.GET)
                                                     .WithLinkObject("basket", "/orders/123", HttpVerbs.GET))
                                       )

                         .Build();
        }
Example #4
0
 public static void Initialize(HAL hal)
 {
     hal.Frame((new Points_CS()
     {
         hal = hal
     }).Frame);
 }
Example #5
0
        /// <summary>
        /// Create a new PCIDevice instance
        /// </summary>
        /// <param name="pciController">The pci controller.</param>
        /// <param name="bus">The bus.</param>
        /// <param name="slot">The slot.</param>
        /// <param name="fun">The fun.</param>
        public PCIDevice(IPCIController pciController, byte bus, byte slot, byte fun)
        {
            base.parent       = pciController as Device;
            base.name         = base.parent.Name + "/" + bus.ToString() + "." + slot.ToString() + "." + fun.ToString();
            base.deviceStatus = DeviceStatus.Available;

            this.pciController = pciController;
            Bus      = bus;
            Slot     = slot;
            Function = fun;

            ioPortRegionCount = memoryRegionCount = 0;
            BaseAddresses     = new BaseAddress[8];

            for (byte i = 0; i < 6; i++)
            {
                uint address = pciController.ReadConfig32(bus, slot, fun, (byte)(16 + (i * 4)));

                if (address != 0)
                {
                    HAL.DisableAllInterrupts();

                    pciController.WriteConfig32(bus, slot, fun, (byte)(16 + (i * 4)), 0xFFFFFFFF);
                    uint mask = pciController.ReadConfig32(bus, slot, fun, (byte)(16 + (i * 4)));
                    pciController.WriteConfig32(bus, slot, fun, (byte)(16 + (i * 4)), address);

                    HAL.EnableAllInterrupts();

                    if (address % 2 == 1)
                    {
                        BaseAddresses[i] = new BaseAddress(AddressType.IO, address & 0x0000FFF8, (~(mask & 0xFFF8) + 1) & 0xFFFF, false);
                    }
                    else
                    {
                        BaseAddresses[i] = new BaseAddress(AddressType.Memory, address & 0xFFFFFFF0, ~(mask & 0xFFFFFFF0) + 1, ((address & 0x08) == 1));
                    }
                }
            }

            if ((ClassCode == 0x03) && (SubClassCode == 0x00) && (ProgIF == 0x00))
            {
                // Special case for generic VGA
                BaseAddresses[6] = new BaseAddress(AddressType.Memory, 0xA0000, 0x1FFFF, false);
                BaseAddresses[7] = new BaseAddress(AddressType.IO, 0x3B0, 0x0F, false);
            }

            foreach (var baseAddress in BaseAddresses)
            {
                if (baseAddress != null)
                {
                    switch (baseAddress.Region)
                    {
                    case AddressType.IO: ioPortRegionCount++; break;

                    case AddressType.Memory: memoryRegionCount++; break;
                    }
                }
            }
        }
Example #6
0
        public static void Initialize(BaseHardwareAbstraction hardware, HAL.HandleInterrupt handleInterrupt)
        {
            // Set device driver system to the hardware HAL
            HAL.SetHardwareAbstraction(hardware);

            // Set the interrupt handler
            HAL.SetInterruptHandler(handleInterrupt);
        }
        public override void RobotInit()
        {
            int  status = 0;
            uint value  = HAL.GetFPGARevision(ref status);

            Utility.CheckStatus(status);
            Console.WriteLine(value);
        }
Example #8
0
        /// <summary>Waits for fifo.</summary>
        protected void WaitForFifo()
        {
            SVGASetRegister(SVGA_REGISTERS.Sync, 1);

            while (SVGAGetRegister(SVGA_REGISTERS.Busy) != 0)
            {
                HAL.Sleep(5);
            }
        }
Example #9
0
        /// <summary>
        /// Waits for fifo.
        /// </summary>
        protected void WaitForFifo()
        {
            SendCommand(Register.Sync, 1);

            while (ReadRegister(Register.Busy) != 0)
            {
                HAL.Sleep(10);
            }
        }
        /// <summary>
        /// Turns the on motor.
        /// </summary>
        /// <param name="drive">The drive.</param>
        protected void TurnOnMotor(uint drive)
        {
            byte reg  = commandPort.Read8();
            byte bits = (byte)(DORFlags.MotorShift << (byte)drive | DORFlags.EnableDMA | DORFlags.EnableController | (byte)drive);

            if (reg != bits)
            {
                commandPort.Write8(bits);
                HAL.Sleep(500);                 // 500 msec
            }
        }
Example #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InterruptHandler"/> class.
        /// </summary>
        /// <param name="interruptManager">The interrupt manager.</param>
        /// <param name="irq">The irq.</param>
        /// <param name="hardwareDevice">The hardware device.</param>
        public InterruptHandler(InterruptManager interruptManager, byte irq, IHardwareDevice hardwareDevice)
        {
            if (hardwareDevice == null)
            {
                HAL.Abort("hardwareDevice == null");
            }

            this.interruptManager = interruptManager;
            this.irq            = irq;
            this.hardwareDevice = hardwareDevice;
        }
        /// <summary>
        /// Resets the controller.
        /// </summary>
        protected void ResetController()
        {
            ClearInterrupt();

            commandPort.Write8(DORFlags.ResetController);

            HAL.Sleep(200);

            commandPort.Write8(DORFlags.EnableController);

            WaitForInterrupt(3000);
        }
Example #13
0
        /// <summary>
        /// Reads the scan code from the device
        /// </summary>
        protected void ReadScanCode()
        {
            spinLock.Enter();

            byte v = commandPort.Read8();

            AddToFIFO(v);

            HAL.DebugWrite(" scancode: " + v.ToString() + "   ");

            spinLock.Exit();
        }
Example #14
0
 public void Should_Raise_Error_If_ObjectState_IsNull()
 {
     //Assert
     Assert.Throws <HalObjectStateIsNullExeption>(() => HAL.Builder().Build());
     Assert.Throws <HalObjectStateIsNullExeption>(() => HAL.Builder().WithLink(new LinkObject("orders")
     {
         Links = new List <Link>()
         {
             new Link("/Order")
         }
     }).Build());
 }
Example #15
0
        public void Test2()
        {
            EmbeddedCollection embeddedCollection = new EmbeddedCollection("Ordered")
            {
                masoud
            };

            var result = HAL.Builder()
                         .WithState(masoud)
                         .WithEmbededState(embeddedCollection)
                         .Build();
        }
 void Connections_OnMessageReceivedPistol1(object sender, HAL.MessageEventArgs e)
 {
     string image = GetImage(e);
     if (!string.IsNullOrEmpty(image))
     {
         UIDispatcher.BeginInvoke(new Action(() =>
         {
             string test = string.Format(@"pack://application:,,,/CarUI;component/Resources/{0}", image);
             this.redArrowImage.Source = new BitmapImage(new Uri(test));
         }));
     }
 }
 void Connections_OnMessageReceivedPistol1(object sender, HAL.MessageEventArgs e)
 {
     Connections.OnMessageReceivedPistol1 -= new EventHandler<HAL.MessageEventArgs>(Connections_OnMessageReceivedPistol1);
     UIDispatcher.BeginInvoke(new Action(() =>
     {
         lblGreen.Visibility = System.Windows.Visibility.Visible;
         if (m_RedConnected)
         {
             StartCountdown();
         }
     }));
     m_GreenConnected = true;
 }
Example #18
0
        public void Should_Be_Ok_If_StateObject_Be_IState()
        {
            //Arrange && Act
            var masoud = new Person("Masoud", "Bahrami", 35);
            var sut    = HAL.Builder()
                         .WithState(masoud)
                         .Build();

            //Assert
            Assert.True(JObject.Parse(sut)[nameof(Person.FirstName)].Value <string>() == masoud.FirstName);
            Assert.True(JObject.Parse(sut)[nameof(Person.LastName)].Value <string>() == masoud.LastName);
            Assert.True(JObject.Parse(sut)[nameof(Person.Age)].Value <int>() == masoud.Age);
            Assert.True(JObject.Parse(sut)[LINK_TITLE].Count() == masoud.LinkObjects.Count);
        }
Example #19
0
        public void Should_Be_Ok_Event_Links_And_Embedded_Are_Empty()
        {
            //Arrange
            var currentDateTime = DateTime.Now;

            //Arrange && Act
            var sut = HAL.Builder()
                      .WithState(new { EventId = 1, OccuredAt = currentDateTime })
                      .Build();

            //Assert
            Assert.True(JObject.Parse(sut)["OccuredAt"].Value <DateTime>() == currentDateTime);
            Assert.True(JObject.Parse(sut)["EventId"].Value <int>() == 1);
        }
Example #20
0
        /// <summary>
        /// Setups this hardware device driver
        /// </summary>
        /// <returns></returns>
        public override bool Setup(IHardwareResources hardwareResources)
        {
            this.hardwareResources = hardwareResources;
            base.name = "VMWARE_SVGA_0x" + hardwareResources.GetIOPortRegion(0).BaseIOPort.ToString("X");

            indexPort = hardwareResources.GetIOPort(0, 0);
            valuePort = hardwareResources.GetIOPort(0, 1);
            HAL.DebugWrite("**G**");
            memory = base.hardwareResources.GetMemory(0);
            HAL.DebugWrite("**I**");
            fifo = base.hardwareResources.GetMemory(1);
            HAL.DebugWrite("**J**");
            return(true);
        }
Example #21
0
        public void Should_Be_Ok_If_StateObject_Is_A_Collection_Of_Key_Value()
        {
            //Arrange && Act
            var sut = HAL.Builder()
                      .WithState("Name", "Masoud")
                      .WithState("Family", "Bahrami")
                      .WithState("Age", "1")
                      .Build();

            //Assert
            Assert.True(JObject.Parse(sut)["Name"].Value <string>() == "Masoud");
            Assert.True(JObject.Parse(sut)["Family"].Value <string>() == "Bahrami");
            Assert.True(JObject.Parse(sut)["Age"].Value <int>() == 1);
        }
        /// <summary>
        /// Seeks the specified drive.
        /// </summary>
        /// <param name="drive">The drive.</param>
        /// <param name="track">The track.</param>
        /// <param name="head">The head.</param>
        /// <returns></returns>
        protected bool Seek(uint drive, byte track, byte head)
        {
            TurnOnMotor(drive);

            if (!lastSeek[drive].calibrated)
            {
                if (!Recalibrate(drive))
                {
                    return(false);
                }
            }

            if ((lastSeek[drive].calibrated) && (lastSeek[drive].track == track) && (lastSeek[drive].head == head))
            {
                return(true);
            }

            for (int i = 0; i < 5; i++)
            {
                ClearInterrupt();

                lastSeek[drive].calibrated = false;

                SendByte(FIFOCommand.Seek);
                SendByte((byte)(((byte)drive | (head << 2))));
                SendByte(track);

                if (!WaitForInterrupt(3000))
                {
                    return(false);
                }

                HAL.Sleep(20);

                SendByte(FIFOCommand.SenseInterrupt);
                byte sr0 = GetByte();
                byte trk = GetByte();

                if ((sr0 == (0x20 + ((byte)drive | (head << 2)))) && (trk == track))
                {
                    lastSeek[drive].calibrated = true;
                    lastSeek[drive].track      = track;
                    lastSeek[drive].head       = head;
                    return(true);
                }
            }

            return(false);
        }
Example #23
0
        public static DeviceManager Initialize(PlatformArchitecture platform, BaseHardwareAbstraction hardware)
        {
            // Create Device Manager
            var deviceManager = new DeviceManager(platform);

            deviceManager.RegisterDaemon(new DiskDeviceMountDeamon());

            // Set device driver system to the hardware HAL
            HAL.SetHardwareAbstraction(hardware);

            // Set the interrupt handler
            HAL.SetInterruptHandler(deviceManager.ProcessInterrupt);

            return(deviceManager);
        }
Example #24
0
        public void Property_State_Will_Be_Replaced_If_Already_Set()
        {
            //Arrange
            var propertyName = "Name";
            var sut          = HAL.Builder()
                               .WithState(propertyName, "Masoud");

            //Arrange && Act
            sut.WithState(propertyName, "Ali");
            var result = sut.Build();

            //Assert
            Assert.True(JObject.Parse(result)[propertyName].Value <string>() == "Ali");
            Assert.False(JObject.Parse(result)[propertyName].Value <string>() == "Masoud");
        }
Example #25
0
        public void Should_Be_Ok_If_StateObject_Is_A_Dictionery_Of_Key_Value()
        {
            //Arrange && Act
            var sut = HAL.Builder()
                      .WithState(new Dictionary <string, object>
            {
                { "Name", "Masoud" },
                { "Family", "Bahrami" }
            })
                      .Build();

            //Assert
            Assert.True(JObject.Parse(sut)["Name"].Value <string>() == "Masoud");
            Assert.True(JObject.Parse(sut)["Family"].Value <string>() == "Bahrami");
        }
Example #26
0
        public void Should_Be_Ok_If_StateObject_Is_Anonymous()
        {
            //Arrange
            var masoud  = "Masoud";
            var bahrami = "Bahrami";

            //Arrange && Act
            var sut = HAL.Builder()
                      .WithState(new { Name = masoud, Familty = "Bahrami", Age = 25 })
                      .Build();

            //Assert
            Assert.True(JObject.Parse(sut)["Name"].Value <string>() == masoud);
            Assert.True(JObject.Parse(sut)["Familty"].Value <string>() == bahrami);
            Assert.True(JObject.Parse(sut)["Age"].Value <int>() == 25);
        }
Example #27
0
        static void Main(string[] args)
        {
            int QueueCapacity   = 10;
            int StorageCapacity = 15;

            HAL    hal01   = new HAL(0.5, 7, "hal01", new Coordinates(0, 0), new Coordinates(5, 5));
            R2D2   r2d201  = new R2D2(1.5, 5.5, "r2d201", new Coordinates(0, 0), new Coordinates(5, 5));
            T_800  t80001  = new T_800(3, 10, "t80001", new Coordinates(0, 0), new Coordinates(5, 5));
            Wall_E walle01 = new Wall_E(2, 4, "walle01", new Coordinates(0, 0), new Coordinates(5, 5));

            UnitFactory unitFactory = new UnitFactory(QueueCapacity, StorageCapacity);

            unitFactory.AddWorkableUnitToQueue(hal01.GetType(), hal01.Name, hal01.parkingPos, hal01.workingPos);
            unitFactory.AddWorkableUnitToQueue(r2d201.GetType(), r2d201.Name, r2d201.parkingPos, r2d201.workingPos);
            unitFactory.AddWorkableUnitToQueue(t80001.GetType(), t80001.Name, hal01.parkingPos, t80001.workingPos);
            unitFactory.AddWorkableUnitToQueue(walle01.GetType(), walle01.Name, walle01.parkingPos, walle01.workingPos);
        }
Example #28
0
        public override void Start()
        {
            if (Device.Status != DeviceStatus.Available)
            {
                return;
            }

            // Enable the card
            //HardwareResources.DeviceResource.EnableDevice(); // TODO

            // Do a 32-bit write to set 32-bit mode
            rdp.Write32(0);

            // Get the EEPROM MAC Address
            var eepromMac = new byte[6];
            var data      = ioProm1.Read32();

            eepromMac[0] = (byte)(data & 0xFF);
            eepromMac[1] = (byte)((data >> 8) & 0xFF);
            eepromMac[2] = (byte)((data >> 16) & 0xFF);
            eepromMac[3] = (byte)((data >> 24) & 0xFF);
            data         = ioProm4.Read32();
            eepromMac[4] = (byte)(data & 0xFF);
            eepromMac[5] = (byte)((data >> 8) & 0xFF);

            macAddress = new MACAddress(eepromMac);

            // Fill in the initialization block
            initBlock.Write32(0, (0x4 << 28) | (0x4 << 30));
            initBlock.Write32(4, (uint)(eepromMac[0] | (eepromMac[1] << 8) | (eepromMac[2] << 16) | (eepromMac[3] << 24)));
            initBlock.Write32(8, (uint)(eepromMac[4] | (eepromMac[5] << 8)));             // Fill in the hardware MAC address
            initBlock.Write32(16, 0x0);
            initBlock.Write32(24, 0x0);
            initBlock.Write32(28, rxDescriptor.Address);
            initBlock.Write32(32, txDescriptor.Address);

            // Write the initialization blocks address to the registers on the card
            InitializationBlockAddress = HAL.GetPhysicalAddress(initBlock);

            // Set the device to PCNet-PCI II Controller mode (full 32-bit mode)
            SoftwareStyleRegister = 0x03;

            nextTXDesc = 0;

            Device.Status = DeviceStatus.Online;
        }
Example #29
0
        public void ProcessInterrupt(uint interrupt, uint errorCode)
        {
            tick++;

            uint column     = debug.Column;
            uint row        = debug.Row;
            var  color      = debug.Color;
            var  background = debug.BackgroundColor;
            uint scrollrow  = debug.ScrollRow;

            debug.Color           = ScreenColor.Cyan;
            debug.BackgroundColor = ScreenColor.Black;
            debug.Row             = 24;
            debug.Column          = 0;
            debug.ScrollRow       = debug.Rows;

            debug.Write("Shell Mode - ");
            debug.Write("Tick: ");
            debug.Write(tick, 10, 7);
            debug.Write(" Free Memory: ");
            debug.Write((PageFrameAllocator.TotalPages - PageFrameAllocator.TotalPagesInUse) * PageFrameAllocator.PageSize / (1024 * 1024));
            debug.Write(" MB ");

            debug.Write("IRQ: ");
            debug.Write(interrupt, 16, 2);

            if (interrupt >= 0x20 && interrupt < 0x30)
            {
                HAL.ProcessInterrupt((byte)(interrupt - 0x20));
            }

            debug.BackgroundColor = background;
            debug.ScrollRow       = scrollrow;
            debug.Column          = column;
            debug.Color           = color;
            debug.Row             = row;

            if (interrupt == 0x21)
            {
                CheckForKeyPress();
            }
        }
Example #30
0
        public void Should_Successfully_Insrted_Edit_Link_Using_WithFirstLink_Method()
        {
            //Arrange
            var currentDateTime = DateTime.Now;

            //Arrange && Act
            var sut = HAL.Builder()
                      .WithState("Name", "Masoud")
                      .WithEditLink("/user/{name}", HttpVerbs.GET, true)
                      .Build();

            //Assert
            Assert.True(JObject.Parse(sut)["Name"].Value <string>() == "Masoud");

            //Arrange
            var link = JObject.Parse(sut)[LINK_TITLE][LinkRelations.Edit].ToObject(typeof(Link));

            //Assert
            Assert.True((link as Link).HRef == "/user/{name}");
        }
Example #31
0
        public void Should_Successfully_Insrted_Curi_Link_Using_WithFirstLink_Method()
        {
            //Arrange
            var currentDateTime = DateTime.Now;

            //Arrange && Act
            var sut = HAL.Builder()
                      .WithState("Name", "Masoud")
                      .WithCuriLink("userMgmt", "/user/")
                      .Build();

            //Assert
            Assert.True(JObject.Parse(sut)["Name"].Value <string>() == "Masoud");

            //Arrange
            var link = JObject.Parse(sut)[LINK_TITLE][LinkRelations.Curries].ToObject(typeof(Link));

            //Assert
            Assert.True((link as Link).HRef == "/user/{rel}");
            Assert.True((link as Link).Templated);
        }
Example #32
0
        /// <summary>
        /// Starts this hardware device.
        /// </summary>
        /// <returns></returns>
        public override DeviceDriverStartStatus Start()
        {
            DeviceHeadPort.Write8(0xA0);

            HAL.Sleep(1000 / 250);             // wait 1/250th of a second

            if ((StatusPort.Read8() & 0x40) == 0x40)
            {
                driveInfo[0].Present = true;
            }

            DeviceHeadPort.Write8(0xB0);

            HAL.Sleep(1000 / 250);             // wait 1/250th of a second

            if ((StatusPort.Read8() & 0x40) == 0x40)
            {
                driveInfo[1].Present = true;
            }

            return(DeviceDriverStartStatus.Started);
        }
 private static string GetImage(HAL.MessageEventArgs e)
 {
     string image = "";
     switch (e.message)
     {
         case "fr":
             image = "arrow forward right.png";
             break;
         case "fl":
             image = "arrow forward left.png";
             break;
         case "br":
             image = "arrow backward right.png";
             break;
         case "bl":
             image = "arrow backward left.png";
             break;
         default:
             break;
     }
     return image;
 }
        void Finish_OnMessageReceived(object sender, HAL.MessageEventArgs e)
        {
            Connections.OnMessageReceivedFinish += new EventHandler<HAL.MessageEventArgs>(Finish_OnMessageReceived);
            Connections.OnMessageReceivedPistol1 -= new EventHandler<HAL.MessageEventArgs>(Connections_OnMessageReceivedPistol1);
            Connections.OnMessageReceivedPistol2 -= new EventHandler<HAL.MessageEventArgs>(Connections_OnMessageReceivedPistol2);
            switch (e.message.ToLower().Trim())
            {
                case "red":

                    if (!hasWinner)
                    {
                        hasWinner = true;
                        UIDispatcher.BeginInvoke(new Action(() =>
                        {
                            greenArrowImage.Visibility = System.Windows.Visibility.Hidden;
                            redArrowImage.Visibility = System.Windows.Visibility.Hidden;
                            redWinnerImage.Visibility = System.Windows.Visibility.Visible;
                            redFlagImage.Visibility = System.Windows.Visibility.Visible;
                        }));
                        Thread.Sleep(10000);
                        UIDispatcher.BeginInvoke(new Action(() =>
                        {
                            Switcher.Switch(new Homepage());
                        }));
                    }
                    break;
                case "green":

                    if (!hasWinner)
                    {
                        hasWinner = true;
                        UIDispatcher.BeginInvoke(new Action(() =>
                        {
                            redArrowImage.Visibility = System.Windows.Visibility.Hidden;
                            greenArrowImage.Visibility = System.Windows.Visibility.Hidden;
                            greenWinnerImage.Visibility = System.Windows.Visibility.Visible;
                            greenFlagImage.Visibility = System.Windows.Visibility.Visible;
                        }));
                        Thread.Sleep(10000);
                        UIDispatcher.BeginInvoke(new Action(() =>
                        {
                            Switcher.Switch(new Homepage());
                        }));
                    }
                    break;
                default:
                    Console.WriteLine("Invalid message from finish: " + e.message);
                    break;
            }
        }
 void Receiver_OnMessageReceived(object sender, HAL.MessageEventArgs e)
 {
     throw new NotImplementedException();
 }