diff --git a/models/utilities/buffers/include/tagged_ring_buffer.hh b/models/utilities/buffers/include/tagged_ring_buffer.hh index 3db46fe8..80df6003 100644 --- a/models/utilities/buffers/include/tagged_ring_buffer.hh +++ b/models/utilities/buffers/include/tagged_ring_buffer.hh @@ -9,6 +9,7 @@ PURPOSE: ( PROGRAMMERS: (((Gary Turner) (OSR) (Sep 2023) (ANTARES) (initial)) + ((Dohyeung Kim) (OSR) (Apr 2026) (Update Proximity Case)) ) ASSUMPTIONS: @@ -27,6 +28,7 @@ ASSUMPTIONS: #include #include #include +#include /***************************************************************************** CMLTaggedRingBufferMember @@ -66,11 +68,25 @@ class CMLTaggedRingBuffer : public CMLSimpleRingBuffer< CMLTaggedRingBufferMembe the specified tag (false, default), or for a data-set with a tag identical to the specified tag (true).*/ + bool proximity_flag{false}; /* (--) + When the model looks for the data-set with a tag closest in value to + the specified tag (require_exact_tag == false), this flag determines + whether the searched closest data-set is within a certain proximity (true) + or simply the absolute closest regardless of time difference (false, + default) */ + + double proximity_threshold{std::numeric_limits::infinity()}; /* (--) + The maximum allowable time difference between a tag closest and the + specified tag. If the proximity_flag is true, the lookup_tag function + returns the data-set with a tag closest in value to the specified tag + only if the difference is within this threshold; otherwise, it returns + a null pointer with a error message*/ explicit CMLTaggedRingBuffer( const std::string& name) : CMLSimpleRingBuffer>(name) {} + ~CMLTaggedRingBuffer() override = default; @@ -222,8 +238,18 @@ Note: tag_delta_min = tag_delta; } } + + if (proximity_flag && tag_delta_min > proximity_threshold) { + CMLMessage::error( __FILE__,__LINE__, + "In buffer ", name_,", could not find a tag ",t," within the proximity threshold ", + proximity_threshold,"\n" + "Cannot identify the desired data set.\n" + "Returning NULL.\n"); + return nullptr; + } + // return the data at the index identified with prox_ix. return &data_[prox_ix].data; } }; -#endif \ No newline at end of file +#endif diff --git a/models/utilities/buffers/verif/SIM_tagged_ring_buffer/RUN_test/input.py b/models/utilities/buffers/verif/SIM_tagged_ring_buffer/RUN_test/input.py index ced5d54b..0e82e162 100644 --- a/models/utilities/buffers/verif/SIM_tagged_ring_buffer/RUN_test/input.py +++ b/models/utilities/buffers/verif/SIM_tagged_ring_buffer/RUN_test/input.py @@ -11,4 +11,9 @@ test.sample.lookup_tag = 8.0 trick.add_read(31, "test.sample.lookup_tag =37.75 ") trick.add_read(33, "test.sample.buffer.require_exact_tag = True") -trick.stop(35) +trick.add_read(36, "test.sample.buffer.require_exact_tag = False") +trick.add_read(37, "test.sample.buffer.proximity_threshold = 0.2") +trick.add_read(38, "test.sample.buffer.proximity_flag = True") +trick.add_read(39, "test.sample.lookup_tag = 32.5 ") +trick.add_read(40, "test.sample.lookup_tag = 36.6 ") +trick.stop(40) \ No newline at end of file diff --git a/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_lookup_data.csv b/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_lookup_data.csv index b2a63cd7..2347745d 100644 --- a/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_lookup_data.csv +++ b/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_lookup_data.csv @@ -35,3 +35,8 @@ sys.exec.out.time {s},test.sample.lookup_tag {1},test.sample.lookup_x {1} 33, 37.75, 34.1 34, 37.75, 36.1 35, 37.75, 36.1 + 36, 37.75, 36.1 + 37, 37.75, 36.1 + 38, 37.75, 36.1 + 39, 32.5, 36.1 + 40, 36.6, 35.1 diff --git a/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_test_data.csv b/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_test_data.csv index c5d0a91e..c89a922f 100644 --- a/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_test_data.csv +++ b/models/utilities/buffers/verif/SIM_tagged_ring_buffer/verif_data/RUN_test/log_test_data.csv @@ -35,3 +35,8 @@ sys.exec.out.time {s},test.sample.buffer_size {1},test.sample.buffer.buffer_ix { 33,5,0, 36.7, 35.1,69, 32.50000000000001, 31.1,61, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67, 0, 0,0, 0, 0,0, 0, 0,0, 0, 0,0, 0, 0,0 34,5,1, 36.7, 35.1,69, 37.75, 36.1,71, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67, 0, 0,0, 0, 0,0, 0, 0,0, 0, 0,0, 0, 0,0 35,10,2, 36.7, 35.1,69, 37.75, 36.1,71, 38.8, 37.1,73, 0, 1.1,1, 0, 1.1,1, 0, 1.1,1, 0, 1.1,1, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67 + 36,10,3, 36.7, 35.1,69, 37.75, 36.1,71, 38.8, 37.1,73, 39.84999999999999, 38.1,75, 0, 1.1,1, 0, 1.1,1, 0, 1.1,1, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67 + 37,10,4, 36.7, 35.1,69, 37.75, 36.1,71, 38.8, 37.1,73, 39.84999999999999, 38.1,75, 40.89999999999999, 39.1,77, 0, 1.1,1, 0, 1.1,1, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67 + 38,10,5, 36.7, 35.1,69, 37.75, 36.1,71, 38.8, 37.1,73, 39.84999999999999, 38.1,75, 40.89999999999999, 39.1,77, 41.94999999999999, 40.1,79, 0, 1.1,1, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67 + 39,10,6, 36.7, 35.1,69, 37.75, 36.1,71, 38.8, 37.1,73, 39.84999999999999, 38.1,75, 40.89999999999999, 39.1,77, 41.94999999999999, 40.1,79, 42.99999999999999, 41.1,81, 33.55000000000001, 32.1,63, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67 + 40,10,7, 36.7, 35.1,69, 37.75, 36.1,71, 38.8, 37.1,73, 39.84999999999999, 38.1,75, 40.89999999999999, 39.1,77, 41.94999999999999, 40.1,79, 42.99999999999999, 41.1,81, 44.04999999999998, 42.1,83, 34.60000000000001, 33.1,65, 35.65000000000001, 34.1,67