/// <summary> /// Read /// </summary> /// <param name="name">Name</param> /// <param name="parameters">Parameters</param> /// <param name="netlist">Netlist</param> /// <returns></returns> public override bool Read(string type, Statement st, Netlist netlist) { // Get the nodes CircuitIdentifier node, reference = null; switch (st.Parameters.Count) { case 0: throw new ParseException(st.Name, "Node expected", false); case 2: if (!ReaderExtension.IsNode(st.Parameters[1])) { throw new ParseException(st.Parameters[1], "Node expected"); } reference = new CircuitIdentifier(st.Parameters[1].image); goto case 1; case 1: if (!ReaderExtension.IsNode(st.Parameters[0])) { throw new ParseException(st.Parameters[0], "Node expected"); } node = new CircuitIdentifier(st.Parameters[0].image); break; default: throw new ParseException(st.Name, "Too many nodes specified", false); } // Add to the exports Export ve = null; switch (type) { case "v": ve = new VoltageExport(node, reference); break; case "vr": ve = new VoltageRealExport(node, reference); break; case "vi": ve = new VoltageImaginaryExport(node, reference); break; case "vdb": ve = new VoltageDecibelExport(node, reference); break; case "vp": ve = new VoltagePhaseExport(node, reference); break; } if (ve != null) { netlist.Exports.Add(ve); } Generated = ve; return(true); }
/// <summary> /// Read /// </summary> /// <param name="name">Name</param> /// <param name="parameters">Parameters</param> /// <param name="netlist">Netlist</param> /// <returns></returns> public override bool Read(string type, Statement st, Netlist netlist) { // Get the source name CircuitIdentifier source; switch (st.Parameters.Count) { case 0: throw new ParseException(st.Name, "Voltage source expected", false); case 1: if (!ReaderExtension.IsName(st.Parameters[0])) { throw new ParseException(st.Parameters[0], "Component name expected"); } source = new CircuitIdentifier(st.Parameters[0].image); break; default: throw new ParseException(st.Name, "Too many nodes specified", false); } // Add to the exports Export ce = null; switch (type) { case "i": ce = new CurrentExport(source); break; case "ir": ce = new CurrentRealExport(source); break; case "ii": ce = new CurrentImaginaryExport(source); break; case "im": ce = new CurrentMagnitudeExport(source); break; case "ip": ce = new CurrentPhaseExport(source); break; case "idb": ce = new CurrentDecibelExport(source); break; } if (ce != null) { netlist.Exports.Add(ce); } Generated = ce; return(true); }