using RobotLib.Communication;
using RobotLib.SplitFlap;
using RobotLib.Movement;
using System.Threading;

namespace RobotLib
{
    public class Robot
    {
        public Robot(IPublisherSubscriber com)
        {
            Com = com;
            //Buzzer = new DevBuzzer(Com);
            //Battery = new DevBattery(Com);
            SplitFlap = new DevSplitFlap(com);
            LineSensor = new DevLineSensor(com);
            Movement = new DevMovement(com);

            Timer timer = new Timer(TimerCallback);
            timer.Change(2000, 10000);
        }

        public IPublisherSubscriber Com { get; }

        //public DevBuzzer Buzzer { get; }
        //public DevBattery Battery { get; }
        public DevSplitFlap SplitFlap { get; }
        public DevMovement Movement { get; }
        public DevLineSensor LineSensor { 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();
            }
        }

    }
}