The time string of csv file header used the session time

This commit is contained in:
dreamsource-tai 2024-07-23 15:10:12 +08:00
parent c428bd66e3
commit 499f90aebe
6 changed files with 24 additions and 3 deletions

View File

@ -71,6 +71,12 @@ uint64_t Snapshot::get_sample_count()
return _sample_count;
}
uint64_t Snapshot::get_total_sample_count()
{
std::lock_guard<std::mutex> lock(_mutex);
return _total_sample_count;
}
uint64_t Snapshot::get_ring_sample_count()
{
std::lock_guard<std::mutex> lock(_mutex);

View File

@ -40,6 +40,7 @@ public:
virtual void init() = 0;
uint64_t get_sample_count();
uint64_t get_total_sample_count();
uint64_t get_ring_sample_count();
uint64_t get_ring_start();
uint64_t get_ring_end();

View File

@ -1474,6 +1474,14 @@ namespace pv
// Post a message to start all decode tasks.
if (mode == LOGIC){
auto logic_data = _capture_data->get_logic();
if (is_loop_mode() && logic_data->get_loop_offset() > 0){
uint64_t milliseconds = logic_data->get_ring_sample_count() / 1000000;
QDateTime sessionTime = QDateTime::currentDateTime();
sessionTime = sessionTime.addMSecs(-milliseconds);
set_session_time(sessionTime);
}
_callback->trigger_message(DSV_MSG_REV_END_PACKET);
}
else{

View File

@ -48,6 +48,7 @@
#include <math.h>
#include <QTextStream>
#include <list>
#include <string.h>
#ifdef _WIN32
#include <QTextCodec>
@ -919,7 +920,10 @@ void StoreSession::export_exec(data::Snapshot *snapshot)
return;
}
}
QString sessionTime = _session->get_session_time().toString("yyyy-MM-dd HH:mm:ss");
strcpy(output.time_string, sessionTime.toStdString().c_str());
QFile file(_file_name);
file.open(QIODevice::WriteOnly | QIODevice::Text);
QTextStream out(&file);

View File

@ -533,6 +533,8 @@ struct sr_output {
void *priv;
uint64_t start_sample_index;
char time_string[30];
};
/** Generic option struct used by various subsystems. */

View File

@ -154,8 +154,8 @@ static GString *gen_header(const struct sr_output *o)
/* Some metadata */
t = time(NULL);
g_string_append_printf(header, "; CSV, generated by %s on %s",
PACKAGE_STRING, ctime(&t));
g_string_append_printf(header, "; CSV, generated by %s on %s\n",
PACKAGE_STRING, o->time_string); //ctime(&t)
/* Columns / channels */
if (ctx->type == SR_CHANNEL_LOGIC)