C/CPP Test Fixes
Fixed incorrect DREF for flaps. Fixed error where sendCTRL and sendPOSI were using abs instead of fabs.
This commit is contained in:
@@ -238,7 +238,7 @@ short sendCTRLTest() // sendCTRL test
|
|||||||
// Initialize
|
// Initialize
|
||||||
int i; // Iterator
|
int i; // Iterator
|
||||||
char DREFArray[100][100];
|
char DREFArray[100][100];
|
||||||
float CTRL[5] = {0.0};
|
float CTRL[6] = {0.0};
|
||||||
float *recDATA[100];
|
float *recDATA[100];
|
||||||
short DREFSizes[100];
|
short DREFSizes[100];
|
||||||
struct xpcSocket sendPort, recvPort;
|
struct xpcSocket sendPort, recvPort;
|
||||||
@@ -256,14 +256,16 @@ short sendCTRLTest() // sendCTRL test
|
|||||||
strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio");
|
strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio");
|
||||||
strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro");
|
strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro");
|
||||||
strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status");
|
strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status");
|
||||||
strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqsts");
|
strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqst");
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
DREFSizes[i] = (int)strlen(DREFArray[i]);
|
DREFSizes[i] = (int)strlen(DREFArray[i]);
|
||||||
}
|
}
|
||||||
CTRL[3] = 0.8; // Throttle
|
CTRL[3] = 0.8; // Throttle
|
||||||
|
CTRL[4] = 1; // Gear
|
||||||
|
CTRL[5] = 0.5; // Flaps
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
sendCTRL(sendPort, 4, CTRL);
|
sendCTRL(sendPort, 6, CTRL);
|
||||||
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
|
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
|
||||||
|
|
||||||
// Close
|
// Close
|
||||||
@@ -275,9 +277,9 @@ short sendCTRLTest() // sendCTRL test
|
|||||||
{
|
{
|
||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
for (i=0;i<6-1;i++)
|
for (i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
if (abs(recDATA[i][0]-CTRL[i])>1e-4)
|
if (fabs(recDATA[i][0]-CTRL[i])>1e-4)
|
||||||
{
|
{
|
||||||
return -i;
|
return -i;
|
||||||
}
|
}
|
||||||
@@ -343,7 +345,7 @@ short sendPOSITest() // sendPOSI test
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (abs(recDATA[i][0]-POSI[i])>1e-4)
|
if (fabs(recDATA[i][0]-POSI[i])>1e-4)
|
||||||
{
|
{
|
||||||
return -i;
|
return -i;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <cmath>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include "xplaneconnect.h"
|
#include "xplaneconnect.h"
|
||||||
@@ -237,7 +238,7 @@ void sendCTRLTest() // sendCTRL test
|
|||||||
// Initialize
|
// Initialize
|
||||||
int i; // Iterator
|
int i; // Iterator
|
||||||
char DREFArray[100][100];
|
char DREFArray[100][100];
|
||||||
float CTRL[5] = {0.0};
|
float CTRL[6] = {0.0};
|
||||||
float *recDATA[100];
|
float *recDATA[100];
|
||||||
short DREFSizes[100];
|
short DREFSizes[100];
|
||||||
struct xpcSocket sendPort, recvPort;
|
struct xpcSocket sendPort, recvPort;
|
||||||
@@ -255,14 +256,16 @@ void sendCTRLTest() // sendCTRL test
|
|||||||
strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio");
|
strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio");
|
||||||
strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro");
|
strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro");
|
||||||
strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status");
|
strcpy(DREFArray[4],"sim/cockpit/switches/gear_handle_status");
|
||||||
strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqsts");
|
strcpy(DREFArray[5],"sim/flightmodel/controls/flaprqst");
|
||||||
for (i = 0; i < 100; i++) {
|
for (i = 0; i < 100; i++) {
|
||||||
DREFSizes[i] = (int)strlen(DREFArray[i]);
|
DREFSizes[i] = (int)strlen(DREFArray[i]);
|
||||||
}
|
}
|
||||||
CTRL[3] = 0.8; // Throttle
|
CTRL[3] = 0.8; // Throttle
|
||||||
|
CTRL[4] = 1.0; // Gear
|
||||||
|
CTRL[5] = 0.5; // Flaps
|
||||||
|
|
||||||
// Execute
|
// Execute
|
||||||
sendCTRL(sendPort, 4, CTRL);
|
sendCTRL(sendPort, 6, CTRL);
|
||||||
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
|
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
|
||||||
|
|
||||||
// Close
|
// Close
|
||||||
@@ -274,9 +277,9 @@ void sendCTRLTest() // sendCTRL test
|
|||||||
{
|
{
|
||||||
throw -6;
|
throw -6;
|
||||||
}
|
}
|
||||||
for (i=0;i<6-1;i++)
|
for (i=0;i<6;i++)
|
||||||
{
|
{
|
||||||
if (abs(recDATA[i][0]-CTRL[i])>1e-4)
|
if (std::abs( recDATA[i][0]-CTRL[i])>1e-4)
|
||||||
{
|
{
|
||||||
throw -i;
|
throw -i;
|
||||||
}
|
}
|
||||||
@@ -340,7 +343,7 @@ void sendPOSITest() // sendPOSI test
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (abs(recDATA[i][0]-POSI[i])>1e-4)
|
if (std::abs(recDATA[i][0]-POSI[i])>1e-4)
|
||||||
{
|
{
|
||||||
throw -i;
|
throw -i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user