SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
LVRing.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Text;
5 
6 namespace Seci.LabView.Controls
7 {
13  class LvRing : LvControl
14  {
18  private String[] _items;
19 
26  public LvRing(String name, String[] items, SerialisableList<int> indices)
27  {
28  _name = name;
29 
30  _items = items;
31 
32  if (indices != null)
33  {
34  _clusterIndices = (Seci.SerialisableList<int>)indices.Clone();
35  }
36  }
37 
42  public override String GetNameAndType()
43  {
44  return _name + " (Ring)";
45  }
46 
47  public override String GetControlType()
48  {
49  return "RING";
50  }
51 
60  public override String[] GetValue(ref strongnameLabview.VirtualInstrument vi)
61  {
62  String temp;
63 
64  if (_clusterIndices == null)
65  {
66  if (_items != null)
67  {
68  temp = _items[Convert.ToInt16(vi.GetControlValue(_name))];
69  }
70  else
71  {
72  temp = vi.GetControlValue(_name).ToString();
73  }
74  }
75  else
76  {
77  if (_items != null)
78  {
79  temp = _items[Convert.ToInt16(GetValueFromCluster(vi)[_clusterIndices[_clusterIndices.Count - 1]])];
80  }
81  else
82  {
83  temp = GetValueFromCluster(vi)[_clusterIndices[_clusterIndices.Count - 1]].ToString();
84 
85  }
86  }
87 
88  String[] result = { temp };
89 
90  return result;
91  }
92 
101  public override void SetValue(ref strongnameLabview.VirtualInstrument vi, Object value)
102  {
103  //Check that value is either the index to set or the name of the value to set
104  int val = 0;
105 
106  if (value.GetType() == typeof(Int16))
107  {
108  val = Convert.ToInt16(value);
109  }
110  else if (value.GetType() == typeof(String))
111  {
112  for (int i = 0; i < _items.GetLength(0); ++i)
113  {
114  if (_items[i] == value.ToString())
115  {
116  val = i;
117  break;
118  }
119  }
120  }
121  else
122  {
123  //Invalid value
124  throw new ArgumentException("Value sent to ring was invalid.");
125  }
126 
127  if (_clusterIndices == null)
128  {
129  vi.SetControlValue(_name, val);
130  }
131  else
132  {
133  SetValueInCluster(ref vi, val);
134  }
135  }
136  }
137 }
This class inherits from LVControl class and is specialised for Ring controls. A Ring is like an enum...
Definition: LVRing.cs:13
override String[] GetValue(ref strongnameLabview.VirtualInstrument vi)
Overriden method for getting the current selected value of the Control. LabVIEW returns an int corres...
Definition: LVRing.cs:60
override String GetNameAndType()
Overriden method which return the name and type of the control.
Definition: LVRing.cs:42
override void SetValue(ref strongnameLabview.VirtualInstrument vi, Object value)
Overriden method for setting the selected value in the Control. The value received could be a String ...
Definition: LVRing.cs:101
override String GetControlType()
Definition: LVRing.cs:47
String[] _items
Stores the values of the selectable options.
Definition: LVRing.cs:18
This class is the abstract base class of the objects used to store the VI control information...
Definition: LVControl.cs:12
LvRing(String name, String[] items, SerialisableList< int > indices)
Constructor
Definition: LVRing.cs:26