//public int PlasmaScale = 100;


        /// <summary>
        /// Parses the setting data. <br />
        /// </summary>
        /// <param name="SettingData">The setting data.</param>
        /// <exception cref="System.Exception">
        /// No data to parse.
        /// or
        /// Cant parse the part {0} of the ledcontrol table config setting {1}..
        /// </exception>
        public void ParseSettingData(string SettingData)
        {
            string S = SettingData.Trim().ToUpper();

            if (S.StartsWith("("))
            {
                //It is a condition

                int BracketCnt        = 1;
                int ClosingBracketPos = -1;
                for (int i = 1; i < S.Length; i++)
                {
                    if (S[i] == '(')
                    {
                        BracketCnt++;
                    }
                    else if (S[i] == ')')
                    {
                        BracketCnt--;
                    }

                    if (BracketCnt == 0)
                    {
                        ClosingBracketPos = i;
                        break;
                    }
                }


                if (ClosingBracketPos > 0)
                {
                    Condition     = S.Substring(0, ClosingBracketPos + 1);
                    OutputControl = OutputControlEnum.Condition;
                    S             = S.Substring(Condition.Length).Trim();
                    //TODO: Maybe add a check for the condition validity
                }
                else
                {
                    Log.Warning("No closing bracket found for condition in setting {0}.".Build(S));

                    throw new Exception("No closing bracket found for condition in setting {0}.".Build(S));
                }
            }
            else
            {
                //not a condition

                if (S.Length == 0)
                {
                    Log.Warning("No data to parse.");

                    throw new Exception("No data to parse.");
                }

                int  TriggerEndPos = -1;
                char LastChar      = (char)0;
                for (int i = 0; i < S.Length - 1; i++)
                {
                    if (S[i] == ' ' && LastChar != '|' && LastChar != (char)0)
                    {
                        TriggerEndPos = i;
                        break;
                    }
                    if (S[i] != ' ')
                    {
                        LastChar = S[i];
                    }
                }
                if (TriggerEndPos == -1)
                {
                    TriggerEndPos = S.Length;
                }

                string Trigger = S.Substring(0, TriggerEndPos).Trim();



                //Get output state and table element (if applicable)
                bool ParseOK = true;
                switch (Trigger.ToUpper())
                {
                case "ON":
                case "1":
                    OutputControl = OutputControlEnum.FixedOn;
                    break;

                case "OFF":
                case "0":
                    OutputControl = OutputControlEnum.FixedOff;
                    break;

                case "B":
                case "BLINK":
                    OutputControl   = OutputControlEnum.FixedOn;
                    Blink           = -1;
                    BlinkIntervalMs = 1000;
                    break;

                default:
                    string[] ATE = Trigger.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(Tr => Tr.Trim()).ToArray();
                    foreach (string E in ATE)
                    {
                        if (E.Length > 1)
                        {
                            if (E[0] == (char)TableElementTypeEnum.NamedElement && E.Substring(1).All(C => char.IsLetterOrDigit(C) || C == '_'))
                            {
                                //Named element
                            }
                            else if (Enum.IsDefined(typeof(TableElementTypeEnum), (int)E[0]) && E.Substring(1).IsInteger())
                            {
                                //Normal table element
                            }
                            else
                            {
                                Log.Write("Failed: " + E);
                                ParseOK = false;
                                break;
                            }
                        }
                        else
                        {
                            ParseOK = false;
                            break;
                        }
                    }
                    if (ParseOK)
                    {
                        OutputControl = OutputControlEnum.Controlled;
                        TableElement  = Trigger;
                    }



                    break;
                }
                if (!ParseOK)
                {
                    Log.Warning("Cant parse the trigger part {0} of the ledcontrol table config setting {1}.".Build(Trigger, SettingData));

                    throw new Exception("Cant parse the part {0} of the ledcontrol table config setting {1}.".Build(Trigger, SettingData));
                }

                //Remove first part
                S = S.Substring(Trigger.Length).Trim();
            }


            string[] Parts = S.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);


            int IntegerCnt = 0;
            int PartNr     = 0;

            while (Parts.Length > PartNr)
            {
                if (Parts[PartNr].ToUpper() == "BLINK")
                {
                    Blink           = -1;
                    BlinkIntervalMs = 1000;
                }
                else if (Parts[PartNr].ToUpper() == "INVERT")
                {
                    Invert = true;
                }
                else if (Parts[PartNr].ToUpper() == "NOBOOL")
                {
                    NoBool = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APS" && Parts[PartNr].Substring(3).IsInteger())
                {
                    PlasmaSpeed = Parts[PartNr].Substring(3).ToInteger();
                    IsPlasma    = true;
                    IsArea      = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APD" && Parts[PartNr].Substring(3).IsInteger())
                {
                    PlasmaDensity = Parts[PartNr].Substring(3).ToInteger();
                    IsPlasma      = true;
                    IsArea        = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APC")
                {
                    ColorName2 = Parts[PartNr].Substring(3);
                    IsPlasma   = true;
                    IsArea     = true;
                }
                //else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "APC" && Parts[PartNr].Substring(3).IsInteger())
                //{
                //    PlasmaScale = Parts[PartNr].Substring(3).ToInteger();
                //    IsPlasma = true;
                //    IsArea = true;
                //}


                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "SHP")
                {
                    ShapeName = Parts[PartNr].Substring(3).Trim();
                    IsArea    = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABT" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapTop = Parts[PartNr].Substring(3).ToInteger();
                    IsArea        = true;
                    IsBitmap      = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABL" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapLeft = Parts[PartNr].Substring(3).ToInteger();
                    IsArea         = true;
                    IsBitmap       = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABW" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapWidth = Parts[PartNr].Substring(3).ToInteger();
                    IsArea          = true;
                    IsBitmap        = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABH" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapHeight = Parts[PartNr].Substring(3).ToInteger();
                    IsArea           = true;
                    IsBitmap         = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ABF" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapFrame = Parts[PartNr].Substring(3).ToInteger();
                    IsArea          = true;
                    IsBitmap        = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAS" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapAnimationStepSize = Parts[PartNr].Substring(3).ToInteger();
                    IsArea   = true;
                    IsBitmap = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAC" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapAnimationStepCount = Parts[PartNr].Substring(3).ToInteger();
                    IsArea   = true;
                    IsBitmap = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAF" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaBitmapAnimationFrameDuration = 1000 / Parts[PartNr].Substring(3).ToInteger().Limit(10, int.MaxValue);
                    IsArea   = true;
                    IsBitmap = true;
                }
                else if (Parts[PartNr].Length == 4 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAD" && Enum.IsDefined(typeof(MatrixAnimationStepDirectionEnum), (int)Parts[PartNr].Substring(3, 1).ToUpper()[0]))
                {
                    AreaBitmapAnimationDirection = (MatrixAnimationStepDirectionEnum)Parts[PartNr].Substring(3, 1).ToUpper()[0];
                    IsArea   = true;
                    IsBitmap = true;
                }
                else if (Parts[PartNr].Length == 4 && Parts[PartNr].Substring(0, 3).ToUpper() == "AAB" && Enum.IsDefined(typeof(AnimationBehaviourEnum), (int)Parts[PartNr].Substring(3, 1).ToUpper()[0]))
                {
                    AreaBitmapAnimationBehaviour = (AnimationBehaviourEnum)Parts[PartNr].Substring(3, 1).ToUpper()[0];
                    IsArea   = true;
                    IsBitmap = true;
                }

                else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() == "AFDEN" && Parts[PartNr].Substring(5).IsInteger())
                {
                    AreaFlickerDensity = Parts[PartNr].Substring(5).ToInteger();
                    IsArea             = true;
                }
                else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() == "AFMIN" && Parts[PartNr].Substring(5).IsInteger())
                {
                    AreaFlickerMinDurationMs = Parts[PartNr].Substring(5).ToInteger();
                    IsArea = true;
                }
                else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 5).ToUpper() == "AFMAX" && Parts[PartNr].Substring(5).IsInteger())
                {
                    AreaFlickerMaxDurationMs = Parts[PartNr].Substring(5).ToInteger();
                    IsArea = true;
                }
                else if (Parts[PartNr].Length > 6 && Parts[PartNr].Substring(0, 6).ToUpper() == "AFFADE" && Parts[PartNr].Substring(6).IsInteger())
                {
                    AreaFlickerFadeDurationMs = Parts[PartNr].Substring(6).ToInteger();

                    IsArea = true;
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AT" && Parts[PartNr].Substring(2).IsInteger())
                {
                    AreaTop = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
                    IsArea  = true;
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AL" && Parts[PartNr].Substring(2).IsInteger())
                {
                    AreaLeft = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
                    IsArea   = true;
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AW" && Parts[PartNr].Substring(2).IsInteger())
                {
                    AreaWidth = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
                    IsArea    = true;
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AH" && Parts[PartNr].Substring(2).IsInteger())
                {
                    AreaHeight = Parts[PartNr].Substring(2).ToInteger().Limit(0, 100);
                    IsArea     = true;
                }
                //TODO: Remove parameter AA
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AA" && Parts[PartNr].Substring(2).IsInteger())
                {
                    AreaAcceleration = Parts[PartNr].Substring(2).ToInteger();
                    IsArea           = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ASA" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaAcceleration = Parts[PartNr].Substring(3).ToInteger();
                    IsArea           = true;
                }

                //TODO:Remove AS para
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].Substring(0, 2).ToUpper() == "AS" && Parts[PartNr].Substring(2).IsInteger())
                {
                    AreaSpeed = Parts[PartNr].Substring(2).ToInteger().Limit(1, 10000);
                    IsArea    = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].Substring(0, 3).ToUpper() == "ASS" && Parts[PartNr].Substring(3).IsInteger())
                {
                    AreaSpeed = Parts[PartNr].Substring(3).ToInteger().Limit(1, 10000);
                    IsArea    = true;
                }
                else if (Parts[PartNr].Length > 5 && Parts[PartNr].Substring(0, 3).ToUpper() == "ASS" && Parts[PartNr].ToUpper().Right(2) == "MS" && Parts[PartNr].Substring(3, Parts[PartNr].Length - 5).IsInteger())
                {
                    AreaSpeed = (int)((double)100000 / Parts[PartNr].Substring(3, Parts[PartNr].Length - 5).ToInteger()).Limit(10, 100000);
                    IsArea    = true;
                }

                //TODO:Remove AD para
                else if (Parts[PartNr].Length == 3 && Parts[PartNr].Substring(0, 2).ToUpper() == "AD" && Enum.IsDefined(typeof(MatrixShiftDirectionEnum), (int)Parts[PartNr].Substring(2, 1).ToUpper()[0]))
                {
                    AreaDirection = (MatrixShiftDirectionEnum)Parts[PartNr].Substring(2, 1).ToUpper()[0];
                    IsArea        = true;
                }
                else if (Parts[PartNr].Length == 4 && Parts[PartNr].Substring(0, 3).ToUpper() == "ASD" && Enum.IsDefined(typeof(MatrixShiftDirectionEnum), (int)Parts[PartNr].Substring(3, 1).ToUpper()[0]))
                {
                    AreaDirection = (MatrixShiftDirectionEnum)Parts[PartNr].Substring(3, 1).ToUpper()[0];
                    IsArea        = true;
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "MAX" && Parts[PartNr].Substring(3).IsInteger())
                {
                    MaxDurationMs = Parts[PartNr].Substring(3).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "BNP" && Parts[PartNr].Substring(3).IsInteger())
                {
                    BlinkIntervalMsNested = Parts[PartNr].Substring(3).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].Length > 4 && Parts[PartNr].ToUpper().Substring(0, 4) == "BNPW" && Parts[PartNr].Substring(4).IsInteger())
                {
                    BlinkPulseWidthNested = Parts[PartNr].Substring(4).ToInteger().Limit(1, 99);
                }

                else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "BPW" && Parts[PartNr].Substring(3).IsInteger())
                {
                    BlinkPulseWidth = Parts[PartNr].Substring(3).ToInteger().Limit(1, 99);
                }
                else if (Parts[PartNr].Length > 3 && Parts[PartNr].ToUpper().Substring(0, 3) == "BL#" && Parts[PartNr].Substring(3).IsHexString())
                {
                    BlinkLow = Parts[PartNr].Substring(3).HexToInt().Limit(0, 255);
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "BL" && Parts[PartNr].Substring(1).IsInteger())
                {
                    BlinkLow = (int)(((double)Parts[PartNr].Substring(2).ToInteger().Limit(0, 48)) * 5.3125);
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "E" && Parts[PartNr].Substring(1).IsInteger())
                {
                    ExtDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) == "I#" && Parts[PartNr].Substring(2).IsHexString())
                {
                    //Intensity setting
                    Intensity = Parts[PartNr].Substring(2).HexToInt().Limit(0, 255);
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "I" && Parts[PartNr].Substring(1).IsInteger())
                {
                    //Intensity setting
                    Intensity = (int)(((double)Parts[PartNr].Substring(1).ToInteger().Limit(0, 48)) * 5.3125);
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "L" && Parts[PartNr].Substring(1).IsInteger())
                {
                    //Layer setting
                    Layer = Parts[PartNr].Substring(1).ToInteger();
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "W" && Parts[PartNr].Substring(1).IsInteger())
                {
                    //WaitDuration setting
                    WaitDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "M" && Parts[PartNr].Substring(1).IsInteger())
                {
                    //MinimumDuration setting
                    MinDurationMs = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].Length > 1 && Parts[PartNr].ToUpper().Substring(0, 1) == "F" && Parts[PartNr].Substring(1).IsInteger())
                {
                    //Dimming duration for up and down
                    FadingUpDurationMs   = Parts[PartNr].Substring(1).ToInteger().Limit(0, int.MaxValue);
                    FadingDownDurationMs = FadingUpDurationMs;
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) == "FU" && Parts[PartNr].Substring(2).IsInteger())
                {
                    //Dimming up duration
                    FadingUpDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].Length > 2 && Parts[PartNr].ToUpper().Substring(0, 2) == "FD" && Parts[PartNr].Substring(2).IsInteger())
                {
                    //Dimming down duration
                    FadingDownDurationMs = Parts[PartNr].Substring(2).ToInteger().Limit(0, int.MaxValue);
                }
                else if (Parts[PartNr].IsInteger())
                {
                    switch (IntegerCnt)
                    {
                    case 0:
                        if (Blink == -1)
                        {
                            //Its a blink interval
                            BlinkIntervalMs = (Parts[PartNr].ToInteger()).Limit(1, int.MaxValue);
                            DurationMs      = 0;
                        }
                        else
                        {
                            //Its a duration

                            DurationMs = Parts[PartNr].ToInteger().Limit(1, int.MaxValue);
                        }
                        break;

                    case 1:
                        if (Blink != -1)
                        {
                            Blink = Parts[PartNr].ToInteger().Limit(1, int.MaxValue);
                            if (DurationMs > 0 & Blink >= 1)
                            {
                                BlinkIntervalMs = (DurationMs / Blink).Limit(1, int.MaxValue);
                                DurationMs      = 0;
                            }
                        }
                        break;

                    default:
                        Log.Warning("The ledcontrol table config setting {0} contains more than 2 numeric values without a type definition.".Build(SettingData));
                        throw new Exception("The ledcontrol table config setting {0} contains more than 2 numeric values without a type definition.".Build(SettingData));
                    }
                    IntegerCnt++;
                }
                else if (PartNr == 0)
                {
                    //This should be a color
                    ColorName = Parts[PartNr];
                }
                else
                {
                    Log.Warning("Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));

                    throw new Exception("Cant parse the part {0} of the ledcontrol table config setting {1}".Build(Parts[PartNr], SettingData));
                }
                PartNr++;
            }
        }