Ejemplo n.º 1
0
        /// <summary>
        /// Create a voltage switch
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="pos">Positive node</param>
        /// <param name="neg">Negative node</param>
        /// <param name="contSource">Controlling source</param>
        /// <param name="modelName">Model name</param>
        /// <param name="modelParameters">Model parameters</param>
        /// <returns></returns>
        CurrentSwitch CreateCurrentSwitch(string name, string pos, string neg, string contSource, string modelName, string modelParameters)
        {
            var model = new CurrentSwitchModel(modelName);

            ApplyParameters(model, modelParameters);

            var vsw = new CurrentSwitch(name, pos, neg, contSource);

            vsw.SetModel(model);
            return(vsw);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a voltage switch
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="pos">Positive node</param>
        /// <param name="neg">Negative node</param>
        /// <param name="contSource">Controlling source</param>
        /// <param name="modelName">Model name</param>
        /// <param name="modelParameters">Model parameters</param>
        /// <returns></returns>
        CurrentSwitch CreateCurrentSwitch(Identifier name, Identifier pos, Identifier neg, Identifier contSource, Identifier modelName, string modelParameters)
        {
            CurrentSwitchModel model = new CurrentSwitchModel(modelName);

            ApplyParameters(model, modelParameters);

            CurrentSwitch vsw = new CurrentSwitch(name, pos, neg, contSource);

            vsw.SetModel(model);
            return(vsw);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Generate a current switch
        /// </summary>
        /// <param name="name">The name</param>
        /// <param name="parameters">Parameters</param>
        /// <param name="netlist">Netlist</param>
        /// <returns></returns>
        protected ICircuitObject GenerateCSW(CircuitIdentifier name, List <Token> parameters, Netlist netlist)
        {
            CurrentSwitch csw = new CurrentSwitch(name);

            csw.ReadNodes(netlist.Path, parameters);
            switch (parameters.Count)
            {
            case 2: throw new ParseException(parameters[1], "Voltage source expected", false);

            case 3: throw new ParseException(parameters[2], "Model expected", false);
            }

            // Get the controlling voltage source
            switch (parameters[2].kind)
            {
            case WORD:
                csw.CSWcontName = new CircuitIdentifier(parameters[2].image);
                break;

            default:
                throw new ParseException(parameters[2], "Voltage source name expected");
            }

            // Get the model
            csw.SetModel(netlist.FindModel <CurrentSwitchModel>(parameters[3]));

            // Optional on or off
            if (parameters.Count > 4)
            {
                switch (parameters[4].image.ToLower())
                {
                case "on":
                    csw.SetOn();
                    break;

                case "off":
                    csw.SetOff();
                    break;

                default:
                    throw new ParseException(parameters[4], "ON or OFF expected");
                }
            }
            return(csw);
        }