Added support for VIEW command to the C client.
This commit is contained in:
@@ -48,9 +48,6 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void printError(char *functionName, char *format, ...)
|
void printError(char *functionName, char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -694,3 +691,31 @@ int sendWYPT(XPCSocket sock, WYPT_OP op, float points[], int count)
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**** End Drawing functions ****/
|
/**** End Drawing functions ****/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**** View functions ****/
|
||||||
|
/*****************************************************************************/
|
||||||
|
int sendVIEW(XPCSocket sock, VIEW_TYPE view)
|
||||||
|
{
|
||||||
|
// Validate Input
|
||||||
|
if (view < XPC_VIEW_FORWARDS || view > XPC_VIEW_FULLSCREENNOHUD)
|
||||||
|
{
|
||||||
|
printError("sendVIEW", "Unrecognized view");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup Command
|
||||||
|
char buffer[9] = "VIEW";
|
||||||
|
*((int*)(buffer + 5)) = view;
|
||||||
|
|
||||||
|
// Send Command
|
||||||
|
if (sendUDP(sock, buffer, 9) < 0)
|
||||||
|
{
|
||||||
|
printError("sendVIEW", "Failed to send command");
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**** End View functions ****/
|
||||||
|
/*****************************************************************************/
|
||||||
@@ -62,6 +62,23 @@ typedef enum
|
|||||||
XPC_WYPT_CLR = 3
|
XPC_WYPT_CLR = 3
|
||||||
} WYPT_OP;
|
} WYPT_OP;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
XPC_VIEW_FORWARDS = 73,
|
||||||
|
XPC_VIEW_DOWN,
|
||||||
|
XPC_VIEW_LEFT,
|
||||||
|
XPC_VIEW_RIGHT,
|
||||||
|
XPC_VIEW_BACK,
|
||||||
|
XPC_VIEW_TOWER,
|
||||||
|
XPC_VIEW_RUNWAY,
|
||||||
|
XPC_VIEW_CHASE,
|
||||||
|
XPC_VIEW_FOLLOW,
|
||||||
|
XPC_VIEW_FOLLOWWITHPANEL,
|
||||||
|
XPC_VIEW_SPOT,
|
||||||
|
XPC_VIEW_FULLSCREENWITHHUD,
|
||||||
|
XPC_VIEW_FULLSCREENNOHUD,
|
||||||
|
} VIEW_TYPE;
|
||||||
|
|
||||||
// Low Level UDP Functions
|
// Low Level UDP Functions
|
||||||
|
|
||||||
/// Opens a new connection to XPC on an OS chosen port.
|
/// Opens a new connection to XPC on an OS chosen port.
|
||||||
@@ -214,6 +231,13 @@ int sendCTRL(XPCSocket sock, float values[], int size, char ac);
|
|||||||
/// \returns 0 if successful, otherwise a negative value.
|
/// \returns 0 if successful, otherwise a negative value.
|
||||||
int sendTEXT(XPCSocket sock, char* msg, int x, int y);
|
int sendTEXT(XPCSocket sock, char* msg, int x, int y);
|
||||||
|
|
||||||
|
/// Sets the camera view in X-Plane.
|
||||||
|
///
|
||||||
|
/// \param sock The socket to use to send the command.
|
||||||
|
/// \param view The view to use.
|
||||||
|
/// \returns 0 if successful, otherwise a negative value.
|
||||||
|
int sendVIEW(XPCSocket sock, VIEW_TYPE view);
|
||||||
|
|
||||||
/// Adds, removes, or clears a set of waypoints. If the command is clear, the points are ignored
|
/// Adds, removes, or clears a set of waypoints. If the command is clear, the points are ignored
|
||||||
/// and all points are removed.
|
/// and all points are removed.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
<ClInclude Include="..\C Tests\Test.h" />
|
<ClInclude Include="..\C Tests\Test.h" />
|
||||||
<ClInclude Include="..\C Tests\TextTests.h" />
|
<ClInclude Include="..\C Tests\TextTests.h" />
|
||||||
<ClInclude Include="..\C Tests\UDPTests.h" />
|
<ClInclude Include="..\C Tests\UDPTests.h" />
|
||||||
|
<ClInclude Include="..\C Tests\ViewTests.h" />
|
||||||
<ClInclude Include="..\C Tests\WyptTests.h" />
|
<ClInclude Include="..\C Tests\WyptTests.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
|
|||||||
73
TestScripts/C Tests/ViewTests.h
Normal file
73
TestScripts/C Tests/ViewTests.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
|
#ifndef VIEWTESTS_H
|
||||||
|
#define VIEWTESTS_H
|
||||||
|
|
||||||
|
#include "Test.h"
|
||||||
|
#include "xplaneConnect.h"
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
XPC_VDREF_FORWARDS = 1000,
|
||||||
|
XPC_VDREF_DOWN4 = 1001,
|
||||||
|
XPC_VDREF_DOWN8 = 1002,
|
||||||
|
XPC_VDREF_LEFT45 = 1004,
|
||||||
|
XPC_VDREF_RIGHT45 = 1005,
|
||||||
|
XPC_VDREF_LEFT90 = 1006,
|
||||||
|
XPC_VDREF_RIGHT90 = 1007,
|
||||||
|
XPC_VDREF_LEFT135 = 1008,
|
||||||
|
XPC_VDREF_RIGHT135 = 1009,
|
||||||
|
XPC_VDREF_BACKWARD = 1010,
|
||||||
|
XPC_VDREF_LEFTUP = 1011,
|
||||||
|
XPC_VDREF_RIGHTUP = 1012,
|
||||||
|
XPC_VDREF_AIRPORTBEACONTOWER = 1014,
|
||||||
|
XPC_VDREF_ONRUNWAY = 1015,
|
||||||
|
XPC_VDREF_CHASE = 1017,
|
||||||
|
XPC_VDREF_FOLLOW = 1018,
|
||||||
|
XPC_VDREF_FOLLOWWITHPANEL = 1019,
|
||||||
|
XPC_VDREF_SPOT = 1020,
|
||||||
|
XPC_VDREF_SPOTMOVING = 1021,
|
||||||
|
XPC_VDREF_FULLSCREENWITHHUD = 1023,
|
||||||
|
XPC_VDREF_FULLSCREENNOHUD = 1024,
|
||||||
|
XPC_VDREF_STRAIGHTDOWN = 1025,
|
||||||
|
XPC_VDREF_3DCOCKPIT = 1026
|
||||||
|
} VIEW_DREF;
|
||||||
|
|
||||||
|
int doViewTest(VIEW_TYPE viewCommand, VIEW_DREF viewResult)
|
||||||
|
{
|
||||||
|
// Setup
|
||||||
|
char* dref = "sim/graphics/view/view_type";
|
||||||
|
float value;
|
||||||
|
int size = 1;
|
||||||
|
|
||||||
|
// Execute command
|
||||||
|
XPCSocket sock = openUDP(IP);
|
||||||
|
int result = sendVIEW(sock, viewCommand);
|
||||||
|
if (result >= 0)
|
||||||
|
{
|
||||||
|
result = getDREF(sock, dref, &value, &size);
|
||||||
|
}
|
||||||
|
closeUDP(sock);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int)value != viewResult)
|
||||||
|
{
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int testView()
|
||||||
|
{
|
||||||
|
int result = doViewTest(XPC_VIEW_FORWARDS, XPC_VDREF_FORWARDS);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return doViewTest(XPC_VIEW_CHASE, XPC_VDREF_CHASE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "PosiTests.h"
|
#include "PosiTests.h"
|
||||||
#include "DataTests.h"
|
#include "DataTests.h"
|
||||||
#include "TextTests.h"
|
#include "TextTests.h"
|
||||||
|
#include "ViewTests.h"
|
||||||
#include "WyptTests.h"
|
#include "WyptTests.h"
|
||||||
|
|
||||||
int main(int argc, const char * argv[])
|
int main(int argc, const char * argv[])
|
||||||
@@ -48,10 +49,14 @@ int main(int argc, const char * argv[])
|
|||||||
runTest(testTEXT, "TEXT");
|
runTest(testTEXT, "TEXT");
|
||||||
// Waypoints
|
// Waypoints
|
||||||
runTest(testWYPT, "WYPT");
|
runTest(testWYPT, "WYPT");
|
||||||
|
// View
|
||||||
|
runTest(testView, "VIEW");
|
||||||
// setConn
|
// setConn
|
||||||
runTest(testCONN, "CONN");
|
runTest(testCONN, "CONN");
|
||||||
|
|
||||||
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );
|
printf( "----------------\nTest Summary\n\tFailed: %i\n\tPassed: %i\n", testFailed, testPassed );
|
||||||
|
printf("Press any key to exit.");
|
||||||
|
getchar();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user