Renamed "setDREF" function back to "sendDREF".
This commit is contained in:
@@ -362,7 +362,7 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
|
||||
/*****************************************************************************/
|
||||
/**** DREF functions ****/
|
||||
/*****************************************************************************/
|
||||
int setDREF(XPCSocket sock, const char* dref, float value[], int size)
|
||||
int sendDREF(XPCSocket sock, const char* dref, float value[], int size)
|
||||
{
|
||||
// Setup command
|
||||
// 5 byte header + max 255 char dref name + max 255 values * 4 bytes per value = 1279
|
||||
|
||||
@@ -133,7 +133,7 @@ int sendDATA(XPCSocket sock, float data[][9], int rows);
|
||||
/// \param values An array of values representing the data to set.
|
||||
/// \param size The number of elements in values.
|
||||
/// \returns 0 if successful, otherwise a negative value.
|
||||
int setDREF(XPCSocket sock, const char* dref, float value[], int size);
|
||||
int sendDREF(XPCSocket sock, const char* dref, float value[], int size);
|
||||
|
||||
/// Gets the value of the specified dataref.
|
||||
///
|
||||
|
||||
@@ -93,7 +93,7 @@ int main()
|
||||
|
||||
const char* dref = "sim/cockpit/switches/gear_handle_status"; // Gear handle data reference
|
||||
float gear = 0; // Stow gear
|
||||
setDREF(sock, dref, &gear, 1); // Set gear to stow
|
||||
sendDREF(sock, dref, &gear, 1); // Set gear to stow
|
||||
|
||||
// Simulate for 10 seconds
|
||||
sleep(10);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Main
|
||||
try { Thread.sleep(10000); } catch (InterruptedException ex) {}
|
||||
|
||||
System.out.println("Stowing landing gear");
|
||||
xpc.setDREF("sim/cockpit/switches/gear_handle_status", 1);
|
||||
xpc.sendDREF("sim/cockpit/switches/gear_handle_status", 1);
|
||||
|
||||
//Let sim run for 10 seconds
|
||||
try { Thread.sleep(10000); } catch (InterruptedException ex) {}
|
||||
|
||||
@@ -306,9 +306,9 @@ public class XPlaneConnect implements AutoCloseable
|
||||
throw new IOException("No response received.");
|
||||
}
|
||||
|
||||
public void setDREF(String dref, float value) throws IOException
|
||||
public void sendDREF(String dref, float value) throws IOException
|
||||
{
|
||||
setDREF(dref, new float[] {value});
|
||||
sendDREF(dref, new float[] {value});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ public class XPlaneConnect implements AutoCloseable
|
||||
* @param value An array of floating point values whose structure depends on the dref specified.
|
||||
* @throws IOException If the command cannot be sent.
|
||||
*/
|
||||
public void setDREF(String dref, float[] value) throws IOException
|
||||
public void sendDREF(String dref, float[] value) throws IOException
|
||||
{
|
||||
//Preconditions
|
||||
if(dref == null)
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
function setDREF( dref, value, socket )
|
||||
function sendDREF( dref, value, socket )
|
||||
% sendDREF Sends a command to X-Plane that sets the given DREF.
|
||||
%
|
||||
% Inputs
|
||||
@@ -150,7 +150,7 @@ int sendDREFTest() // sendDREF test
|
||||
}
|
||||
|
||||
// Execution
|
||||
setDREF(sock, drefs[0], &value, 1);
|
||||
sendDREF(sock, drefs[0], &value, 1);
|
||||
int result = getDREFs(sock, drefs, data, 1, sizes);
|
||||
|
||||
// Close
|
||||
|
||||
@@ -308,7 +308,7 @@ public class XPlaneConnectTest
|
||||
float gearHandle = xpc.getDREF(dref)[0];
|
||||
|
||||
float value = gearHandle > 0.5 ? 0 : 1;
|
||||
xpc.setDREF(dref, value);
|
||||
xpc.sendDREF(dref, value);
|
||||
|
||||
float result = xpc.getDREF(dref)[0];
|
||||
assertEquals(value, result, 1e-4);
|
||||
@@ -320,7 +320,7 @@ public class XPlaneConnectTest
|
||||
{
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
xpc.setDREF(null, 0);
|
||||
xpc.sendDREF(null, 0);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
@@ -332,7 +332,7 @@ public class XPlaneConnectTest
|
||||
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
xpc.setDREF(dref, null);
|
||||
xpc.sendDREF(dref, null);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
@@ -343,7 +343,7 @@ public class XPlaneConnectTest
|
||||
String dref = "sim/cockpit/switches/gear_handle_status";
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
xpc.setDREF(dref, new float[0]);
|
||||
xpc.sendDREF(dref, new float[0]);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class XPlaneConnectTest
|
||||
String dref = "sim/cockpit/switches/gear_handle_status";
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
xpc.setDREF(dref, new float[200]);
|
||||
xpc.sendDREF(dref, new float[200]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ public class XPlaneConnectTest
|
||||
String dref = "sim/cockpit/switches/i/am/a/very/long/fake/dref/that/is/over/255/characters/./which/means/that/my/length/cant/be/encoded/in/the/single/byte/allocated/by/the/message/format/,/so/i/should/cause/an/exception/instead/./i/am/still/not/long/enough/./almost/there";
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
xpc.setDREF(dref, 0);
|
||||
xpc.sendDREF(dref, 0);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
@@ -379,7 +379,7 @@ public class XPlaneConnectTest
|
||||
String dref = "";
|
||||
try(XPlaneConnect xpc = new XPlaneConnect())
|
||||
{
|
||||
xpc.setDREF(dref, 0);
|
||||
xpc.sendDREF(dref, 0);
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
function setDREFTest( )
|
||||
function sendDREFTest( )
|
||||
%SENDREADTEST Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
addpath('../../MATLAB')
|
||||
@@ -7,7 +7,7 @@ import XPlaneConnect.*
|
||||
DREFS = {'sim/cockpit/switches/gear_handle_status'};
|
||||
value = randi([0 10]);
|
||||
|
||||
setDREF(DREFS{1},value);
|
||||
sendDREF(DREFS{1},value);
|
||||
result = getDREFs(DREFS);
|
||||
|
||||
assert(isequal(length(result),1),'setDREFTest: requestDREF unsucessful-wrong number of elements returned');
|
||||
@@ -13,7 +13,7 @@ disp(['XPC Tests-MATLAB (', os, ')']);
|
||||
theTests = {{@openCloseTest, 'Open/Close Test', 0},...
|
||||
{@sendTEXTTest,'TEXT Test', 0},...
|
||||
{@getDREFsTest,'Request DREF Test', 0},...
|
||||
{@setDREFTest,'Send DREF Test', 0},...
|
||||
{@sendDREFTest,'Send DREF Test', 0},...
|
||||
{@DATATest,'DATA Test', 0},...
|
||||
{@CTRLTest,'CTRL Test', 0},...
|
||||
{@POSITest,'POSI Test', 0},...
|
||||
|
||||
Reference in New Issue
Block a user