-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRemote.cs
More file actions
72 lines (67 loc) · 2.25 KB
/
Remote.cs
File metadata and controls
72 lines (67 loc) · 2.25 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ControlProgram
{
public class Remote
{
private Logger logger;
private Comms comms;
public struct AzEl
{
public double Az;
public double El;
}
public struct remoteData
{
public AzEl rxCurrentAzEl;
public AzEl rxDesiredAzEl;
public AzEl txAzEl;
public bool moving;
public double volts;
public bool lights;
public bool connect;
}
public remoteData data;
public Remote()
{
//comms = new Comms("REMOTE", 115200);
logger = new Logger("REMOTE", Logger.Level.INFO);
logger.log(Logger.Level.INFO, "Setting up remote comms.");
Thread remoteLoop = new Thread(remoteCommsLoop);
remoteLoop.Start();
logger.log(Logger.Level.INFO, "Started data loop");
}
private void remoteCommsLoop()
{
while(true)
{
/*comms.Send("autoupdate " + data.txAzEl.Az + " " + data.txAzEl.El +"\n\r");
Thread.Sleep(50);
if(comms.DataAvailable() > 0)
{
data.connect = true;
var incoming = comms.ReadExisting().Split(' ');
if(incoming.Length > 1)
{
data.rxCurrentAzEl.Az = Convert.ToDouble(incoming[0]);
data.rxCurrentAzEl.El = Convert.ToDouble(incoming[1]);
data.rxDesiredAzEl.Az = Convert.ToDouble(incoming[2]);
data.rxDesiredAzEl.El = Convert.ToDouble(incoming[3]);
data.moving = Convert.ToBoolean(incoming[4]);
data.volts = Convert.ToDouble(incoming[5]);
}
}
else
{
data.connect = false;
logger.log(Logger.Level.ERROR, "Did not receive data from remote box!");
Thread.Sleep(5000);
}*/
Thread.Sleep(100);
}
}
}
}