Ejemplo n.º 1
0
 private void CheckSingleValue(ChoiceParameter p, int val, string valStr, int idx)
 {
     Assert.AreEqual(p.Value, val, $"Value '{val}' expected but was '{p.Value}'");
     Assert.AreEqual(p.AsString, valStr, $"AsString '{valStr}' expected but was '{p.Value}'");
     Assert.AreEqual(p.ValueIdx, idx, $"ValueIdx '{idx}' expected but was  '{p.ValueIdx}'");
     Assert.IsTrue(_passedOnChanged, "IsModified = false but must be true");
 }
Ejemplo n.º 2
0
 /// <summary>
 /// C'tor
 /// </summary>
 /// <param name="param">The <see cref="DataParameterBase"/> this proxy is connected to</param>
 public ChoiceParameterProxy(ChoiceParameter param) : base(param)
 {
     foreach (var choice in param.Choices)
     {
         Choices.Add(choice.Item2);
     }
 }
Ejemplo n.º 3
0
    static List <Parameter> ParseParameters(JSONArray parametersArray)
    {
        var parameters = new List <Parameter>();

        for (int i = 0; i < parametersArray.Count; i++)
        {
            var parameterJson = parametersArray[i];

            switch (parameterJson["type"])
            {
            case "bool":
                BoolParameter pBool = new BoolParameter();
                pBool.Name             = parameterJson["name"].Value;
                pBool.DisplayName      = parameterJson["displayName"].Value;
                pBool.IntensityDefault = ParseBoolValues(parameterJson["intensityDefault"].AsArray);
                parameters.Add(pBool);
                break;

            case "int":
                IntParameter pInt = new IntParameter();
                pInt.Min              = parameterJson["min"].AsInt;
                pInt.Max              = parameterJson["max"].AsInt;
                pInt.Name             = parameterJson["name"].Value;
                pInt.DisplayName      = parameterJson["displayName"].Value;
                pInt.IntensityDefault = ParseIntValues(parameterJson["intensityDefault"].AsArray);
                parameters.Add(pInt);
                break;

            case "float":
                FloatParameter pFloat = new FloatParameter();
                pFloat.Min              = parameterJson["min"].AsFloat;
                pFloat.Max              = parameterJson["max"].AsFloat;
                pFloat.Name             = parameterJson["name"].Value;
                pFloat.DisplayName      = parameterJson["displayName"].Value;
                pFloat.IntensityDefault = ParseFloatValues(parameterJson["intensityDefault"].AsArray);
                parameters.Add(pFloat);
                break;

            case "choice":
                ChoiceParameter pString = new ChoiceParameter();
                pString.Values           = ParseStringValues(parameterJson["values"].AsArray);
                pString.Name             = parameterJson["name"].Value;
                pString.DisplayName      = parameterJson["displayName"].Value;
                pString.IntensityDefault = ParseIntValues(parameterJson["intensityDefault"].AsArray);
                parameters.Add(pString);
                break;
            }
        }

        return(parameters);
    }
Ejemplo n.º 4
0
 public Cont2(DataContainer parent)
     : base(parent, "Cont2", "Cont2")
 {
     IntParam3  = new IntParameter(this, "IntParam3", "IntParam3", 0);
     StrParam4  = new StringParameter(this, "StrParam4", "StrParam4", "def");
     BoolParam5 = new BoolParameter(this, "BoolParam5", "BoolParam5", true);
     ChParam6   = new ChoiceParameter(this, "ChParam6", "ChParam6", 5,
                                      new List <Tuple <int, string> >
     {
         new Tuple <int, string>(0, "rot"),
         new Tuple <int, string>(5, "gelb"),
         new Tuple <int, string>(10, "grün"),
         new Tuple <int, string>(20, "blau"),
     });
     BinParam7 = new BinaryParameter(this, "BinParam7", "BinParam7", new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });
 }
Ejemplo n.º 5
0
        public TestCont1(DataContainer parent, string id, string name)
            : base(parent, id, name)
        {
            Tc3 = new TestCont3(this);

            IntParam = new IntParameter(this, "IP", "IntParam", 0);
            StrParam = new StringParameter(this, "SP", "StrParam", "abc");
            FloatParam = new FloatParameter(this, "FP", "FloatParam", 0.5f, "m/s", 5);
            BinParam = new BinaryParameter(this, "BP", "BinParam", new byte[] { 1, 2, 3, 4, 5 });
            ChParam = new ChoiceParameter(this, "CP", "ChParam", 0, new List<Tuple<int, string>>()
                                                                    {
                                                                        new Tuple<int, string>(0, "Ch1"),
                                                                        new Tuple<int, string>(3, "Ch2"),
                                                                        new Tuple<int, string>(5, "Ch3"),
                                                                        new Tuple<int, string>(15, "Ch4"),
                                                                    });
        }
Ejemplo n.º 6
0
        private List <ParameterBase> GetBuildParameters(XDocument xDoc)
        {
            // Construct the build parameters
            var buildParameters = new List <ParameterBase>();
            var parametersNodes = xDoc.Descendants("action").Elements("parameterDefinition");
            var supportedTypes  = Enum.GetNames(typeof(BuildParameterType));

            foreach (var parameterNode in parametersNodes)
            {
                var type = (string)parameterNode.Element("type");
                if (!supportedTypes.Contains(type))
                {
                    continue;
                }

                switch ((BuildParameterType)Enum.Parse(typeof(BuildParameterType), type))
                {
                case BuildParameterType.BooleanParameterDefinition:
                    var booleanBuildParamter = new BuildParameters.BooleanParameter(parameterNode);
                    buildParameters.Add(booleanBuildParamter.ToParameterBase());
                    break;

                case BuildParameterType.ChoiceParameterDefinition:
                    var choiceBuildParameter = new ChoiceParameter(parameterNode);
                    buildParameters.Add(choiceBuildParameter.ToParameterBase());
                    break;

                case BuildParameterType.StringParameterDefinition:
                    var stringBuildParameter = new StringParameter(parameterNode);
                    buildParameters.Add(stringBuildParameter.ToParameterBase());
                    break;
                }
            }

            return(buildParameters);
        }
Ejemplo n.º 7
0
        public void TestChoiceParameter()
        {
            var xml = @"<parameterDefinition>
                        <defaultParameterValue>
                        <value>ONE</value>
                        </defaultParameterValue>
                        <description>Select a choice</description>
                        <name>CHOICE.1</name>
                        <type>ChoiceParameterDefinition</type>
                        <choice>ONE</choice>
                        <choice>TWO</choice>
                        <choice>THREE</choice>
                        </parameterDefinition>";

            var xDoc   = XDocument.Parse(xml).Descendants().First();
            var choice = new ChoiceParameter(xDoc);

            Assert.AreEqual(choice.Name, "CHOICE.1");
            Assert.AreEqual(choice.Description, "Select a choice");
            Assert.AreEqual(choice.ParameterType, BuildParameterType.ChoiceParameterDefinition);
            Assert.AreEqual(choice.DefaultValue, "ONE");

            CollectionAssert.AllItemsAreNotNull(choice.Options);
            CollectionAssert.AllItemsAreUnique(choice.Options);

            // Check the name/value pairs
            Assert.AreEqual(choice.Options.Length, 3);
            Assert.AreEqual(choice.Options[0].Value, "ONE");
            Assert.AreEqual(choice.Options[0].Name, "ONE");

            Assert.AreEqual(choice.Options[1].Value, "TWO");
            Assert.AreEqual(choice.Options[1].Name, "TWO");

            Assert.AreEqual(choice.Options[2].Value, "THREE");
            Assert.AreEqual(choice.Options[2].Name, "THREE");
        }