uncommented sendPOSITest

This commit is contained in:
Chris Teubert
2015-04-29 16:26:47 -07:00
committed by Jason Watkins
parent 93c54e315a
commit 644dc8c5eb

View File

@@ -657,143 +657,147 @@ int psendPOSITest() // sendPOSI test
return 0; return 0;
} }
//int sendPOSITest() // sendPOSI test int sendPOSITest() // sendPOSI test
//{ {
// // Initialization // Initialization
// int i; // Iterator int i; // Iterator
// char* drefs[100] = char* drefs[100] =
// { {
// // TODO: Can't get global position for multiplayer a/c? // TODO: Can't get global position for multiplayer a/c?
// "sim/flightmodel/position/plane1_latitude", "sim/multiplayer/position/plane1_lat",
// "sim/flightmodel/position/plane1_longitude", "sim/multiplayer/position/plane1_lon",
// "sim/flightmodel/position/plane1_y_agl", "sim/multiplayer/position/plane1_el",
// "sim/multiplayer/position/plane1_phi", "sim/multiplayer/position/plane1_phi",
// "sim/multiplayer/position/plane1_the", "sim/multiplayer/position/plane1_the",
// "sim/multiplayer/position/plane1_psi", "sim/multiplayer/position/plane1_psi",
// "sim/multiplayer/position/plane1_gear_deploy" "sim/multiplayer/position/plane1_gear_deploy"
// }; };
// float* data[100]; float* data[100];
// int sizes[100]; int sizes[100];
// float POSI[7] = { 37.524F, -122.06899F, 2500, 0, 0, 0, 1 }; float POSI[7] = { 37.524F, -122.06899F, 2500, 0, 0, 0, 1 };
// XPCSocket sock = openUDP(IP); XPCSocket sock = openUDP(IP);
//
// // Setup // Setup
// for (i = 0; i < 100; i++) for (i = 0; i < 100; i++)
// { {
// data[i] = (float*)malloc(40 * sizeof(float)); data[i] = (float*)malloc(40 * sizeof(float));
// sizes[i] = 40; sizes[i] = 40;
// } }
//
// // Execution 1 // Execution 1
// pauseSim(sock, 1); pauseSim(sock, 1);
// sendPOSI(sock, POSI, 7, 0); sendPOSI(sock, POSI, 7, 1);
// int result = getDREFs(sock, drefs, data, 7, sizes); int result = getDREFs(sock, drefs, data, 7, sizes);
// pauseSim(sock, 0); pauseSim(sock, 0);
//
// // Close // Close
// closeUDP(sock); closeUDP(sock);
//
// // Tests // Tests
// if (result < 0) if (result < 0)
// { {
// return -1; return -1;
// } }
// for (i = 0; i < 7; ++i) for (i = 0; i < 7; ++i)
// { {
// if (fabs(data[i][0] - POSI[i]) > 1e-4) if (fabs(data[i][0] - POSI[i]) > 1e-4)
// { {
// return -i - 11; return -i - 11;
// } }
// } }
//
// // Setup 2 // Setup 2
// sock = openUDP("localhost"); sock = openUDP(IP);
// POSI[0] = -998.0F; POSI[0] = -998.0F;
// POSI[1] = -998.0F; POSI[1] = -998.0F;
// POSI[2] = -998.0F; POSI[2] = -998.0F;
// POSI[3] = 5.0F; POSI[3] = 5.0F;
// POSI[4] = -5.0F; POSI[4] = -5.0F;
// POSI[5] = 10.0F; POSI[5] = 10.0F;
// POSI[6] = 0; POSI[6] = 0;
//
// // Execution 2 // Execution 2
// pauseSim(sock, 1); pauseSim(sock, 1);
// float loc[3]; float* loc[3];
// getDREFs(sock, drefs, loc, 3, sizes); for(int i = 0; i < 3; ++i)
// sendPOSI(sock, POSI, 7, 0); {
// int result = getDREFs(sock, drefs, data, 7, sizes); loc[i] = (float*)malloc(sizeof(float));
// pauseSim(sock, 0); }
// getDREFs(sock, drefs, loc, 3, sizes);
// // Close sendPOSI(sock, POSI, 7, 1);
// closeUDP(sock); result = getDREFs(sock, drefs, data, 7, sizes);
// pauseSim(sock, 0);
// // Tests
// if (result < 0) // Close
// { closeUDP(sock);
// return -2;
// } // Tests
// // Compare position to make sure they weren't set if (result < 0)
// for (int i = 0; i < 3; ++i) {
// { return -2;
// // Note: Because the sim was paused when both of these were read, we really do expect *exactly* }
// // the same value even though we are comparing floats. // Compare position to make sure they weren't set
// if (data[i][0] != loc[i]) for (int i = 0; i < 3; ++i)
// { {
// return -i - 21; // Note: Because the sim was paused when both of these were read, we really do expect *exactly*
// } // the same value even though we are comparing floats.
// } if (data[i][0] != loc[i][0])
// // Compare everything else. {
// for (i = 3; i < 7; ++i) return -i - 21;
// { }
// if (fabs(data[i][0] - POSI[i]) > 1e-4) }
// { // Compare everything else.
// return -i - 21; for (i = 3; i < 7; ++i)
// } {
// } if (fabs(data[i][0] - POSI[i]) > 1e-4)
// {
// // Setup 3 return -i - 21;
// sock = openUDP("localhost"); }
// POSI[0] = 37.524F; }
// POSI[1] = -122.06899;
// POSI[2] = 20000; // Setup 3
// POSI[3] = 15.0F; sock = openUDP(IP);
// POSI[4] = -25.0F; POSI[0] = 37.524F;
// POSI[5] = -10.0F; POSI[1] = -122.06899;
// POSI[6] = 1; POSI[2] = 20000;
// POSI[3] = 15.0F;
// // Execution 2 POSI[4] = -25.0F;
// pauseSim(sock, 1); POSI[5] = -10.0F;
// sendPOSI(sock, POSI, 3, 0); POSI[6] = 1;
// int result = getDREFs(sock, drefs, data, 7, sizes);
// pauseSim(sock, 0); // Execution 2
// pauseSim(sock, 1);
// // Close sendPOSI(sock, POSI, 3, 1);
// closeUDP(sock); result = getDREFs(sock, drefs, data, 7, sizes);
// pauseSim(sock, 0);
// // Tests
// if (result < 0) // Close
// { closeUDP(sock);
// return -3;
// } // Tests
// // Compare position to make sure it was set. if (result < 0)
// for (int i = 0; i < 3; ++i) {
// { return -3;
// if (fabs(data[i][0] - POSI[i]) > 1e-4) }
// { // Compare position to make sure it was set.
// return -i - 31; for (int i = 0; i < 3; ++i)
// } {
// } if (fabs(data[i][0] - POSI[i]) > 1e-4)
// // Compare everything else to make sure it *wasn't*. {
// for (i = 3; i < 7; ++i) return -i - 31;
// { }
// if (fabs(data[i][0] - POSI[i]) < 1) }
// { // Compare everything else to make sure it *wasn't*.
// return -i - 31; for (i = 3; i < 7; ++i)
// } {
// } if (fabs(data[i][0] - POSI[i]) < 1)
// {
// return 0; return -i - 31;
//} }
}
return 0;
}
int sendWYPTTest() int sendWYPTTest()
{ {
@@ -943,7 +947,7 @@ int main(int argc, const char * argv[])
runTest(sendDATATest, "DATA"); runTest(sendDATATest, "DATA");
runTest(sendCTRLTest, "CTRL"); runTest(sendCTRLTest, "CTRL");
runTest(psendCTRLTest, "CTRL (player)"); runTest(psendCTRLTest, "CTRL (player)");
//runTest(sendPOSITest, "POSI"); runTest(sendPOSITest, "POSI");
runTest(psendPOSITest, "POSI (player)"); runTest(psendPOSITest, "POSI (player)");
runTest(sendWYPTTest, "WYPT"); runTest(sendWYPTTest, "WYPT");
runTest(sendTEXTTest, "TEXT"); runTest(sendTEXTTest, "TEXT");