aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/ScrewLoopswithbusy.cs
blob: b0d02a43683083be0c8b2adc744816a005bf4a01 (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
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 FPGA1 =  0x60000000;
const Int32 F1_GPI_Busy_Direct = 0x60;

public void OnExecute(StubManager stubManager)
{
	// FALSE - to the body
	//TRUE out
	stubManager.Run("StubMotorRunRequest" ,15, false, 3000 ); //5000 fidder (18 TESTED)
	//Thread.Sleep(1000);
	bool flag = true;
	//for (int i = 0; i < 20000; i++)
	while (1==1)
		{
			var response = stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,14, false, 800);
			//Thread.Sleep(1000);
			while (flag == true)
			{
					Thread.Sleep(200);
					var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" , FPGA1 + F1_GPI_Busy_Direct);
					if ((response1.Value & 0x2)==2)
						flag = false;
					else
						flag = true;
			}
			//var response2 = stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,14,2);
			//Thread.Sleep(300);
			var response3 = stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,14, true, 800);
	//		Thread.Sleep(1000);
			while (flag == true)
			{
					Thread.Sleep(200);
					var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" , FPGA1 + F1_GPI_Busy_Direct);
					if ((response1.Value & 0x2)==2)
						flag = false;
					else
						flag = true;
			}
		}
		//var response1 = stubManager.Run<StubMotorMovResponse>("StubMotorMovRequest" ,14, false, 500);
		// Request ----
// UInt32 : Address

// Response ----
// UInt32 : Address
// UInt32 : Value
// String : Status
// UInt32 : StatusWord
    /*{

		var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,14, false, 20);
		Thread.Sleep(600);
		var response1 = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,14, true, 20);
		Thread.Sleep(600);
	}
	
//var response1 = stubManager.Run<StubMotorStatusResponse>("StubMotorStatusRequest" ,14, true);
//Thread.Sleep(1000);
//		var response = stubManager.Run<StubMotorRunResponse>("StubMotorRunRequest" ,24, false, 20);
//		Thread.Sleep(700);

var response2 = stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,15, 0);
var response4 = stubManager.Run<StubMotorStopResponse>("StubMotorStopRequest" ,14, 0);*/
// Request ----
// UInt32 : Address
// UInt32 : Value

// Response ---- 
// String : Status
// UInt32 : StatusWord
//var response = stubManager.Run<StubFpgaWriteRegResponse>("StubFpgaWriteRegRequest" ,0x600008e2, 0);
// Request ----
// UInt32 : Address

// Response ----
// UInt32 : Address
// UInt32 : Value
// String : Status
// UInt32 : StatusWord
//var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x600008e2);
}