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.
73 lines
1.9 KiB
73 lines
1.9 KiB
using RobotLib.Communication;
|
|
using RobotLib.SplitFlap;
|
|
using RobotLib.Movement;
|
|
using RobotLib.Battery;
|
|
using System.Timers;
|
|
using RobotLib.Status;
|
|
|
|
namespace RobotLib
|
|
{
|
|
public class Robot
|
|
{
|
|
public Robot(IPublisherSubscriber com, RobotMode mode)
|
|
{
|
|
Com = com;
|
|
Mode = mode;
|
|
if(mode == RobotMode.Undefined)
|
|
{
|
|
throw new System.ArgumentException("Undefined robot mode, must define mode!");
|
|
}
|
|
|
|
// battery is applicable for both modes
|
|
Battery = new DevBattery(Com, mode);
|
|
|
|
if(mode == RobotMode.Mobile)
|
|
{
|
|
//Buzzer = new DevBuzzer(Com);
|
|
LineSensor = new DevLineSensor(com);
|
|
Movement = new DevMovement(com);
|
|
Status = new DevStatus(com);
|
|
}
|
|
else if(mode == RobotMode.Stationary)
|
|
{
|
|
SplitFlap = new DevSplitFlap(com);
|
|
}
|
|
|
|
Timer timer = new Timer
|
|
{
|
|
Interval = 15000
|
|
};
|
|
timer.Enabled= true;
|
|
timer.Elapsed += Timer_Elapsed;
|
|
}
|
|
|
|
public IPublisherSubscriber Com { get; }
|
|
public RobotMode Mode { get; }
|
|
|
|
//public DevBuzzer Buzzer { get; }
|
|
public DevBattery Battery { get; }
|
|
public DevSplitFlap SplitFlap { get; }
|
|
public DevMovement Movement { get; }
|
|
public DevLineSensor LineSensor { get; }
|
|
|
|
public DevStatus Status { get; }
|
|
|
|
public void Connect(string host, int port)
|
|
{
|
|
//Com.Connect(host, port);
|
|
}
|
|
|
|
public void Disconnect()
|
|
{
|
|
//Com.Disconnect();
|
|
}
|
|
|
|
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
|
{
|
|
if (Com.IsConnected)
|
|
{
|
|
//Battery?.RequestBatteryVoltage();
|
|
}
|
|
}
|
|
}
|
|
} |