Esempio n. 1
0
        public static KSPSpecialAttrib Load(List <string[]> config)
        {
            KSPAdvancedSAS part = new KSPAdvancedSAS();

            foreach (var line in config)
            {
                switch (line[0].Trim())
                {
                case "Ki":
                    try
                    {
                        part.Ki = Double.Parse(line[1].Trim());
                    }
                    catch (Exception e)
                    {
                        throw new Exception(String.Format("Ki string '{0}' could not be parsed into a double value.", line[1].Trim()), e);
                    }
                    break;

                case "Kp":
                    try
                    {
                        part.Kp = Double.Parse(line[1].Trim());
                    }
                    catch (Exception e)
                    {
                        throw new Exception(String.Format("Kp string '{0}' could not be parsed into a double value.", line[1].Trim()), e);
                    }
                    break;

                case "Kd":
                    try
                    {
                        part.Kd = Double.Parse(line[1].Trim());
                    }
                    catch (Exception e)
                    {
                        throw new Exception(String.Format("Kd string '{0}' could not be parsed into a double value.", line[1].Trim()), e);
                    }
                    break;
                }
            }

            return(part);
        }
Esempio n. 2
0
        public static KSPSpecialAttrib Load(List<string[]> config)
        {
            KSPAdvancedSAS part = new KSPAdvancedSAS();

            foreach (var line in config)
            {
                switch (line[0].Trim())
                {
                    case "Ki":
                        try
                        {
                            part.Ki = Double.Parse(line[1].Trim());
                        }
                        catch (Exception e)
                        {
                            throw new Exception(String.Format("Ki string '{0}' could not be parsed into a double value.", line[1].Trim()), e);
                        }
                        break;
                    case "Kp":
                        try
                        {
                            part.Kp = Double.Parse(line[1].Trim());
                        }
                        catch (Exception e)
                        {
                            throw new Exception(String.Format("Kp string '{0}' could not be parsed into a double value.", line[1].Trim()), e);
                        }
                        break;
                    case "Kd":
                        try
                        {
                            part.Kd = Double.Parse(line[1].Trim());
                        }
                        catch (Exception e)
                        {
                            throw new Exception(String.Format("Kd string '{0}' could not be parsed into a double value.", line[1].Trim()), e);
                        }
                        break;
                }
            }

            return part;
        }