forked from HAMGZZ/DEATHRAY-ControlProgram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remote.cs
64 lines (59 loc) · 2.04 KB
/
Remote.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace ControllProgram
{
public class Remote
{
private Logger logger;
private Comms comms;
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.");
//hread 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);
Thread.Sleep(100);
if(comms.DataAvailable() > 0)
{
data.connect = true;
var incoming = comms.ReadLine().Split(' ');
//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(500);
}
}
}
}