void InitializeDataGridView(string filepath, string[] _parameterValues, string[] _parameterTypes, int _numSequences, int sequenceNumber) { this.dataGridView1.Rows.Clear(); //Empty the grid if (filepath != null && filepath != "" && System.IO.File.Exists(filepath)) //Don't try to initialize with a blank filepath { try { RealTimeSequence newRTSeq = new RealTimeSequence(filepath); ParameterDeclaration[] seqParam = newRTSeq.Variables.Parameters.Variables; int n = 0; string[] currentSeqParamValues; string[] currentSeqParamTypes; this.dataGridView1.Rows.Add(seqParam.Length); try { currentSeqParamValues = StringUtilities.expressionArrayToStringArray(_parameterValues[sequenceNumber]); currentSeqParamTypes = StringUtilities.expressionArrayToStringArray(_parameterTypes[sequenceNumber]); } catch (System.IndexOutOfRangeException ex) { currentSeqParamValues = new string[0]; currentSeqParamTypes = new string[0]; } foreach (ParameterDeclaration param in seqParam) { this.dataGridView1[0, n].Value = param.Identifier; try { if (n < currentSeqParamTypes.Length && n < currentSeqParamValues.Length) { this.dataGridView1[2, n].Value = currentSeqParamValues[n]; this.dataGridView1[1, n].Value = currentSeqParamTypes[n]; } } catch (System.Runtime.InteropServices.COMException ex) { //Intentionally do nothing for now. Might want to add a dialog here in the future } catch (System.NullReferenceException ex) { } n++; } } catch (System.ArgumentException) { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Invalid Filepath:" + filepath); } } }
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); }
public ConfigureRTSequenceNumericLimit(SequenceContext _seqContext) { InitializeComponent(); returnParamDataType = ""; seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type FilePath.SetValidEvaluationTypes(eval); FilePath.Context = seqContextPO; EvaluationTypes evalNumeric = seqContext.Engine.NewEvaluationTypes(); VSDialogs vsdiag = new VSDialogs(); int timeoutValue = 0; stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Get old values if they exist try { timeoutValue = (int)stepPropertyObject.GetValNumber("Veristand.Timeout", 0); target = stepPropertyObject.GetValString("Veristand.Target", 0); sequenceFileExp = stepPropertyObject.GetValString("Veristand.SequenceFilePath", 0); parameterValuesArray = StringUtilities.expressionArrayToStringArray(stepPropertyObject.GetValVariant("Veristand.ParamValuesArray", 0)); parameterTypesArray = StringUtilities.expressionArrayToStringArray(stepPropertyObject.GetValVariant("Veristand.ParamTypesArray", 0)); parameterNamesArray = StringUtilities.expressionArrayToStringArray(stepPropertyObject.GetValVariant("Veristand.ParamNamesArray", 0)); sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1); seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); if (sysDefPath != null && sysDefPath != "") { try { currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(sysDefPath)); } catch (System.ArgumentException ex) { //Do Nothing } } try { this.Timeout.Value = timeoutValue; this.targetString.Text = target; EventHandler handler = new EventHandler(this.FilePath_TextChanged); /* Disable FilePath_TextChanged event. We need to disable the FilePath_TextChanged event * because when the dialog is launching, the System Definition Path variable from TestStand will * be populated to the FilePath control. Once it is populated, the FilePath control's event will fire, * thus it will try to reload the table. We don't want the table to load twice every time the dialog is launched. */ this.FilePath.Change -= handler; // Change the File Path this.FilePath.Text = sequenceFileExp; // Re-enable FilePath_TextChanged event this.FilePath.Change += handler; //If the file at path FileGlobals.Veristand.SystemDefinitionPath exists and the extension is ".nivssdf" use that System Definition file to initialize the TreeAliasBrowserWF. if (System.IO.File.Exists(StringUtilities.unparseFilePathString(sequenceFileExp)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sequenceFileExp)) == ".nivsseq") { //File exists with correct extension so try and populate the tree InitializeTableView(_seqContext, sequenceFileExp, parameterValuesArray, parameterTypesArray, false); //Initialize the data grid with the previously selected data } ////If FileGlobals.Veristand.SystemDefinitionPath is empty or the file does not exist at path FileGlobals.Veristand.SystemDefinitionPath. else //(sysDefPath == "" || !System.IO.File.Exists(StringUtilities.unparseFilePathString(sysDefPath))) { //Clear the grid InitializeTableView(_seqContext, "", parameterValuesArray, parameterTypesArray, true); } } catch (System.ArgumentException ex) { //Intentially do nothing } catch (IndexOutOfRangeException ex) { //no sequences, don't need to initialize the data grid } } catch (System.Runtime.InteropServices.COMException ex) { //Variables are not already created in TestStand. They will be created later vsdiag.ShowWarningDialog(ex.Message + "------" + ex.StackTrace); sequenceFileExp = ""; this.FilePath.Text = sequenceFileExp; } }