Azure IoT Hub MQTT client
Beispiel #1
0
        private readonly Stopwatch _dpadStopwatch = new Stopwatch();//Basically a "debounce"

        internal Hexapi(IkController ikController, 
                        XboxController xboxController, 
                        Navigator navigator, 
                        SparkFunSerial16X2Lcd display, 
                        Gps.Gps gps,
                        IoTClient ioTClient)
        {
            _ik = ikController;
            _xboxController = xboxController;
            _gps = gps;
            _navigator = navigator;
            _display = display;
            _ioTClient = ioTClient;

            _functionStopwatch.Start();
            _dpadStopwatch.Start();

            SetGaitOptions();

            XboxController.LeftDirectionChanged += XboxController_LeftDirectionChanged;
            XboxController.RightDirectionChanged += XboxController_RightDirectionChanged;
            XboxController.DpadDirectionChanged += XboxController_DpadDirectionChanged;
            XboxController.LeftTriggerChanged += XboxController_LeftTriggerChanged;
            XboxController.RightTriggerChanged += XboxController_RightTriggerChanged;
            XboxController.FunctionButtonChanged += XboxController_FunctionButtonChanged;
            XboxController.BumperButtonChanged += XboxController_BumperButtonChanged;
            XboxController.DisconnectedEvent += XboxController_DisconnectedEvent; ;
        }
Beispiel #2
0
        private readonly Stopwatch _dpadStopwatch     = new Stopwatch(); //Basically a "debounce"

        internal Hexapi(IkController ikController,
                        XboxController xboxController,
                        Navigator navigator,
                        SparkFunSerial16X2Lcd display,
                        Gps.Gps gps,
                        IoTClient ioTClient)
        {
            _ik             = ikController;
            _xboxController = xboxController;
            _gps            = gps;
            _navigator      = navigator;
            _display        = display;
            _ioTClient      = ioTClient;

            _functionStopwatch.Start();
            _dpadStopwatch.Start();

            SetGaitOptions();

            XboxController.LeftDirectionChanged  += XboxController_LeftDirectionChanged;
            XboxController.RightDirectionChanged += XboxController_RightDirectionChanged;
            XboxController.DpadDirectionChanged  += XboxController_DpadDirectionChanged;
            XboxController.LeftTriggerChanged    += XboxController_LeftTriggerChanged;
            XboxController.RightTriggerChanged   += XboxController_RightTriggerChanged;
            XboxController.FunctionButtonChanged += XboxController_FunctionButtonChanged;
            XboxController.BumperButtonChanged   += XboxController_BumperButtonChanged;
            XboxController.DisconnectedEvent     += XboxController_DisconnectedEvent;;
        }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();

            _display = new SparkFunSerial16X2Lcd();
            _xboxController = new XboxController(_display);
            _ntripClient = new NtripClient("172.16.0.237", 8000, "", "", "", _display); //172.16.0.227
            _ioTClient = new IoTClient(_display);
            _gps = new Gps.Gps( _display, _ntripClient);
            _inverseKinematics = new InverseKinematics(_display);
            _ikController = new IkController(_inverseKinematics, _display, _ioTClient, _gps); //Range and yaw/pitch/roll data from Arduino and SparkFun Razor IMU
            _navigator = new Navigator(_ikController, _display, _gps);
            _hexapi = new Hexapi(_ikController, _xboxController, _navigator, _display, _gps, _ioTClient);

            _initializeTasks.Add(_display.InitializeAsync());
            _initializeTasks.Add(_xboxController.InitializeAsync());
            _initializeTasks.Add(_ikController.InitializeAsync());
            _initializeTasks.Add(_ntripClient.InitializeAsync());
            _initializeTasks.Add(_gps.InitializeAsync());
            _initializeTasks.Add(_inverseKinematics.InitializeAsync());
            _initializeTasks.Add(_ioTClient.InitializeAsync());

            _startTasks.Add(_ntripClient.StartAsync());
            _startTasks.Add(_ikController.StartAsync());
            _startTasks.Add(_gps.StartAsync());
            _startTasks.Add(_inverseKinematics.StartAsync());
            //_startTasks.Add(_ioTClient.StartAsync());//only needed if expecting messages from the server

            //foreach (var d in await SerialDeviceHelper.ListAvailablePorts())
            //{
            //    await _ioTClient.SendEvent(d);
            //}

            await Task.WhenAll(_initializeTasks.ToArray());

            await Task.WhenAll(_startTasks.ToArray());
        }
Beispiel #4
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();

            _display           = new SparkFunSerial16X2Lcd();
            _xboxController    = new XboxController(_display);
            _ntripClient       = new NtripClient("172.16.0.237", 8000, "", "", "", _display); //172.16.0.227
            _ioTClient         = new IoTClient(_display);
            _gps               = new Gps.Gps(_display, _ntripClient);
            _inverseKinematics = new InverseKinematics(_display);
            _ikController      = new IkController(_inverseKinematics, _display, _ioTClient, _gps); //Range and yaw/pitch/roll data from Arduino and SparkFun Razor IMU
            _navigator         = new Navigator(_ikController, _display, _gps);
            _hexapi            = new Hexapi(_ikController, _xboxController, _navigator, _display, _gps, _ioTClient);

            _initializeTasks.Add(_display.InitializeAsync());
            _initializeTasks.Add(_xboxController.InitializeAsync());
            _initializeTasks.Add(_ikController.InitializeAsync());
            _initializeTasks.Add(_ntripClient.InitializeAsync());
            _initializeTasks.Add(_gps.InitializeAsync());
            _initializeTasks.Add(_inverseKinematics.InitializeAsync());
            _initializeTasks.Add(_ioTClient.InitializeAsync());

            _startTasks.Add(_ntripClient.StartAsync());
            _startTasks.Add(_ikController.StartAsync());
            _startTasks.Add(_gps.StartAsync());
            _startTasks.Add(_inverseKinematics.StartAsync());
            //_startTasks.Add(_ioTClient.StartAsync());//only needed if expecting messages from the server

            //foreach (var d in await SerialDeviceHelper.ListAvailablePorts())
            //{
            //    await _ioTClient.SendEvent(d);
            //}

            await Task.WhenAll(_initializeTasks.ToArray());

            await Task.WhenAll(_startTasks.ToArray());
        }