private void OK_Click(object sender, EventArgs e) { //Setting Variables this way is necessary for them to persist when TestStand Closes and is Opened again ProcessSequenceParameters(); seqContext.SequenceFile.FileGlobalsDefaultValues.SetValIDispatch("Veristand.StimulusProfileReference", 1, null); stepPropertyObject.SetValBoolean("Veristand.StimProfAutoStart", 1, autostart); stepPropertyObject.SetValNumber("Veristand.StimProfTimeout", 1, timeout); stepPropertyObject.SetValString("Veristand.RTSessionName", 1, this.sessionName_Control.Text); stepPropertyObject.SetValVariant("Veristand.ParamNames", 0, parameterNames); stepPropertyObject.SetValVariant("Veristand.SequenceNames", 0, sequenceNames); stepPropertyObject.SetValVariant("Veristand.ParamValues", 0, parameterValues); stepPropertyObject.SetValVariant("Veristand.ParamTypes", 0, parameterTypes); try { seqCallInfoArray = Array.FindAll(seqCallInfoArray, isNotNull).ToArray(); //return all non-null entries stepPropertyObject.SetValNumber("Veristand.RTNumSequences", 1, (uint)seqCallInfoArray.Length); cq.Enqueue(seqCallInfoArray); //Send the sequence call info object back to the original thread so it can be returned to TestStand //The normal method I had been using of setting the object directly in TestStand through ActiveX does not work for this object //type because it could not be converted properly } catch (System.Runtime.InteropServices.COMException ex) { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog(ex.Message + "------" + ex.StackTrace); } propObjectFile.IncChangeCount(); //Sets the flag that means the sequence has changes to save (dirty dot*) this.Close(); //Close the form }
private void OK_Click(object sender, EventArgs e) { //Setting Variables this way is necessary for them to persist when TestStand Closes and is Opened again if (!ProcessSequenceParameters()) { try { stepPropertyObject.SetValNumber("Veristand.Timeout", 0, (double)Timeout.Value); stepPropertyObject.SetValString("Veristand.Target", 0, target); seqContext.SequenceFile.FileGlobalsDefaultValues.SetValIDispatch("Veristand.StimulusProfileReference", 1, null); seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.StimulusProfileReference", 0, 0x4400000); stepPropertyObject.SetValVariant("Veristand.SequenceFilePath", 0, StringUtilities.parseFilePathString(sequenceFileExp)); stepPropertyObject.SetValVariant("Veristand.ParamNamesArray", 0, StringUtilities.stringArrayToExpressionArray(parameterNamesArray)); stepPropertyObject.SetValVariant("Veristand.ParamValuesArray", 0, StringUtilities.stringArrayToExpressionArray(parameterValuesArray)); stepPropertyObject.SetValVariant("Veristand.ParamTypesArray", 0, StringUtilities.stringArrayToExpressionArray(parameterTypesArray)); stepPropertyObject.SetValString("Veristand.NumericDataType", 0, StringUtilities.addDoubleQuotesAroundString(returnParamDataType)); propObjectFile.IncChangeCount(); //Sets the flag that means the sequence has changes to save (dirty dot*) } catch (System.NullReferenceException ex) { //do nothing } catch (System.ArgumentNullException ex) { //do nothing } this.Close(); //Close the form } else { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Please specify all Parameters."); } }
public GetChannelsDialog(SequenceContext _seqContext, ChannelType _channelType) { InitializeComponent(); seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Set up dialog objects sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1); //Get the System Definition path for the Client Sequence File. Create it if it does not exist. seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); channelNamesList.AddRange(stepPropertyObject.GetValVariant("VeriStand.ChannelNames", 0)); //Get ChannelNames array of strings. channelType = _channelType; VSDialogs vsdiag = new VSDialogs(); this.loggingChannelSelection.ShowCheckBox = true; //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(sysDefPath)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sysDefPath)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeListBox(sysDefPath); } //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))) { //Do nothing } }
private void ParameterTypeChanged(object sender, EventArgs e) { try { ComboBox changedComboBox = (ComboBox)sender; TableLayoutPanelCellPosition comboBoxPosition = tableLayoutPanel1.GetPositionFromControl(changedComboBox); AxExpressionEdit comboBoxExpEdit = (AxExpressionEdit)tableLayoutPanel1.GetControlFromPosition(2, comboBoxPosition.Row); System.Windows.Forms.Button currentBrowseButton = (Button)tableLayoutPanel1.GetControlFromPosition(3, comboBoxPosition.Row); VSDialogs vsdiag = new VSDialogs(); string comboBoxSelectedItem = changedComboBox.SelectedItem.ToString(); SetExpressionEvalTypeByParameterType(ref comboBoxExpEdit, comboBoxSelectedItem); if (comboBoxSelectedItem == "Path") { currentBrowseButton.Enabled = true; } else { currentBrowseButton.Enabled = false; } } catch (System.NullReferenceException ex) { VSDialogs vsdiag = new VSDialogs(); vsdiag.ShowWarningDialog("Parameter Type Changed Null Reference Exception"); } }
public ConfigureRTSequence(SequenceContext _seqContext, ConcurrentQueue <SequenceCallInfo[]> _cq) { InitializeComponent(); 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(); VSDialogs vsdiag = new VSDialogs(); cq = _cq; selectedSequence = 0; stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Get old values if they exist try { autostart = stepPropertyObject.GetValBoolean("Veristand.StimProfAutoStart", 0); this.auto_start.Checked = autostart; timeout = (uint)stepPropertyObject.GetValNumber("Veristand.StimProfTimeout", 0); this.rtseq_timeout.Value = timeout; this.sessionName_Control.Text = stepPropertyObject.GetValString("Veristand.RTSessionName", 0); sequenceNames = Array.ConvertAll((object[])stepPropertyObject.GetValVariant("Veristand.SequenceNames", 0), o => o.ToString()); 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()); numSequences = (int)stepPropertyObject.GetValNumber("Veristand.RTNumSequences", 0); try { InitializeDataGridView(sequenceNames[0], parameterValues, parameterTypes, numSequences, 0); //Initialize the data grid with the previously selected data this.FilePath.Text = sequenceNames[0]; } 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); autostart = false; StimProfilePathStr = ""; this.auto_start.Checked = autostart; this.FilePath.Text = StimProfilePathStr; timeout = 1000; this.rtseq_timeout.Value = timeout; this.sessionName_Control.Text = "Session 1"; } }
// public string dataGridView_ToolTipText = //@"Lists the File Properties written to the TDMS log file. // //For each property, the following information is stored: //Name (string) //Data type (tdsDataType) //Value (strings are encoded in UTF-8 Unicode). // //Strings in TDMS files can be null-terminated, but since the length //information is stored, the null terminator will be ignored when //you read from the file."; public AdvancedLoggingProperties(SequenceContext _seqContext, ConfigureLoggingFile CallingForm) { InitializeComponent(); CallingFormGlobal = CallingForm; //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type EvaluationTypes evalNumeric = seqContext.Engine.NewEvaluationTypes(); stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); FileDescription_text.Text = CallingForm.fileDescription; filePropertyNames = CallingFormGlobal.filePropertyNames; filePropertyValues = CallingFormGlobal.filePropertyValues; InitializeFilePropertiesDataGridView(); VSDialogs vsdiag = new VSDialogs(); //this.OK.Click +=new EventHandler(OK_Click,new EventArgs(_fileAuthor)); }
public ConfigureSequenceName(SequenceContext _seqContext) { InitializeComponent(); seqContext = _seqContext; selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; seqContextPO = selectedTSSequence.Locals; int thisStepIndex = selectedTSStep.StepIndex; propObjectFile = seqFile.AsPropertyObjectFile(); try { this.sequenceName_Control.Text = seqContextPO.GetValString("Veristand." + stepID + "RTSequenceName", 0); } catch (System.Runtime.InteropServices.COMException) { //If variables don't exist set default values this.sequenceName_Control.Text = ""; } int count = thisStepIndex; bool found = false; while (count >= 0 && found == false) { Step currentStep = selectedTSSequence.GetStep(count, StepGroups.StepGroup_Main); if (currentStep.Name == "Open and Deploy RT Sequence") //This will need to change if the name of the Open RT Sequence Name Step Changes { //this is the open RTSequence step that is the closes previous to this step name configuration string openRTSequenceStepID = currentStep.UniqueStepId; VSDialogs vsdiags = new VSDialogs(); try //When this does and does not exist is different from the RTSequenceName so it needs its own Try/Catch block { seqCallInfoArray = vsdiags.ReinitializeSequenceCallInfo(seqContext, openRTSequenceStepID); //Get the sequence info created by the Open RT Sequence Step allSequenceNames = ParseNamesFromSequenceCallInfo(seqCallInfoArray); //Populate the parsed list of sequence names if (allSequenceNames.Length > 0) { if (allSequenceNames[0] != null) { //Set the sequence name control to the first name we parsed this.sequenceName_Control.Text = allSequenceNames[0]; } else { this.sequenceName_Control.Text = ""; } } } catch (System.Runtime.InteropServices.COMException) { seqCallInfoArray = null; } } count--; } }
public NativeChannelSelectionDialog(SequenceContext _seqContext, ChannelType _channelType) { InitializeComponent(); channelType = _channelType; //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type EvaluationTypes evalNumeric = seqContext.Engine.NewEvaluationTypes(); evalNumeric.PropertyValueTypeFlags = 0x2; //Set valid evaluation types to number value_exp.SetValidEvaluationTypes(evalNumeric); value_exp.Context = seqContextPO; stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); VSDialogs vsdiag = new VSDialogs(); try { value_exp.Text = stepPropertyObject.GetValString("Veristand.ValueToSet", 0); selectedChannelName = stepPropertyObject.GetValString("Veristand.ChannelName", 0); sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1);//Try to get the specific system definition path associated with this step seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); if (sysDefPath == null) { sysDefPath = ""; } if (channelType == ChannelType.paramChannel) { ModelListFullPath = stepPropertyObject.GetValString("Veristand.FullChannelPath", 0); } } catch (System.Runtime.InteropServices.COMException ex) { selectedChannelName = ""; } catch (System.NullReferenceException ex) { //Do Nothing } if (sysDefPath != null) { if (System.IO.File.Exists(StringUtilities.unparseFilePathString(sysDefPath)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sysDefPath)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeListBox(sysDefPath); } } }
public IStimulusProfileSession StartStimulusProfile(NationalInstruments.TestStand.Interop.API.SequenceContext seqContext, SequenceCallInfo[] seqCallInfoArray, string gatewayIP) { seqCallInfoArray = Array.FindAll(seqCallInfoArray, isNotNull).ToArray(); Step activeStep = seqContext.Step; string stepID = activeStep.UniqueStepId; Sequence selectedTSSequence = seqContext.Sequence; PropertyObject stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); try { PropertyObject seqContextPO = seqContext.AsPropertyObject(); Factory vsFact = new Factory(); string sequenceName; try { sequenceName = stepPropertyObject.GetValString("Veristand.RTSessionName", 0); } catch (System.Runtime.InteropServices.COMException ex) { sequenceName = "CouldNotFindName"; VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Could not find name of RT Sequence"); } IStimulusProfileSession stimProfSession = vsFact.GetIStimulusProfileSession(gatewayIP, sequenceName, seqCallInfoArray, "Teststand Stimulus Profile Session"); bool auto_start; try { auto_start = stepPropertyObject.GetValBoolean("Veristand.StimProfAutoStart", 0); } catch (System.Runtime.InteropServices.COMException ex) { auto_start = false; } string sessionName; NationalInstruments.VeriStand.Error vsError; stimProfSession.Deploy(auto_start, out sessionName, out vsError); if (vsError.Code != 0) { VSDialogs dialogs2 = new VSDialogs(); dialogs2.ShowWarningDialog(vsError.ResolvedErrorMessage); } return(stimProfSession); } catch (NationalInstruments.VeriStand.VeriStandException ex) { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog(ex.ResolvedErrorMessage + "------" + ex.StackTrace); } catch (System.InvalidCastException ex) { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog(ex.Message + "------" + ex.StackTrace); } return(null); }
private void OK_Click(object sender, EventArgs e) { //Setting Variables this way is necessary for them to persist when TestStand Closes and is Opened again if (!ProcessSequenceParameters()) { stepPropertyObject.SetValNumber("Veristand.Timeout", 0, (double)Timeout.Value); stepPropertyObject.SetValString("Veristand.Target", 0, target); seqContext.SequenceFile.FileGlobalsDefaultValues.SetValIDispatch("Veristand.StimulusProfileReference", 1, null); seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.StimulusProfileReference", 0, 0x4400000); stepPropertyObject.SetValVariant("Veristand.SequenceFilePath", 0, StringUtilities.parseFilePathString(sequenceFileExp)); stepPropertyObject.SetValVariant("Veristand.ParamNamesArray", 0, StringUtilities.stringArrayToExpressionArray(parameterNamesArray)); stepPropertyObject.SetValVariant("Veristand.ParamValuesArray", 0, StringUtilities.stringArrayToExpressionArray(parameterValuesArray)); stepPropertyObject.SetValVariant("Veristand.ParamTypesArray", 0, StringUtilities.stringArrayToExpressionArray(parameterTypesArray)); if (!stepPropertyObject.Exists("Result.Veristand.Returnval", 0)) { if (returnParamDataType == "Boolean") { stepPropertyObject.NewSubProperty("Result.Veristand.Returnval", PropertyValueTypes.PropValType_Boolean, false, "", 1); stepPropertyObject.SetFlags("Result.Veristand.Returnval", 0, 0x4000000); } else //Number formats: Int32, Int64, UInt32, UInt64, Double { stepPropertyObject.NewSubProperty("Result.Veristand.Returnval", PropertyValueTypes.PropValType_Number, false, "", 1); stepPropertyObject.SetFlags("Result.Veristand.Returnval", 0, 0x4000000); } } else //"Step.Result.Veristand.Returnval" already exists { stepPropertyObject.DeleteSubProperty("Result.Veristand.Returnval", 0); //Remove it so that we can ensure that it will be the correct ValueType. We must do this because there does //not appear to be a way to just use the TestStand API to change Type.ValueType. It is Read-only. if (returnParamDataType == "Boolean") { stepPropertyObject.NewSubProperty("Result.Veristand.Returnval", PropertyValueTypes.PropValType_Boolean, false, "", 1); stepPropertyObject.SetFlags("Result.Veristand.Returnval", 0, 0x4000000); } else //Number formats: Int32, Int64, UInt32, UInt64, Double { stepPropertyObject.NewSubProperty("Result.Veristand.Returnval", PropertyValueTypes.PropValType_Number, false, "", 1); stepPropertyObject.SetFlags("Result.Veristand.Returnval", 0, 0x4000000); } } propObjectFile.IncChangeCount(); //Sets the flag that means the sequence has changes to save (dirty dot*) this.Close(); //Close the form } else { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Please specify all Parameters."); } }
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 ConfigureLoggingFile(SequenceContext _seqContext, ChannelType _channelType) { InitializeComponent(); //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type LogFilePath_exp.SetValidEvaluationTypes(eval); LogFilePath_exp.Context = seqContextPO; EvaluationTypes evalNumeric = seqContext.Engine.NewEvaluationTypes(); stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Set up dialog objects sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1); //Get the System Definition path for the Client Sequence File. Create it if it does not exist. seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); channelList = stepPropertyObject.GetValVariant("Veristand.ChannelPaths", 0); //Get ChannelPaths array of strings. LogFilePath_exp.Text = stepPropertyObject.GetValString("Veristand.LogFilePath", 0); //Try to get the Log File Path associated with this step SegmentFileSize_boolean.Checked = stepPropertyObject.GetValBoolean("Veristand.FileSegmenting", 0); //Get the boolean for Segmenting File Size option FileSegmentSize_num.Value = (int)stepPropertyObject.GetValNumber("Veristand.FileSegmentingSize", 0); //Get the File Segment Size value fileDescription = stepPropertyObject.GetValString("Veristand.FileDescription", 0); //Get the File Description advanced property filePropertyNames.AddRange(stepPropertyObject.GetValVariant("Veristand.FilePropertyNames", 0)); filePropertyValues.AddRange(stepPropertyObject.GetValVariant("Veristand.FilePropertyValues", 0)); channelType = _channelType; loggingChannelSelection.ShowCheckBox = true; //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(sysDefPath)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sysDefPath)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeListBox(sysDefPath); } //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))) { //Do nothing } VSDialogs vsdiag = new VSDialogs(); }
private void FilePath_TextChanged(object sender, EventArgs e) { sequenceFileExp = this.FilePath.Text; if (System.IO.File.Exists(StringUtilities.unparseFilePathString(sequenceFileExp))) //Check to see if the currently entered path is a valid filename { string extension = System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sequenceFileExp)); if (extension == ".csv" || extension == ".nivsseq") //Check to make sure we have a valid file extension { InitializeTableView(seqContext, sequenceFileExp, parameterValuesArray, parameterTypesArray, true); //Fill grid in with current file data } else { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Invalid File Extension:" + extension + "\n Please select a .csv or .nivsseq file"); } } }
public SetMultipleChannelsDialogDGV(SequenceContext _seqContext, ChannelType _channelType) { InitializeComponent(); this.DoubleBuffered = true; //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Set up dialog objects sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1); //Get the System Definition path for the Client Sequence File. Create it if it does not exist. seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); channelNamesList.AddRange(stepPropertyObject.GetValVariant("VeriStand.ChannelNames", 0)); //Get ChannelNames array of strings. channelValuesArray = stepPropertyObject.GetValVariant("VeriStand.ValuesToSet", 0); //Get ValuesToSet array of numbers channelType = _channelType; if (baseNodeArray != null) { baseNodeArray = (BaseNodeType[])stepPropertyObject.GetValInterface("Veristand.BaseNodeArray", 0);//Get the BaseNodeArray from TestStand and cast to a BaseNodeType[] } else { baseNodeArray = new BaseNodeType[0]; } VSDialogs vsdiag = new VSDialogs(); //If the file at path FileGlobals.Veristand.SystemDefinitionPath exists and the extension is ".nivssdf" use that System Definition file to initialize the list of channels in the dataGridView1 if (System.IO.File.Exists(StringUtilities.unparseFilePathString(sysDefPath)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sysDefPath)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeDataGridView(sysDefPath, channelNamesList, channelValuesArray, true); } //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))) { //Do nothing } }
private void FilePath_TextChanged(object sender, EventArgs e) { StimProfilePathStr = this.FilePath.Text; if (System.IO.File.Exists(StimProfilePathStr)) //Check to see if the currently entered path is a valid filename { string extension = System.IO.Path.GetExtension(StimProfilePathStr); if (extension == ".csv" || extension == ".nivsseq") //Check to make sure we have a valid file extension { insertIntoArray(ref sequenceNames, selectedSequence, this.FilePath.Text); InitializeDataGridView(StimProfilePathStr, parameterValues, parameterTypes, numSequences, selectedSequence); //Fill grid in with current file data } else { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Invalid File Extension:" + extension + "\n Please select a .csv or .nivsseq file"); } } }
public ConfigureAlarm(SequenceContext _seqContext) { InitializeComponent(); //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type systemDefinitionPath_exp.SetValidEvaluationTypes(eval); systemDefinitionPath_exp.Context = seqContextPO; stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); VSDialogs vsdiag = new VSDialogs(); try { alarmstate_control.SelectedItem = StringUtilities.removeDoubleQuotesAroundString(stepPropertyObject.GetValString("Veristand.AlarmState", 0)); alarmName = stepPropertyObject.GetValString("Veristand.AlarmName", 0); AlarmListFullPath = stepPropertyObject.GetValString("Veristand.FullAlarmPath", 0); systemDefinitionPath_exp.Text = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1);//Try to get the specific system definition path associated with this step seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); } catch (System.Runtime.InteropServices.COMException) { systemDefinitionPath_exp.Text = ""; //If there is no system definition path default to the empty string } if (System.IO.File.Exists(StringUtilities.unparseFilePathString(systemDefinitionPath_exp.Text)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(systemDefinitionPath_exp.Text)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeListBox(systemDefinitionPath_exp.Text); } }
public SetMultipleChannelsDialog(SequenceContext _seqContext, ChannelType _channelType) { InitializeComponent(); //this.DoubleBuffered = true; //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type EvaluationTypes evalNumeric = seqContext.Engine.NewEvaluationTypes(); stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Set up dialog objects sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1); //Get the System Definition path for the Client Sequence File. Create it if it does not exist. channelNamesList.AddRange(stepPropertyObject.GetValVariant("VeriStand.ChannelNames", 0)); //Get ChannelNames array of strings. channelValuesArray = stepPropertyObject.GetValVariant("VeriStand.ValuesToSet", 0); //Get ValuesToSet array of numbers channelType = _channelType; VSDialogs vsdiag = new VSDialogs(); //If the file at path FileGlobals.Veristand.SystemDefinitionPath exists and the extension is ".nivssdf" use that System Definition file to initialize the list of channels in the dataGridView1 if (System.IO.File.Exists(StringUtilities.unparseFilePathString(sysDefPath)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sysDefPath)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeTableView(sysDefPath, channelNamesList, channelValuesArray); } //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))) { //Do nothing } }
private string[] ParseNamesFromSequenceCallInfo(SequenceCallInfo[] seqCallInfoArr) { //Gets the sequence names from the sequence call info //This is found by parsing the list of sequences to find duplicate sequences and incrementing the instance number for each duplicate try { string[] sequenceNames = new string[seqCallInfoArray.Length]; Hashtable seqNameTable = new Hashtable(); int count = 0; foreach (SequenceCallInfo seqInfo in seqCallInfoArray) { string fullSequencePath = seqInfo.SequencePath; string sequenceName = Path.GetFileNameWithoutExtension(fullSequencePath); if (seqNameTable.ContainsKey(sequenceName)) { int instance = (int)seqNameTable[sequenceName]; instance++; seqNameTable[sequenceName] = instance; sequenceNames[count] = sequenceName + ":" + instance.ToString(); } else { seqNameTable.Add(sequenceName, 1); sequenceNames[count] = sequenceName + ":1"; } count++; } return(sequenceNames); } catch (System.NullReferenceException ex) { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("RT Sequence Information Not Found\n\n" + ex.Message + "------" + ex.StackTrace); string[] name = { "No Sequence Found" }; return(name); } }
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; } }
void InitializeTableView(SequenceContext _seqContext, string fileExp, string[] _parameterValues, string[] _parameterTypes, bool reset) { //MessageBox.Show(reset.ToString()); PropertyObject seqContextPO; seqContextPO = _seqContext.AsPropertyObject(); string filePath = StringUtilities.unparseFilePathString(fileExp); this.OpenSelectSingleChannelsDialog = new SelectSingleChannelPanel(this); string[] comboBoxParameterTypes = { "Path", "Boolean", "Double", "I32", "I64", "U32", "U64" }; this.tableLayoutPanel1.Controls.Clear();//Empty the table //Add in the column headers this.tableLayoutPanel1.Controls.Add(this.ParameterNameTitle_label, 0, 0); this.tableLayoutPanel1.Controls.Add(this.ParameterTypeTitle_label, 1, 0); this.tableLayoutPanel1.Controls.Add(this.ParameterValueTitle_label, 2, 0); this.tableLayoutPanel1.Controls.Add(this.SelectChannelTitle_label, 3, 0); this.tableLayoutPanel1.AutoSize = true; this.tableLayoutPanel1.RowCount = 1; TableLayoutRowStyleCollection rowStyles = this.tableLayoutPanel1.RowStyles; foreach (RowStyle style in rowStyles) { if (style.SizeType == SizeType.Percent) { style.SizeType = SizeType.AutoSize; } } 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; string parameterValueElement; ReturnDeclaration returnParam = newRTSeq.Variables.ReturnType; string returnParamType = returnParam.DataType.ToString(); returnParamDataType = returnParamType; if (!reset) { this.tableLayoutPanel1.RowCount = seqParam.Length + 1; //Need rows for the header and one row for each parameter if (seqParam.Length != _parameterValues.Length) { VSDialogs vsdialog = new VSDialogs(); vsdialog.ShowWarningDialog("It appears that the Real-Time Sequence has changed. Please reload the file by clicking \"Browse...\"."); } if (seqParam.Length == _parameterValues.Length && seqParam.Length > 0 && _parameterValues.Length > 0) { for (int i = 0; i < seqParam.Length; i++) { ParameterDeclaration param = seqParam[i]; System.Windows.Forms.Label currentNameLabel = new System.Windows.Forms.Label(); System.Windows.Forms.ComboBox currentTypeComboBox = new System.Windows.Forms.ComboBox(); currentTypeComboBox.Enabled = false; NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit currentExpression = new NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit(); if (param.EvaluationMethod == EvaluationMethod.ByReference) { parameterValueElement = StringUtilities.removeDoubleQuotesAroundString(_parameterValues[i]); if (param.DefaultAssignment.Channel.ToString() == parameterValueElement) { int rowToAddControl = i + 1; currentNameLabel.Text = param.Identifier; currentNameLabel.AutoSize = true; this.tableLayoutPanel1.Controls.Add(currentNameLabel, 0, rowToAddControl); currentTypeComboBox.Items.AddRange(comboBoxParameterTypes); currentTypeComboBox.SelectedValueChanged += new System.EventHandler(this.ParameterTypeChanged); currentExpression.Visible = true; currentExpression.Dock = DockStyle.Fill; this.tableLayoutPanel1.Controls.Add(currentExpression, 2, rowToAddControl); currentExpression.Parent = tableLayoutPanel1; string handle = currentExpression.Handle.ToString();//force creation of the handle System.Windows.Forms.Button selectChannelButton = new System.Windows.Forms.Button(); selectChannelButton.Text = "Browse..."; selectChannelButton.Enabled = false; selectChannelButton.Click += new System.EventHandler(selectChannelButton_Click); selectChannelButton.Parent = this.tableLayoutPanel1; this.tableLayoutPanel1.Controls.Add(selectChannelButton, 3, rowToAddControl); currentExpression.CreateControl(); currentExpression.Context = seqContextPO; currentExpression.SyntaxHighlightingEnabled = true; currentExpression.Style = NationalInstruments.TestStand.Interop.UI.ExpressionEditStyles.ExpressionEditStyle_Edit; currentExpression.TextType = NationalInstruments.TestStand.Interop.UI.TextTypes.TextType_Expression; currentExpression.Text = StringUtilities.addDoubleQuotesAroundString(param.DefaultAssignment.Channel.ToString());//Just use the DefaultAssignment if they are the same. this.tableLayoutPanel1.GetControlFromPosition(3, rowToAddControl).Enabled = true; currentTypeComboBox.SelectedText = "Path"; this.tableLayoutPanel1.Controls.Add(currentTypeComboBox, 1, rowToAddControl); } else { int rowToAddControl = i + 1; currentNameLabel.Text = param.Identifier; currentNameLabel.AutoSize = true; this.tableLayoutPanel1.Controls.Add(currentNameLabel, 0, rowToAddControl); currentTypeComboBox.Items.AddRange(comboBoxParameterTypes); currentTypeComboBox.SelectedValueChanged += new System.EventHandler(this.ParameterTypeChanged); currentExpression.Visible = true; currentExpression.Dock = DockStyle.Fill; this.tableLayoutPanel1.Controls.Add(currentExpression, 2, rowToAddControl); currentExpression.Parent = tableLayoutPanel1; string handle = currentExpression.Handle.ToString();//force creation of the handle System.Windows.Forms.Button selectChannelButton = new System.Windows.Forms.Button(); selectChannelButton.Text = "Browse..."; selectChannelButton.Enabled = false; selectChannelButton.Click += new System.EventHandler(selectChannelButton_Click); selectChannelButton.Parent = this.tableLayoutPanel1; this.tableLayoutPanel1.Controls.Add(selectChannelButton, 3, rowToAddControl); currentExpression.CreateControl(); currentExpression.Context = seqContextPO; currentExpression.SyntaxHighlightingEnabled = true; currentExpression.Style = NationalInstruments.TestStand.Interop.UI.ExpressionEditStyles.ExpressionEditStyle_Edit; currentExpression.TextType = NationalInstruments.TestStand.Interop.UI.TextTypes.TextType_Expression; currentExpression.Text = StringUtilities.addDoubleQuotesAroundString(parameterValueElement);//Use the value from TestStand instead of the DefaultAssignment if they are not the same. this.tableLayoutPanel1.GetControlFromPosition(3, rowToAddControl).Enabled = true; currentTypeComboBox.SelectedText = "Path"; this.tableLayoutPanel1.Controls.Add(currentTypeComboBox, 1, rowToAddControl); } } else { parameterValueElement = StringUtilities.removeDoubleQuotesAroundString(_parameterValues[i]); if (param.DefaultAssignment.ToString() == parameterValueElement) { int rowToAddControl = i + 1; currentNameLabel.Text = param.Identifier; currentNameLabel.AutoSize = true; this.tableLayoutPanel1.Controls.Add(currentNameLabel, 0, rowToAddControl); currentTypeComboBox.Items.AddRange(comboBoxParameterTypes); currentTypeComboBox.SelectedValueChanged += new System.EventHandler(this.ParameterTypeChanged); currentExpression.Visible = true; currentExpression.Dock = DockStyle.Fill; this.tableLayoutPanel1.Controls.Add(currentExpression, 2, rowToAddControl); currentExpression.Parent = tableLayoutPanel1; string handle = currentExpression.Handle.ToString();//force creation of the handle System.Windows.Forms.Button selectChannelButton = new System.Windows.Forms.Button(); selectChannelButton.Text = "Browse..."; selectChannelButton.Enabled = false; selectChannelButton.Click += new System.EventHandler(selectChannelButton_Click); selectChannelButton.Parent = this.tableLayoutPanel1; this.tableLayoutPanel1.Controls.Add(selectChannelButton, 3, rowToAddControl); currentExpression.CreateControl(); currentExpression.Context = seqContextPO; currentExpression.SyntaxHighlightingEnabled = true; currentExpression.Style = NationalInstruments.TestStand.Interop.UI.ExpressionEditStyles.ExpressionEditStyle_Edit; currentExpression.TextType = NationalInstruments.TestStand.Interop.UI.TextTypes.TextType_Expression; currentExpression.Text = param.DefaultAssignment.ToString();//Just use the DefaultAssignment if they are the same. this.tableLayoutPanel1.GetControlFromPosition(3, rowToAddControl).Enabled = false; switch (param.DefaultValue.Type.ToString()) { case "Double": currentTypeComboBox.SelectedText = "Double"; break; case "UInt64": currentTypeComboBox.SelectedText = "U64"; break; case "Int64": currentTypeComboBox.SelectedText = "I64"; break; case "UInt32": currentTypeComboBox.SelectedText = "U32"; break; case "Int32": currentTypeComboBox.SelectedText = "I32"; break; case "Boolean": currentTypeComboBox.SelectedText = "Boolean"; break; } this.tableLayoutPanel1.Controls.Add(currentTypeComboBox, 1, rowToAddControl); } else { int rowToAddControl = i + 1; currentNameLabel.Text = param.Identifier; currentNameLabel.AutoSize = true; this.tableLayoutPanel1.Controls.Add(currentNameLabel, 0, rowToAddControl); currentTypeComboBox.Items.AddRange(comboBoxParameterTypes); currentTypeComboBox.SelectedValueChanged += new System.EventHandler(this.ParameterTypeChanged); currentExpression.Visible = true; currentExpression.Dock = DockStyle.Fill; this.tableLayoutPanel1.Controls.Add(currentExpression, 2, rowToAddControl); currentExpression.Parent = tableLayoutPanel1; string handle = currentExpression.Handle.ToString();//force creation of the handle System.Windows.Forms.Button selectChannelButton = new System.Windows.Forms.Button(); selectChannelButton.Text = "Browse..."; selectChannelButton.Enabled = false; selectChannelButton.Click += new System.EventHandler(selectChannelButton_Click); selectChannelButton.Parent = this.tableLayoutPanel1; this.tableLayoutPanel1.Controls.Add(selectChannelButton, 3, rowToAddControl); currentExpression.CreateControl(); currentExpression.Context = seqContextPO; currentExpression.SyntaxHighlightingEnabled = true; currentExpression.Style = NationalInstruments.TestStand.Interop.UI.ExpressionEditStyles.ExpressionEditStyle_Edit; currentExpression.TextType = NationalInstruments.TestStand.Interop.UI.TextTypes.TextType_Expression; currentExpression.Text = parameterValueElement;//Use the value from TestStand instead of the DefaultAssignment if they are not the same. this.tableLayoutPanel1.GetControlFromPosition(3, rowToAddControl).Enabled = false; switch (param.DefaultValue.Type.ToString()) { case "Double": currentTypeComboBox.SelectedText = "Double"; break; case "UInt64": currentTypeComboBox.SelectedText = "U64"; break; case "Int64": currentTypeComboBox.SelectedText = "I64"; break; case "UInt32": currentTypeComboBox.SelectedText = "U32"; break; case "Int32": currentTypeComboBox.SelectedText = "I32"; break; case "Boolean": currentTypeComboBox.SelectedText = "Boolean"; break; } this.tableLayoutPanel1.Controls.Add(currentTypeComboBox, 1, rowToAddControl); } //switch (param.DefaultValue.Type.ToString()) //{ // case "Double": // currentTypeComboBox.SelectedText = "Double"; // break; // case "UInt64": // currentTypeComboBox.SelectedText = "U64"; // break; // case "Int64": // currentTypeComboBox.SelectedText = "I64"; // break; // case "UInt32": // currentTypeComboBox.SelectedText = "U32"; // break; // case "Int32": // currentTypeComboBox.SelectedText = "I32"; // break; // case "Boolean": // currentTypeComboBox.SelectedText = "Boolean"; // break; //} } } } } if (reset) { this.tableLayoutPanel1.RowCount = seqParam.Length + 1; //Need rows for the header and one row for each parameter if (seqParam.Length > 0) { this.tableLayoutPanel1.AutoSize = true; int n = 1; foreach (ParameterDeclaration param in seqParam) { System.Windows.Forms.Label currentNameLabel = new System.Windows.Forms.Label(); currentNameLabel.Text = param.Identifier; currentNameLabel.AutoSize = true; this.tableLayoutPanel1.Controls.Add(currentNameLabel, 0, n); System.Windows.Forms.ComboBox currentTypeComboBox = new System.Windows.Forms.ComboBox(); currentTypeComboBox.Items.AddRange(comboBoxParameterTypes); currentTypeComboBox.SelectedValueChanged += new System.EventHandler(this.ParameterTypeChanged); currentTypeComboBox.Enabled = false; NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit currentExpression = new NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit(); currentExpression.Visible = true; currentExpression.Dock = DockStyle.Fill; this.tableLayoutPanel1.Controls.Add(currentExpression, 2, n); currentExpression.Parent = tableLayoutPanel1; string handle = currentExpression.Handle.ToString();//force creation of the handle System.Windows.Forms.Button selectChannelButton = new System.Windows.Forms.Button(); selectChannelButton.Text = "Browse..."; selectChannelButton.Enabled = false; selectChannelButton.Click += new System.EventHandler(selectChannelButton_Click); selectChannelButton.Parent = this.tableLayoutPanel1; this.tableLayoutPanel1.Controls.Add(selectChannelButton, 3, n); currentExpression.CreateControl(); currentExpression.Context = seqContextPO; currentExpression.SyntaxHighlightingEnabled = true; currentExpression.Style = NationalInstruments.TestStand.Interop.UI.ExpressionEditStyles.ExpressionEditStyle_Edit; currentExpression.TextType = NationalInstruments.TestStand.Interop.UI.TextTypes.TextType_Expression; if (param.EvaluationMethod == EvaluationMethod.ByReference) { currentTypeComboBox.SelectedText = "Path"; currentExpression.Text = StringUtilities.addDoubleQuotesAroundString(param.DefaultAssignment.Channel.ToString()); this.tableLayoutPanel1.GetControlFromPosition(3, n).Enabled = true; } else { switch (param.DefaultValue.Type.ToString()) { case "Double": currentTypeComboBox.SelectedText = "Double"; break; case "UInt64": currentTypeComboBox.SelectedText = "U64"; break; case "Int64": currentTypeComboBox.SelectedText = "I64"; break; case "UInt32": currentTypeComboBox.SelectedText = "U32"; break; case "Int32": currentTypeComboBox.SelectedText = "I32"; break; case "Boolean": currentTypeComboBox.SelectedText = "Boolean"; break; } currentExpression.Text = param.DefaultAssignment.ToString(); } this.tableLayoutPanel1.Controls.Add(currentTypeComboBox, 1, n); n++; } } } } catch (System.ArgumentException) { VSDialogs dialogs = new VSDialogs(); dialogs.ShowWarningDialog("Invalid Filepath:" + filePath); } } }
public ConfigureLoggingFile(SequenceContext _seqContext, ChannelType _channelType) { InitializeComponent(); //Set up Teststand objects seqContext = _seqContext; seqContextPO = seqContext.AsPropertyObject(); selectedTSSequence = seqContext.SelectedSequences[0]; selectedTSStep = seqContext.SelectedSteps[0]; stepID = selectedTSStep.UniqueStepId; seqFile = selectedTSSequence.SequenceFile; permSeqContext = selectedTSSequence.Locals; //Must get sequence context this way for variables to save if teststand is restarted propObjectFile = seqFile.AsPropertyObjectFile(); EvaluationTypes eval = seqContext.Engine.NewEvaluationTypes(); eval.PropertyValueTypeFlags = 0x4; //set string as the valid evaluation type LogFilePath_exp.SetValidEvaluationTypes(eval); LogFilePath_exp.Context = seqContextPO; EvaluationTypes evalNumeric = seqContext.Engine.NewEvaluationTypes(); stepPropertyObject = selectedTSSequence.GetStepByUniqueId(stepID).AsPropertyObject(); //Set up dialog objects sysDefPath = seqContext.SequenceFile.FileGlobalsDefaultValues.GetValString("Veristand.SystemDefinitionPath", 1); //Get the System Definition path for the Client Sequence File. Create it if it does not exist. seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); channelList = stepPropertyObject.GetValVariant("Veristand.ChannelPaths", 0); //Get ChannelPaths array of strings. LogFilePath_exp.Text = stepPropertyObject.GetValString("Veristand.LogFilePath", 0); //Try to get the Log File Path associated with this step SegmentFileSize_boolean.Checked = stepPropertyObject.GetValBoolean("Veristand.FileSegmenting", 0); //Get the boolean for Segmenting File Size option FileSegmentSize_num.Value = (int)stepPropertyObject.GetValNumber("Veristand.FileSegmentingSize", 0); //Get the File Segment Size value fileDescription = stepPropertyObject.GetValString("Veristand.FileDescription", 0); //Get the File Description advanced property filePropertyNames.AddRange(stepPropertyObject.GetValVariant("Veristand.FilePropertyNames", 0)); filePropertyValues.AddRange(stepPropertyObject.GetValVariant("Veristand.FilePropertyValues", 0)); channelType = _channelType; if (stepPropertyObject.GetValInterface("Veristand.BaseNodeArray", 0) != null) { baseNodeArray = (BaseNodeType[])stepPropertyObject.GetValInterface("Veristand.BaseNodeArray", 0);//Get the BaseNodeArray from TestStand and cast to a BaseNodeType[] } else { baseNodeArray = new BaseNodeType[0]; } // These changes are in the 2014 VeriStand trunk so as soon as we start using that assembly we should revert these changes. // This is a hack for now to get check boxes on the Windows Form TreeAliasBrowserWF. Type TreeAliasBrowser = typeof(StorageChannelAndAliasBrowser); FieldInfo m_ChanAliasWPFElement = typeof(NationalInstruments.VeriStand.SystemStorageUI.WinFormsWrapper.TreeAliasBrowserWF).GetField( "m_ChanAliasWPFElement", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo aliasBrowserInfo = TreeAliasBrowser.GetField( "AliasTab", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo treeviewInfo = TreeAliasBrowser.GetField( "TreeView", BindingFlags.NonPublic | BindingFlags.Instance); var topLevelBrowser = (StorageChannelAndAliasBrowser)m_ChanAliasWPFElement.GetValue(loggingChannelSelection); this._aliasBrowser = (SystemDefinitionBrowser)aliasBrowserInfo.GetValue(topLevelBrowser); this._treeView = (SystemDefinitionBrowser)treeviewInfo.GetValue(topLevelBrowser); this._aliasBrowser.ShowCheckBox = true; this._treeView.ShowCheckBox = true; //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(sysDefPath)) && System.IO.Path.GetExtension(StringUtilities.unparseFilePathString(sysDefPath)) == ".nivssdf") { //File exists with correct extension so try and populate the tree InitializeListBox(sysDefPath); } //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))) { //Do nothing } VSDialogs vsdiag = new VSDialogs(); }
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"); } }
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); }