mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
removed time_{fscan,fprint} functions to avoid code duplication
This commit is contained in:
parent
4ba0f17366
commit
1b9a1abffd
3 changed files with 4 additions and 18 deletions
|
@ -48,10 +48,4 @@ double time_to_double(struct timespec *ts);
|
|||
/** Convert double containing seconds after 1970 to timespec. */
|
||||
struct timespec time_from_double(double secs);
|
||||
|
||||
/** Read a timestamp from a file with the format: "secs.nanosecs\t" */
|
||||
int time_fscan(FILE *f, struct timespec *ts);
|
||||
|
||||
/** Write a timestamp to a file with the format: "secs.nanosecs\t" */
|
||||
int time_fprint(FILE *f, struct timespec *ts);
|
||||
|
||||
#endif /* _TIMING_H_ */
|
|
@ -107,12 +107,14 @@ int file_open(struct node *n)
|
|||
serror("Failed to start timer");
|
||||
}
|
||||
else {
|
||||
struct msg m;
|
||||
/* Get current time */
|
||||
struct timespec now, tmp;
|
||||
clock_gettime(CLOCK_REALTIME, &now);
|
||||
|
||||
/* Get timestamp of first sample */
|
||||
time_fscan(f->in, &f->start); rewind(f->in);
|
||||
msg_fscan(f->in, &m, NULL, NULL);
|
||||
first = MSG_TS(&m);
|
||||
|
||||
/* Set offset depending on epoch_mode */
|
||||
switch (f->epoch_mode) {
|
||||
|
|
|
@ -81,14 +81,4 @@ double time_delta(struct timespec *start, struct timespec *end)
|
|||
struct timespec diff = time_diff(start, end);
|
||||
|
||||
return time_to_double(&diff);
|
||||
}
|
||||
|
||||
int time_fscan(FILE *f, struct timespec *ts)
|
||||
{
|
||||
return fscanf(f, "%lu.%lu", &ts->tv_sec, &ts->tv_nsec);
|
||||
}
|
||||
|
||||
int time_fprint(FILE *f, struct timespec *ts)
|
||||
{
|
||||
return fprintf(f, "%lu.%09lu\t", ts->tv_sec, ts->tv_nsec);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue