|
|
@ -5,6 +5,8 @@
|
|
|
|
#include "../DTO/packet.hpp"
|
|
|
|
#include "../DTO/packet.hpp"
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include <sstream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include <locale>
|
|
|
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> split(const std::string& s, char delimiter)
|
|
|
|
std::vector<std::string> split(const std::string& s, char delimiter)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -18,6 +20,38 @@ std::vector<std::string> split(const std::string& s, char delimiter)
|
|
|
|
return tokens;
|
|
|
|
return tokens;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t convertStringToTimestampMicros(std::string textTimestamp){
|
|
|
|
|
|
|
|
uint64_t timestamp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::tm t = {};
|
|
|
|
|
|
|
|
std::istringstream ssTimestamp = std::istringstream(textTimestamp);
|
|
|
|
|
|
|
|
if (ssTimestamp >> std::get_time(&t, "%H:%M:%S"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Get current time
|
|
|
|
|
|
|
|
std::time_t curT = std::time(0);
|
|
|
|
|
|
|
|
std::tm* curTime = std::localtime(&curT);
|
|
|
|
|
|
|
|
// Set missing fields
|
|
|
|
|
|
|
|
t.tm_mday = curTime->tm_mday;
|
|
|
|
|
|
|
|
t.tm_mon = curTime->tm_mon;
|
|
|
|
|
|
|
|
t.tm_year = curTime->tm_year;
|
|
|
|
|
|
|
|
t.tm_zone = curTime->tm_zone;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Convert tm to time
|
|
|
|
|
|
|
|
std::time_t time = std::mktime(&t);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get micros
|
|
|
|
|
|
|
|
int micros = std::stoi(textTimestamp.substr(9, 6));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate timestamp epoch in micros
|
|
|
|
|
|
|
|
timestamp = time*1000000 + micros;
|
|
|
|
|
|
|
|
return timestamp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw std::runtime_error("Could not parse time: '"+ textTimestamp +"'");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void textPacketHandler(std::vector<std::string> textPacket){
|
|
|
|
void textPacketHandler(std::vector<std::string> textPacket){
|
|
|
|
/// Here we have to parse the packet
|
|
|
|
/// Here we have to parse the packet
|
|
|
|
// Create empty packet
|
|
|
|
// Create empty packet
|
|
|
@ -28,6 +62,8 @@ void textPacketHandler(std::vector<std::string> textPacket){
|
|
|
|
const std::vector<std::string> headerData = split(textHeader, ' ');
|
|
|
|
const std::vector<std::string> headerData = split(textHeader, ' ');
|
|
|
|
|
|
|
|
|
|
|
|
std::string textTimestamp = headerData[0];
|
|
|
|
std::string textTimestamp = headerData[0];
|
|
|
|
|
|
|
|
uint64_t timestamp = convertStringToTimestampMicros(textTimestamp);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* EE781A91_6D07_47AC_B3C4_F99E29F3731F */
|
|
|
|
#endif /* EE781A91_6D07_47AC_B3C4_F99E29F3731F */
|
|
|
|