diff --git a/docs/documentation/simulation_capabilities/Data-Record.md b/docs/documentation/simulation_capabilities/Data-Record.md index 80325a16..c7ab2391 100644 --- a/docs/documentation/simulation_capabilities/Data-Record.md +++ b/docs/documentation/simulation_capabilities/Data-Record.md @@ -55,6 +55,8 @@ drg.add_variable("ball.obj.state.output.position[0]", "x_pos") drg.add_variable("ball.obj.state.output.position[1]", "y_pos") ``` +Only individual primitive types can be recorded. Arrays, strings/char *, structured objects, or STL types are not supported. + ### Changing the Recording Rate To change the recording rate call the set_cycle() method of the recording group. diff --git a/include/trick/DataRecordGroup.hh b/include/trick/DataRecordGroup.hh index ac5631e7..d6587083 100644 --- a/include/trick/DataRecordGroup.hh +++ b/include/trick/DataRecordGroup.hh @@ -405,6 +405,10 @@ namespace Trick { */ virtual int add_time_variable() ; + /** Check that a variable is supported by data recording. */ + /** Variable must be a single primitive type - no STL, array, structured, string */ + bool isSupportedType(REF2 * ref2, std::string& message); + /** Max number of digits to expect per recorded value.\n */ static const unsigned int record_size = 25; /**< trick_io(**) trick_units(--) */ diff --git a/test/SIM_test_dr/Modified_data/dr_typesASCII.dr b/test/SIM_test_dr/Modified_data/dr_typesASCII.dr index 9189faad..57635126 100644 --- a/test/SIM_test_dr/Modified_data/dr_typesASCII.dr +++ b/test/SIM_test_dr/Modified_data/dr_typesASCII.dr @@ -27,5 +27,12 @@ drg[DR_GROUP_ID].add_variable("drx.drt.m") drg[DR_GROUP_ID].add_variable("drx.drt.n") drg[DR_GROUP_ID].add_variable("drx.drt.o") drg[DR_GROUP_ID].add_variable("drx.drt.p") +drg[DR_GROUP_ID].add_variable("drx.drt.q[0]") +drg[DR_GROUP_ID].add_variable("drx.drt.q[1]") +drg[DR_GROUP_ID].add_variable("drx.drt.q[2]") +drg[DR_GROUP_ID].add_variable("drx.drt.q[3]") +drg[DR_GROUP_ID].add_variable("drx.drt.q[4]") +drg[DR_GROUP_ID].add_variable("drx.drt.r[0][0]") + trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer) drg[DR_GROUP_ID].enable() diff --git a/test/SIM_test_dr/RUN_test/Ref_Logs/log_DR_typesASCII_Master.csv b/test/SIM_test_dr/RUN_test/Ref_Logs/log_DR_typesASCII_Master.csv index b8b16b8a..4e7a07f8 100644 --- a/test/SIM_test_dr/RUN_test/Ref_Logs/log_DR_typesASCII_Master.csv +++ b/test/SIM_test_dr/RUN_test/Ref_Logs/log_DR_typesASCII_Master.csv @@ -1,12 +1,12 @@ -sys.exec.out.time {s},drx.drt.a {1},drx.drt.b {1},drx.drt.c {1},drx.drt.d {1},drx.drt.e {1},drx.drt.f {1},drx.drt.g {1},drx.drt.h {1},drx.drt.i {1},drx.drt.j {1},drx.drt.k {1},drx.drt.l {1},drx.drt.m {1},drx.drt.n {1} - 0,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.1,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.2,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.3,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.4,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.5,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.6,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.7,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.8,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 0.9,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 - 1,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3 +sys.exec.out.time {s},drx.drt.a {1},drx.drt.b {1},drx.drt.c {1},drx.drt.d {1},drx.drt.e {1},drx.drt.f {1},drx.drt.g {1},drx.drt.h {1},drx.drt.i {1},drx.drt.j {1},drx.drt.k {1},drx.drt.l {1},drx.drt.m {1},drx.drt.n {1},drx.drt.q[0] {1},drx.drt.q[1] {1},drx.drt.q[2] {1},drx.drt.q[3] {1},drx.drt.q[4] {1},drx.drt.r[0][0] {1} + 0,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.1,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.2,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.3,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.4,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.5,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.6,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.7,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.8,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 0.9,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 + 1,a,98,-1234,1234,-123456,123456,-1234567,123456789, 1234.5677, -1234.56789,-12345678912345,12345678912345,0,3,0,1,2,3,4, 10 diff --git a/test/SIM_test_dr/models/dr/include/DR.hh b/test/SIM_test_dr/models/dr/include/DR.hh index a4c132d7..1cd7b261 100644 --- a/test/SIM_test_dr/models/dr/include/DR.hh +++ b/test/SIM_test_dr/models/dr/include/DR.hh @@ -89,6 +89,8 @@ class DRTypes { NUM_DEFS n; char * o; // Should not actually be added std::string p; // Should not actually be added + int q[5]; + double r[2][2]; UINT_BITS uintB; INT_BITS intB; diff --git a/test/SIM_test_dr/models/dr/src/DR_default_data.cpp b/test/SIM_test_dr/models/dr/src/DR_default_data.cpp index d4564c3f..38ac316b 100644 --- a/test/SIM_test_dr/models/dr/src/DR_default_data.cpp +++ b/test/SIM_test_dr/models/dr/src/DR_default_data.cpp @@ -27,6 +27,13 @@ int DRTypes::init() { n = THREE; //enumerated type o = "3 May. Bistritz.—Left Munich at 8:35 P. M., on 1st May, arriving at Vienna early next morning; should have arrived at 6:46, but train was an hour late. Buda-Pesth seems a wonderful place, from the glimpse which I got of it from the train and the little I could walk through the streets. I feared to go very far from the station, as we had arrived late and would start as near the correct time as possible. The impression I had was that we were leaving the West and entering the East; the most western of splendid bridges over the Danube, which is here of noble width and depth, took us among the traditions of Turkish rule."; p = "We left in pretty good time, and came after nightfall to Klausenburgh. Here I stopped for the night at the Hotel Royale. I had for dinner, or rather supper, a chicken done up some way with red pepper, which was very good but thirsty. (Mem., get recipe for Mina.) I asked the waiter, and he said it was called “paprika hendl,” and that, as it was a national dish, I should be able to get it anywhere along the Carpathians. I found my smattering of German very useful here; indeed, I don't know how I should be able to get on without it."; + for (int i = 0; i < 5; i++) { + q[i] = i; + } + r[0][0] = 10; + r[0][1] = 20; + r[1][0] = 30; + r[1][1] = 40; /*============================================================================ Bitfields diff --git a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp index 36d40292..cdb66f38 100644 --- a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp +++ b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp @@ -339,6 +339,21 @@ int Trick::DataRecordGroup::add_change_variable( std::string in_name ) { } +bool Trick::DataRecordGroup::isSupportedType(REF2 * ref2, std::string& message) { + if (ref2->attr->type == TRICK_STRING || ref2->attr->type == TRICK_STL || ref2->attr->type == TRICK_STRUCTURED) { + message = "Cannot Data Record variable " + std::string(ref2->reference) + " of unsupported type " + std::to_string(ref2->attr->type); + return false; + } + + // If this is an array and not a single value, don't record it + if (ref2->num_index != ref2->attr->num_index) { + message = "Cannot Data Record arrayed variable " + std::string(ref2->reference); + return false; + } + + return true; +} + /** @details -# The simulation output directory is retrieved from the CommandLineArguments @@ -380,8 +395,9 @@ int Trick::DataRecordGroup::init() { delete drb ; continue ; } else { - if (ref2->attr->type == TRICK_STRING || ref2->attr->type == TRICK_STL || ref2->attr->type == TRICK_STRUCTURED || ref2->attr->num_index != 0) { - message_publish(MSG_WARNING, "Cannot Data Record unsupported type variable %s.\n", drb->name.c_str()) ; + std::string message; + if (!isSupportedType(ref2, message)) { + message_publish(MSG_WARNING, "%s\n", message.c_str()) ; rec_buffer.erase(rec_buffer.begin() + jj--) ; delete drb ; continue ;