SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
SampleParameters.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using Seci.Definitions;
5 
6 namespace Seci.Standard
7 {
11  public static class SampleParameters
12  {
13  private static String _filePath;
14 
15  public static String FilePath { get { return _filePath; } }
16 
20  public static void Initialise()
21  {
22  _filePath = Status.SampleParametersVI;
23 
24  //Load VI
25  LabView.LabViewApp.LoadVI(_filePath, true);
26 
27  //Start it running
28  LabView.LabViewApp.StartVI(_filePath);
29  }
30 
34  public static void ShowVi()
35  {
36  LabView.LabViewApp.ShowVI(_filePath);
37  }
38 
42  public static void HideVi()
43  {
44  LabView.LabViewApp.HideVI(_filePath);
45  }
46 
51  public static String[,] GetParameters()
52  {
53  try
54  {
55  Object val = LabView.LabViewApp.GetRawValue(_filePath, "Additional Parameters");
56 
57  return (String[,])val;
58  }
59  catch
60  {
61  return null;
62  }
63  }
64 
69  public static List<String> GetParameterNames()
70  {
71  try
72  {
73  Object val = LabView.LabViewApp.GetRawValue(_filePath, "Standard Parameters");
74 
75  String[,] temp = (String[,])val;
76  List<String> vals = new List<String>();
77 
78  for (int i = 0; i < temp.GetLength(0); ++i)
79  {
80  vals.Add(temp[i, 1]);
81  }
82 
83  return vals;
84  }
85  catch
86  {
87  return null;
88  }
89  }
90 
95  public static List<String> GetParameterTypes()
96  {
97  try
98  {
99  Object val = LabView.LabViewApp.GetRawValue(_filePath, "Types");
100 
101  return new List<String>((String[]) val);
102  }
103  catch
104  {
105  return null;
106  }
107  }
108 
114  public static void CreateParameter(int index, String value)
115  {
116  try
117  {
118  LabView.LabViewApp.SetRawValue(_filePath, "Standard Parameter Name", index);
119  LabView.LabViewApp.SetRawValue(_filePath, "Standard Parameter Value", value);
120  LabView.LabViewApp.SetRawValue(_filePath, "Add Standard Parameter", true);
121  }
122  catch (Exception e)
123  {
124  throw new Exception("Could not set parameter. Error message is: " + e.Message);
125  }
126  }
127 
135  public static void CreateParameter(String name, int typeIndex, String units, String value)
136  {
137  try
138  {
139  LabView.LabViewApp.SetRawValue(_filePath, "Custom Parameter Name", name);
140  LabView.LabViewApp.SetRawValue(_filePath, "Custom Parameter Type", typeIndex);
141  LabView.LabViewApp.SetRawValue(_filePath, "Custom Parameter Units", units);
142  LabView.LabViewApp.SetRawValue(_filePath, "Custom Parameter Value", value);
143  LabView.LabViewApp.SetRawValue(_filePath, "Add Custom parameter", true);
144  }
145  catch (Exception e)
146  {
147  throw new Exception("Could not set parameter. Error message is: " + e.Message);
148  }
149  }
150 
155  public static void RemoveParameter(String name)
156  {
157  try
158  {
159  List<String> stdNames = new List<String>(GetParameterNames());
160 
161  if (stdNames.Contains(name))
162  {
163  //Is a standard parameter
164  //Remove using standard remove
165  int index = stdNames.IndexOf(name);
166  LabView.LabViewApp.SetRawValue(_filePath, "Standard Parameter Name", index);
167  LabView.LabViewApp.SetRawValue(_filePath, "Remove Standard Parameter", true);
168  }
169  else
170  {
171  //Is a custom parameter
172  //Remove using custom remove
173  LabView.LabViewApp.SetRawValue(_filePath, "Custom Parameter Name", name);
174  LabView.LabViewApp.SetRawValue(_filePath, "Remove Custom Parameter", true);
175  }
176  }
177  catch (Exception e)
178  {
179  throw new Exception("Could not remove parameter. Error message is: " + e.Message);
180  }
181  }
182 
183 
184  }
185 }
static void CreateParameter(int index, String value)
Adds a standard parameter to the VI.
static List< String > GetParameterTypes()
Method for retrieving the standard parameter types for creating a new parameter.
static String[,] GetParameters()
Method for retrieving the parameters associated with the current experiment.
static void HideVi()
Method for hiding the VI - it is hidden by default.
static void CreateParameter(String name, int typeIndex, String units, String value)
Adds a custom parameter to the VI.
static void ShowVi()
Method for showing the VI - it is hidden by default.
static List< String > GetParameterNames()
Method for retrieving the standard parameter names for creating a new parameter.
static void Initialise()
Method for loading and starting the VI.
static void RemoveParameter(String name)
Remove a parameter to the VI.
This class is a wrapper for the Sample Parameters VI.