Files
XPlaneConnectCSP/TestScripts/C Tests/DrefTests.h
Jason Watkins a3be4cb1b6 Version 1.3-rc.1 (#138)
* Minor improvements to the handling of landing gear by the SetGear and HandlePOSI functions

* sendPOSI command change (double for lat/lon/h) (#111)

* Updated POSI to use doubles for lat/lon/alt, as step size for floats was unacceptably large at high longitudes.

* Updated Java library for MATLAB, updated Java project, and updated Windows plugin binaries

* Rolled back Java version to 1.7 for MATLAB compatibility

* Update MessageHandlers.cpp

* Update DataManager.cpp

* Added pause functionality for individual a/c

Adds new cases such that:
0: Unpauses all a/c
1: Pauses all a/c
2: Switches case for all a/c
100:119: Pauses a/c 0:19
200:219: Unpauses a/c 0:19

Updates log messages.

Keeps the 0,1,2 arguments as they previously were.

* Finished individual pause functionality

* Update DataManager.cpp

* Updated flags to allow for individual pause commands

* Individual pause command documentation

* Updated flags to allow for individual pause commands

* Adding individual pause to documentation

* Updated flags to allow for individual pause commands

* Requested changes, cleaning

* Update CMakeLists.txt

Include "-fno-stack-protector" for linking and compiling for systems that do not have this have this flag as a default.

* Enabling AI after setting position (#118)

Previously, the code enabled the AI before setting the position of a/c, which negated its purpose.

* Updated XPlane SDK to version 2.1.3

* Resolve function ambiguity for std::abs on mac

Fixes #126

* Update copyright notice

* Update Windows binaries

* Update Linux binaries

* Update version numbers

* fix osx abs ambiguity (#142)

* fix indexing error (#143)

* Runway camera location control (#144)

* update ignore

* basics working

* set cam pos remotely

* log cam position

* keep default behaviour, if short view message is received

Compatibility with existing software

* all to tabs

* rename variable

* option to use camera direction fields

* Added UDP multicast for plugin discovery (#153)

* Added Timer

* Added UDPSocket::GetAddr

* Added MessageHandlers::SendBeacon()

* PoC of starting a timer on PluginEnable

* C++11

* Added Timer to xcode project

* C++11 in cmake

* added Timer to cmake

* use function pointer in Timer

* moved Timer to namespace

+ wait for thread to join when stopping the timer

* Windows: changed uint to unisgned short

* Windows: Added Timer.h/cpp to project

* GetAddr static

* Send xplane and plugin version with BECN

* SendBeacon with params

* fixed file copyrights

* Include functional

to fix Linux compile error

* review fixes

* Send plugin receive port in BECN

* review fixes

* Fixed tabs vs spaces indentations (#157)

* Java client BECN implementation (#155)

* Added MS Azure Dev Ops CI integration (#162)

* Do not build for i386 on macOS

Use ARCHS_STANDARD  to avoid the error “The i386 architecture is deprecated. You should update your ARCHS build setting to remove the i386 architecture.”

* Fixed missing include

The Visual Studio solution was not compiling

* Fixed isnan ambigious refernce

Ambigious reference when compiling on travis

https://stackoverflow.com/questions/33770374/why-is-isnan-ambiguous-and-how-to-avoid-it

* Set MSVC warning level to 3

Too many warnings were generated when building a Release build making Travis job to fail because of too much output

* Use default toolset for Visual Studio

AppVeyor recommends to set the default toolset

* #include <cstdint>

* Use MSVC ToolsVersion="14.0"

# Conflicts:
#	xpcPlugin/xpcPlugin/xpcPlugin.vcxproj

* Removed binaries from repository

# Conflicts:
#	xpcPlugin/XPlaneConnect/64/win.xpl
#	xpcPlugin/XPlaneConnect/win.xpl

* Added ms azure ci

xcode

linux

linux + macos

linux + macos

removed branch filter

win tests

win tests

Test all platfroms

artifacts tests

* output all binaries to ‘XPlaneConnect’

All platforms produce a binary in
xpcPlugin/XPlaneConnect/
xpcPlugin/XPlaneConnect/64/

* Added ms azure GH deploy

deploy stage

GH release test

trigger tags

* Clean up yml file

- Added variables
- Added job decriptions

* Ignore script to ignore .exp files

+ fixed output path

* Renamed ms azure GH connection

* Update service connection for azure pipeline

* Added Python3 compatible xpc client. (#156)

* Update Azure Pipelines service connection
2019-07-20 08:43:51 -07:00

248 lines
5.5 KiB
C

//Copyright (c) 2013-2018 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
#ifndef DREFTESTS_H
#define DREFTESTS_H
#include "Test.h"
#include "xplaneConnect.h"
int doGETDTest(char* drefs[], float* expected[], int count, int sizes[])
{
// Setup memory
int* asizes = (int*)malloc(sizeof(int) * count);
float** actual = (float**)malloc(sizeof(float*) * count);
for (int i = 0; i < count; ++i)
{
asizes[i] = sizes[i];
actual[i] = (float*)malloc(sizeof(float) * sizes[i]);
}
// Execute command
XPCSocket sock = openUDP(IP);
int result = getDREFs(sock, drefs, actual, count, asizes);
closeUDP(sock);
if (result < 0)
{
return -1;
}
// Test sizes and values
result = compareArrays(expected, sizes, actual, asizes, count);
for (int i = 0; i < count; ++i)
{
free(actual[i]);
}
free(actual);
free(asizes);
return result;
}
int doDREFTest(char* drefs[], float* values[], float* expected[], int count, int sizes[])
{
// Setup memory
int* asizes = (int*)malloc(sizeof(int) * count);
float** actual = (float**)malloc(sizeof(float*) * count);
for (int i = 0; i < count; ++i)
{
asizes[i] = sizes[i];
actual[i] = (float*)malloc(sizeof(float) * sizes[i]);
}
// Execute command
XPCSocket sock = openUDP(IP);
int result = sendDREFs(sock, drefs, values, sizes, count);
if (result >= 0)
{
result = getDREFs(sock, drefs, actual, count, asizes);
}
closeUDP(sock);
if (result < 0)
{
return -1;
}
// Test sizes and values
result = compareArrays(expected, sizes, actual, asizes, count);
for (int i = 0; i < count; ++i)
{
free(actual[i]);
}
free(actual);
free(asizes);
return result;
}
int testGETD_Basic()
{
char* drefs[] =
{
"sim/cockpit/switches/gear_handle_status", //int
"sim/cockpit/autopilot/altitude", //float
"sim/aircraft/prop/acf_prop_type", //int[8]
"sim/cockpit2/switches/panel_brightness_ratio", //float[4]
"sim/aircraft/view/acf_tailnum", //byte[40]
"sim/flightmodel/position/elevation" //double
};
int sizes[] = { 1, 1, 8, 4, 40, 1 };
float* expected[6];
for (int i = 0; i < 6; ++i)
{
expected[i] = (float*)malloc(sizeof(float) * sizes[i]);
for (int j = 0; j < sizes[i]; ++j)
{
expected[i][j] = NAN;
}
}
return doGETDTest(drefs, expected, 6, sizes);
}
int testGETD_TestFloat()
{
char* dref = "sim/test/test_float";
int size = 1;
float* expected[1];
expected[0] = (float*)malloc(sizeof(float));
expected[0][0] = 0.0F;
int result = doGETDTest(&dref, &expected, 1, &size);
free(expected[0]);
return result;
}
int testGETD_Types()
{
char* drefs[] =
{
"sim/cockpit/switches/gear_handle_status", //int
"sim/cockpit/autopilot/altitude", //float
"sim/aircraft/prop/acf_prop_type", //int[8]
"sim/cockpit2/switches/panel_brightness_ratio", //float[4]
"sim/aircraft/view/acf_tailnum", //byte[40]
"sim/flightmodel/position/elevation" //double
};
int sizes[] = { 1, 1, 8, 4, 40, 1 };
float* data[6];
for (int i = 0; i < 6; ++i)
{
data[i] = (float*)malloc(sizeof(float) * sizes[i]);
}
// Execute command
XPCSocket sock = openUDP(IP);
int result = getDREFs(sock, drefs, data, 6, sizes);
closeUDP(sock);
// Tests
if (result < 0)
{
return -1;
}
// Verify sizes
if (sizes[0] != 1 || sizes[1] != 1 || sizes[2] != 8
|| sizes[3] != 4 || sizes[4] != 40 || sizes[5] != 1)
{
return -2;
}
// Verify integer drefs are integers
if ((float)((int)data[0][0]) != data[0][0])
{
return -3;
}
for (int i = 0; i < 8; ++i)
{
if ((float)((int)data[2][i]) != data[2][i])
{
return -3;
}
}
for (int i = 0; i < 40; ++i)
{
if ((float)((char)data[4][i]) != data[4][i])
{
return -3;
}
}
// Verify tail number has at least one valid character
if (data[4][0] <= 0 || data[4][0] > 127)
{
return -4;
}
return 0;
}
int testDREF()
{
char* drefs[] =
{
"sim/cockpit/switches/gear_handle_status", //int
"sim/cockpit/autopilot/altitude", //float
"sim/aircraft/prop/acf_prop_type", //int[8]
"sim/cockpit2/switches/panel_brightness_ratio", //float[4]
"sim/aircraft/view/acf_tailnum", //byte[40]
"sim/flightmodel/position/elevation" //double - Read only
};
float* values[6];
float* expected[6];
int sizes[6];
// Setup
sizes[0] = 1;
values[0] = (float*)malloc(sizes[0] * sizeof(float));
expected[0] = values[0];
values[0][0] = 1;
sizes[1] = 1;
values[1] = (float*)malloc(sizes[1] * sizeof(float));
expected[1] = values[1];
values[1][0] = 4000.0F;
sizes[2] = 8;
values[2] = (float*)malloc(sizes[2] * sizeof(float));
expected[2] = values[2];
for (int i = 0; i < 8; ++i)
{
values[2][i] = 0;
}
sizes[3] = 4;
values[3] = (float*)malloc(sizes[3] * sizeof(float));
expected[3] = values[3];
for (int i = 0; i < 4; ++i)
{
values[3][i] = 0.25F;
}
sizes[4] = 40;
values[4] = (float*)malloc(sizes[4] * sizeof(float));
expected[4] = (float*)malloc(sizes[4] * sizeof(float));
memset(values[4], 0, sizes[4] * sizeof(float));
values[4][0] = 78.0F; //N
values[4][1] = 55.0F; //7
values[4][2] = 52.0F; //4
values[4][3] = 56.0F; //8
values[4][4] = 53.0F; //5
values[4][5] = 89.0F; //Y
expected[4][0] = 78.0F; //N
expected[4][1] = 55.0F; //7
expected[4][2] = 52.0F; //4
expected[4][3] = 56.0F; //8
expected[4][4] = 53.0F; //5
expected[4][5] = 89.0F; //Y
for (int i = 6; i < sizes[4]; ++i)
{
expected[4][i] = NAN;
}
sizes[5] = 1;
values[5] = (float*)malloc(sizes[5] * sizeof(float));
expected[5] = (float*)malloc(sizes[5] * sizeof(float));
values[5][0] = 5000.0F;
expected[5][0] = NAN;
return doDREFTest(drefs, values, expected, 6, sizes);
}
#endif