Exemple #1
0
        public static void Load(ConfigNode node)
        {
            toolings.Clear();

            if (node == null)
            {
                return;
            }

            foreach (ConfigNode c in node.GetNodes("TYPE"))
            {
                string type = c.GetValue("type");
                if (string.IsNullOrEmpty(type))
                {
                    continue;
                }

                List <ToolingDiameter> lst = new List <ToolingDiameter>();

                foreach (ConfigNode n in c.GetNodes("DIAMETER"))
                {
                    float tmp = 0f;
                    if (!n.TryGetValue("diameter", ref tmp))
                    {
                        continue;
                    }

                    ToolingDiameter d = new ToolingDiameter(tmp);

                    ConfigNode len = n.GetNode("LENGTHS");
                    if (len != null)
                    {
                        foreach (ConfigNode.Value v in len.values)
                        {
                            if (float.TryParse(v.value, out tmp))
                            {
                                d.lengths.Add(tmp);
                            }
                        }
                    }

                    lst.Add(d);
                }

                toolings[type] = lst;
            }
        }
Exemple #2
0
        public static bool UnlockTooling(string type, float diam, float len)
        {
            List <ToolingDiameter> lst;

            if (!toolings.TryGetValue(type, out lst))
            {
                lst            = new List <ToolingDiameter>();
                toolings[type] = lst;
            }
            if (lst.Count == 0)
            {
                lst.Add(new ToolingDiameter(diam, len));
                return(true);
            }
            else
            {
                int insertionIdx;
                int dIndex = DiamIndex(diam, lst, out insertionIdx);
                if (dIndex == -1)
                {
                    ToolingDiameter d = new ToolingDiameter(diam, len);
                    lst.Insert(insertionIdx, d);
                    return(true);
                }

                int lIndex = LengthIndex(len, lst[dIndex].lengths, out insertionIdx);

                if (lIndex != -1)
                {
                    return(false);
                }
                else
                {
                    lst[dIndex].lengths.Insert(insertionIdx, len);
                    return(true);
                }
            }
        }