@@ -373,7 +373,7 @@ short sendPOSI(struct xpcSocket recfd, short ACNum, short numArgs, float valueAr
|
||||
|
||||
short sendCTRL(struct xpcSocket recfd, short numArgs, float valueArray[])
|
||||
{
|
||||
char message[29] = {0};
|
||||
char message[26] = {0};
|
||||
int i;
|
||||
short position = 5;
|
||||
|
||||
@@ -396,12 +396,21 @@ short sendCTRL(struct xpcSocket recfd, short numArgs, float valueArray[])
|
||||
val = valueArray[i];
|
||||
}
|
||||
|
||||
// Float Values
|
||||
memcpy(&message[position],&val,sizeof(float));
|
||||
position += sizeof(float);
|
||||
if (i==4) // Integer-gear
|
||||
{
|
||||
message[position] = (short int) val;
|
||||
position += 1;
|
||||
}
|
||||
else // float
|
||||
{
|
||||
// Float Values
|
||||
memcpy(&message[position],&val,sizeof(float));
|
||||
position += sizeof(float);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sendUDP(recfd, message, 29);
|
||||
sendUDP(recfd, message, 26);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ short sendCTRLTest() // sendCTRL test
|
||||
// Initialize
|
||||
int i; // Iterator
|
||||
char DREFArray[100][100];
|
||||
float CTRL[5] = {0.0};
|
||||
float CTRL[6] = {0.0};
|
||||
float *recDATA[100];
|
||||
short DREFSizes[100];
|
||||
struct xpcSocket sendPort, recvPort;
|
||||
@@ -256,14 +256,16 @@ short sendCTRLTest() // sendCTRL test
|
||||
strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio");
|
||||
strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro");
|
||||
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++) {
|
||||
DREFSizes[i] = (int)strlen(DREFArray[i]);
|
||||
}
|
||||
CTRL[3] = 0.8; // Throttle
|
||||
CTRL[4] = 1; // Gear
|
||||
CTRL[5] = 0.5; // Flaps
|
||||
|
||||
// Execute
|
||||
sendCTRL(sendPort, 4, CTRL);
|
||||
sendCTRL(sendPort, 6, CTRL);
|
||||
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
|
||||
|
||||
// Close
|
||||
@@ -275,9 +277,9 @@ short sendCTRLTest() // sendCTRL test
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -343,7 +345,7 @@ short sendPOSITest() // sendPOSI test
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (abs(recDATA[i][0]-POSI[i])>1e-4)
|
||||
if (fabs(recDATA[i][0]-POSI[i])>1e-4)
|
||||
{
|
||||
return -i;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cmath>
|
||||
#include <time.h>
|
||||
#include <exception>
|
||||
#include "xplaneconnect.h"
|
||||
@@ -237,7 +238,7 @@ void sendCTRLTest() // sendCTRL test
|
||||
// Initialize
|
||||
int i; // Iterator
|
||||
char DREFArray[100][100];
|
||||
float CTRL[5] = {0.0};
|
||||
float CTRL[6] = {0.0};
|
||||
float *recDATA[100];
|
||||
short DREFSizes[100];
|
||||
struct xpcSocket sendPort, recvPort;
|
||||
@@ -255,14 +256,16 @@ void sendCTRLTest() // sendCTRL test
|
||||
strcpy(DREFArray[2],"sim/cockpit2/controls/yoke_heading_ratio");
|
||||
strcpy(DREFArray[3],"sim/flightmodel/engine/ENGN_thro");
|
||||
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++) {
|
||||
DREFSizes[i] = (int)strlen(DREFArray[i]);
|
||||
}
|
||||
CTRL[3] = 0.8; // Throttle
|
||||
CTRL[4] = 1.0; // Gear
|
||||
CTRL[5] = 0.5; // Flaps
|
||||
|
||||
// Execute
|
||||
sendCTRL(sendPort, 4, CTRL);
|
||||
sendCTRL(sendPort, 6, CTRL);
|
||||
result = requestDREF(sendPort, recvPort, DREFArray, DREFSizes, 6, recDATA, DREFSizes); // Test
|
||||
|
||||
// Close
|
||||
@@ -274,9 +277,9 @@ void sendCTRLTest() // sendCTRL test
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -340,7 +343,7 @@ void sendPOSITest() // sendPOSI test
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (abs(recDATA[i][0]-POSI[i])>1e-4)
|
||||
if (std::abs(recDATA[i][0]-POSI[i])>1e-4)
|
||||
{
|
||||
throw -i;
|
||||
}
|
||||
|
||||
@@ -755,7 +755,7 @@ int handleCTRL(char buf[])
|
||||
{
|
||||
setGEAR(0, gear, 0); // Gear
|
||||
}
|
||||
if ( flaps > -999.5 && flaps < -997.5 ) // Flaps
|
||||
if ( flaps < -999.5 || flaps > -997.5 ) // Flaps
|
||||
{
|
||||
XPLMSetDataf(XPLMDataRefs[13][3],flaps);
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
xpcPlugin/XPlaneConnect/mac.xpl
Normal file → Executable file
BIN
xpcPlugin/XPlaneConnect/mac.xpl
Normal file → Executable file
Binary file not shown.
Binary file not shown.
@@ -9,7 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
BE37D960187C8B0F0033B082 /* XPCPlugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE37D95E187C8B0F0033B082 /* XPCPlugin.cpp */; };
|
||||
BE5F2FF118FCA1D500AFCD17 /* xpcPluginTools.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */; };
|
||||
BE8361EF18C5591C00E9C923 /* xpcPlugin.xpl in CopyFiles */ = {isa = PBXBuildFile; fileRef = D607B19909A556E400699BC3 /* xpcPlugin.xpl */; };
|
||||
BE8361EF18C5591C00E9C923 /* mac.xpl in CopyFiles */ = {isa = PBXBuildFile; fileRef = D607B19909A556E400699BC3 /* mac.xpl */; };
|
||||
BEDC620418EDF1A7005DB364 /* xplaneConnect.c in Sources */ = {isa = PBXBuildFile; fileRef = BEDC620218EDF1A7005DB364 /* xplaneConnect.c */; };
|
||||
D6A7BDAA16A1DEA200D1426A /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDA916A1DEA200D1426A /* OpenGL.framework */; };
|
||||
D6A7BDC116A1DEC000D1426A /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6A7BDC016A1DEC000D1426A /* CoreFoundation.framework */; };
|
||||
@@ -21,10 +21,10 @@
|
||||
BE8361EE18C5591600E9C923 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 12;
|
||||
dstPath = "/Applications/X-Plane 10/Resources/plugins";
|
||||
dstPath = "/Applications/X-Plane 10/Resources/plugins/XPlaneConnect";
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
BE8361EF18C5591C00E9C923 /* xpcPlugin.xpl in CopyFiles */,
|
||||
BE8361EF18C5591C00E9C923 /* mac.xpl in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -37,7 +37,7 @@
|
||||
BE5F2FF018FCA1D500AFCD17 /* xpcPluginTools.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xpcPluginTools.cpp; sourceTree = "<group>"; };
|
||||
BEDC620218EDF1A7005DB364 /* xplaneConnect.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = xplaneConnect.c; path = ../C/src/xplaneConnect.c; sourceTree = "<group>"; };
|
||||
BEDC620318EDF1A7005DB364 /* xplaneConnect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xplaneConnect.h; path = ../C/src/xplaneConnect.h; sourceTree = "<group>"; };
|
||||
D607B19909A556E400699BC3 /* xpcPlugin.xpl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = xpcPlugin.xpl; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D607B19909A556E400699BC3 /* mac.xpl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = mac.xpl; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
D6A7BDA916A1DEA200D1426A /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; };
|
||||
D6A7BDC016A1DEC000D1426A /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
D6A7BDF016A1DED200D1426A /* XPLM.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XPLM.framework; path = SDK/Libraries/Mac/XPLM.framework; sourceTree = "<group>"; };
|
||||
@@ -84,7 +84,7 @@
|
||||
D607B19A09A556E400699BC3 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D607B19909A556E400699BC3 /* xpcPlugin.xpl */,
|
||||
D607B19909A556E400699BC3 /* mac.xpl */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -117,7 +117,7 @@
|
||||
);
|
||||
name = xpcPlugin;
|
||||
productName = StarterPlugin;
|
||||
productReference = D607B19909A556E400699BC3 /* xpcPlugin.xpl */;
|
||||
productReference = D607B19909A556E400699BC3 /* mac.xpl */;
|
||||
productType = "com.apple.product-type.library.dynamic";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
@@ -165,7 +165,7 @@
|
||||
D607B16309A5563100699BC3 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CONFIGURATION_BUILD_DIR = ./Mac;
|
||||
CONFIGURATION_BUILD_DIR = ./XPlaneConnect;
|
||||
DYLIB_COMPATIBILITY_VERSION = "";
|
||||
DYLIB_CURRENT_VERSION = "";
|
||||
EXECUTABLE_EXTENSION = xpl;
|
||||
@@ -284,7 +284,7 @@
|
||||
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/xplaneConnect-asdjuezcjkhojuewbyxhyhabxfwc/Build/Products/Debug",
|
||||
);
|
||||
MACH_O_TYPE = mh_bundle;
|
||||
PRODUCT_NAME = xpcPlugin;
|
||||
PRODUCT_NAME = mac;
|
||||
STRIP_INSTALLED_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = XPC;
|
||||
@@ -322,7 +322,7 @@
|
||||
"$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/xplaneConnect-asdjuezcjkhojuewbyxhyhabxfwc/Build/Products/Debug",
|
||||
);
|
||||
MACH_O_TYPE = mh_bundle;
|
||||
PRODUCT_NAME = xpcPlugin;
|
||||
PRODUCT_NAME = mac;
|
||||
STRIP_INSTALLED_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = XPC;
|
||||
|
||||
Reference in New Issue
Block a user