@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// DISCLAIMERS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
@@ -38,6 +38,7 @@
|
||||
// CONTRIBUTORS
|
||||
// CT: Christopher Teubert (christopher.a.teubert@nasa.gov)
|
||||
// JW: Jason Watkins (jason.w.watkins@nasa.gov)
|
||||
|
||||
#include "xplaneConnect.h"
|
||||
|
||||
#include <math.h>
|
||||
@@ -46,12 +47,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <time.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
int sendUDP(XPCSocket sock, char buffer[], int len);
|
||||
int readUDP(XPCSocket sock, char buffer[], int len);
|
||||
int sendDREFRequest(XPCSocket sock, const char* drefs[], unsigned char count);
|
||||
int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int sizes[]);
|
||||
|
||||
void printError(char *functionName, char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -306,8 +313,9 @@ int sendDATA(XPCSocket sock, float data[][9], int rows)
|
||||
// 5 byte header + 134 rows * 9 values * 4 bytes per value => 4829 byte max length.
|
||||
char buffer[4829] = "DATA";
|
||||
int len = 5 + rows * 9 * sizeof(float);
|
||||
unsigned short step = 9 * sizeof(float);
|
||||
for (int i=0;i<rows;i++)
|
||||
unsigned short step = 9 * sizeof(float);
|
||||
int i; // iterator
|
||||
for (i = 0; i < rows; i++)
|
||||
{
|
||||
buffer[5 + i * step] = (char)data[i][0];
|
||||
memcpy(&buffer[9 + i*step], &data[i][1], 8 * sizeof(float));
|
||||
@@ -328,14 +336,14 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
|
||||
// shouldn't be trying to read nearly this much data at once anyway.
|
||||
if (rows > 134)
|
||||
{
|
||||
printError("sendDATA", "Too many rows.");
|
||||
printError("readDATA", "Too many rows.");
|
||||
// Read as much as we can anyway
|
||||
rows = 134;
|
||||
}
|
||||
|
||||
// Read data
|
||||
char buffer[4829] = { 0 };
|
||||
int result = readUDP(sock, buffer, 5120);
|
||||
int result = readUDP(sock, buffer, 4829);
|
||||
if (result <= 0)
|
||||
{
|
||||
printError("readDATA", "Failed to read from socket.");
|
||||
@@ -346,12 +354,17 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
|
||||
if (readRows > rows)
|
||||
{
|
||||
printError("readDATA", "Read more rows than will fit in dataRef.");
|
||||
// Copy as much data as we can anyway
|
||||
}
|
||||
else if (readRows < rows)
|
||||
{
|
||||
printError("readDATA", "Read fewer rows than expected.");
|
||||
// Copy as much data as we read anyway
|
||||
rows = readRows;
|
||||
}
|
||||
|
||||
// Parse data
|
||||
for (int i = 0; i < rows; ++i)
|
||||
int i; // iterator
|
||||
for (i = 0; i < rows; ++i)
|
||||
{
|
||||
data[i][0] = buffer[5 + i * 36];
|
||||
memcpy(&data[i][1], &buffer[9 + i * 36], 8 * sizeof(float));
|
||||
@@ -376,7 +389,8 @@ int sendDREFs(XPCSocket sock, const char* drefs[], float* values[], int sizes[],
|
||||
// Max size is technically unlimited.
|
||||
unsigned char buffer[65536] = "DREF";
|
||||
int pos = 5;
|
||||
for (int i = 0; i < count; ++i)
|
||||
int i; // Iterator
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
int drefLen = strnlen(drefs[i], 256);
|
||||
if (pos + drefLen + sizes[i] * 4 + 2 > 65536)
|
||||
@@ -422,7 +436,8 @@ int sendDREFRequest(XPCSocket sock, const char* drefs[], unsigned char count)
|
||||
unsigned char buffer[65536] = "GETD";
|
||||
buffer[5] = count;
|
||||
int len = 6;
|
||||
for (int i = 0; i < count; ++i)
|
||||
int i; // iterator
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
size_t drefLen = strnlen(drefs[i], 256);
|
||||
if (drefLen > 255)
|
||||
@@ -470,7 +485,8 @@ int getDREFResponse(XPCSocket sock, float* values[], unsigned char count, int si
|
||||
}
|
||||
|
||||
int cur = 6;
|
||||
for (int i = 0; i < count; ++i)
|
||||
int i; // Iterator
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
int l = buffer[cur++];
|
||||
if (l > sizes[i])
|
||||
@@ -571,7 +587,8 @@ int sendPOSI(XPCSocket sock, float values[], int size, char ac)
|
||||
// 5 byte header + up to 7 values * 5 bytes each
|
||||
unsigned char buffer[40] = "POSI";
|
||||
buffer[5] = ac;
|
||||
for (int i = 0; i < 7; i++)
|
||||
int i; // iterator
|
||||
for (i = 0; i < 7; i++)
|
||||
{
|
||||
float val = -998;
|
||||
|
||||
@@ -650,7 +667,8 @@ int sendCTRL(XPCSocket sock, float values[], int size, char ac)
|
||||
// 5 byte header + 5 float values * 4 + 2 byte values
|
||||
unsigned char buffer[31] = "CTRL";
|
||||
int cur = 5;
|
||||
for (int i = 0; i < 6; i++)
|
||||
int i; // iterator
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
float val = -998;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
//Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
//DISCLAIMERS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//NOTICES:
|
||||
// Copyright <EFBFBD> 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// DISCLAIMERS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//NOTICES:
|
||||
// Copyright <EFBFBD> 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// DISCLAIMERS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//NOTICES:
|
||||
// Copyright ã 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2016 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// DISCLAIMERS
|
||||
|
||||
@@ -37,7 +37,7 @@ import XPlaneConnect.*
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(istrue(length(clients) < 2), '[readDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
assert(isequal((length(clients) < 2),1), '[readDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
@@ -46,7 +46,7 @@ if ~exist('socket', 'var')
|
||||
end
|
||||
|
||||
%% Get data
|
||||
result.raw = socket.readDATA();
|
||||
result.raw = socket.readData();
|
||||
|
||||
%% Format data
|
||||
rows = (length(result.raw) - 5) / 9;
|
||||
|
||||
@@ -19,7 +19,7 @@ import XPlaneConnect.*
|
||||
%% Get client
|
||||
global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(istrue(length(clients) < 2), '[selectDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
assert(isequal((length(clients) < 2),1), '[selectDATA] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
else
|
||||
|
||||
@@ -67,7 +67,7 @@ against the "develop" branch. Pull requests will be evaluated and integrated int
|
||||
the next official release.
|
||||
|
||||
###Notices
|
||||
Copyright ©2013-2015 United States Government as represented by the Administrator
|
||||
Copyright ©2013-2016 United States Government as represented by the Administrator
|
||||
of the National Aeronautics and Space Administration. All Rights Reserved.
|
||||
|
||||
No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
@@ -44,26 +44,26 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -56,5 +56,8 @@
|
||||
<ClInclude Include="..\C Tests\Test.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\C Tests\ViewTests.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "Test.h"
|
||||
#include "xplaneConnect.h"
|
||||
|
||||
int doCTRLTest(char* drefs[7], float values[], int size, int ac, float expected[7])
|
||||
int doCTRLTest(XPCSocket *sock, char* drefs[7], float values[], int size, int ac, float expected[7])
|
||||
{
|
||||
float* data[7];
|
||||
int sizes[7];
|
||||
@@ -17,13 +17,13 @@ int doCTRLTest(char* drefs[7], float values[], int size, int ac, float expected[
|
||||
}
|
||||
|
||||
// Execute command
|
||||
XPCSocket sock = openUDP(IP);
|
||||
int result = sendCTRL(sock, values, size, ac);
|
||||
int result = sendCTRL(*sock, values, size, ac);
|
||||
int d = 0.0f;
|
||||
if (result >= 0)
|
||||
{
|
||||
result = getDREFs(sock, drefs, data, 7, sizes);
|
||||
result = getDREFs(*sock, drefs, data, 7, sizes);
|
||||
}
|
||||
closeUDP(sock);
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
@@ -35,6 +35,7 @@ int doCTRLTest(char* drefs[7], float values[], int size, int ac, float expected[
|
||||
{
|
||||
actual[i] = data[i][0];
|
||||
}
|
||||
|
||||
return compareArray(expected, actual, 7);
|
||||
}
|
||||
|
||||
@@ -70,11 +71,14 @@ int basicCTRLTest(char** drefs, int ac)
|
||||
// Set control surfaces to known state.
|
||||
float CTRL[6] = { 0.0F, 0.0F, 0.0F, 0.8F, 1.0F, 0.5F };
|
||||
float expected[7] = { 0.0F, 0.0F, 0.0F, NAN, NAN, NAN, NAN };
|
||||
int result = doCTRLTest(drefs, CTRL, 3, ac, expected);
|
||||
XPCSocket sock = openUDP(IP);
|
||||
pauseSim(sock, 1); // Pause so the controls wont change between 2 and 3
|
||||
int result = doCTRLTest(&sock, drefs, CTRL, 3, ac, expected);
|
||||
if (result < 0)
|
||||
{
|
||||
return -10000 + result;
|
||||
}
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
|
||||
// Test control surfaces and set other values to known state.
|
||||
expected[0] = CTRL[0] = 0.2F;
|
||||
@@ -83,22 +87,29 @@ int basicCTRLTest(char** drefs, int ac)
|
||||
expected[3] = 0.8F;
|
||||
expected[4] = 1.0F;
|
||||
expected[5] = 0.5F;
|
||||
result = doCTRLTest(drefs, CTRL, 6, ac, expected);
|
||||
result = doCTRLTest(&sock, drefs, CTRL, 6, ac, expected);
|
||||
if (result < 0)
|
||||
{
|
||||
return -20000 + result;
|
||||
}
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
|
||||
// Test other values and verify control surfaces unchanged.
|
||||
CTRL[0] = -998;
|
||||
CTRL[1] = -998;
|
||||
CTRL[2] = -998;
|
||||
expected[0] = CTRL[0] = 0.15F;
|
||||
expected[1] = CTRL[1] = 0.15F;
|
||||
expected[2] = CTRL[2] = 0.15F;
|
||||
expected[3] = CTRL[3] = 0.9F;
|
||||
expected[4] = CTRL[4] = 0.0F;
|
||||
expected[5] = CTRL[5] = 0.75F;
|
||||
result = doCTRLTest(drefs, CTRL, 6, ac, expected);
|
||||
CTRL[4] = -998;
|
||||
CTRL[5] = -998;
|
||||
result = doCTRLTest(&sock, drefs, CTRL, 6, ac, expected);
|
||||
|
||||
pauseSim(sock, 0);
|
||||
closeUDP(sock);
|
||||
if (result < 0)
|
||||
{
|
||||
if (result == -1004) {
|
||||
printf("GEAR FAILURE... ARE YOU USING AN AIRCRAFT WITH FIXED GEARS? ");
|
||||
}
|
||||
return -30000 + result;
|
||||
}
|
||||
return 0;
|
||||
@@ -129,7 +140,7 @@ int testCTRL_NonPlayer()
|
||||
"sim/multiplayer/position/plane1_throttle",
|
||||
"sim/multiplayer/position/plane1_gear_deploy",
|
||||
"sim/multiplayer/position/plane1_flap_ratio",
|
||||
"sim/multiplayer/position/plane1_sbrkrqst"
|
||||
"sim/multiplayer/position/plane1_speedbrake_ratio"
|
||||
};
|
||||
return basicCTRLTest(drefs, 1);
|
||||
}
|
||||
@@ -150,7 +161,9 @@ int testCTRL_Speedbrakes()
|
||||
// Arm
|
||||
float CTRL[7] = { -998, -998, -998, -998, -998, -998, -0.5F };
|
||||
float expected[7] = { NAN, NAN, NAN, NAN, NAN, NAN, -0.5F };
|
||||
int result = doCTRLTest(drefs, CTRL, 7, 0, expected);
|
||||
XPCSocket sock = openUDP(IP);
|
||||
pauseSim(sock, 1); // Pause so the controls wont change between 2 and 3
|
||||
int result = doCTRLTest(&sock, drefs, CTRL, 7, 0, expected);
|
||||
if (result < 0)
|
||||
{
|
||||
return -10000 + result;
|
||||
@@ -158,7 +171,7 @@ int testCTRL_Speedbrakes()
|
||||
|
||||
// Set to full
|
||||
expected[6] = CTRL[6] = 1.5F;
|
||||
result = doCTRLTest(drefs, CTRL, 7, 0, expected);
|
||||
result = doCTRLTest(&sock, drefs, CTRL, 7, 0, expected);
|
||||
if (result < 0)
|
||||
{
|
||||
return -20000 + result;
|
||||
@@ -166,7 +179,9 @@ int testCTRL_Speedbrakes()
|
||||
|
||||
// Retract
|
||||
expected[6] = CTRL[6] = 0.0F;
|
||||
result = doCTRLTest(drefs, CTRL, 7, 0, expected);
|
||||
result = doCTRLTest(&sock, drefs, CTRL, 7, 0, expected);
|
||||
pauseSim(sock, 0);
|
||||
closeUDP(sock);
|
||||
if (result < 0)
|
||||
{
|
||||
return -30000 + result;
|
||||
|
||||
@@ -21,6 +21,14 @@ void runTest(int(*test)(), char* name)
|
||||
}
|
||||
}
|
||||
|
||||
void crossPlatformUSleep(int uSleep) {
|
||||
#ifdef _WIN32
|
||||
Sleep(uSleep/1000);
|
||||
#else
|
||||
usleep(uSleep);
|
||||
#endif
|
||||
}
|
||||
|
||||
int compareFloat(float expected, float actual)
|
||||
{
|
||||
return feq(expected, actual) || isnan(expected) ? 0 : -1;
|
||||
|
||||
@@ -9,10 +9,22 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef LINUX
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#define SLEEP_AMOUNT 100000
|
||||
|
||||
#define feq(x, y) (fabs(x - y) < 1e-4)
|
||||
|
||||
#define IP "127.0.0.1"
|
||||
|
||||
void crossPlatformUSleep(int uSleep);
|
||||
|
||||
extern int testFailed;
|
||||
extern int testPassed;
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "ViewTests.h"
|
||||
#include "WyptTests.h"
|
||||
|
||||
int main(int argc, const char * argv[])
|
||||
{
|
||||
int main(int argc, const char * argv[]) {
|
||||
printf("XPC Tests-c ");
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -27,36 +26,58 @@ int main(int argc, const char * argv[])
|
||||
|
||||
// Basic Networking
|
||||
runTest(testOpen, "open");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testClose, "close");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
|
||||
// Datarefs
|
||||
runTest(testGETD_Basic, "GETD");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testGETD_Types, "GETD (types)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testGETD_TestFloat, "GETD (test float)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testDREF, "DREF");
|
||||
// Pause
|
||||
runTest(testSIMU_Basic, "SIMU");
|
||||
runTest(testSIMU_Toggle, "SIMU (toggle)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testSIMU_Basic, "SIMU");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testSIMU_Toggle, "SIMU (toggle)");
|
||||
// CTRL
|
||||
runTest(testCTRL_Player, "CTRL (player)");
|
||||
runTest(testCTRL_NonPlayer, "CTRL (non-player)");
|
||||
runTest(testCTRL_Speedbrakes, "CTRL (speedbrakes)");
|
||||
runTest(testGETC, "GETC (player)");
|
||||
runTest(testGETC_NonPlayer, "GETC (Non-player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testCTRL_Player, "CTRL (player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testCTRL_NonPlayer, "CTRL (non-player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testCTRL_Speedbrakes, "CTRL (speedbrakes)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testGETC, "GETC (player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testGETC_NonPlayer, "GETC (Non-player)");
|
||||
// POSI
|
||||
runTest(testPOSI_Player, "POSI (player)");
|
||||
runTest(testPOSI_NonPlayer, "POSI (non-player)");
|
||||
runTest(testGetPOSI_Player, "GETP (player)");
|
||||
runTest(testGetPOSI_NonPlayer, "GETP (non-player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testPOSI_Player, "POSI (player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testPOSI_NonPlayer, "POSI (non-player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testGetPOSI_Player, "GETP (player)");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testGetPOSI_NonPlayer, "GETP (non-player)");
|
||||
// Data
|
||||
runTest(testDATA, "DATA");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testDATA, "DATA");
|
||||
// Text
|
||||
runTest(testTEXT, "TEXT");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testTEXT, "TEXT");
|
||||
// Waypoints
|
||||
runTest(testWYPT, "WYPT");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testWYPT, "WYPT");
|
||||
// View
|
||||
runTest(testView, "VIEW");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testView, "VIEW");
|
||||
// setConn
|
||||
runTest(testCONN, "CONN");
|
||||
crossPlatformUSleep(SLEEP_AMOUNT);
|
||||
runTest(testCONN, "CONN");
|
||||
|
||||
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );
|
||||
printf("Press any key to exit.");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// X-Plane API
|
||||
@@ -680,6 +680,17 @@ namespace XPC
|
||||
pos[2] = (float)GetDouble(DREF_Elevation, aircraft);
|
||||
}
|
||||
|
||||
// See: http://www.xsquawkbox.net/xpsdk/mediawiki/MovingThePlane
|
||||
// Need to get the aircraft's current orientation before moving and
|
||||
// reset the orientation after moving to update the quaternion
|
||||
float orient[3];
|
||||
orient[0] = GetFloat(DREF_Pitch, aircraft);
|
||||
orient[1] = GetFloat(DREF_Roll, aircraft);
|
||||
orient[2] = GetFloat(DREF_HeadingTrue, aircraft);
|
||||
|
||||
// Now set the aircraft's position. Need to set world position for
|
||||
// "long" moves, but since there isn't an easy way to calculate "long",
|
||||
// we just set it every time.
|
||||
double local[3];
|
||||
XPLMWorldToLocal(pos[0], pos[1], pos[2], &local[0], &local[1], &local[2]);
|
||||
// If the sim is paused, setting global position won't update the
|
||||
@@ -691,6 +702,9 @@ namespace XPC
|
||||
Set(DREF_Latitude, (double)pos[0], aircraft);
|
||||
Set(DREF_Longitude, (double)pos[1], aircraft);
|
||||
Set(DREF_Elevation, (double)pos[2], aircraft);
|
||||
|
||||
// Now reset orientation to update q
|
||||
SetOrientation(orient, aircraft);
|
||||
}
|
||||
|
||||
void DataManager::SetOrientation(float orient[3], char aircraft)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPCPLUGIN_DATAMANAGER_H_
|
||||
#define XPCPLUGIN_DATAMANAGER_H_
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// X-Plane API
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPCPLUGIN_DRAWING_H_
|
||||
#define XPCPLUGIN_DRAWING_H_
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#include "Log.h"
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace XPC
|
||||
|
||||
std::fprintf(fd, "X-Plane Connect [Version %s]\n", version.c_str());
|
||||
std::fprintf(fd, "Compiled %s %s\n", __DATE__, __TIME__);
|
||||
std::fprintf(fd, "Copyright (c) 2013-2015 United States Government as represented by the\n");
|
||||
std::fprintf(fd, "Copyright (c) 2013-2017 United States Government as represented by the\n");
|
||||
std::fprintf(fd, "Administrator of the National Aeronautics and Space Administration.\n");
|
||||
std::fprintf(fd, "All Rights Reserved.\n\n");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPCPLUGIN_LOG_H_
|
||||
#define XPCPLUGIN_LOG_H_
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#include "Message.h"
|
||||
#include "Log.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPCPLUGIN_MESSAGE_H_
|
||||
#define XPCPLUGIN_MESSAGE_H_
|
||||
@@ -26,9 +26,6 @@ namespace XPC
|
||||
/// with the size set to 0.
|
||||
static Message ReadFrom(const UDPSocket& sock);
|
||||
|
||||
/// Gets the message header in binary form.
|
||||
unsigned long GetMagicNumber() const;
|
||||
|
||||
/// Gets the message header.
|
||||
std::string GetHead() const;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// X-Plane API
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPCPLUGIN_MESSAGEHANDLERS_H_
|
||||
#define XPCPLUGIN_MESSAGEHANDLERS_H_
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#include "Log.h"
|
||||
#include "UDPSocket.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
#ifndef XPCPLUGIN_SOCKET_H_
|
||||
#define XPCPLUGIN_SOCKET_H_
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||
// Copyright (c) 2013-2017 United States Government as represented by the Administrator of the
|
||||
// National Aeronautics and Space Administration. All Rights Reserved.
|
||||
//
|
||||
// DISCLAIMERS
|
||||
@@ -79,8 +79,6 @@ double start;
|
||||
double lap;
|
||||
static double timeConvert = 0.0;
|
||||
int benchmarkingSwitch = 0; // 1 = time for operations, 2 = time for op + cycle;
|
||||
int cyclesToClear = -1; // Clear message bus every n cycles. -1 == dont clear
|
||||
int counter = 0;
|
||||
|
||||
PLUGIN_API int XPluginStart(char* outName, char* outSig, char* outDesc);
|
||||
PLUGIN_API void XPluginStop(void);
|
||||
@@ -91,9 +89,9 @@ static float XPCFlightLoopCallback(float inElapsedSinceLastCall, float inElapsed
|
||||
|
||||
PLUGIN_API int XPluginStart(char* outName, char* outSig, char* outDesc)
|
||||
{
|
||||
strcpy(outName, "X-Plane Connect [Version 1.2.0]");
|
||||
strcpy(outName, "X-Plane Connect [Version 1.2.1]");
|
||||
strcpy(outSig, "NASA.XPlaneConnect");
|
||||
strcpy(outDesc, "X Plane Communications Toolbox\nCopyright (c) 2013-2015 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved.");
|
||||
strcpy(outDesc, "X Plane Communications Toolbox\nCopyright (c) 2013-2017 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved.");
|
||||
|
||||
#if (__APPLE__)
|
||||
if ( abs(timeConvert) <= 1e-9 ) // is about 0
|
||||
@@ -105,7 +103,7 @@ PLUGIN_API int XPluginStart(char* outName, char* outSig, char* outDesc)
|
||||
1000000000.0;
|
||||
}
|
||||
#endif
|
||||
XPC::Log::Initialize("1.1.1");
|
||||
XPC::Log::Initialize("1.2.1");
|
||||
XPC::Log::WriteLine(LOG_INFO, "EXEC", "Plugin Start");
|
||||
XPC::DataManager::Initialize();
|
||||
|
||||
@@ -170,13 +168,13 @@ float XPCFlightLoopCallback(float inElapsedSinceLastCall,
|
||||
double diff_t;
|
||||
#endif
|
||||
|
||||
counter++;
|
||||
if (benchmarkingSwitch > 1)
|
||||
{
|
||||
XPC::Log::FormatLine(LOG_DEBUG, "EXEC", "Cycle time %.6f", inElapsedSinceLastCall);
|
||||
}
|
||||
|
||||
for (int i = 0; i < OPS_PER_CYCLE; i++)
|
||||
int ops;
|
||||
for (ops = 0; ops < OPS_PER_CYCLE; ops++)
|
||||
{
|
||||
if (benchmarkingSwitch > 0)
|
||||
{
|
||||
@@ -202,11 +200,18 @@ float XPCFlightLoopCallback(float inElapsedSinceLastCall,
|
||||
}
|
||||
}
|
||||
|
||||
if (cyclesToClear != -1 && counter%cyclesToClear == 0)
|
||||
// If we have processed the maximum number of requests in a single frame,
|
||||
// the socket is probably overloaded. Hopefully this is caused by a
|
||||
// transitory event like a long load inside X-Plane that caused us to stop
|
||||
// responding to requests for a while. We drop the current socket and
|
||||
// re-create it to drop any old packets that have probably already timed
|
||||
// out on the client side.
|
||||
if (ops == OPS_PER_CYCLE)
|
||||
{
|
||||
XPC::Log::WriteLine(LOG_DEBUG, "EXEC", "Cleared UDP Buffer");
|
||||
XPC::Log::WriteLine(LOG_WARN, "EXEC", "Cleared UDP Buffer");
|
||||
delete sock;
|
||||
sock = new XPC::UDPSocket(RECVPORT);
|
||||
XPC::MessageHandlers::SetSocket(sock);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -365,7 +365,9 @@
|
||||
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/xplaneConnect-asdjuezcjkhojuewbyxhyhabxfwc/Build/Products/Debug",
|
||||
);
|
||||
MACH_O_TYPE = mh_bundle;
|
||||
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
|
||||
PRODUCT_NAME = mac;
|
||||
SDKROOT = macosx;
|
||||
STRIP_INSTALLED_PRODUCT = YES;
|
||||
|
||||
@@ -22,30 +22,31 @@
|
||||
<ProjectGuid>{6AEF5D28-2701-44FF-AE10-1DEF07C5CAEA}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>xpcPlugin</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
|
||||
Reference in New Issue
Block a user