From 9359a93068b8e4b9eb37b472c38c6fcdce49ce1f Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Thu, 11 Jun 2015 09:58:01 -0700 Subject: [PATCH 1/6] Created basic example that continuously prints the player aircraft's position. --- C/monitorExample/main.c | 96 +++++++++++++++++++ C/monitorExample/monitorExample.sln | 22 +++++ C/monitorExample/monitorExample.vcxproj | 79 +++++++++++++++ .../monitorExample.vcxproj.filters | 25 +++++ 4 files changed, 222 insertions(+) create mode 100644 C/monitorExample/main.c create mode 100644 C/monitorExample/monitorExample.sln create mode 100644 C/monitorExample/monitorExample.vcxproj create mode 100644 C/monitorExample/monitorExample.vcxproj.filters diff --git a/C/monitorExample/main.c b/C/monitorExample/main.c new file mode 100644 index 0000000..ffc9159 --- /dev/null +++ b/C/monitorExample/main.c @@ -0,0 +1,96 @@ +// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the +// National Aeronautics and Space Administration. All Rights Reserved. +// +// DISCLAIMERS +// No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, +// EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT +// THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY +// THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, +// WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN +// ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, +// HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT +// SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING +// THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS." +// +// Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES +// GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF +// RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES +// OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING +// FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE +// UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, +// TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE +// IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. + +#include "../src/xplaneConnect.h" +#include "stdio.h" + +#ifdef WIN32 +#include "Windows.h" + +HANDLE console; + +void setCursor(short x, short y) +{ + if (!console) + { + console = GetStdHandle(STD_OUTPUT_HANDLE); + } + COORD dwCursorPosition; + dwCursorPosition.X = x; + dwCursorPosition.Y = y; + + BOOL result = SetConsoleCursorPosition(console, dwCursorPosition); + if (!result) + { + printf("Unable to set console cursor position. Failed with error code %i.\n", GetLastError()); + exit(EXIT_FAILURE); + } +} +#else +void setCursor(short x, short y) +{ + // ??? +} +#endif + +void printChrome() +{ + setCursor(0, 0); + + // Set up initial screen, assuming the console is at least 72 characters wide and 16 lines tall. + printf("+======================================================================+\n"); + printf("| X-Plane Connect Status Monitor Example Application |\n"); + printf("+===================+==================================================+\n"); + printf("| Aircraft Position | |\n"); + printf("+-------------------+ |\n"); + printf("| Lat: | |\n"); + printf("| Lon: | |\n"); + printf("| Alt: | |\n"); + printf("+-------------------+ |\n"); + printf("+======================================================================+\n"); +} + +void printLocation(float lat, float lon, float alt) +{ + setCursor(7, 5); + printf("%4f", lat); + setCursor(7, 6); + printf("%4f", lon); + setCursor(7, 7); + printf("%2fm", alt); +} + +int main(void) +{ + printChrome(); + XPCSocket client = openUDP("127.0.0.1"); + + while (1) + { + float posi[7]; + getPOSI(client, posi, 0); + printLocation(posi[0], posi[1], posi[2]); + } + return 0; +} \ No newline at end of file diff --git a/C/monitorExample/monitorExample.sln b/C/monitorExample/monitorExample.sln new file mode 100644 index 0000000..11435f7 --- /dev/null +++ b/C/monitorExample/monitorExample.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "monitorExample", "monitorExample.vcxproj", "{0F45204B-6910-46C7-BECD-273985390F75}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0F45204B-6910-46C7-BECD-273985390F75}.Debug|Win32.ActiveCfg = Debug|Win32 + {0F45204B-6910-46C7-BECD-273985390F75}.Debug|Win32.Build.0 = Debug|Win32 + {0F45204B-6910-46C7-BECD-273985390F75}.Release|Win32.ActiveCfg = Release|Win32 + {0F45204B-6910-46C7-BECD-273985390F75}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/C/monitorExample/monitorExample.vcxproj b/C/monitorExample/monitorExample.vcxproj new file mode 100644 index 0000000..3be8e30 --- /dev/null +++ b/C/monitorExample/monitorExample.vcxproj @@ -0,0 +1,79 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {0F45204B-6910-46C7-BECD-273985390F75} + monitorExample + + + + Application + true + v120 + MultiByte + + + Application + false + v120 + true + MultiByte + + + + + + + + + + + + + ../src;$(IncludePath) + + + ../src;$(IncludePath) + + + + Level3 + Disabled + true + _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + + + \ No newline at end of file diff --git a/C/monitorExample/monitorExample.vcxproj.filters b/C/monitorExample/monitorExample.vcxproj.filters new file mode 100644 index 0000000..50a53c3 --- /dev/null +++ b/C/monitorExample/monitorExample.vcxproj.filters @@ -0,0 +1,25 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + \ No newline at end of file From 337182f24150a4c0f5132bcce433cef974398efe Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Thu, 11 Jun 2015 12:15:14 -0700 Subject: [PATCH 2/6] Fleshed out monitor example --- C/monitorExample/main.c | 74 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/C/monitorExample/main.c b/C/monitorExample/main.c index ffc9159..f3d4862 100644 --- a/C/monitorExample/main.c +++ b/C/monitorExample/main.c @@ -35,6 +35,10 @@ void setCursor(short x, short y) if (!console) { console = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_CURSOR_INFO info; + info.dwSize = 0; + info.bVisible = FALSE; + SetConsoleCursorInfo(console, &info); } COORD dwCursorPosition; dwCursorPosition.X = x; @@ -48,10 +52,19 @@ void setCursor(short x, short y) } } #else +#include "time.h" + void setCursor(short x, short y) { // ??? } + +void Sleep(int ms) +{ + struct timespec tv; + tv.tv_nsec = ms * 1000 * 1000; + nanosleep(tv, NULL); +} #endif void printChrome() @@ -62,12 +75,16 @@ void printChrome() printf("+======================================================================+\n"); printf("| X-Plane Connect Status Monitor Example Application |\n"); printf("+===================+==================================================+\n"); - printf("| Aircraft Position | |\n"); - printf("+-------------------+ |\n"); - printf("| Lat: | |\n"); - printf("| Lon: | |\n"); - printf("| Alt: | |\n"); - printf("+-------------------+ |\n"); + printf("| Aircraft Position | Aircraft Orientation | Aircraft Control Surfaces |\n"); + printf("+-------------------+----------------------+---------------------------+\n"); + printf("| Lat: | Roll: | Aileron: |\n"); + printf("| Lon: | Pitch: | Elevator: |\n"); + printf("| Alt: | Yaw: | Rudder: |\n"); + printf("| | | Flaps: |\n"); + printf("+-------------------+----------------------+---------------------------+\n"); + printf("| Throttle: | Gear: | |\n"); + printf("+-------------------+----------------------+---------------------------+\n"); + printf("| Press Ctrl+C to quit. |\n"); printf("+======================================================================+\n"); } @@ -81,16 +98,59 @@ void printLocation(float lat, float lon, float alt) printf("%2fm", alt); } +void printOrientation(float roll, float pitch, float yaw) +{ + setCursor(29, 5); + printf("%4f", roll); + setCursor(29, 6); + printf("%4f", pitch); + setCursor(29, 7); + printf("%4f", yaw); +} + +void printControls(float aileron, float elevator, float rudder, float flaps) +{ + setCursor(55, 5); + printf("%4f", aileron); + setCursor(55, 6); + printf("%4f", elevator); + setCursor(55, 7); + printf("%4f", rudder); + setCursor(55, 8); + printf("%4f", flaps); +} + +void printThrottle(float throttle) +{ + setCursor(12, 10); + printf("%2f", throttle); +} + +void printGear(float gear) +{ + setCursor(28, 10); + printf("%2f", gear); +} + int main(void) { printChrome(); XPCSocket client = openUDP("127.0.0.1"); + const int aircraftNum = 0; while (1) { float posi[7]; - getPOSI(client, posi, 0); + getPOSI(client, posi, aircraftNum); printLocation(posi[0], posi[1], posi[2]); + printOrientation(posi[4], posi[3], posi[5]); + + float ctrl[7]; + getCTRL(client, ctrl, aircraftNum); + printControls(ctrl[1], ctrl[0], ctrl[2], ctrl[5]); + printThrottle(ctrl[3]); + printGear(ctrl[4]); + Sleep(100); } return 0; } \ No newline at end of file From d045e649b54dd76e98de9efe2b24c8ccaf254fcf Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 19 Jun 2015 09:37:20 -0700 Subject: [PATCH 3/6] Simplified example to allow for cross platform compatibility. --- C/monitorExample/main.c | 152 +++++++++++++--------------------------- 1 file changed, 49 insertions(+), 103 deletions(-) diff --git a/C/monitorExample/main.c b/C/monitorExample/main.c index f3d4862..fc06679 100644 --- a/C/monitorExample/main.c +++ b/C/monitorExample/main.c @@ -26,131 +26,77 @@ #include "stdio.h" #ifdef WIN32 -#include "Windows.h" - -HANDLE console; - -void setCursor(short x, short y) +HANDLE hStdIn = NULL; +INPUT_RECORD buffer; +int waitForInput() { - if (!console) + if (hStdIn == NULL) { - console = GetStdHandle(STD_OUTPUT_HANDLE); - CONSOLE_CURSOR_INFO info; - info.dwSize = 0; - info.bVisible = FALSE; - SetConsoleCursorInfo(console, &info); + hStdIn = GetStdHandle(STD_INPUT_HANDLE); } - COORD dwCursorPosition; - dwCursorPosition.X = x; - dwCursorPosition.Y = y; - - BOOL result = SetConsoleCursorPosition(console, dwCursorPosition); - if (!result) + FlushConsoleInputBuffer(hStdIn); + DWORD result = WaitForSingleObject(hStdIn, 100); + if (result == WAIT_OBJECT_0) { - printf("Unable to set console cursor position. Failed with error code %i.\n", GetLastError()); - exit(EXIT_FAILURE); + DWORD eventsRead; + PeekConsoleInput(hStdIn, &buffer, 1, &eventsRead); + if (eventsRead > 0) + { + return buffer.EventType == KEY_EVENT; + } } + return FALSE; } #else -#include "time.h" +int fdstdin = 0; +fd_set fds; +struct timeval tv; +tv.tv_usec = 100 * 1000; -void setCursor(short x, short y) +int waitForInput() { - // ??? + + FD_ZERO(&fds); + FD_SET(fdstdin, &fds); + select(1, &fds, NULL, NULL, &tv); + return FD_ISSET(fdstdin, &fds); } -void Sleep(int ms) -{ - struct timespec tv; - tv.tv_nsec = ms * 1000 * 1000; - nanosleep(tv, NULL); -} #endif -void printChrome() -{ - setCursor(0, 0); - - // Set up initial screen, assuming the console is at least 72 characters wide and 16 lines tall. - printf("+======================================================================+\n"); - printf("| X-Plane Connect Status Monitor Example Application |\n"); - printf("+===================+==================================================+\n"); - printf("| Aircraft Position | Aircraft Orientation | Aircraft Control Surfaces |\n"); - printf("+-------------------+----------------------+---------------------------+\n"); - printf("| Lat: | Roll: | Aileron: |\n"); - printf("| Lon: | Pitch: | Elevator: |\n"); - printf("| Alt: | Yaw: | Rudder: |\n"); - printf("| | | Flaps: |\n"); - printf("+-------------------+----------------------+---------------------------+\n"); - printf("| Throttle: | Gear: | |\n"); - printf("+-------------------+----------------------+---------------------------+\n"); - printf("| Press Ctrl+C to quit. |\n"); - printf("+======================================================================+\n"); -} - -void printLocation(float lat, float lon, float alt) -{ - setCursor(7, 5); - printf("%4f", lat); - setCursor(7, 6); - printf("%4f", lon); - setCursor(7, 7); - printf("%2fm", alt); -} - -void printOrientation(float roll, float pitch, float yaw) -{ - setCursor(29, 5); - printf("%4f", roll); - setCursor(29, 6); - printf("%4f", pitch); - setCursor(29, 7); - printf("%4f", yaw); -} - -void printControls(float aileron, float elevator, float rudder, float flaps) -{ - setCursor(55, 5); - printf("%4f", aileron); - setCursor(55, 6); - printf("%4f", elevator); - setCursor(55, 7); - printf("%4f", rudder); - setCursor(55, 8); - printf("%4f", flaps); -} - -void printThrottle(float throttle) -{ - setCursor(12, 10); - printf("%2f", throttle); -} - -void printGear(float gear) -{ - setCursor(28, 10); - printf("%2f", gear); -} - int main(void) { - printChrome(); - XPCSocket client = openUDP("127.0.0.1"); + XPCSocket client = openUDP("127.0.0.1"); const int aircraftNum = 0; while (1) { float posi[7]; - getPOSI(client, posi, aircraftNum); - printLocation(posi[0], posi[1], posi[2]); - printOrientation(posi[4], posi[3], posi[5]); + int result = getPOSI(client, posi, aircraftNum); + if (result < 0) // Error in getPOSI + { + break; + } float ctrl[7]; - getCTRL(client, ctrl, aircraftNum); - printControls(ctrl[1], ctrl[0], ctrl[2], ctrl[5]); - printThrottle(ctrl[3]); - printGear(ctrl[4]); - Sleep(100); + result = getCTRL(client, ctrl, aircraftNum); + if (result < 0) // Error in getCTRL + { + break; + } + + printf("Loc: (%4f, %4f, %4f) Aileron:%2f Elevator:%2f Rudder:%2f\n", + posi[0], posi[1], posi[2], ctrl[1], ctrl[0], ctrl[2]); + + // Check if any key has been pressed and break + if (waitForInput()) + { + break; + } } + + + printf("\n\nPress Any Key to exit..."); + getchar(); return 0; } \ No newline at end of file From 49fb706e9db6082fa4fe081a3af519d6e7519c71 Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 19 Jun 2015 13:09:17 -0700 Subject: [PATCH 4/6] Added monitor example for Python --- Python/src/{example.py => basicExample.py} | 0 Python/src/monitorExample.py | 16 ++++++++++++++++ Python/xplaneConnect.pyproj | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) rename Python/src/{example.py => basicExample.py} (100%) create mode 100644 Python/src/monitorExample.py diff --git a/Python/src/example.py b/Python/src/basicExample.py similarity index 100% rename from Python/src/example.py rename to Python/src/basicExample.py diff --git a/Python/src/monitorExample.py b/Python/src/monitorExample.py new file mode 100644 index 0000000..c4cdb48 --- /dev/null +++ b/Python/src/monitorExample.py @@ -0,0 +1,16 @@ +import sys + +import xpc + +def monitor(): + with xpc.XPlaneConnect() as client: + while True: + posi = client.getPOSI(); + ctrl = client.getCTRL(); + + print "Loc: (%4f, %4f, %4f) Aileron:%2f Elevator:%2f Rudder:%2f\n"\ + % (posi[0], posi[1], posi[2], ctrl[1], ctrl[0], ctrl[2]) + + +if __name__ == "__main__": + monitor() \ No newline at end of file diff --git a/Python/xplaneConnect.pyproj b/Python/xplaneConnect.pyproj index c288a9c..08039aa 100644 --- a/Python/xplaneConnect.pyproj +++ b/Python/xplaneConnect.pyproj @@ -5,7 +5,7 @@ 2.0 3c7a940d-17c8-4e91-882f-9bc8b1d2f54b . - src\example.py + src\basicExample.py . @@ -24,8 +24,11 @@ false + + Code + - + Code From f449ec8074eb33b6f8e79ffe7ab904217a04be6f Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Fri, 19 Jun 2015 13:37:09 -0700 Subject: [PATCH 5/6] Added monitor example for Java --- Java/Examples/ContinuousOperation/.idea/.name | 1 + .../ContinuousOperation/.idea/compiler.xml | 22 ++++++++ .../.idea/copyright/profiles_settings.xml | 3 ++ .../.idea/libraries/XPlaneConnect.xml | 9 ++++ .../ContinuousOperation/.idea/misc.xml | 19 +++++++ .../ContinuousOperation/.idea/modules.xml | 8 +++ .../ContinuousOperation/.idea/vcs.xml | 6 +++ .../ContinuousOperation.iml | 12 +++++ .../libs/XPlaneConnect.jar | Bin 0 -> 8657 bytes .../ContinuousOperation/src/Main.java | 47 ++++++++++++++++++ 10 files changed, 127 insertions(+) create mode 100644 Java/Examples/ContinuousOperation/.idea/.name create mode 100644 Java/Examples/ContinuousOperation/.idea/compiler.xml create mode 100644 Java/Examples/ContinuousOperation/.idea/copyright/profiles_settings.xml create mode 100644 Java/Examples/ContinuousOperation/.idea/libraries/XPlaneConnect.xml create mode 100644 Java/Examples/ContinuousOperation/.idea/misc.xml create mode 100644 Java/Examples/ContinuousOperation/.idea/modules.xml create mode 100644 Java/Examples/ContinuousOperation/.idea/vcs.xml create mode 100644 Java/Examples/ContinuousOperation/ContinuousOperation.iml create mode 100644 Java/Examples/ContinuousOperation/libs/XPlaneConnect.jar create mode 100644 Java/Examples/ContinuousOperation/src/Main.java diff --git a/Java/Examples/ContinuousOperation/.idea/.name b/Java/Examples/ContinuousOperation/.idea/.name new file mode 100644 index 0000000..9ac7aa6 --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/.name @@ -0,0 +1 @@ +ContinuousOperation \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/.idea/compiler.xml b/Java/Examples/ContinuousOperation/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/.idea/copyright/profiles_settings.xml b/Java/Examples/ContinuousOperation/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/.idea/libraries/XPlaneConnect.xml b/Java/Examples/ContinuousOperation/.idea/libraries/XPlaneConnect.xml new file mode 100644 index 0000000..da48fd9 --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/libraries/XPlaneConnect.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/.idea/misc.xml b/Java/Examples/ContinuousOperation/.idea/misc.xml new file mode 100644 index 0000000..a61f7bc --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/misc.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/.idea/modules.xml b/Java/Examples/ContinuousOperation/.idea/modules.xml new file mode 100644 index 0000000..0a1c2fe --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/.idea/vcs.xml b/Java/Examples/ContinuousOperation/.idea/vcs.xml new file mode 100644 index 0000000..6564d52 --- /dev/null +++ b/Java/Examples/ContinuousOperation/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/ContinuousOperation.iml b/Java/Examples/ContinuousOperation/ContinuousOperation.iml new file mode 100644 index 0000000..6c4f0ab --- /dev/null +++ b/Java/Examples/ContinuousOperation/ContinuousOperation.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Java/Examples/ContinuousOperation/libs/XPlaneConnect.jar b/Java/Examples/ContinuousOperation/libs/XPlaneConnect.jar new file mode 100644 index 0000000000000000000000000000000000000000..eba5283b15fa5c42fbefe5574182eeb93a54c183 GIT binary patch literal 8657 zcmZ{qWl&scv&XUE?(XhB4DJMX*TEq$xCKcF?!nzGOJod)sf2b#QOMa`*jZ;IF*E$(5UfOZ^Y9tr%?4)QgtPJ5mT9IF&=Lcw|n3z-tW) zcKLNn5OOTv7#!ZXb1;4b?PptY++l7BykXu7xa9F6IPGyJxViDEH}2zH2(}sKsN=ld z(cAAZinaxWZLM0$cO1(vDE3Vn91gyTRqnGkFR)06G!pV7T>4R@Yt-j8^M^K{Jy7!a zE>#A~)Sr1(hKK*qTRYE~8m{ZK6XbBm7ah71CdD1%N;q5GEIT&BEG3Pg)NR$V7g1|i ztYuFRsW>+^3xFE`PGR!27Iyv$ArO!qWc5*6V+#-OVIpcK(?e-2F4TE|>h{>Uq<>{p zYJOMMg5_N)zq0N&jHh`_rY>NuT^e{ZJPs@~o+7CVKVKx8B_dQw>&!aV84sWEda{&S z60H^b)h#`5x9NSpNSpfv++rb|BT#ZVUujJI0$MU{SOB{Yq(n!yFMK7ZQlU;QE5^Cc z+FhbUs(PEx+74~Tx+e1c_O_}Yy=LQ!;hSv#i)R4;#2e4fp<-c3Uw?c!+aci$PeN9_ zdTqt7>H0wn1BF#QqHd$yvWwo}>4-tu^D<^Tsqpq-CogNBD_y3v_> z?&ikeiQvj};Z%Wvd8*cO0OC$hwo^b$p?4dxlJC%Et z$ML)Ihn!pBzQ?NFTIMvP)QJD=yNkoA&jsbjcs0)sP>t_nJ9N~*10-d3}$K&)xmm6enj zxa9WW8IqOE2;EIbf*5LsYu7d2OCDG7(gIQ`bsn0 z56&d%Hl;4i&++s7&9lYzztyi1+HYm_LQIe31?J`QH8Ff>;v7q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(5&N>JLHpmoo?;aJVQxiNKJ3wQA9}~&qFkPwlFsfq)Xt0Ta zCTqE2xp7jbRmuTmBP{!-xV-W&27^FzT9XT(qf%&|2tZEU3JgsZbh@xFPSC7ps^GLg z5jr|S@YUsda-^}X5ZC#VT=zEj)BcIheEERAj`DPM8f~T8keU~wmLm+&SH3#^+*Cfw z^M>cTsp|-X=hX+^F05CU-GlwpHK;#4>zQUdjMC8BYwPEAe`76@Vpzco>UI!8EIUtVNbUR2ldeqTB=C1zCR z!;-vunpX~Urxu{VK#am;!B*!hS)J@gsI3=Y^N+xeb^=pJGVgLbkcRUR!HJ*=1U#g_ z(BPKvKK_=nd$BkZ??9}xf2ovw|8lg)iNSy3sn&}W{@$&khN7`60Q*z# zET!CyT?6lIU%XPwr_fBbu4V4*JScn@EV}^PzaR$m%d8bkt9?N-?A@&aVgsxgUuZ!Y z&)wG5d@st-otnQG9d#)=XFM?sOf>hOYy%b!73RNN2L1pX|IptCg8yFir-k5eG5!($ z!%*<6ZHIv zCI433AL!>l8vPqm{kvGLLX literal 0 HcmV?d00001 diff --git a/Java/Examples/ContinuousOperation/src/Main.java b/Java/Examples/ContinuousOperation/src/Main.java new file mode 100644 index 0000000..61a14eb --- /dev/null +++ b/Java/Examples/ContinuousOperation/src/Main.java @@ -0,0 +1,47 @@ +package gov.nasa.xpc.ex; + +import gov.nasa.xpc.XPlaneConnect; + +import java.io.IOException; + +/** + * An example program demonstrating the use of X-PlaneConnect in a continuous loop. + * + * @author Jason Watkins + * @version 1.0 + * @since 2015-06-19 + */ +public class Main +{ + public static void main(String[] args) + { + try (XPlaneConnect xpc = new XPlaneConnect()) + { + int aircraft = 0; + while(true) + { + float[] posi = xpc.getPOSI(aircraft); + float[] ctrl = xpc.getCTRL(aircraft); + + System.out.format("Loc: (%4f, %4f, %4f) Aileron:%2f Elevator:%2f Rudder:%2f\n", + posi[0], posi[1], posi[2], ctrl[1], ctrl[0], ctrl[2]); + + try + { + Thread.sleep(100); + } + catch (InterruptedException ex) {} + + if(System.in.available() > 0) + { + break; + } + } + } + catch(IOException ex) + { + System.out.println("Error:"); + System.out.println(ex.getMessage()); + } + } +} From 87672e132b82476c06ce566370bfe9b6e1609efb Mon Sep 17 00:00:00 2001 From: Jason Watkins Date: Mon, 29 Jun 2015 12:45:36 -0700 Subject: [PATCH 6/6] Added MATLAB monitor example. --- MATLAB/MonitorExample/MonitorExample.m | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 MATLAB/MonitorExample/MonitorExample.m diff --git a/MATLAB/MonitorExample/MonitorExample.m b/MATLAB/MonitorExample/MonitorExample.m new file mode 100644 index 0000000..fa42115 --- /dev/null +++ b/MATLAB/MonitorExample/MonitorExample.m @@ -0,0 +1,20 @@ +%% X-Plane Connect MATLAB Example Script +% This script demonstrates how to read and write data to the XPC plugin. +% Before running this script, ensure that the XPC plugin is installed and +% X-Plane is running. +%% Import XPC +clear all; +addpath('../') +import XPlaneConnect.* + +Socket = openUDP(); +while 1 + posi = getPOSI(1, Socket); + ctrl = getCTRL(1, Socket); + + fprintf('Loc: (%4f, %4f, %4f) Aileron:%2f Elevator:%2f Rudder:%2f\n', ... + posi(1), posi(2), posi(3), ctrl(2), ctrl(1), ctrl(3)); + + pause(0.1); +end +closeUDP(Socket); \ No newline at end of file