Renamed "setDREF" function back to "sendDREF".

This commit is contained in:
Jason Watkins
2015-04-27 10:02:31 -07:00
parent 22a2adf5f2
commit 8932edbd67
11 changed files with 19 additions and 19 deletions

View File

@@ -362,7 +362,7 @@ int readDATA(XPCSocket sock, float data[][9], int rows)
/*****************************************************************************/ /*****************************************************************************/
/**** DREF functions ****/ /**** 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 // Setup command
// 5 byte header + max 255 char dref name + max 255 values * 4 bytes per value = 1279 // 5 byte header + max 255 char dref name + max 255 values * 4 bytes per value = 1279

View File

@@ -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 values An array of values representing the data to set.
/// \param size The number of elements in values. /// \param size The number of elements in values.
/// \returns 0 if successful, otherwise a negative value. /// \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. /// Gets the value of the specified dataref.
/// ///

View File

@@ -93,7 +93,7 @@ int main()
const char* dref = "sim/cockpit/switches/gear_handle_status"; // Gear handle data reference const char* dref = "sim/cockpit/switches/gear_handle_status"; // Gear handle data reference
float gear = 0; // Stow gear 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 // Simulate for 10 seconds
sleep(10); sleep(10);

View File

@@ -71,7 +71,7 @@ public class Main
try { Thread.sleep(10000); } catch (InterruptedException ex) {} try { Thread.sleep(10000); } catch (InterruptedException ex) {}
System.out.println("Stowing landing gear"); 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 //Let sim run for 10 seconds
try { Thread.sleep(10000); } catch (InterruptedException ex) {} try { Thread.sleep(10000); } catch (InterruptedException ex) {}

View File

@@ -306,9 +306,9 @@ public class XPlaneConnect implements AutoCloseable
throw new IOException("No response received."); 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. * @param value An array of floating point values whose structure depends on the dref specified.
* @throws IOException If the command cannot be sent. * @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 //Preconditions
if(dref == null) if(dref == null)

View File

@@ -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. % sendDREF Sends a command to X-Plane that sets the given DREF.
% %
% Inputs % Inputs

View File

@@ -150,7 +150,7 @@ int sendDREFTest() // sendDREF test
} }
// Execution // Execution
setDREF(sock, drefs[0], &value, 1); sendDREF(sock, drefs[0], &value, 1);
int result = getDREFs(sock, drefs, data, 1, sizes); int result = getDREFs(sock, drefs, data, 1, sizes);
// Close // Close

View File

@@ -308,7 +308,7 @@ public class XPlaneConnectTest
float gearHandle = xpc.getDREF(dref)[0]; float gearHandle = xpc.getDREF(dref)[0];
float value = gearHandle > 0.5 ? 0 : 1; float value = gearHandle > 0.5 ? 0 : 1;
xpc.setDREF(dref, value); xpc.sendDREF(dref, value);
float result = xpc.getDREF(dref)[0]; float result = xpc.getDREF(dref)[0];
assertEquals(value, result, 1e-4); assertEquals(value, result, 1e-4);
@@ -320,7 +320,7 @@ public class XPlaneConnectTest
{ {
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(null, 0); xpc.sendDREF(null, 0);
fail(); fail();
} }
} }
@@ -332,7 +332,7 @@ public class XPlaneConnectTest
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, null); xpc.sendDREF(dref, null);
fail(); fail();
} }
} }
@@ -343,7 +343,7 @@ public class XPlaneConnectTest
String dref = "sim/cockpit/switches/gear_handle_status"; String dref = "sim/cockpit/switches/gear_handle_status";
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, new float[0]); xpc.sendDREF(dref, new float[0]);
fail(); fail();
} }
} }
@@ -358,7 +358,7 @@ public class XPlaneConnectTest
String dref = "sim/cockpit/switches/gear_handle_status"; String dref = "sim/cockpit/switches/gear_handle_status";
try(XPlaneConnect xpc = new XPlaneConnect()) 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"; 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()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, 0); xpc.sendDREF(dref, 0);
fail(); fail();
} }
} }
@@ -379,7 +379,7 @@ public class XPlaneConnectTest
String dref = ""; String dref = "";
try(XPlaneConnect xpc = new XPlaneConnect()) try(XPlaneConnect xpc = new XPlaneConnect())
{ {
xpc.setDREF(dref, 0); xpc.sendDREF(dref, 0);
fail(); fail();
} }
} }

View File

@@ -1,4 +1,4 @@
function setDREFTest( ) function sendDREFTest( )
%SENDREADTEST Summary of this function goes here %SENDREADTEST Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
addpath('../../MATLAB') addpath('../../MATLAB')
@@ -7,7 +7,7 @@ import XPlaneConnect.*
DREFS = {'sim/cockpit/switches/gear_handle_status'}; DREFS = {'sim/cockpit/switches/gear_handle_status'};
value = randi([0 10]); value = randi([0 10]);
setDREF(DREFS{1},value); sendDREF(DREFS{1},value);
result = getDREFs(DREFS); result = getDREFs(DREFS);
assert(isequal(length(result),1),'setDREFTest: requestDREF unsucessful-wrong number of elements returned'); assert(isequal(length(result),1),'setDREFTest: requestDREF unsucessful-wrong number of elements returned');

View File

@@ -13,7 +13,7 @@ disp(['XPC Tests-MATLAB (', os, ')']);
theTests = {{@openCloseTest, 'Open/Close Test', 0},... theTests = {{@openCloseTest, 'Open/Close Test', 0},...
{@sendTEXTTest,'TEXT Test', 0},... {@sendTEXTTest,'TEXT Test', 0},...
{@getDREFsTest,'Request DREF Test', 0},... {@getDREFsTest,'Request DREF Test', 0},...
{@setDREFTest,'Send DREF Test', 0},... {@sendDREFTest,'Send DREF Test', 0},...
{@DATATest,'DATA Test', 0},... {@DATATest,'DATA Test', 0},...
{@CTRLTest,'CTRL Test', 0},... {@CTRLTest,'CTRL Test', 0},...
{@POSITest,'POSI Test', 0},... {@POSITest,'POSI Test', 0},...