You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
877 B
46 lines
877 B
using System.Threading;
|
|
|
|
namespace RobotLib
|
|
{
|
|
public class Robot
|
|
{
|
|
|
|
public static Robot Instance { get; } = new Robot();
|
|
|
|
|
|
private Robot()
|
|
{
|
|
Com = new Com();
|
|
Buzzer = new DevBuzzer(Com);
|
|
Battery = new DevBattery(Com);
|
|
|
|
Timer timer = new Timer(TimerCallback);
|
|
timer.Change(2000, 10000);
|
|
}
|
|
|
|
public Com Com { get; }
|
|
|
|
public DevBuzzer Buzzer { get; }
|
|
public DevBattery Battery { get; }
|
|
|
|
|
|
public void Connect(string host, int port)
|
|
{
|
|
Com.Connect(host, port);
|
|
}
|
|
|
|
public void Disconnect()
|
|
{
|
|
Com.Disconnect();
|
|
}
|
|
|
|
private void TimerCallback(object state)
|
|
{
|
|
if (Com.IsConnected)
|
|
{
|
|
Battery.Refresh();
|
|
}
|
|
}
|
|
|
|
}
|
|
} |