Changeset 16:1d329bbc0303 in xplra for test


Ignore:
Timestamp:
01/28/13 19:25:31 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added the functions to handle the array queries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/basictest.cc

    r15 r16  
    3939using hu::varadiistvan::xplra::ProtocolException;
    4040
     41using std::string;
     42
    4143//------------------------------------------------------------------------------
    4244
     
    7577        printf("The coordinates: %f, %f\n\n", latitude, longitude);
    7678
     79        printf("Querying the aircraft's description as an array of a fixed size...\n");
     80        uint8_t result[260];
     81        size_t length = xplane.getByteArray("sim/aircraft/view/acf_descrip",
     82                                            result, sizeof(result)/sizeof(result[0]));
     83        printf("Got %zu bytes, as a string: '%s'\n\n", length, result);
     84
     85        printf("Querying the aircraft's description as a dynamically created array...\n");
     86        uint8_t* result1 = xplane.getByteArray("sim/aircraft/view/acf_descrip", length);
     87        printf("Got %zu bytes, as a string: '%s'\n\n", length, result1);
     88
     89        printf("Querying the aircraft's description as a string, with an offset of 3...\n");
     90        string result2 = xplane.getString("sim/aircraft/view/acf_descrip", 3);
     91        printf("Got: '%s'\n\n", result2.c_str());
     92
     93        printf("Querying the aircraft's engine types as an array of a fixed size...\n");
     94        int32_t result3[8];
     95        length = xplane.getIntArray("sim/aircraft/prop/acf_en_type",
     96                                    result3, sizeof(result3)/sizeof(result3[0]));
     97        printf("Got %zu values:", length);
     98        for(size_t i = 0; i<length; ++i) {
     99            if (i>0) printf(",");
     100            printf(" %d", result3[i]);
     101        }
     102        printf("\n\n");
     103
     104        printf("Querying the aircraft's engine types as a dynamically created array...\n");
     105        length = 0;
     106        int32_t* result4 = xplane.getIntArray("sim/aircraft/prop/acf_en_type", length);
     107        printf("Got %zu values:", length);
     108        for(size_t i = 0; i<length; ++i) {
     109            if (i>0) printf(",");
     110            printf(" %d", result4[i]);
     111        }
     112        printf("\n\n");
     113
     114        printf("Querying the aircraft's propeller direction as an array of a fixed size...\n");
     115        float result5[8];
     116        length = xplane.getFloatArray("sim/aircraft/prop/acf_prop_dir",
     117                                      result5, sizeof(result5)/sizeof(result5[0]));
     118        printf("Got %zu values:", length);
     119        for(size_t i = 0; i<length; ++i) {
     120            if (i>0) printf(",");
     121            printf(" %f", result5[i]);
     122        }
     123        printf("\n\n");
     124
     125        printf("Querying the aircraft's propeller direction as a dynamically created array...\n");
     126        length = 0;
     127        float* result6 = xplane.getFloatArray("sim/aircraft/prop/acf_prop_dir", length);
     128        printf("Got %zu values:", length);
     129        for(size_t i = 0; i<length; ++i) {
     130            if (i>0) printf(",");
     131            printf(" %f", result6[i]);
     132        }
     133        printf("\n\n");
     134
    77135        return 0;
    78136    } catch(const Exception& exception) {
Note: See TracChangeset for help on using the changeset viewer.