blob: a3a8477913043721b7d808e7479598cf29591118 (
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
|
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;
Int32 temp;
Int32 counter = 0;
UInt32 Direction = 0;
Int32 Prev_counter = 0;
public void OnExecute(StubManager stubManager)
{
while (true)
{
// Request ----
// UInt32 : Address
// Response ----
// UInt32 : Address
// UInt32 : Value
// String : Status
// UInt32 : StatusWord
var response = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000100); //LSB
//stubManager.WriteLine(response.Value);
var response1 = stubManager.Run<StubFpgaReadRegResponse>("StubFpgaReadRegRequest" ,0x60000102); //MSB
//stubManager.WriteLine(response1.Value & 0x3FF );
Direction = (response1.Value) & 0400;
temp = ((Int32)(response1.Value) & 0x3FF);
temp = temp << 16;
temp = temp + (Int32)(response.Value);
if((Prev_counter - temp > 10) || (temp - Prev_counter > 10))
{
if(Direction != 0)
counter = counter - temp;
else
counter = counter + temp;
}
stubManager.WriteLine(temp);
Prev_counter = temp;
//counter = counter + temp;
//stubManager.WriteLine(counter);
//stubManager.WriteLine(temp);
stubManager.Write("\n");
Thread.Sleep(1000);
}
}
|