예제 #1
0
 //DCSolver getSolver();
 public void AddComponent(List <string> parts, Component c)
 {
     c.ComponentID = parts[1];
     if (parts.Count >= (c.GetNumberOfPins() + 1))
     {
         for (int i = 0; i < c.GetNumberOfPins(); i++)
         {
             string netName  = parts[i + 2];
             Net    net      = new Net();
             bool   foundNet = false;
             foreach (var a in Nets)
             {
                 if (a.NetName == netName)
                 {
                     net      = a;
                     foundNet = true;
                     break;
                 }
             }
             if (!foundNet)
             {
                 net         = new Net();
                 net.NetName = netName;
                 Nets.Add(net);
             }
             c.PinConnections.Add(net);
             NetConnection conn = new NetConnection();
             conn.component = c;
             conn.pin       = i;
             net.connections.Add(conn);
         }
     }
     c.SetParameters(new ParameterSet(parts));
     Components.Add(c);
 }
예제 #2
0
        public Form1()
        {
            InitializeComponent();
            label1.Text  = "Net";
            label2.Text  = "Mask";
            button1.Text = "Search";
            label3.Text  = "/";
            Nets.Add("192.168.0.1");
            Nets.Add("168.95.1.1");
            Nets.Add("168.95.128.1");
            comboBox1.Items.AddRange(Nets.ToArray());
            Masks = Enumerable.Range(24, 32 - 24 + 1).ToList();
            foreach (var item in Masks)
            {
                comboBox2.Items.Add(item);
            }
            using (StreamReader sr = new StreamReader("IP.txt"))
            {
                while (!sr.EndOfStream)
                {
                    ONets.Add(sr.ReadLine());
                }
            }
            Dictionary <string, int> dic = new Dictionary <string, int>();

            dic.Add("A", 0);
            dic.Add("B", 64);
            dic.Add("C", 192);
            foreach (var item in ONets)
            {
                string temp = item.Split(',')[0] + ",";

                temp += dic[item.Split(',')[0]] + ".";

                var a = item.Split(',')[1].Split('.');
                for (int i = 1; i <= 3; i++)
                {
                    temp += a[i] + ".";
                }
                temp  = temp.Substring(0, temp.Length - 1) + ",";
                temp += item.Split(',')[2];

                FixNets.Add(temp);
            }
            foreach (var item in FixNets)
            {
                CleanNets.Add(item.Split(',')[1].Split('.').ToList().ConvertAll <int>(int.Parse).ToList().ToArray());
            }
            comboBox1.SelectedIndex = 0;
            comboBox2.Text          = "24";
            button1_Click(null, null);
        }
 private void AddNet(WaterNet net)
 {
     net.Manager = this;
     Nets.Add(net);
 }
예제 #4
0
        public void ReadNetlist(string data)
        {
            var ss1 = data.Split(new[] { '\r', '\n' });

            foreach (var line in ss1)
            {
                var           ss2   = line.Split(new[] { ' ' });
                List <string> parts = new List <string>();
                foreach (var part in ss2)
                {
                    parts.Add(part);
                }
                if (parts.Count >= 2)
                {
                    if (parts[0] == "NET")
                    {
                        Net n = new Net();
                        n.NetName = parts[1];
                        if (parts.Count >= 3)
                        {
                            n.IsFixedVoltage = true;
                            n.NetVoltage     = Convert.ToDouble(parts[2]);
                        }
                        Nets.Add(n);
                    }

                    else if (parts[0] == "RES")
                    {
                        AddComponent(parts, new Resistor());
                    }
                    else if (parts[0] == "CAP")
                    {
                        AddComponent(parts, new Capacitor());
                    }
                    else if (parts[0] == "DIODE")
                    {
                        AddComponent(parts, new Diode());
                    }
                    else if (parts[0] == "BJT")
                    {
                        AddComponent(parts, new BJT());
                    }
                    else if (parts[0] == "NMOS")
                    {
                        AddComponent(parts, new NMOS());
                    }
                    else if (parts[0] == "OPAMP")
                    {
                        AddComponent(parts, new Opamp());
                    }
                    else if (parts[0].StartsWith("LOGIC_"))
                    {
                        AddComponent(parts, new LogicGate(parts[0].Substring(6)));
                    }
                    else
                    {
                        Console.WriteLine("WARNING : Unknown component type " + parts[0]);
                    }
                }
            }
        }