From 930dfbc683410883a36e6d1aca985ed9f52a9dad Mon Sep 17 00:00:00 2001 From: Jacqueline Deans Date: Tue, 7 Feb 2023 16:41:53 -0600 Subject: [PATCH] Add check and warning for unsupported types in data recording (#1441) --- test/SIM_test_dr/Modified_data/dr_typesASCII.dr | 2 ++ test/SIM_test_dr/Modified_data/dr_typesBINARY.dr | 2 ++ test/SIM_test_dr/models/dr/include/DR.hh | 2 ++ test/SIM_test_dr/models/dr/src/DR_default_data.cpp | 3 ++- trick_source/sim_services/DataRecord/DataRecordGroup.cpp | 9 ++++++++- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/SIM_test_dr/Modified_data/dr_typesASCII.dr b/test/SIM_test_dr/Modified_data/dr_typesASCII.dr index 7d290b62..9189faad 100644 --- a/test/SIM_test_dr/Modified_data/dr_typesASCII.dr +++ b/test/SIM_test_dr/Modified_data/dr_typesASCII.dr @@ -25,5 +25,7 @@ drg[DR_GROUP_ID].add_variable("drx.drt.k") drg[DR_GROUP_ID].add_variable("drx.drt.l") 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") trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer) drg[DR_GROUP_ID].enable() diff --git a/test/SIM_test_dr/Modified_data/dr_typesBINARY.dr b/test/SIM_test_dr/Modified_data/dr_typesBINARY.dr index 2afbec4e..6c2de8a9 100644 --- a/test/SIM_test_dr/Modified_data/dr_typesBINARY.dr +++ b/test/SIM_test_dr/Modified_data/dr_typesBINARY.dr @@ -25,5 +25,7 @@ drg[DR_GROUP_ID].add_variable("drx.drt.k") drg[DR_GROUP_ID].add_variable("drx.drt.l") 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") trick.add_data_record_group(drg[DR_GROUP_ID], trick.DR_Buffer) drg[DR_GROUP_ID].enable() diff --git a/test/SIM_test_dr/models/dr/include/DR.hh b/test/SIM_test_dr/models/dr/include/DR.hh index 0afebe8c..a4c132d7 100644 --- a/test/SIM_test_dr/models/dr/include/DR.hh +++ b/test/SIM_test_dr/models/dr/include/DR.hh @@ -87,6 +87,8 @@ class DRTypes { unsigned long long l; bool m; NUM_DEFS n; + char * o; // Should not actually be added + std::string p; // Should not actually be added 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 77586c42..d4564c3f 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 @@ -25,7 +25,8 @@ int DRTypes::init() { l = 12345678912345; //unsigned long m = false; //boolean 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."; /*============================================================================ Bitfields diff --git a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp index 7429d24a..36d40292 100644 --- a/trick_source/sim_services/DataRecord/DataRecordGroup.cpp +++ b/trick_source/sim_services/DataRecord/DataRecordGroup.cpp @@ -380,7 +380,14 @@ int Trick::DataRecordGroup::init() { delete drb ; continue ; } else { - drb->ref = ref2 ; + 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()) ; + rec_buffer.erase(rec_buffer.begin() + jj--) ; + delete drb ; + continue ; + } else { + drb->ref = ref2 ; + } } } if ( drb->alias.compare("") ) {