Esempio n. 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dev">The device</param>
        public SpiceParam(SpiceDevice dev, Dictionary <string, ParameterExtractor.DeviceParameter> dp, SpiceDevice.Methods p, SpiceDevice.Methods a)
        {
            // Get the param method
            string content = dev.GetMethod(p);

            Code.GetSwitchCases(content, param);
            Code.GetMethodParameters(content, par_parameters, dev.GetMethodName(p));

            // Get the "here" variable
            var m = Regex.Match(content, $@"(\w+)\s*\*\s*(?<var>\w+)\s*\=\s*\(\s*\1\s*\*\s*\)\s*{par_parameters[2]}");

            if (m.Success)
            {
                par_here = m.Groups["var"].Value;
            }
            else
            {
                throw new Exception("Could not find 'here' parameter");
            }
            par_value = par_parameters[1];

            // Get the ask method
            content = dev.GetMethod(a);
            Code.GetSwitchCases(content, ask);
            Code.GetMethodParameters(content, ask_parameters, dev.GetMethodName(a));

            // Get the "here" variable
            m = Regex.Match(content, $@"(\w+)\s*\*\s*(?<var>\w+)\s*\=\s*\(\s*\1\s*\*\s*\)\s*{ask_parameters[1]}");
            if (m.Success)
            {
                ask_here = m.Groups["var"].Value;
            }
            else
            {
                throw new Exception("Could not find 'here' parameter");
            }
            ask_value = ask_parameters[3];

            BuildParameters(dp);
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dev">The device</param>
        public SpiceSetup(SpiceDevice dev)
        {
            // Get the
            string content = dev.GetMethod(SpiceDevice.Methods.Setup);

            // Get the parameters
            List <string> p = new List <string>();

            Code.GetMethodParameters(content, p, dev.GetMethodName(SpiceDevice.Methods.Setup));
            states = p[3];

            ReadMethod(content);
        }