Updated C client to support "switch" argument in SIMU command.
This commit is contained in:
@@ -264,9 +264,17 @@ int setCONN(XPCSocket* sock, unsigned short port)
|
|||||||
|
|
||||||
int pauseSim(XPCSocket sock, char pause)
|
int pauseSim(XPCSocket sock, char pause)
|
||||||
{
|
{
|
||||||
|
// Validte input
|
||||||
|
if (pause < 0 || pause > 2)
|
||||||
|
{
|
||||||
|
printError("pauseSim", "Invalid argument: %i", pause);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup command
|
// Setup command
|
||||||
char buffer[6] = "SIMU";
|
char buffer[6] = "SIMU";
|
||||||
buffer[5] = pause == 0 ? 0 : 1;
|
buffer[5] = pause;
|
||||||
|
|
||||||
// Send command
|
// Send command
|
||||||
if (sendUDP(sock, buffer, 6) < 0)
|
if (sendUDP(sock, buffer, 6) < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -833,56 +833,63 @@ int sendWYPTTest()
|
|||||||
|
|
||||||
int pauseTest() // pauseSim test
|
int pauseTest() // pauseSim test
|
||||||
{
|
{
|
||||||
// Initialize
|
// Setup
|
||||||
// Note: Always run this test to the end so that the sim ends up unpaused in the
|
// Note: Always run this test to the end so that the sim ends up unpaused in the
|
||||||
// case where commands are working but reading results isn't.
|
// case where commands are working but reading results isn't.
|
||||||
int result = 0;
|
int result = 0;
|
||||||
char* drefs[100] =
|
char* dref = "sim/operation/override/override_planepath";
|
||||||
{
|
int size = 20;
|
||||||
"sim/operation/override/override_planepath"
|
float data[20];
|
||||||
};
|
|
||||||
float* data[100];
|
|
||||||
int sizes[100];
|
|
||||||
XPCSocket sock = openUDP(IP);
|
XPCSocket sock = openUDP(IP);
|
||||||
|
|
||||||
// Setup
|
|
||||||
for (int i = 0; i < 100; i++)
|
|
||||||
{
|
|
||||||
data[i] = (float*)malloc(40 * sizeof(float));
|
|
||||||
sizes[i] = 40;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
pauseSim(sock, 1);
|
pauseSim(sock, 0);
|
||||||
result = getDREF(sock, drefs[0], data[0], sizes);
|
result = getDREF(sock, dref, data, &size);
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
result = -1;
|
result = -1;
|
||||||
}
|
}
|
||||||
if (data[0][0] != 1)
|
else if (data[0] != 0)
|
||||||
{
|
{
|
||||||
result = -2;
|
result = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
// Execute 2
|
// Execute 2
|
||||||
pauseSim(sock, 0);
|
pauseSim(sock, 2);
|
||||||
result = getDREF(sock, drefs[0], data[0], sizes);
|
result = getDREF(sock, dref, data, &size);
|
||||||
|
|
||||||
// Test 2
|
// Test 2
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
{
|
||||||
result = -3;
|
result = -3;
|
||||||
}
|
}
|
||||||
if (data[0][0] != 0)
|
else if (data[0] != 1)
|
||||||
{
|
{
|
||||||
result = -4;
|
result = -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
// Execute 3
|
||||||
|
pauseSim(sock, 0);
|
||||||
|
result = getDREF(sock, dref, data, &size);
|
||||||
|
|
||||||
|
// Test 2
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
result = -5;
|
||||||
|
}
|
||||||
|
else if (data[0] != 0)
|
||||||
|
{
|
||||||
|
result = -6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Close
|
// Close
|
||||||
closeUDP(sock);
|
closeUDP(sock);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user