Пример #1
0
        public RestModule()
        {
            // Register the API endpoints.
            RegisterCorsOptions("/latitude");
            Get("/latitude", async _ =>
            {
                var latitude = await Sim.GetValueAsync("PLANE LATITUDE", "degree");

                return(WrapResponse(latitude.ToString()));
            });

            RegisterCorsOptions("/longitude");
            Get("/longitude", async _ =>
            {
                var longitude = await Sim.GetValueAsync("PLANE LONGITUDE", "degree");

                return(WrapResponse(longitude.ToString()));
            });

            RegisterCorsOptions("/coordinates");
            Get("/coordinates", (args) =>
            {
                var lat = (double)this.Context.Request.Query.latitude;
                var lng = (double)this.Context.Request.Query.longitude;

                Sim.SetValue("PLANE LATITUDE", "degree", lat);
                Sim.SetValue("PLANE LONGITUDE", "degree", lng);

                return(WrapResponse("success"));
            });
        }
Пример #2
0
        private async void TestAsync_Click(object sender, RoutedEventArgs e)
        {
            if (!_sim.IsConnected())
                return;

            var value = await _sim.GetValueAsync("FLAPS HANDLE INDEX", "number");

            Console.WriteLine("Async value: " + value);
        }