コード例 #1
0
        public SequenceCallInfo[] ReinitializeSequenceCallInfo(NationalInstruments.TestStand.Interop.API.SequenceContext seqContext, string stepID)
        {
            string         paramType    = "";
            string         paramValue   = "";
            string         paramName    = "";
            PropertyObject seqContextPO = seqContext.AsPropertyObject();
            Step           activeStep   = seqContext.Step;

            string[]         parameterTypes;
            string[]         parameterValues;
            string[]         parameterNames;
            SequenceCallInfo seqCallInfo;

            SequenceCallInfo[] seqCallInfoArray;
            Sequence           selectedTSSequence = seqContext.Sequence;
            PropertyObject     stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject();

            string[] sequenceNames = Array.ConvertAll((object[])stepPropertyObject.GetValVariant("Veristand.SequenceNames", 0), o => o.ToString());

            string gatewayIP;

            try
            {
                gatewayIP = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.GatewayIP", 0);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                gatewayIP = "localhost";
            }
            try
            {
                parameterValues = Array.ConvertAll((object[])stepPropertyObject.GetValVariant("Veristand.ParamValues", 0), o => o.ToString());
                parameterTypes  = Array.ConvertAll((object[])stepPropertyObject.GetValVariant("Veristand.ParamTypes", 0), o => o.ToString());
                parameterNames  = Array.ConvertAll((object[])stepPropertyObject.GetValVariant("Veristand.ParamNames", 0), o => o.ToString());
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                parameterValues = new string[0];
                parameterTypes  = new string[0];
                parameterNames  = new string[0];
            }

            int numberofSequences = (int)stepPropertyObject.GetValNumber("Veristand.RTNumSequences", 0);

            seqCallInfoArray = new SequenceCallInfo[numberofSequences];
            for (int sequenceNumber = 0; sequenceNumber < numberofSequences; sequenceNumber++)
            {
                string[] curParameterValues = StringUtilities.expressionArrayToStringArray(parameterValues[sequenceNumber]);
                string[] curParameterNames  = StringUtilities.expressionArrayToStringArray(parameterNames[sequenceNumber]);
                string[] curParameterTypes  = StringUtilities.expressionArrayToStringArray(parameterTypes[sequenceNumber]);

                int numParameters = curParameterNames.Length;
                if (numParameters > 0)
                {
                    resolveExpressions(ref curParameterValues, seqContextPO);
                }
                SequenceParameterAssignmentInfo[] seqParametersInfo = new SequenceParameterAssignmentInfo[numParameters];
                try
                {
                    for (uint parameterNumber = 0; parameterNumber < numParameters; parameterNumber++)
                    {
                        try
                        {
                            paramValue = curParameterValues[parameterNumber];
                            paramType  = curParameterTypes[parameterNumber];
                            paramName  = curParameterNames[parameterNumber];
                        }
                        catch (System.Runtime.InteropServices.COMException ex) //We have processed all the sequences
                        {
                        }
                        switch (paramType)
                        {//Initialize the correct type of parameter based on the Users Type setting
                        case "Path":
                            SystemDefinitionChannelResource sysDefChannel = new SystemDefinitionChannelResource(paramValue);
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, sysDefChannel);

                            break;

                        case "Boolean":
                            BooleanValue boolVal = new BooleanValue(Convert.ToBoolean(paramValue));
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, boolVal);
                            break;

                        case "Double":
                            DoubleValue doubleVal = new DoubleValue(Convert.ToDouble(paramValue));
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, doubleVal);
                            break;

                        case "I32":
                            I32Value i32Val = new I32Value(Convert.ToInt32(paramValue));
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, i32Val);
                            break;

                        case "I64":
                            I64Value i64Val = new I64Value(Convert.ToInt64(paramValue));
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, i64Val);
                            break;

                        case "U32":
                            U32Value u32Val = new U32Value(Convert.ToUInt32(paramValue));
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, u32Val);
                            break;

                        case "U64":
                            U64Value u64Val = new U64Value(Convert.ToUInt64(paramValue));
                            seqParametersInfo[parameterNumber] = new SequenceParameterAssignmentInfo(paramName, u64Val);
                            break;
                        }
                    }
                }
                catch (IndexOutOfRangeException ex)
                {
                    //Parameter numbers don't match up
                    VSDialogs vsdiag = new VSDialogs();
                    vsdiag.ShowWarningDialog("Parameter Import Failed");
                }



                seqCallInfo = new SequenceCallInfo(sequenceNames[sequenceNumber], "", seqParametersInfo, false, 1000);
                seqCallInfoArray[sequenceNumber] = seqCallInfo;
            }
            seqCallInfoArray = Array.FindAll(seqCallInfoArray, isNotNull).ToArray(); //Get rid of all null entries in the array
            return(seqCallInfoArray);
        }
コード例 #2
0
        private void ProcessSequenceParameters()
        {
            SequenceParameterAssignmentInfo[] seqParametersInfo = new SequenceParameterAssignmentInfo[this.dataGridView1.Rows.Count];
            string text = "";
            bool   allFieldsComplete    = true;
            string paramValuesExpString = "{";
            string paramNamesExpString  = "{";
            string paramTypesExpString  = "{";

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                if (this.dataGridView1[1, i].Value != null && this.dataGridView1[2, i].Value != null)
                {
                    paramNamesExpString  += this.dataGridView1[0, i].Value.ToString() + ",";
                    paramValuesExpString += this.dataGridView1[2, i].Value.ToString() + ",";
                    paramTypesExpString  += this.dataGridView1[1, i].Value.ToString() + ",";
                    try
                    {
                        switch (this.dataGridView1[1, i].Value.ToString())
                        {//Initialize the correct type of parameter based on the Users Type setting
                        case "Path":
                            SystemDefinitionChannelResource sysDefChannel = new SystemDefinitionChannelResource(this.dataGridView1[2, i].Value.ToString());
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), sysDefChannel);

                            break;

                        case "Boolean":
                            BooleanValue boolVal = new BooleanValue(Convert.ToBoolean(this.dataGridView1[2, i].Value.ToString()));
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), boolVal);
                            break;

                        case "Double":
                            DoubleValue doubleVal = new DoubleValue(Convert.ToDouble(this.dataGridView1[2, i].Value.ToString()));
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), doubleVal);
                            break;

                        case "I32":
                            I32Value i32Val = new I32Value(Convert.ToInt32(this.dataGridView1[2, i].Value.ToString()));
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), i32Val);
                            break;

                        case "I64":
                            I64Value i64Val = new I64Value(Convert.ToInt64(this.dataGridView1[2, i].Value.ToString()));
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), i64Val);
                            break;

                        case "U32":
                            U32Value u32Val = new U32Value(Convert.ToUInt32(this.dataGridView1[2, i].Value.ToString()));
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), u32Val);
                            break;

                        case "U64":
                            U64Value u64Val = new U64Value(Convert.ToUInt64(this.dataGridView1[2, i].Value.ToString()));
                            seqParametersInfo[i] = new SequenceParameterAssignmentInfo(this.dataGridView1[0, i].Value.ToString(), u64Val);
                            break;
                        }
                    }
                    catch (System.FormatException ex)
                    {
                        //Incorrect datatype was entered in the RT sequence window
                        VSDialogs dialogs = new VSDialogs();
                        dialogs.ShowWarningDialog(ex.Message + "------" + ex.StackTrace);
                    }
                }
                else
                {
                    allFieldsComplete = false;
                }
            }



            //If sequence information already exists for the selected sequence replace it. If not insert new elements into array

            if (allFieldsComplete && StimProfilePathStr != "")
            {//Only try to create an seqCallInfo object if all fields have been initialized
                //Create SequenceCallInfo Object
                seqCallInfo = new SequenceCallInfo(StimProfilePathStr, "", seqParametersInfo, false, 1000);

                insertIntoArray(ref seqCallInfoArray, selectedSequence, seqCallInfo);
                paramValuesExpString = paramValuesExpString.Remove(paramValuesExpString.Length - 1) + "}";  //remove trailing comma and add in a clsoing }
                paramNamesExpString  = paramNamesExpString.Remove(paramNamesExpString.Length - 1) + "}";
                paramTypesExpString  = paramTypesExpString.Remove(paramTypesExpString.Length - 1) + "}";

                insertIntoArray(ref parameterValues, selectedSequence, paramValuesExpString);
                insertIntoArray(ref parameterNames, selectedSequence, paramNamesExpString);
                insertIntoArray(ref parameterTypes, selectedSequence, paramTypesExpString);
            }
            else
            {
                VSDialogs dialogs = new VSDialogs();
                dialogs.ShowWarningDialog("Active sequence information not processesed because not all parameters have been specified");
            }
        }