aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/Scripts/Assemblies/LTFU/LTFU_Right_Position.cs
blob: ebd2cf414a153f9367da1a24a4363b60e09bb62e (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
using System;
using System.Text;
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 Int32 x_ABS_POS    = 0x01;
const Int32 x_EL_POS     = 0x02;
const Int32 x_MARK       = 0x03;
const Int32 x_SPEED      = 0x04;
const Int32 x_ACC        = 0x05;
const Int32 x_DEC        = 0x06;
const Int32 x_MAX_SPEED  = 0x07;
const Int32 x_MIN_SPEED  = 0x08;
const Int32 x_FS_SPD     = 0x15;
const Int32 x_KVAL_HOLD  = 0x09;
const Int32 x_KVAL_RUN   = 0x0A;
const Int32 x_KVAL_ACC   = 0x0B;
const Int32 x_KVAL_DEC   = 0x0C;
const Int32 x_INT_SPD    = 0x0D;
const Int32 x_ST_SLP     = 0x0E;
const Int32 x_FN_SLP_ACC = 0x0F;
const Int32 x_FN_SLP_DEC = 0x10;
const Int32 x_K_THERM    = 0x11;
const Int32 x_ADC_OUT    = 0x12;
const Int32 x_OCD_TH     = 0x13;
const Int32 x_STALL_TH   = 0x14;
const Int32 x_STEP_MODE  = 0x16;
const Int32 x_ALARM_EN   = 0x17;
const Int32 x_CONFIG     = 0x18;
const Int32 x_STATUS     = 0x19;
//-------------------------------
const Int32 x_GET_PARAM  = 0x20;
//-------------------------------
const Int32 F1_LS_02_Direct = 0x60000030	;	
const	Int32	F1_LS_LSPARE2		= 0x0004;		//up	
const	Int32	F1_LS_LDANCER1_UP 	= 0x1000;













public void OnExecute(StubManager stubManager)
{
 int counter;
 
	stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,17, 3);					//hold Ldancer high z

		var response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,17, (x_GET_PARAM | x_ABS_POS)<<24, 0, 0);
		response.RecivedData=response.RecivedData & 0x00ffffff;
		stubManager.WriteHex(response.RecivedData,8); 
		stubManager.Write("\n");			

		var response3 = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,17, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0);
		response3.RecivedData=response3.RecivedData & 0x00007;
		
		stubManager.WriteHex(response3.RecivedData,4); 
		stubManager.Write("\nNober uStep is - ");			
		if (response3.RecivedData>4)
			response3.RecivedData=4;
		stubManager.WriteLine(Math.Pow(2,response3.RecivedData));			
		

//----------------------------------------- check F1_LS_LDANCER2_UP -------------------------------------------------
	stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,17,false,100);				//move Lloading up
	counter =0;
	while ( counter < 800)
	{
		counter = counter + 1;
var		response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct);	//if F1_LS_LSPARE2 is up then move down
		if ((response1.Value & F1_LS_LSPARE2) != F1_LS_LSPARE2  )
			counter=900;
		
			Thread.Sleep(100);
	}
	stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,17, 3);					//hold Ldancer high z
	
var	response2 = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,17, (x_GET_PARAM | x_ABS_POS)<<24, 0, 0);
		response2.RecivedData=response2.RecivedData & 0x00ffffff;
		stubManager.WriteHex(response2.RecivedData,8); 
		stubManager.Write("\n");			

		stubManager.Write("Motor Puller positon is - "+ (response2.RecivedData-response.RecivedData)/(Math.Pow(2,response3.RecivedData)));			
//---------------------------------------------------------------------------------------------------------------------
 
	stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,16, 3);					//hold Ldancer high z

		response = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,16, (x_GET_PARAM | x_ABS_POS)<<24, 0, 0);
		response.RecivedData=response.RecivedData & 0x00ffffff;
		stubManager.WriteHex(response.RecivedData,8); 
		stubManager.Write("\n");			

		response3 = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,16, (x_GET_PARAM | x_STEP_MODE)<<8, 0, 0);
		response3.RecivedData=response3.RecivedData & 0x00007;
		
		stubManager.WriteHex(response3.RecivedData,4); 
		stubManager.Write("\nNober uStep is - ");			
		if (response3.RecivedData>4)
			response3.RecivedData=4;
		stubManager.WriteLine(Math.Pow(2,response3.RecivedData));			
		

//----------------------------------------- check F1_LS_LDANCER2_UP -------------------------------------------------
	stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,16,false,100);				//move Lloading up
	counter =0;
	while ( counter < 800)
	{
		counter = counter + 1;
			var	response8 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,F1_LS_02_Direct);	//if F1_LS_LSPARE2 is up then move up
	if ((response8.Value & F1_LS_LDANCER1_UP) !=F1_LS_LDANCER1_UP )								//if F1_LS_LDANCER1_UP is up then error
			counter=900;

			Thread.Sleep(100);
	}
	stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,16, 3);					//hold Ldancer high z
	
 response2 = stubManager.Run<StubMotorResponse>("StubMotorRequest" ,16, (x_GET_PARAM | x_ABS_POS)<<24, 0, 0);
		response2.RecivedData=response2.RecivedData & 0x00ffffff;
		stubManager.WriteHex(response2.RecivedData,8); 
		stubManager.Write("\n");			

		stubManager.Write("Motor Winder positon is - "+ (response2.RecivedData-response.RecivedData)/(Math.Pow(2,response3.RecivedData)));			

		
		
	
	
}