public string Parse(EBinaryReader binreader)
 {
     switch (Type)
     {
         case SmartDataTypes.Byte:
         case SmartDataTypes.Char:
         case SmartDataTypes.Int:
         case SmartDataTypes.Long:
         case SmartDataTypes.Short:
         case SmartDataTypes.Float:
         case SmartDataTypes.Double:
         case SmartDataTypes.String:
         case SmartDataTypes.Bool:
         case SmartDataTypes.UTF8String:
             binreader.ReadByte();
             break;
         default:
             break;
     }
     switch (Type)
     {
         case SmartDataTypes.Byte:
             return binreader.ReadByte().ToString();
         case SmartDataTypes.Char:
             binreader.ReadByte();//I don't know why, just do it (always '\0')
             return binreader.ReadChar().ToString();
         case SmartDataTypes.Int:
             return binreader.ReadInt32().ToString();
         case SmartDataTypes.Long:
             return binreader.ReadInt64().ToString();
         case SmartDataTypes.Short:
             return binreader.ReadInt16().ToString();
         case SmartDataTypes.Float:
             return binreader.ReadSingle().ToString();
         case SmartDataTypes.Double:
             return binreader.ReadDouble().ToString();
         case SmartDataTypes.String:
             return binreader.ReadString();
         case SmartDataTypes.Bool:
             return binreader.ReadByte().ToString();
         case SmartDataTypes.UTF8String:
             return binreader.ReadUTFString();
         default:
             return "";
     }
 }
        /// <summary>
        /// The background worker. Will exit after 10 consectutive errors
        /// </summary>
        private void DoWork()
        {
            //number of errors
            int nume = 0;
            while (isrunning)
            {
                try
                {
                    IPEndPoint RIPend = null;
                    //Recieve the data
                    while (cRIOConnection.Available < 1018 && isrunning) { Thread.Sleep(2); }
                    if (!isrunning)
                    {
                        cRIOConnection.Close();
                        return;
                    }
                    byte[] buffer = cRIOConnection.Receive(ref RIPend);

                    //Check first
                    if (!VerifyPacket(buffer))
                    {
                        if (InvalidPacketRecieved != null && !peeking)
                        {
                            //Create our e
                            InvalidPacketRecievedEventArgs e = new InvalidPacketRecievedEventArgs(buffer, ddh.InvalidPacketAction == InvalidPacketActions.AlwaysContinue || ddh.InvalidPacketAction == InvalidPacketActions.Continue);
                            InvalidPacketRecieved(this, e);
                            if ((int)ddh.InvalidPacketAction < 3)//1-4
                            {
                                if (!e.ContinueAnyway)
                                    break;
                            }
                            else if (ddh.InvalidPacketAction == InvalidPacketActions.AlwaysIgnore)
                                break;
                        }
                    }

                    //DS Status
                    cStat = ParseDSBytes(buffer);

                    //Get a stream
                    MemoryStream Output = new MemoryStream(buffer);
                    Output.Seek(27, SeekOrigin.Begin);
                    EBinaryReader binladen = new EBinaryReader(Output);

                    //get length
                    int totallength = (binladen.ReadUInt16() << 16);
                    totallength += binladen.ReadUInt16();

                    //clear last loop's controls
                    kys = new ZomBDataLookup();

                    //loop all controls
                    while (totallength > (Output.Position - 27))
                    {
                        byte b = binladen.ReadByte();
                        switch (b)
                        {
                            case 0://Announce
                                {
                                    int id = binladen.ReadByte();
                                    SmartDataTypes type = (SmartDataTypes)binladen.ReadByte();
                                    int len = binladen.ReadUInt16();
                                    byte[] name = new byte[len];
                                    binladen.Read(name, 0, len);
                                    if (peeking)
                                    {
                                        dp.Invoke(cb, Encoding.UTF8.GetString(name));
                                        nametable[id] = new SmartInfo { Name = Encoding.UTF8.GetString(name), Type = type };
                                    }
                                    else
                                    {
                                        nametable[id] = new SmartInfo { Name = Encoding.UTF8.GetString(name), Type = type };
                                    }
                                    break;
                                }
                            case 1://Update
                                {
                                    int id = binladen.ReadByte();
                                    if (nametable.ContainsKey(id))
                                    {
                                        var info = nametable[id];
                                        string value = info.Parse(binladen);
                                        kys[info.Name] = new ZomBDataObject(value, info.ZomBTypeHint);
                                    }
                                    else
                                    {
                                        b = binladen.ReadByte();//get length
                                        binladen.Read(new byte[b], 0, b);//skip it
                                    }
                                    break;
                                }
                            case 2://GUI Announce, not impl
                                {
                                    System.Windows.Forms.MessageBox.Show("Dashboard selection via Protocol has not been implemented in ZomB, try WPF tabs instead");
                                    break;
                                }
                            default:
                                throw new Exception("Bin ("+b+") not a 1 or zero, exiting");
                        }
                    }

                    if (kys.Count > 0)//Empty keys in empty packet, "Smart" Dashboard can be dumb
                        //All in favor of chaging the name to DumbDashboard say "aye!" "sqrt(-1)!"
                    {
                        //Fire events
                        if (DataRecieved != null)
                            DataRecieved(this, new EventArgs());
                        if (NewStatusRecieved != null)
                            NewStatusRecieved(this, new NewStatusRecievedEventArgs(cStat));
                        if (NewDataRecieved != null)
                            NewDataRecieved(this, new NewDataRecievedEventArgs(kys));
                    }

                    if (nume > 0)
                        nume--;
                }
                catch (ThreadAbortException)
                {
                    isrunning = false;
                    cRIOConnection.Close();
                    return;
                }
                catch (Exception ex)
                {
                    nume++;
                    DoError(ex);
                    if (nume > 10)
                    {
                        isrunning = false;
                        DoError(new Exception("10 consecutive errors were encountered, stopping Smart"));
                        isrunning = false;
                        try
                        {
                            cRIOConnection.Close();
                        }
                        catch { }
                        return;
                    }
                }
            }
        }