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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
using System;
using System.Text;
using System.IO;
using System.Linq;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using Tango.PMR.Stubs;
using Tango.Stubs;
const int DyeHead_UNDER_TEST=16;
float [] DyeHeadTemp = new float[6] ;
string [,] Units_status_DyeHead = new string[DyeHead_UNDER_TEST,2] {
{"Pt100_Zone_1","Not Test"},
{"Pt100_Zone_2","Not Test"},
{"Pt100_Zone_3","Not Test"},
{"Pt100_Zone_4","Not Test"},
{"Pt100_Zone_5","Not Test"},
{"Pt100_Zone_6","Not Test"},
{"Heater_Zone_1","Not Test"},
{"Heater_Zone_2","Not Test"},
{"Heater_Zone_3","Not Test"},
{"Heater_Zone_4","Not Test"},
{"Heater_Zone_5","Not Test"},
{"Heater_Zone_6","Not Test"},
{"Magnet ","Not Test"},
{"LS_DH_LID_Open","Not Test"},
{"LS_DH_LID_Close","Not Test"},
{"DH_LID_Motor","Not Test"},
};
//--------------------------------------------------------------------------------
public Task<decimal> DyeHead_test( Action<string> settext, CancellationToken cancellationToken, string SN, string Location)
{
Task<decimal> task = null;
// Start a task and return it
task = Task.Run(() =>
{
stubManager.Write("S/N:" +SN+ "\n");
stubManager.Write("Location:" +Location+ "\n");
copy_table (DyeHead_UNDER_TEST,Units_status_DyeHead);
DialogResult result1 = MessageBox.Show("Make shure, Dyehead is not hot", "Warning",MessageBoxButtons.OKCancel);
if(result1 == DialogResult.Cancel)
{
stubManager.AppendToFile(File_Name1,"Dyehead is too hot \tFail");
stubManager.Write("Dyehead is too hot \tFail\n");
return 0 ;
}
else
{
//------------------------------- start test -----------
settext("Test Magnet Motor LS");
Test_Magnet_Motor_LS_DyeHead();
settext("Test heaters &pt100");
Test_heaters_pt100 ();
Status=write_to_file(SN,Location,DyeHead_UNDER_TEST,"Dyehead");
settext("End Test");
}
decimal result = 0;
return result;
});
return task;
}
//--------------------------------------------
int Test_Magnet_Motor_LS_DyeHead()
{
Int32 Bit = 1;
stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,MAGNET_Driver, false,0x800000+0);
stubManager.Write("\nTesting SSR no. 13 of magnet or motor driver");
DialogResult result = MessageBox.Show("Make shure, Magnet is open", "Warning",MessageBoxButtons.OKCancel);
if(result == DialogResult.Cancel)
{
Units_status[12,1]="Fail";
stubManager.Write("Magnet Not Open\n");
return 0;
}
Units_status[12,1]="Pass";
stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, true, 250);
stubManager.Write("\n*** Open Lid Head ");
Bit = 1;
int i=0;
while ((Bit != 0x0)&& (i<200) ) //wait until Limit Switch or timeout 200*50msec=10sec
{
Bit = GetBit(F1_LS_01_Direct,7);
delay(50);
i++;
}
stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor
DialogResult result1 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel);
if(result1 == DialogResult.Cancel)
{
Units_status[15,1]="Fail";
Units_status[13,1]="Fail";
stubManager.Write("LS_DH_LID_Open Not calibrate\n");
return 0;
}
Units_status[13,1]="Pass";
stubManager.Write("\n*** Close Lid Head ");
Bit = 1;
stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,DyeingHeadLid_Motor, false, 250);
i=0;
while ((Bit != 0x0) && (i<200)) //wait until Limit Switch or timeout 200*50msec=10sec
{
Bit = GetBit(F1_LS_01_Direct,8);
delay(50);
i++;
}
stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,DyeingHeadLid_Motor,3); //stop motor
DialogResult result2 = MessageBox.Show("Limit Switch calibrate ?", "Warning",MessageBoxButtons.OKCancel);
if(result2 == DialogResult.Cancel)
{
Units_status[14,1]="Fail";
Units_status[15,1]="Fail";
stubManager.Write("LS_DH_LID_Close Not calibrate\n");
return 0;
}
Units_status[14,1]="Pass";
stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,MAGNET_Driver, false,0x800000+2);
DialogResult result3 = MessageBox.Show("Make shure, Magnet is close", "Warning",MessageBoxButtons.OKCancel);
if(result3 == DialogResult.Cancel)
{
Units_status[12,1]="Fail";
stubManager.Write("Magnet Not close\n");
return 0;
}
Units_status[12,1]="Pass";
Units_status[15,1]="Pass";
return 0;
}
//------------------------------------
public int Test_heaters_pt100()
{
// uint utemp=0;
uint temp=0;
float ftemp=0;
float ftemp1=0;
float current=0;
stubManager.Write("\nTemp Befor heating \n");
if (test_pt100_dyehead()!=0)
return 0;
//------------Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 8
SetBit (F2_CTRL, 3, 1);
stubManager.Write("Testing SSR no. 8\tHeadZone-1\t");
delay(15000);
adc_configuration(0x40,0x10); //a2d_address 0x40 channel 3
adc_set_for_read_ch(0x40);
temp=adc_read_ch(0x40);
current= (float)(temp);
current=( float) (0.001221) * current;
SetBit (F2_CTRL, 3, 0);
ftemp=Read_pt100(1);
stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ current + "\n");
ftemp = ftemp - DyeHeadTemp[0];
if ((current>1.5)|| (current<0.9)||(ftemp<5)||(ftemp>40))
Units_status[6,1]="Fail";
else
Units_status[6,1]="Pass";
//Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 7
ftemp=Read_pt100(2);
ftemp1 = ftemp - DyeHeadTemp[1];
if ( ftemp1>4)
Units_status[7,1]="Fail";
else
{
SetBit (F2_CTRL, 4, 1);
stubManager.Write("Testing SSR no. 7\tHeadZone-2\t");
delay(15000);
adc_configuration(0x40,0x08); //a2d_address 0x40 channel 4
adc_set_for_read_ch(0x40);
temp=adc_read_ch(0x40);
current= (float)(temp);
current=( float) (0.001221) * current;
SetBit (F2_CTRL, 4, 0);
ftemp=Read_pt100(2);
stubManager.Write("After heating " + ftemp +"c\tCurrent is "+ current + "\n");
ftemp = ftemp - DyeHeadTemp[1];
if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>40))
Units_status[7,1]="Fail";
else
Units_status[7,1]="Pass";
}
//Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 6
ftemp=Read_pt100(3);
ftemp1 = ftemp - DyeHeadTemp[2];
if ( ftemp1>4)
Units_status[8,1]="Fail";
else
{
SetBit (F2_CTRL, 5, 1);
stubManager.Write("Testing SSR no. 6\tHeadZone-3\t");
delay(15000);
adc_configuration(0x40,0x04); //a2d_address 0x40 channel 5
adc_set_for_read_ch(0x40);
temp=adc_read_ch(0x40);
current= (float)(temp);
current=( float) (0.001221) * current;
SetBit (F2_CTRL, 5, 0);
ftemp=Read_pt100(3);
stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current +"\n");
ftemp = ftemp - DyeHeadTemp[2];
if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>40))
Units_status[8,1]="Fail";
else
Units_status[8,1]="Pass";
}
//Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 5
ftemp=Read_pt100(4);
ftemp1 = ftemp - DyeHeadTemp[3];
if ( ftemp1>4)
Units_status[9,1]="Fail";
else
{
SetBit (F2_CTRL, 6, 1);
stubManager.Write("Testing SSR no. 5\tHeadZone-4\t");
delay(15000);
adc_configuration(0x44,0x80); //a2d_address 0x44 channel 0
adc_set_for_read_ch(0x44);
temp=adc_read_ch(0x44);
current= (float)(temp);
current=( float) (0.001221) * current;
SetBit (F2_CTRL, 6, 0);
ftemp=Read_pt100(4);
stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n");
ftemp = ftemp - DyeHeadTemp[3];
if ((current<2.9)|| (current>3.4)||(ftemp<5)||(ftemp>40 ))
Units_status[9,1]="Fail";
else
Units_status[9,1]="Pass";
}
//Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 10
ftemp=Read_pt100(5);
ftemp1 = ftemp - DyeHeadTemp[4];
if ( ftemp1>4)
Units_status[10,1]="Fail";
else
{
SetBit (F1_gpo_01, 2, 1);
stubManager.Write("Testing SSR no. 10\tHeadZone-5\t");
delay(15000);
adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1
adc_set_for_read_ch(0x44);
temp=adc_read_ch(0x44);
current= (float)(temp);
current=( float) (0.001526) * current;
SetBit (F1_gpo_01, 2, 0);
ftemp=Read_pt100(5);
stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n");
ftemp = ftemp - DyeHeadTemp[4];
if ((current<2.9)|| (current>3.4)||(ftemp<5)||(ftemp>40))
Units_status[10,1]="Fail";
else
Units_status[10,1]="Pass";
}
//Write GPO_DYEINGH_SSR1_CTRL SSR/SSR no. 11
ftemp=Read_pt100(11);
ftemp1 = ftemp - DyeHeadTemp[5];
if ( ftemp1>4)
Units_status[11,1]="Fail";
else
{
SetBit (F3_GPO_01_bus, 4, 1);
stubManager.Write("Testing SSR no. 11\tHeadZone-6\t");
delay(15000);
adc_configuration(0x44,0x40); //a2d_address 0x44 channel 1
adc_set_for_read_ch(0x44);
temp=adc_read_ch(0x44);
current= (float)(temp);
current=( float) (0.001526) * current;
SetBit (F3_GPO_01_bus, 4, 0);
ftemp=Read_pt100(11);
stubManager.Write("After heating " + ftemp +"c\tCurrent is "+current + "\n");
ftemp = ftemp - DyeHeadTemp[5];
if ((current<1.6)|| (current>2.1)||(ftemp<5)||(ftemp>40))
Units_status[11,1]="Fail";
else
Units_status[11,1]="Pass";
}
return 0;
}
//------------------------------------------------
int test_pt100_dyehead()
{
float ftemp=0;
int temp=0;
int j=0;
for (int i = 0; i < 6; i++)
{
if (i==5)
j=11;
else
j=i+1;
DyeHeadTemp[i]=Read_pt100(j);
ftemp=DyeHeadTemp[i];
if ((ftemp>100)|| (ftemp<10))
{
Units_status[i,1]="Fail";
}
else
{
Units_status[i,1]="Pass";
}
stubManager.Write("Zone-"+(i+1)+ "\t" + ftemp.ToString("F2"));
stubManager.Write("°C\n");
}
return 0;
}
|