Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion models/utilities/buffers/include/tagged_ring_buffer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PURPOSE: (

PROGRAMMERS:
(((Gary Turner) (OSR) (Sep 2023) (ANTARES) (initial))
((Dohyeung Kim) (OSR) (Apr 2026) (Update Proximity Case))
)

ASSUMPTIONS:
Expand All @@ -27,6 +28,7 @@ ASSUMPTIONS:
#include <string>
#include <cstddef>
#include <vector>
#include <limits>

/*****************************************************************************
CMLTaggedRingBufferMember
Expand Down Expand Up @@ -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<double>::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<CMLTaggedRingBufferMember<T_Tag, T_Data>>(name)
{}

~CMLTaggedRingBuffer() override = default;


Expand Down Expand Up @@ -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
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading