Handle aggregation CSV format version
The first field of the Aggregator's CSV output files is now an unsigned integer that announces the version of the CSV format used. Current version is 1 and the subsequent fields are not modified, so that an aggregation file generated with a previous version can still be used by adding "1;" at the beginning of each line. The Positioner has been adapted to handle this new format.
This commit is contained in:
parent
b97085d79f
commit
5bf1bcb4d2
7
TODO.t2t
7
TODO.t2t
|
@ -21,13 +21,6 @@ Work to do in OwlPS
|
|||
- Known bugs:
|
||||
- libconfuse bug (Listener & Aggregator): http://bugs.debian.org/639115
|
||||
|
||||
- Handle the aggregation format version
|
||||
|
||||
In the aggregation files, a version number describing the file format
|
||||
should be added (as the 2nd field, right after the client's MAC
|
||||
address). That would allow the positioning server to handle several
|
||||
formats instead of just the last version.
|
||||
|
||||
- Add a library to parse aggregation files, handling the different
|
||||
formats ?
|
||||
|
||||
|
|
|
@ -61,6 +61,12 @@ extern "C" {
|
|||
//@}
|
||||
|
||||
|
||||
/** @name Miscellaneous informations */
|
||||
//@{
|
||||
#define OWL_LATEST_AGGREGATION_CSV_FORMAT 1
|
||||
//@}
|
||||
|
||||
|
||||
/// Directions
|
||||
enum owl_directions
|
||||
{
|
||||
|
|
|
@ -1000,6 +1000,9 @@ void output_request(request_list *const request_ptr,
|
|||
owl_request_info info;
|
||||
request_info_list *request_info_ptr = NULL ;
|
||||
|
||||
// Print CSV format version to the output file
|
||||
fprintf(stream, "%d;", OWL_LATEST_AGGREGATION_CSV_FORMAT) ;
|
||||
|
||||
// Print mobile MAC address to the output file
|
||||
owl_mac_bytes_to_string_r(request_ptr->mobile_mac_addr_bytes,
|
||||
mac_str) ;
|
||||
|
|
|
@ -44,6 +44,28 @@ bool InputCSV::fill_current_request()
|
|||
return false ;
|
||||
++current_line_nb ;
|
||||
|
||||
// Read CSV format version
|
||||
uint_fast16_t csv_format_version ;
|
||||
if (! file.read_field(csv_format_version))
|
||||
{
|
||||
// Wrong number of fields
|
||||
if (Configuration::is_configured("verbose"))
|
||||
cerr << "InputCSV: cannot read the CSV format version.\n" ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Check the CSV format
|
||||
switch (csv_format_version)
|
||||
{
|
||||
case 1 :
|
||||
// Format 1 is the only one we handle for now.
|
||||
break ;
|
||||
default :
|
||||
cerr << "InputCSV: CSV format version " << csv_format_version
|
||||
<< " is not handled!\n" ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Read Mobile MAC field
|
||||
string mac_mobile ;
|
||||
if (! file.read_field(mac_mobile)) // Wrong number of fields
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
/// Reads [requests](@ref Request) from a CSV file
|
||||
/**
|
||||
* CSV format is:
|
||||
* Mobile_MAC;Request_type;Number_of_packets;Timestamp;X;Y;Z;Direction;
|
||||
* AP_MAC_1;Packet_ID_1;SS_1;…;AP_MAC_n;Packet_ID_n;SS_n
|
||||
* Format_version;Mobile_MAC;Request_type;Number_of_packets;
|
||||
* Timestamp;X;Y;Z;Direction;AP_MAC_1;Packet_ID_1;SS_1;…;
|
||||
* AP_MAC_n;Packet_ID_n;SS_n
|
||||
*/
|
||||
class InputCSV: public InputMedium
|
||||
{
|
||||
|
|
|
@ -210,6 +210,12 @@ const string Request::to_csv() const
|
|||
{
|
||||
ostringstream csv_line ;
|
||||
|
||||
// CSV format version
|
||||
// (this should match OWL_LATEST_AGGREGATION_CSV_FORMAT)
|
||||
constexpr unsigned int aggregation_csv_format = 1 ;
|
||||
|
||||
csv_line << aggregation_csv_format << ';' ;
|
||||
|
||||
if (mobile != NULL)
|
||||
csv_line << mobile->get_mac_addr() ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue