Changeset 18:c957b01ca44c in xplra for test
- Timestamp:
- 01/31/13 18:44:47 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/basictest.cc
r17 r18 32 32 33 33 #include <cstdio> 34 #include <cstring> 34 35 35 36 //------------------------------------------------------------------------------ … … 145 146 printf("The aircraft elevator up control set to %f\n\n", acfElevUp); 146 147 147 double acfElevDown = xplane.getDouble("sim/flightmodel/position/local_x"); 148 printf("Setting the aircraft elevator down control from %f to %f...\n", 149 acfElevDown, acfElevDown + 15.0); 150 xplane.setDouble("sim/flightmodel/position/local_x", acfElevDown + 15.0); 151 acfElevDown = xplane.getDouble("sim/flightmodel/position/local_x"); 152 printf("The aircraft elevator down control set to %f\n\n", acfElevDown); 148 double localX = xplane.getDouble("sim/flightmodel/position/local_x"); 149 printf("Setting the aircraft's local X-coordinate from %f to %f...\n", 150 localX, localX + 15.0); 151 xplane.setDouble("sim/flightmodel/position/local_x", localX + 15.0); 152 localX = xplane.getDouble("sim/flightmodel/position/local_x"); 153 printf("The aircraft's local X-coordinate set to %f\n\n", localX); 154 155 float numBlades[8]; 156 length = xplane.getFloatArray("sim/aircraft/prop/acf_num_blades", 157 numBlades, sizeof(numBlades)/sizeof(numBlades[0])); 158 159 printf("Setting the number of blades\n from:"); 160 for(size_t i = 0; i<length; ++i) { 161 if (i>0) printf(","); 162 printf(" %f", numBlades[i]); 163 } 164 printf("\n to:"); 165 for(size_t i = 0; i<length; ++i) { 166 numBlades[i] += 2.5; 167 if (i>0) printf(","); 168 printf(" %f", numBlades[i]); 169 } 170 printf("\n"); 171 xplane.setFloatArray("sim/aircraft/prop/acf_num_blades", 172 numBlades, length); 173 length = xplane.getFloatArray("sim/aircraft/prop/acf_num_blades", 174 numBlades, sizeof(numBlades)/sizeof(numBlades[0])); 175 printf("The result:"); 176 for(size_t i = 0; i<length; ++i) { 177 if (i>0) printf(","); 178 printf(" %f", numBlades[i]); 179 } 180 printf("\n\n"); 181 182 int32_t batteryArrayOn[8]; 183 length = xplane.getIntArray("sim/cockpit/electrical/battery_array_on", 184 batteryArrayOn, 185 sizeof(batteryArrayOn)/sizeof(batteryArrayOn[0])); 186 187 printf("Setting the batteries\n from:"); 188 for(size_t i = 0; i<length; ++i) { 189 if (i>0) printf(","); 190 printf(" %d", batteryArrayOn[i]); 191 } 192 printf("\n to:"); 193 for(size_t i = 0; i<length; ++i) { 194 batteryArrayOn[i] = !batteryArrayOn[i]; 195 numBlades[i] += 2.5; 196 if (i>0) printf(","); 197 printf(" %d", batteryArrayOn[i]); 198 } 199 printf("\n"); 200 xplane.setIntArray("sim/cockpit/electrical/battery_array_on", 201 batteryArrayOn, length); 202 length = xplane.getIntArray("sim/cockpit/electrical/battery_array_on", 203 batteryArrayOn, 204 sizeof(batteryArrayOn)/sizeof(batteryArrayOn[0])); 205 printf("The result:"); 206 for(size_t i = 0; i<length; ++i) { 207 if (i>0) printf(","); 208 printf(" %d", batteryArrayOn[i]); 209 } 210 printf("\n\n"); 211 212 uint8_t tailNum[40]; 213 memset(tailNum, 0, sizeof(tailNum)); 214 strcpy(reinterpret_cast<char*>(tailNum), "HA-VAI"); 215 printf("Setting the tail number to %s as a byte array...\n", tailNum); 216 xplane.setByteArray("sim/aircraft/view/acf_tailnum", 217 tailNum, sizeof(tailNum)); 218 printf("The tail number is: '%s'\n\n", 219 xplane.getString("sim/aircraft/view/acf_tailnum").c_str()); 220 221 static const char* tailNum1 = "VAI"; 222 printf("Setting the tail number to %s as a string...\n", tailNum1); 223 xplane.setString("sim/aircraft/view/acf_tailnum", tailNum1, 40); 224 printf("The tail number is: '%s'\n\n", 225 xplane.getString("sim/aircraft/view/acf_tailnum").c_str()); 153 226 154 227 try {
Note:
See TracChangeset
for help on using the changeset viewer.