Added getPOSI and getCTRL support to the C client.
This commit is contained in:
@@ -38,6 +38,33 @@ int doCTRLTest(char* drefs[7], float values[], int size, int ac, float expected[
|
||||
return compareArray(expected, actual, 7);
|
||||
}
|
||||
|
||||
int doGETCTest(float values[7], int ac, float expected[7])
|
||||
{
|
||||
// Execute Test
|
||||
float actual[7];
|
||||
XPCSocket sock = openUDP(IP);
|
||||
int result = sendCTRL(sock, values, 7, ac);
|
||||
if (result >= 0)
|
||||
{
|
||||
result = getCTRL(sock, actual, ac);
|
||||
}
|
||||
closeUDP(sock);
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Test values
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
if (fabs(expected[i] - actual[i]) > 1e-4)
|
||||
{
|
||||
return -10 - i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int basicCTRLTest(char** drefs, int ac)
|
||||
{
|
||||
// Set control surfaces to known state.
|
||||
@@ -146,4 +173,16 @@ int testCTRL_Speedbrakes()
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int testGETC()
|
||||
{
|
||||
float CTRL[7] = { 0.0F, 0.0F, 0.0F, 0.8F, 1.0F, 0.5F, -1.5F };
|
||||
return doGETCTest(CTRL, 0, CTRL);
|
||||
}
|
||||
|
||||
int testGETC_NonPlayer()
|
||||
{
|
||||
float CTRL[7] = { 0.0F, 0.0F, 0.0F, 0.8F, 1.0F, 0.5F, -1.5F };
|
||||
return doGETCTest(CTRL, 2, CTRL);
|
||||
}
|
||||
#endif
|
||||
@@ -40,6 +40,33 @@ int doPOSITest(char* drefs[7], float values[], int size, int ac, float expected[
|
||||
return compareArray(expected, actual, 7);
|
||||
}
|
||||
|
||||
int doGETPTest(float values[7], int ac, float expected[7])
|
||||
{
|
||||
// Execute Test
|
||||
float actual[7];
|
||||
XPCSocket sock = openUDP(IP);
|
||||
int result = sendPOSI(sock, values, 7, ac);
|
||||
if (result >= 0)
|
||||
{
|
||||
result = getPOSI(sock, actual, ac);
|
||||
}
|
||||
closeUDP(sock);
|
||||
if (result < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Test values
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
if (fabs(expected[i] - actual[i]) > 1e-4)
|
||||
{
|
||||
return -10 - i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int basicPOSITest(char** drefs, int ac)
|
||||
{
|
||||
// Set psoition and initial orientation
|
||||
@@ -116,6 +143,16 @@ int testPOSI_NonPlayer()
|
||||
return basicPOSITest(drefs, 1);
|
||||
}
|
||||
|
||||
int testGetPOSI_Player()
|
||||
{
|
||||
float POSI[7] = { 37.524F, -122.06899F, 2500, 0, 0, 0, 1 };
|
||||
doGETPTest(POSI, 0, POSI);
|
||||
}
|
||||
|
||||
int testGetPOSI_NonPlayer()
|
||||
{
|
||||
float POSI[7] = { 37.624F, -122.06899F, 1500, 0, 0, 0, 1 };
|
||||
doGETPTest(POSI, 3, POSI);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -40,9 +40,13 @@ int main(int argc, const char * argv[])
|
||||
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)");
|
||||
// POSI
|
||||
runTest(testPOSI_Player, "POSI (player)");
|
||||
runTest(testPOSI_NonPlayer, "POSI (non-player)");
|
||||
runTest(testGetPOSI_Player, "GETP (player)");
|
||||
runTest(testGetPOSI_NonPlayer, "GETP (non-player)");
|
||||
// Data
|
||||
runTest(testDATA, "DATA");
|
||||
// Text
|
||||
|
||||
Reference in New Issue
Block a user