using RobotLib;
using RobotLib.Communication;

namespace RobotConsoleClient
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var com = MqttPublisherSubscriber.Instance;
            com.Connect("192.168.20.22", "ADIS", "TEST");
            var robotStationary = new Robot(com);
            var robotMobile = new Robot(com);
            robotStationary.SplitFlap.SplitFlapDisplayChanged += SplitFlap_SplitFlapDisplayChanged;
            //Console.ReadLine();
            Thread.Sleep(1000);
            robotStationary.SplitFlap.ConfigureSplitflap(setupId: 1, hardwareId: 21);
            Thread.Sleep(1000);
            robotStationary.SplitFlap.InitializeAllSplitflaps();

            Thread.Sleep(1000);
            robotMobile.Movement.SetSpeed(1000);
            robotMobile.Movement.Turn(-10);
            robotMobile.Movement.SetSpeed(-500);
            robotMobile.Movement.Stop();
            robotMobile.Movement.SetMobilityMode(automatic: true);

        }

        private static void SplitFlap_SplitFlapDisplayChanged(object? sender, RobotLib.SplitFlap.SplitFlapDisplayEventArgs e)
        {
            Console.WriteLine($"SplitFlap changed Display to '{e.DisplayMessage}'");
        }

        //private static void Battery_BatteryChanged(object? sender, BatteryEventArgs e)
        //{
        //    Console.WriteLine($"Received Battery Changed event. New Battery voltage = {e.Voltage} V");
        //}
    }
}