The code after reading .dat file and generates .csv format file which is consist of many frame names (columns) and respective timings (microseconds)(rows) stored in a string separated by ';' :
MFK3_ECAN 1625069169;1625072194;1625072216;1625072229;1625072241;1625072253;
MFK3_VIDEO_FrameID 1625334304;1625612508;1625890712;1626168916;1626447120;1626725324;
What I need help with is to find a solution, by which these above mentioned two "specific name" strings can be subtracted for each time frame (converted to sec i.e. micsec/10^7) with a constraint that if there is a time difference of 3 or more seconds one state should be logged as ".dat file is corrupt".
Part of code reading .dat file:
std::string file_name = m_Filename.toStdString();
size_t found = file_name.find (".dat");
file_name.erase (found, 4);
file_name.insert (found, "_Timestamp_Log");
file_name += ".csv";
m_log.open (file_name.c_str(), std::ofstream::out);
QList<tTimeStamp> tmp_lst;
for (int col = 0; col < m_nStreamCnt; col++)
{
tmp_lst = m_TimestampMap.value(col+1);
m_log << m_StreamIDMap.value(col+1).toStdString() << ";"; //writing Column names
for(int row = 0; row < tmp_lst.size(); row++)
{
m_log << QString::number(tmp_lst.at(row)).toStdString() << ";"; //writing Row values
}
m_log << endl;
}
m_log.close();
So, finally I worked out with the solution. As per now its clear I wasn't asking with complete information. But nevertheless hopefully the solution would help others who might come across such issue.
Problem 1: I had to look for a specific stream name and than store it via toFloat() for later subtraction. Caution: toInt() or toStdString() would give incorrect values.
Problem 2: QString::number(tmp_lst[0]) would give the first number from string to subtract and check either difference is less than 3 seconds.
for (int col = 0; col < m_nStreamCnt; col++) //m_nStreamCnt contains function names
{
tmp_lst = m_TimestampMap.value(col+1);
m_log << m_StreamIDMap.value(col+1).toStdString() << ";"; //Column names
if (m_StreamIDMap.value(col+1) == "MFK3_VIDEO_FrameID")
{
m_log << QString::number(tmp_lst[0]).toStdString() << ";"; //Row values
m_current = QString::number(tmp_lst[0]).toFloat();
m_current = m_current/10000000;
}
else if (m_StreamIDMap.value(col+1) == "MFK3_ECAN")
{
m_future = QString::number(tmp_lst[0]).toFloat(); //
m_future = m_future/10000000;
m_log << QString::number(tmp_lst[0]).toStdString() << ";"; //Row values
}
m_diff = std::abs(m_current - m_future); //
if (m_diff <= 3)
{ //details etc}