-
Notifications
You must be signed in to change notification settings - Fork 0
/
AgilentMUX.cs
199 lines (186 loc) · 7.05 KB
/
AgilentMUX.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Temperature_Monitor
{
public class AgilentMUX:MUX
{
private string append_string;
private Object thislock = new Object();
//Since the agilient MUX and bridge are actually one unit the constructor here only needs to take
//one argument. The address and the SICL are not required because they are contain in the agilent bridge.
public AgilentMUX(ref PRT[] prts_connected):base(ref prts_connected)
{
base.prts = prts_connected; //The PRTs that are currently connected to the mux
append_string = "(@101)\r\n"; //default append string
base.selected_channel = 1;
}
/// <summary>
/// Sets what channel the multiplexor is switched to
/// creates a string to append to the Bridge send command
/// </summary>
/// <param name="channel_number">channel number is a value between 1 and 30</param>
public override void setChannel(short channel_number)
{
lock (thislock)
{
if ((channel_number > 0) && (channel_number <= 10))
{
if (channel_number < 10)
{
append_string = string.Concat("(@10", channel_number.ToString(), ")\r\n");
}
else append_string = "(@110)\r\n";
}
else if ((channel_number > 10) && (channel_number <= 20))
{
if (channel_number < 20)
{
append_string = string.Concat("(@20", (channel_number-10).ToString(), ")\r\n");
}
else append_string = "(@210)\r\n";
}
else if ((channel_number > 20) && (channel_number <= 30))
{
if (channel_number < 30)
{
append_string = string.Concat("(@30", (channel_number-20).ToString(), ")\r\n");
}
else append_string = "(@310)\r\n";
}
selected_channel = channel_number;
}
}
/// <summary>
/// -Gets the channel the mux is set to
/// </summary>
/// <param name="probe_name">A channel type</param>
public override short getCurrentChannel()
{
return selected_channel;
}
/// <summary>
/// -Gets the probe that is plugged into a given channel
/// -30 prts can be connected to this type of multiplexor
/// </summary>
/// <param name="probe_name">The channel from 1 to 30</param>
public override PRT getProbe(string channel_)
{
PRT probe_on_this_channel = null;
switch (channel_)
{
case "CH1":
probe_on_this_channel = prts[0];
break;
case "CH2":
probe_on_this_channel = prts[1];
break;
case "CH3":
probe_on_this_channel = prts[2];
break;
case "CH4":
probe_on_this_channel = prts[3];
break;
case "CH5":
probe_on_this_channel = prts[4];
break;
case "CH6":
probe_on_this_channel = prts[5];
break;
case "CH7":
probe_on_this_channel = prts[6];
break;
case "CH8":
probe_on_this_channel = prts[7];
break;
case "CH9":
probe_on_this_channel = prts[8];
break;
case "CH10":
probe_on_this_channel = prts[9];
break;
case "CH11":
probe_on_this_channel = prts[10];
break;
case "CH12":
probe_on_this_channel = prts[11];
break;
case "CH13":
probe_on_this_channel = prts[12];
break;
case "CH14":
probe_on_this_channel = prts[13];
break;
case "CH15":
probe_on_this_channel = prts[14];
break;
case "CH16":
probe_on_this_channel = prts[15];
break;
case "CH17":
probe_on_this_channel = prts[16];
break;
case "CH18":
probe_on_this_channel = prts[17];
break;
case "CH19":
probe_on_this_channel = prts[18];
break;
case "CH20":
probe_on_this_channel = prts[19];
break;
case "CH21":
probe_on_this_channel = prts[20];
break;
case "CH22":
probe_on_this_channel = prts[21];
break;
case "CH23":
probe_on_this_channel = prts[22];
break;
case "CH24":
probe_on_this_channel = prts[23];
break;
case "CH25":
probe_on_this_channel = prts[24];
break;
case "CH26":
probe_on_this_channel = prts[25];
break;
case "CH27":
probe_on_this_channel = prts[26];
break;
case "CH28":
probe_on_this_channel = prts[27];
break;
case "CH29":
probe_on_this_channel = prts[28];
break;
case "CH30":
probe_on_this_channel = prts[30];
break;
}
return probe_on_this_channel;
}
public override void setProbe(PRT new_PRT,short channel_is_on)
{
try
{
prts[channel_is_on - 1] = new_PRT;
}
catch (IndexOutOfRangeException)
{
channel_is_on = 1;
prts[channel_is_on - 1] = new_PRT;
}
}
/// <summary>
/// -Gets the channel append string to be send with the agilent bridge command, of the form "(@XXX)"
/// </summary>
public string AppendString
{
get {return append_string;}
}
}
}