public SelectChannelsDialog(SetMultipleChannelsDialogDGV CallingForm) { InitializeComponent(); //Set up Variable objects CallingFormGlobal = CallingForm; sysDefPath = CallingFormGlobal.sysDefPath; channelNamesList = CallingFormGlobal.channelNamesList; channelValuesArray = CallingFormGlobal.channelValuesArray; channelNamesListOld = CallingFormGlobal.channelNamesListOld; channelValuesArrayOld = CallingFormGlobal.channelValuesArrayOld; channelType = (ChannelType)CallingFormGlobal.channelType; baseNodeArray = CallingFormGlobal.baseNodeArray; baseNodeElement = CallingFormGlobal.baseNodeElement; 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 } }
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 SelectChannels_button_Click(object sender, EventArgs e) { channelNamesListOld.Clear(); Array.Resize(ref channelValuesArrayOld, this.dataGridView1.Rows.Count); for (int i = 0; i < this.dataGridView1.Rows.Count; i++) { if (this.dataGridView1[0, i].Value != null /*&& this.dataGridView1[1, i].Value != null*/) { channelNamesListOld.Add(this.dataGridView1[0, i].Value.ToString()); channelValuesArrayOld[i] = Convert.ToDouble(this.dataGridView1[1, i].Value); } } this.OpenSelectChannelsDialog = new SelectChannelsDialog(this); this.OpenSelectChannelsDialog.ShowDialog(); //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, false); } //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 } }
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); } } }
private void InitializeListBox(string _sysDefPath) { currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(_sysDefPath)); switch (channelType) { case ChannelType.faultChannel: loggingChannelSelection.DisplayFilter = ISystemDefinitionBrowserFilterType.K_CHAN_FAULT; loggingChannelSelection.StartNode = currentSysDef.Root.BaseNodeType; break; case ChannelType.readableChannel: loggingChannelSelection.DisplayFilter = ISystemDefinitionBrowserFilterType.K_CHAN_R; loggingChannelSelection.StartNode = currentSysDef.Root.BaseNodeType; break; case ChannelType.writableChannel: loggingChannelSelection.DisplayFilter = ISystemDefinitionBrowserFilterType.K_CHAN_W; loggingChannelSelection.StartNode = currentSysDef.Root.BaseNodeType; break; case ChannelType.paramChannel: loggingChannelSelection.DisplayFilter = ISystemDefinitionBrowserFilterType.K_ALL; loggingChannelSelection.StartNode = currentSysDef.Root.BaseNodeType; break; } //Check to see if Step.Veristand.ChannelPath[] not empty. //We should not attempt to initialize the TreeALiasBrowserWF with an empty set of ChannelPaths. if (channelNamesListOld.Count > 0) { Root currentSysDefRoot = currentSysDef.Root; currentSysDefRoot.FindNodeByPath(channelNamesListOld.ElementAt(0), out baseNodeElement); if (baseNodeElement != null) { if (baseNodeArray.Length == channelNamesListOld.Count) { for (int i = 0; i < channelNamesListOld.Count; i++) { currentSysDefRoot.FindNodeByPath(channelNamesListOld.ElementAt(i), out baseNodeElement); baseNodeArray[i] = baseNodeElement.BaseNodeType; } } else { Array.Resize(ref baseNodeArray, channelNamesListOld.Count); for (int i = 0; i < channelNamesListOld.Count; i++) { currentSysDefRoot.FindNodeByPath(channelNamesListOld.ElementAt(i), out baseNodeElement); baseNodeArray[i] = baseNodeElement.BaseNodeType; } } this._aliasBrowser.SetCheckBoxSelections(baseNodeArray); this._treeView.SetCheckBoxSelections(baseNodeArray); } } }
private void InitializeListBox(string _sysDefPath) { currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(_sysDefPath)); channel_browser.StartNode = currentSysDef.Root.BaseNodeType; BaseNode highlightedNode; if (currentSysDef.Root.FindNodeByPath(StringUtilities.removeDoubleQuotesAroundString(AlarmListFullPath), out highlightedNode)) { BaseNodeType[] bnArray = { highlightedNode.BaseNodeType }; channel_browser.SetCurrentSelections(bnArray); } }
public SelectChannelsDialog(SetMultipleChannelsDialogDGV CallingForm) { InitializeComponent(); //Set up Variable objects CallingFormGlobal = CallingForm; sysDefPath = CallingFormGlobal.sysDefPath; channelNamesList = CallingFormGlobal.channelNamesList; channelValuesArray = CallingFormGlobal.channelValuesArray; channelNamesListOld = CallingFormGlobal.channelNamesListOld; channelValuesArrayOld = CallingFormGlobal.channelValuesArrayOld; channelType = (ChannelType)CallingFormGlobal.channelType; baseNodeArray = CallingFormGlobal.baseNodeArray; // 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 } }
private void InitializeListBox(string _sysDefPath, string _selectedTarget) { SystemDefinition _currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(_sysDefPath)); TravNdMatchNodeTypeFilter targetFilter = new TravNdMatchNodeTypeFilter(NodeType.K_TARGET); targetBrowser.SetSystemDefinitionDisplayFilter(ISystemDefinitionBrowserFilterType.K_CUSTOM, targetFilter); targetBrowser.StartNode = _currentSysDef.Root.BaseNodeType; //Check to see if selected target is empty. //We should not attempt to initialize the TreeALiasBrowserWF with an empty target path. if (_selectedTarget != "") { BaseNode startNode; _currentSysDef.Root.GetTargets().FindFirstChildWithName(_selectedTarget, out startNode, true); targetBrowser.SetCurrentSelections(new BaseNodeType[] { startNode.BaseNodeType }); } }
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 } }
public SelectTargetDialog(string sysDefPath, string target) { InitializeComponent(); SysDefPath = sysDefPath; SelectedTarget = target; //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, SelectedTarget); } //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 InitializeListBox(string _sysDefPath) { currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(_sysDefPath)); BaseNode highlightedNode; switch (channelType) { case ChannelType.faultChannel: channel_browser.DisplayFilter = ISystemDefinitionBrowserFilterType.K_CHAN_FAULT; channel_browser.StartNode = currentSysDef.Root.BaseNodeType; break; case ChannelType.readableChannel: channel_browser.DisplayFilter = ISystemDefinitionBrowserFilterType.K_CHAN_R; channel_browser.StartNode = currentSysDef.Root.BaseNodeType; break; case ChannelType.writableChannel: channel_browser.DisplayFilter = ISystemDefinitionBrowserFilterType.K_CHAN_W; channel_browser.StartNode = currentSysDef.Root.BaseNodeType; break; case ChannelType.paramChannel: channel_browser.DisplayFilter = ISystemDefinitionBrowserFilterType.K_ALL; channel_browser.StartNode = currentSysDef.Root.BaseNodeType; break; } if (channelType == ChannelType.paramChannel) { if (currentSysDef.Root.FindNodeByPath(StringUtilities.removeDoubleQuotesAroundString(ModelListFullPath), out highlightedNode)) { BaseNodeType[] bnArray = { highlightedNode.BaseNodeType }; channel_browser.SetCurrentSelections(bnArray); } } else { if (currentSysDef.Root.FindNodeByPath(StringUtilities.removeDoubleQuotesAroundString(selectedChannelName), out highlightedNode)) { BaseNodeType[] bnArray = { highlightedNode.BaseNodeType }; channel_browser.SetCurrentSelections(bnArray); } } }
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 } }
void InitializeDataGridView(string _sysDefPath, List <string> _channelNamesList, double[] _channelValuesArray, bool reset) { currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(_sysDefPath)); Root currentSysDefRoot = currentSysDef.Root; //Check to see if Step.VeriStand.ChannelNames[] not empty. //We should not attempt to initialize the dataGridView1 with an empty set of ChannelNames. if (channelNamesList.Count == 0) { this.dataGridView1.Rows.Clear();//Empty the table this.noChannelsLabel.BringToFront(); this.noChannelsLabel.Visible = true; } if (channelNamesList.Count > 0 && reset) { this.dataGridView1.Rows.Clear();//Empty the table this.noChannelsLabel.Visible = false; currentSysDefRoot.FindNodeByPath(channelNamesList.ElementAt(0), out baseNodeElement); if (baseNodeElement != null) { if (baseNodeArray.Length == channelNamesList.Count) { for (int i = 0; i < channelNamesList.Count; i++) { currentSysDefRoot.FindNodeByPath(channelNamesList.ElementAt(i), out baseNodeElement); baseNodeArray[i] = baseNodeElement.BaseNodeType; if (baseNodeElement != null) { dataGridView1.Rows.Add(); dataGridView1[0, i].Value = channelNamesList.ElementAt(i); dataGridView1[1, i].Value = channelValuesArray[i]; } } } else { Array.Resize(ref baseNodeArray, channelNamesList.Count); for (int i = 0; i < channelNamesList.Count; i++) { currentSysDefRoot.FindNodeByPath(channelNamesList.ElementAt(i), out baseNodeElement); baseNodeArray[i] = baseNodeElement.BaseNodeType; if (baseNodeElement != null) { dataGridView1.Rows.Add(); dataGridView1[0, i].Value = channelNamesList.ElementAt(i); dataGridView1[1, i].Value = channelValuesArray[i]; } } } } } if (channelNamesList.Count > 0 && !reset) { this.dataGridView1.Rows.Clear(); this.noChannelsLabel.Visible = false; for (int i = 0; i < channelNamesList.Count; i++) { int foundIndex = channelNamesListOld.IndexOf(channelNamesList.ElementAt(i)); if (foundIndex >= 0) { channelValuesArray[i] = channelValuesArrayOld[foundIndex]; dataGridView1.Rows.Add(); dataGridView1[0, i].Value = channelNamesList.ElementAt(i); dataGridView1[1, i].Value = channelValuesArray[i]; } else { dataGridView1.Rows.Add(); dataGridView1[0, i].Value = channelNamesList.ElementAt(i); dataGridView1[1, i].Value = 0; } } } }
void InitializeTableView(string _sysDefPath, List <string> _channelNamesList, double[] _channelValuesArray) { this.tableLayoutPanel1.Controls.Clear();//Empty the table //Add in the column headers this.tableLayoutPanel1.Controls.Add(this.ChannelNamesTitle_label, 0, 0); this.tableLayoutPanel1.Controls.Add(this.ChannelValuesTitle_label, 1, 0); currentSysDef = new SystemDefinition(StringUtilities.unparseFilePathString(_sysDefPath)); //Check to see if Step.VeriStand.ChannelNames[] not empty. //We should not attempt to initialize the dataGridView1 with an empty set of ChannelNames. if (channelNamesList.Count == 0) { this.tableLayoutPanel1.RowCount = 1; this.noChannelsLabel.BringToFront(); this.noChannelsLabel.Visible = true; this.tableLayoutPanel1.AutoSize = true; System.Drawing.Size tableLayoutPanel1MinSize = new System.Drawing.Size(); tableLayoutPanel1MinSize.Height = 0; tableLayoutPanel1MinSize.Width = 0; this.tableLayoutPanel1.MinimumSize = tableLayoutPanel1MinSize; } if (channelNamesList.Count > 0) { //if (channelNamesList.Count <= 8) //{ this.noChannelsLabel.Visible = false; TableLayoutRowStyleCollection rowStyles = this.tableLayoutPanel1.RowStyles; foreach (RowStyle style in rowStyles) { if (style.SizeType == SizeType.Percent) { style.SizeType = SizeType.AutoSize; } } this.tableLayoutPanel1.AutoSize = true; System.Drawing.Size tableLayoutPanel1MinSize = new System.Drawing.Size(); tableLayoutPanel1MinSize.Height = 0; tableLayoutPanel1MinSize.Width = 0; this.tableLayoutPanel1.MinimumSize = tableLayoutPanel1MinSize; this.tableLayoutPanel1.RowCount = channelNamesList.Count + 1; //Need rows for the header and one row for each channel. for (int i = 0; i < channelNamesList.Count; i++) { Label currentChannelNameLabel = new System.Windows.Forms.Label(); currentChannelNameLabel.Text = channelNamesList.ElementAt(i); this.tableLayoutPanel1.Controls.Add(currentChannelNameLabel, 0, i + 1); currentChannelNameLabel.AutoSize = true; TextBox currentValueTextBox = new System.Windows.Forms.TextBox(); currentValueTextBox.Text = channelValuesArray.ElementAt(i).ToString(); this.tableLayoutPanel1.Controls.Add(currentValueTextBox, 1, i + 1); currentValueTextBox.Dock = DockStyle.Fill; //NumericUpDown currentValueNumUpDown = new System.Windows.Forms.NumericUpDown(); //currentValueNumUpDown.Value = (int)channelValuesArray.ElementAt(i); //this.tableLayoutPanel1.Controls.Add(currentValueNumUpDown, 1, i + 1); //currentValueNumUpDown.AutoSize = true; } Root currentSysDefRoot = currentSysDef.Root; currentSysDefRoot.FindNodeByPath(channelNamesList[0], out baseNodeElement); //} //else if (channelNamesList.Count > 8) //{ // this.noChannelsLabel.Visible = false; // this.tableLayoutPanel1.AutoSize = true; // TableLayoutRowStyleCollection rowStyles = this.tableLayoutPanel1.RowStyles; // foreach (RowStyle style in rowStyles) // { // if (style.SizeType == SizeType.Percent) // { // style.SizeType = SizeType.AutoSize; // } // } // this.tableLayoutPanel1.RowCount = channelNamesList.Count + 1; //Need rows for the header and one row for each channel. // for (int i = 0; i < channelNamesList.Count; i++) // { // Label currentChannelNameLabel = new System.Windows.Forms.Label(); // currentChannelNameLabel.Text = channelNamesList.ElementAt(i); // this.tableLayoutPanel1.Controls.Add(currentChannelNameLabel, 0, i + 1); // currentChannelNameLabel.AutoSize = true; // NumericUpDown currentValueNumUpDown = new System.Windows.Forms.NumericUpDown(); // currentValueNumUpDown.Value = (int)channelValuesArray.ElementAt(i); // this.tableLayoutPanel1.Controls.Add(currentValueNumUpDown, 1, i + 1); // currentValueNumUpDown.AutoSize = true; // } // Root currentSysDefRoot = currentSysDef.Root; // currentSysDefRoot.FindNodeByPath(channelNamesList[0], out baseNodeElement); //} } }
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(); }
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); } } }
private void OK_Click(object sender, EventArgs e) { //Make or Set all specified variables in TestStand /*Set variables needed for other steps in System Definition and Project since these steps are guaranteed to be called first*/ permSeqContext.SetValIDispatch("Veristand.VSDialogs", 1, null); /*Set variables needed for project */ SeqContextFileGlobals.SetValString("Veristand.GatewayIP", 0, gatewayIP); SeqContextFileGlobals.SetValString("Veristand.ProjectPath", 0, projectpath_exp.Text); stepPropertyObject.SetValString("Veristand.username", 0, username); stepPropertyObject.SetValString("Veristand.password", 0, password); stepPropertyObject.SetValString("Veristand.Visible", 0, visible_exp.Text); string nodoublequotes = StringUtilities.removeDoubleQuotesAroundString(projectpath_exp.Text); string projectpathclean = StringUtilities.unparseFilePathString(nodoublequotes); if (projectpath_exp.Text == "" || !System.IO.File.Exists(projectpathclean) || System.IO.Path.GetExtension(projectpathclean) != ".nivsproj") { SeqContextFileGlobals.SetValString("Veristand.SystemDefinitionPath", 1, ""); seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); } if (System.IO.File.Exists(projectpathclean) && System.IO.Path.GetExtension(projectpathclean) == ".nivsproj") { string projectFileText = System.IO.File.ReadAllText(StringUtilities.removeDoubleQuotesAroundString(projectpath_exp.Text)); string sysDefGUIDPattern = "b9227a5b-2770-4a62-8621-ac414d4124fb.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*\n.*"; string pathTypePattern = "DependentFile Type=\""; string pathPattern = "Path=\""; string endpattern = "\".*"; Regex sysDefGUIDRegX = new Regex(sysDefGUIDPattern); Regex pathTypePatternRegx = new Regex(pathTypePattern); Regex filePathPatternRegx = new Regex(pathPattern); Regex endpatternRegx = new Regex(endpattern); string sysDefFileInfo = sysDefGUIDRegX.Match(projectFileText).ToString(); string[] dependentFileTypeArray = pathTypePatternRegx.Split(sysDefFileInfo); string [] pathPatternArray = endpatternRegx.Split(dependentFileTypeArray[1]); string[] messyFilePathArray = filePathPatternRegx.Split(sysDefFileInfo); string[] cleanFilePathArray = endpatternRegx.Split(messyFilePathArray[1]); switch (pathPatternArray[0]) { case "Relative": { string projectDirectory = System.IO.Path.GetDirectoryName(projectpathclean); sysDefPath = System.IO.Path.Combine(projectDirectory, cleanFilePathArray[0]); break; } case "Absolute": { sysDefPath = cleanFilePathArray[0]; break; } case "To Common Doc Dir": { string publicDocumentsPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments); sysDefPath = System.IO.Path.Combine(publicDocumentsPath, "National Instruments", "VeriStand 2014", cleanFilePathArray[0]); break; } case "": { break; } } SeqContextFileGlobals.SetValString("Veristand.SystemDefinitionPath", 1, sysDefPath); seqContext.SequenceFile.FileGlobalsDefaultValues.SetFlags("Veristand.SystemDefinitionPath", 0, 0x4400000); } propObjectFile.IncChangeCount(); //Sets the flag that means the sequence has changes to save (dirty dot*) this.Close(); }