[scripts] AggSetCoord: -m option (client MAC)
This commit is contained in:
parent
0addbc2a0f
commit
98a3e04c89
|
@ -7,7 +7,11 @@ owlps-aggsetcoord - set the coordinates in an aggregation CSV file
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
B<owlps-aggsetcoord> [ B<-h> | B<-V> ] [ B<-v> ] [ <I<aggregation_file>> ]
|
B<owlps-aggsetcoord>
|
||||||
|
[ B<-h> | B<-V> ]
|
||||||
|
[ B<-v> ]
|
||||||
|
[ B<-m> <I<mac>> ]
|
||||||
|
[ <I<aggregation_file>> ]
|
||||||
|
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
@ -33,10 +37,6 @@ standard input is read.
|
||||||
|
|
||||||
=over 3
|
=over 3
|
||||||
|
|
||||||
=item *
|
|
||||||
The mobile terminal's MAC address is not taken into account, so if the input
|
|
||||||
file includes several mobiles the results won't make any sense.
|
|
||||||
|
|
||||||
=item *
|
=item *
|
||||||
It is not yet possible to choose an interval of lines to work on: the whole file
|
It is not yet possible to choose an interval of lines to work on: the whole file
|
||||||
is treated.
|
is treated.
|
||||||
|
@ -60,6 +60,10 @@ Print version message and exit.
|
||||||
|
|
||||||
Turn on verbose mode (displays a trace on the standard error).
|
Turn on verbose mode (displays a trace on the standard error).
|
||||||
|
|
||||||
|
=item B<-m> <I<mac>>
|
||||||
|
|
||||||
|
Work only on positioning requests transmitted by MAC address I<mac>.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +95,7 @@ use OwlPS::CSV;
|
||||||
use constant FORMAT_VERSION => 1;
|
use constant FORMAT_VERSION => 1;
|
||||||
|
|
||||||
# Indexes of the fields in the CSV lines (first field is #0)
|
# Indexes of the fields in the CSV lines (first field is #0)
|
||||||
|
use constant MAC_FIELD_INDEX => 1;
|
||||||
use constant TYPE_FIELD_INDEX => 2;
|
use constant TYPE_FIELD_INDEX => 2;
|
||||||
use constant TIMESTAMP_FIELD_INDEX => 4;
|
use constant TIMESTAMP_FIELD_INDEX => 4;
|
||||||
use constant X_FIELD_INDEX => 5;
|
use constant X_FIELD_INDEX => 5;
|
||||||
|
@ -109,6 +114,9 @@ use constant BASE_COORD => "0.00";
|
||||||
# Verbose mode
|
# Verbose mode
|
||||||
my $verbose;
|
my $verbose;
|
||||||
|
|
||||||
|
# Selected transmitter's MAC address (will stay undefined if -m was not used)
|
||||||
|
my $selected_mac;
|
||||||
|
|
||||||
# Current line
|
# Current line
|
||||||
my $cur_line;
|
my $cur_line;
|
||||||
|
|
||||||
|
@ -161,6 +169,15 @@ sub print_warning(@) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Returns true if $mac is the transmitter's MAC address selected by the user, or
|
||||||
|
# if the user didn't select any particular MAC address.
|
||||||
|
# Parameters: $mac
|
||||||
|
sub is_selected_mac($) {
|
||||||
|
if (!defined($selected_mac)) { return 1 }
|
||||||
|
return $selected_mac eq $_[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Returns true if all $x, $y and $z are ready to be printed.
|
# Returns true if all $x, $y and $z are ready to be printed.
|
||||||
# Arguments: $x, $y, $z
|
# Arguments: $x, $y, $z
|
||||||
sub is_complete($$$) {
|
sub is_complete($$$) {
|
||||||
|
@ -203,9 +220,12 @@ sub check_oldest_lines() {
|
||||||
$end_line
|
$end_line
|
||||||
) = split(';', $prev_lines[0], 9);
|
) = split(';', $prev_lines[0], 9);
|
||||||
|
|
||||||
# Display and delete the line if it is not a positioning request or if
|
# Display and delete the line if either of the following is true:
|
||||||
# it is complete
|
# - it is not a positioning request
|
||||||
if ($type != REQUEST_TYPE_NORMAL
|
# - it is not the selected transmitter's MAC address
|
||||||
|
# - it is complete
|
||||||
|
if ( $type != REQUEST_TYPE_NORMAL
|
||||||
|
|| !is_selected_mac($mac)
|
||||||
|| is_complete($x, $y, $z))
|
|| is_complete($x, $y, $z))
|
||||||
{
|
{
|
||||||
print shift @prev_lines;
|
print shift @prev_lines;
|
||||||
|
@ -244,6 +264,15 @@ sub apply_interpolation($$$$$$) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Skip requests sent by other devices than the selected one
|
||||||
|
if (defined($selected_mac)) {
|
||||||
|
my $mac = get_field($prev_lines[-$i], MAC_FIELD_INDEX);
|
||||||
|
if ($selected_mac ne $mac) {
|
||||||
|
$nb_lines++;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
my $time = get_field($prev_lines[-$i], TIMESTAMP_FIELD_INDEX);
|
my $time = get_field($prev_lines[-$i], TIMESTAMP_FIELD_INDEX);
|
||||||
my $newvalue =
|
my $newvalue =
|
||||||
interpolate_1d($start, $start_time, $stop, $stop_time, $time);
|
interpolate_1d($start, $start_time, $stop, $stop_time, $time);
|
||||||
|
@ -261,7 +290,7 @@ sub apply_interpolation($$$$$$) {
|
||||||
## Option parsing ##
|
## Option parsing ##
|
||||||
|
|
||||||
$Getopt::Std::STANDARD_HELP_VERSION = 1;
|
$Getopt::Std::STANDARD_HELP_VERSION = 1;
|
||||||
use constant OPTIONS => 'hvV';
|
use constant OPTIONS => 'hm:vV';
|
||||||
my %options;
|
my %options;
|
||||||
if (!getopts(OPTIONS, \%options)) {
|
if (!getopts(OPTIONS, \%options)) {
|
||||||
HELP_MESSAGE(*STDERR);
|
HELP_MESSAGE(*STDERR);
|
||||||
|
@ -279,7 +308,8 @@ if ($options{'V'}) {
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$verbose = $options{'v'};
|
$verbose = $options{'v'};
|
||||||
|
$selected_mac = $options{'m'};
|
||||||
|
|
||||||
|
|
||||||
## Main loop: read lines ##
|
## Main loop: read lines ##
|
||||||
|
@ -291,10 +321,9 @@ while ($cur_line = <>) {
|
||||||
|
|
||||||
# The current line is empty
|
# The current line is empty
|
||||||
if ($cur_line eq "\n") {
|
if ($cur_line eq "\n") {
|
||||||
# If we don't have previous lines, we print it
|
# If we don't have previous lines, we print it; if we do, we store it
|
||||||
if (@prev_lines == 0) { print "\n" }
|
if (@prev_lines == 0) { print "\n" }
|
||||||
# If we have previous lines, we store it
|
else { push @prev_lines, "\n" }
|
||||||
else { push @prev_lines, "\n" }
|
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,16 +353,22 @@ while ($cur_line = <>) {
|
||||||
# Check the request type: we work only on positioning requests but must take
|
# Check the request type: we work only on positioning requests but must take
|
||||||
# into account other request types
|
# into account other request types
|
||||||
if ($type != REQUEST_TYPE_NORMAL) {
|
if ($type != REQUEST_TYPE_NORMAL) {
|
||||||
|
trace("Non-positioning request: line skipped.\n");
|
||||||
# If we have no lines in memory, we can just print the line and jump to
|
# If we have no lines in memory, we can just print the line and jump to
|
||||||
# the next one
|
# the next one, otherwise we have to store the line
|
||||||
if (@prev_lines == 0) {
|
if (@prev_lines == 0) { print $cur_line }
|
||||||
print $cur_line;
|
else { push @prev_lines, $cur_line }
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Otherwise, we have to store the line
|
|
||||||
trace("Non-positioning request line stored.\n");
|
# Check the transmitter's MAC address
|
||||||
push @prev_lines, $cur_line;
|
if (!is_selected_mac($mac)) {
|
||||||
|
trace( "Transmitter's MAC address ($mac) doesn't match the selected"
|
||||||
|
. " transmiter's MAC address ($selected_mac): line skipped.\n");
|
||||||
|
# Print or store the line
|
||||||
|
if (@prev_lines == 0) { print $cur_line }
|
||||||
|
else { push @prev_lines, $cur_line }
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue