[Positioner] Option calibration-requests-timeout
Introduce the option positioning.calibration-requests-timeout, to avoid keeping the old calibration requests.
This commit is contained in:
parent
7a6a85ad19
commit
3cbe9c2df5
3
TODO
3
TODO
|
@ -110,9 +110,6 @@
|
|||
- Algorithms
|
||||
° Add to the result the information "area error" (whether on not the
|
||||
computed result is in the same room as the real position).
|
||||
° Delete reference points after a given amount of time. This is to
|
||||
avoid meaningless old reference points, for instance if an AP was
|
||||
shut down.
|
||||
° Handle the power and antenna gain difference between the
|
||||
calibration mobile (or pseudo-mobile, for autocalibration) and the
|
||||
mobile to position.
|
||||
|
|
|
@ -110,6 +110,11 @@ csv-file = /tmp/owlps-positioner.log
|
|||
# it is not activated by default for security purposes.
|
||||
#accept-new-calibration-requests = false
|
||||
|
||||
# Maximum age of the calibration requests, in seconds. If greater than
|
||||
# zero, the positioning requests older than this timeout will be
|
||||
# deleted.
|
||||
#calibration-requests-timeout = 0
|
||||
|
||||
# If you activate the above option and want the calibration requests
|
||||
# to be treated as positioning requests (in addition to the normal
|
||||
# treatment of calibration requests), activate this option.
|
||||
|
|
|
@ -136,6 +136,12 @@ void Positioning::loop()
|
|||
if (! request)
|
||||
continue ;
|
||||
|
||||
unsigned int cr_timeout =
|
||||
Configuration::uint_value(
|
||||
"positioning.calibration-requests-timeout") ;
|
||||
if (cr_timeout > 0)
|
||||
Stock::delete_calibration_requests_older_than(cr_timeout) ;
|
||||
|
||||
Point3D real_position ;
|
||||
bool compute_error = false ;
|
||||
ResultList results(&request) ;
|
||||
|
|
|
@ -656,6 +656,32 @@ delete_calibration_request(const CalibrationRequest &request)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param timeout The maximum age of the calibration requests (seconds).
|
||||
*/
|
||||
void Stock::delete_calibration_requests_older_than(int timeout)
|
||||
{
|
||||
assert(timeout > 0) ;
|
||||
|
||||
unordered_set<CalibrationRequest>::iterator cr =
|
||||
calibration_requests.begin() ;
|
||||
while (cr != calibration_requests.end())
|
||||
{
|
||||
const Timestamp &elapsed = cr->get_time_sent().elapsed() ;
|
||||
uint64_t elapsed_sec = static_cast<uint64_t>(elapsed) / 1000 ;
|
||||
if (elapsed_sec >= static_cast<unsigned int>(timeout))
|
||||
{
|
||||
ReferencePoint *rp = cr->get_reference_point() ;
|
||||
cr = calibration_requests.erase(cr) ;
|
||||
if (rp && rp->get_requests().empty())
|
||||
reference_points.erase(*rp) ;
|
||||
}
|
||||
else
|
||||
++cr ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const CalibrationRequest& Stock::
|
||||
find_create_calibration_request(const CalibrationRequest &request)
|
||||
{
|
||||
|
|
|
@ -169,6 +169,9 @@ public:
|
|||
/// Deletes a CalibrationRequest
|
||||
static void delete_calibration_request(
|
||||
const CalibrationRequest &request) ;
|
||||
/// \brief Deletes the calibration requests that are older than
|
||||
/// \em timeout seconds
|
||||
static void delete_calibration_requests_older_than(int timeout) ;
|
||||
/// Searches for a CalibrationRequest and adds it if it does not exist
|
||||
static const CalibrationRequest&
|
||||
find_create_calibration_request(const CalibrationRequest &request) ;
|
||||
|
|
|
@ -252,6 +252,10 @@ void UserInterface::fill_positioning_options()
|
|||
" self-calibration. If unactivated, the calibration requests"
|
||||
" are handled as positioning requests (default is unactivated,"
|
||||
" for security purposes).")
|
||||
("positioning.calibration-requests-timeout",
|
||||
po::value<unsigned int>()->default_value(0),
|
||||
"Maximum age of a calibration request before to delete it"
|
||||
" (0 = unlimited).")
|
||||
("positioning.position-calibration-requests",
|
||||
po::value<bool>()->default_value(false),
|
||||
"When accept-new-calibration-requests is activated, allow the"
|
||||
|
|
Loading…
Reference in New Issue