// Copyright (c) 2013 by István Váradi // This file is part of XPLRA, a remote-access plugin for X-Plane // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // 1. Redistributions of source code must retain the above copyright notice, this // list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // The views and conclusions contained in the software and documentation are those // of the authors and should not be interpreted as representing official policies, // either expressed or implied, of the FreeBSD Project. //------------------------------------------------------------------------------ #include #include "ccommon.h" #include #include #include //------------------------------------------------------------------------------ int main(int argc, char* argv[]) { int retval = 0; const char* errorString; int i; int connectionID = -1; int setterID = -1; size_t simSpeedID = INVALID_DATAREF_ID; size_t zuluSecID = INVALID_DATAREF_ID; size_t localXID = INVALID_DATAREF_ID; size_t tailNumID = INVALID_DATAREF_ID; size_t generatorOnID = INVALID_DATAREF_ID; size_t propPitchID = INVALID_DATAREF_ID; int32_t generatorOn[8] = { 1, 0, 1, 0, 1, 0, 1, 0 }; float propPitch[2] = { 32.4, 78.2 }; int dontregister = 0; for(i = 1; i=0) { printf("Connected to X-Plane.\n\n"); } else { printf("Connection failed.\n\n"); goto cleanup; } setterID = xplra_multi_create_setter(connectionID); if (setterID<0) goto error; simSpeedID = xplra_multi_add_int(setterID, "sim/time/sim_speed"); zuluSecID = xplra_multi_add_float(setterID, "sim/time/zulu_time_sec"); localXID = xplra_multi_add_double(setterID, "sim/flightmodel/position/local_x"); tailNumID = xplra_multi_add_byte_array(setterID, "sim/aircraft/view/acf_tailnum", 40, 0); generatorOnID = xplra_multi_add_int_array(setterID, "sim/cockpit/electrical/generator_on", 8, 0); propPitchID = xplra_multi_add_float_array(setterID, "sim/cockpit2/engine/actuators/prop_pitch_deg", 2, 0); if (dontregister) { xplra_multi_finalize(setterID); } else { printf("Registering getter...\n"); if (xplra_multi_register(setterID)<0) goto error; printf("Registered getter.\n\n"); } printf("Setting values...\n"); xplra_multi_set_int(setterID, simSpeedID, 0); xplra_multi_set_float(setterID, zuluSecID, 7265.0); xplra_multi_set_double(setterID, localXID, 12.0); xplra_multi_set_string(setterID, tailNumID, "Kukutyin", 0); xplra_multi_set_int_array(setterID, generatorOnID, generatorOn, 8, 0); xplra_multi_set_float_array(setterID, propPitchID, propPitch, 2, 0); printf("Executing...\n"); if (xplra_multi_execute(setterID)<0) goto error; printf("Done.\n"); goto cleanup; error: errorString = xplra_get_last_error_string(connectionID); if (errorString==0) { printf("\nUnknown error occured!\n"); } else { printf("\nError: %s\n", errorString); } retval = 1; cleanup: if (connectionID>=0) xplra_disconnect(connectionID); return retval; } //------------------------------------------------------------------------------ // Local Variables: // mode: C++ // c-basic-offset: 4 // indent-tabs-mode: nil // End: