예제 #1
0
        private void BtnSave_Click(object sender, EventArgs e)
        {
            string installFolder = Properties.Settings.Default.installLocation;

            if (Directory.Exists(installFolder + "\\Community\\Tree-Editor\\vegetation") == false)
            {
                Directory.CreateDirectory(installFolder + "\\Community\\Tree-Editor\\vegetation");
            }
            xmlBiomes.Save(Properties.Settings.Default.xmlFileBiomes);

            int        xmlFileSize = (int)new FileInfo(Properties.Settings.Default.xmlFileBiomes).Length;
            LayoutJson layout      = new LayoutJson();

            layout.setSize(xmlFileSize);
            File.WriteAllText(Properties.Settings.Default.layoutFile, layout.getJson());
            if (File.Exists(Properties.Settings.Default.xmlFile))
            {
                xmlFileSize += (int)new FileInfo(Properties.Settings.Default.xmlFile).Length;
            }
            if (File.Exists(Properties.Settings.Default.xmlFileBiomesCities))
            {
                xmlFileSize += (int)new FileInfo(Properties.Settings.Default.xmlFileBiomesCities).Length;
            }
            Manifest manifest = new Manifest();

            manifest.setSize(xmlFileSize);
            File.WriteAllText(Properties.Settings.Default.manifestFile, manifest.getJson());
        }
        private void GenerateTraceSubckt(LayoutJson.Signal trace)
        {
            // this is where the smarts of what type of trace subcircuit to generate will reside
            // reference hspice98 - chapter21, pp 21-2: Selecting Wire Models

            // choices for wire models:
            // 1. no model
            // 2. lumped models with RLC - simple R, shunt cap C, series inductor and resistor RL, series resistor and shunt cap RC
            // 3. ideal - lossless transmission line
            // 4. lossy transmission line

            // decision based on : 
            // 1. source properties: rise time - trise, source resistance - Rsource
            // 2. connector properties: characteristic impedance - Z0, time delay - TD (function of length/frequency)
            //                  OR    : equiv resistance - R, equiv inductance - L, equiv capacitance - C
 
            // decision tree: Figure 21-1, Wire Model Selection Chart (wire_select.jpg)
            // a) trise > 5TD (low frequency) --- use lumped model with RLC (criteria for R / RL / RC in wire_select.jpg)
            // b) trise < 5TD (high frequence) --- use lossy or lossless transmission line
            StringWriter subckt = new StringWriter();
            subckt.WriteLine(".subckt Trace_{0} 1 2", trace.name);
            subckt.WriteLine("* Simple Transmission Line Model ");
            subckt.WriteLine("TL 1 0 2 0 Z0=50 TD=10ns");
            subckt.WriteLine(".ends Trace_{0}", trace.name);
            circuit_obj.subcircuits.Add(string.Format("Trace_{0}", trace.name), subckt.ToString());
        }