aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/Scripts/Jig_Tester/New_Mixer_Jig.cs
blob: 076f4ce68a6a996b58e94363afc6eecfa16fe63d (plain)
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
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 New_Mixer_UNDER_TEST=4;

const 	Int32	Valve_EN=0x42F501;
const 	Int32	Valve_DIS=0x42F500;
const 	Int32	Mixer_ON=0x42F401;
const 	Int32	Mixer_OFF=0x42F400;

float  NewMixerTemp ;

string [,] Units_status_New_Mixer = new string[New_Mixer_UNDER_TEST,2]	{ 
												{"Pt100_Mixer","Pass"},		//0
												{"Heater_Mixer","Pass"},	//1
												{"Break_Mixer","Pass"},			//2
												{"VALVE_Mixer","Not Test"},		//3
											};



//--------------------------------------------------------------------------------

public Task<decimal> New_Mixer_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 (New_Mixer_UNDER_TEST,Units_status_New_Mixer);


//------------------------------- start test -----------
	settext("Test heater & pt100");
	Test_New_Mixer_heater_pt100 ();
	settext("Test VALVE Mixer");
	Test_VALVE_New_Mixer ();
	
	Status=write_to_file(SN,Location,New_Mixer_UNDER_TEST,"Mixer");

	settext("End Test");
	
	decimal result = 0;
		
        return result;
    });
    return task;
}

//-------------------------------------------- 	 
 int	Test_VALVE_New_Mixer ()
 {
		stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Valve_EN);	// Valve enable
	 
	DialogResult result = MessageBox.Show("MixCHIP Valve Open ?", "Warning",MessageBoxButtons.YesNo);
	if(result == DialogResult.No)
		{
			Units_status[3,1]="Fail";
			stubManager.Write("VALVE_MIXCHIP_WASTECH Not open\n");
			return 0;
		}
		stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Valve_DIS);	// Valve enable
	 
	DialogResult result1 = MessageBox.Show("MixCHIP Valve close ?", "Warning",MessageBoxButtons.YesNo);
	if(result1 == DialogResult.No)
		{
			Units_status[3,1]="Fail";
			stubManager.Write("VALVE_MIXCHIP_WASTECH Not close\n");
			return 0;
		}
			Units_status[3,1]="Pass";
			return 0;
 }

//------------------------------------  
public int Test_New_Mixer_heater_pt100()
{
	Int32 temp=0;
	float ftemp=0;
	float ftemp1=0;
	float current=0;
	Int32 tdly=15000;
	Double current_sense; 

//---------------------- get tempurature of mixer---------------------------- 
	
//	stubManager.Write("\nTemp Befor heating \n");

		var response = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , 19);	//get temperature from mixer
		 ftemp = (float)response.TemperatureCMultBy100;
		ftemp = ftemp / 100;
	if ((ftemp>100)|| (ftemp<10))
		{	
			Units_status[0,1]="Fail";
			tdly=1000;
		}
	stubManager.Write("Temp Befor heating is"+ ftemp.ToString("F2")); 
	stubManager.Write("°C\n");	
//---------------------- get current of mixer  ---------------------------- 
	var response1 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + 20); // get current mixer
		current_sense=response1.Pressure;
		if (current_sense>0.1)
		{	
			Units_status[1,1]="Fail";
		}
		stubManager.Write("current is " + current_sense +"\n"); 
//---------------------- get Break of Mixer  ---------------------------- 
	var response2 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x460000 +0x10);	// read break
		temp = (Int32) (response2.Progress);
		if ((temp & 0x10 )==0)						//if break ok
		{	
			Units_status[2,1]="Fail";
			stubManager.Write("Break Mixer is On\n"); 
		}
		else
		{
			stubManager.Write("Break Mixer is off\n"); 
		}
//---------------------- turn Mixer on  ---------------------------- 
		stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Mixer_ON);	// turn mixer on 
		stubManager.Write("Mixer On\n"); 
		delay(tdly);																					//delay 20 second
//---------------------- get current of mixer  ---------------------------- 
	var response3 = stubManager.Run<StubMidTankPressureSensorResponse>("StubMidTankPressureSensorRequest" ,0x8000 + 20); // get current
		current_sense=response3.Pressure;
		if ((current_sense<2) ||(current_sense>3) )		//if current not 2.5A  
		{	
			Units_status[3,1]="Fail";
		}
		stubManager.Write("current in Mixer is " + current_sense +"\n"); 
//---------------------- get Break of Mixer  ---------------------------- 
	var response4 = stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,0x460000 +0x10);	// read break
		temp = (Int32) (response4.Progress);
		if ((temp & 0x10 )==0)						//if break ok
		{	
			Units_status[2,1]="Fail";
			stubManager.Write("Break Mixer is On\n"); 
		}
		else
		{
			stubManager.Write("Break Mixer is Off\n"); 
		}
//---------------------- get tempurature of mixer---------------------------- 
		var response5 = stubManager.Run<StubTempSensorResponse>("StubTempSensorRequest" , 19);	//get temperature from the mixer
		ftemp1 = (float)response5.TemperatureCMultBy100;
		ftemp1 = ftemp1 / 100;

		if (((ftemp1-ftemp)<5)|| ((ftemp1-ftemp)>50))
		{	
			Units_status[0,1]="Fail";
		}
		stubManager.Write("Mixer after heating is \t" + ftemp1.ToString("F2")+"°C\n"); 
//---------------------- turn Mixer off  ---------------------------- 
		stubManager.Run<ProgressResponse>("ProgressRequest" ,0x0EAD,Mixer_OFF);	// turn mixer off 
		stubManager.Write("Mixer is Off\n"); 
	return 0;
}