Advanced Distributed Systems module at HSLU
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.
 
 

71 lines
1.8 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 type)
{
Com = com;
Type = type;
if(type == RobotMode.Undefined)
{
throw new System.ArgumentException("Undefined robot mode, must define mode!");
}
if(type == RobotMode.Mobile)
{
//Buzzer = new DevBuzzer(Com);
Battery = new DevBattery(Com);
LineSensor = new DevLineSensor(com);
Movement = new DevMovement(com);
Status = new DevStatus(com);
}
else if(type == RobotMode.Stationary)
{
SplitFlap = new DevSplitFlap(com);
}
Timer timer = new Timer
{
Interval = 10000
};
timer.Enabled= true;
timer.Elapsed += Timer_Elapsed;
}
public IPublisherSubscriber Com { get; }
public RobotMode Type { 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();
}
}
}
}