mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
renamed ‚path‘ setting of file node-type to ‚uri‘ in preparation for upcoming advio remote IO
This commit is contained in:
parent
aa62c8af99
commit
ec49fc6bad
4 changed files with 22 additions and 22 deletions
|
@ -7,9 +7,9 @@ The `file` node-type can be used to log or replay samples to / from disk.
|
|||
Every `file` node can be configured to only read or write or to do both at the same time.
|
||||
The node configuration is splitted in to groups: `in` and `out`.
|
||||
|
||||
#### `path` *(string: filesystem path)*
|
||||
#### `uri` *(string: libcurl URI)*
|
||||
|
||||
Specifies the path to a file from which is written to or read from (depending in which group is used).
|
||||
Specifies the URI to a file from which is written to or read from depending in which group (`in`or `out`) is used.
|
||||
|
||||
See below for a description of the file format.
|
||||
This setting allows to add special paceholders for time and date values.
|
||||
|
@ -17,7 +17,7 @@ See [strftime(3)](http://man7.org/linux/man-pages/man3/strftime.3.html) for a li
|
|||
|
||||
**Example**:
|
||||
|
||||
out = "logs/measurements_%Y-%m-%d_%H-%M-%S.log"
|
||||
uri = "logs/measurements_%Y-%m-%d_%H-%M-%S.log"
|
||||
|
||||
will create a file called: *path_of_working_directory*/logs/measurements_2015-08-09_22-20-50.log
|
||||
|
||||
|
@ -29,7 +29,7 @@ Specifies the mode which should be used to open the output file.
|
|||
See [open(2)](http://man7.org/linux/man-pages/man2/open.2.html) for an explanation of allowed values.
|
||||
The default value is `w+` which will start writing at the beginning of the file and create it in case it does not exist yet.
|
||||
|
||||
#### `epoch_mode` *("direct"|"wait" | "relative"|"absolute")*
|
||||
#### `epoch_mode` *("direct" | "wait" | "relative" | "absolute")*
|
||||
|
||||
The *epoch* describes the point in time when the first message will be read from the file.
|
||||
This setting allows to select the behaviour of the following `epoch` setting.
|
||||
|
@ -65,7 +65,7 @@ If this setting has a non-zero value, the default behaviour is overwritten with
|
|||
|
||||
Only valid for the `out` group.
|
||||
|
||||
Splits the output file every `split` mega-byte. This setting will append the chunk number to the `path` setting.
|
||||
Splits the output file every `split` mega-byte. This setting will append the chunk number to the `uri` setting.
|
||||
|
||||
Example: `data/my_measurements.log_001`
|
||||
|
||||
|
@ -84,7 +84,7 @@ Expects the input data in splitted format.
|
|||
### The following settings are specific to the file node-type!! ###
|
||||
|
||||
in = {
|
||||
path = "logs/input.log", # These options specify the path prefix where the the files are stored
|
||||
uri = "logs/input.log", # These options specify the URI where the the files are stored
|
||||
mode = "w+", # The mode in which files should be opened (see open(2))
|
||||
|
||||
epoch_mode = "direct" # One of: direct (default), wait, relative, absolute
|
||||
|
@ -98,7 +98,7 @@ Expects the input data in splitted format.
|
|||
splitted = false
|
||||
},
|
||||
out = {
|
||||
path = "logs/output_%F_%T.log" # The output path accepts all format tokens of (see strftime(3))
|
||||
URI = "logs/output_%F_%T.log" # The output URI accepts all format tokens of (see strftime(3))
|
||||
mode = "a+" # You might want to use "a+" to append to a file
|
||||
|
||||
split = 100, # Split output file every 100 MB
|
||||
|
|
|
@ -84,7 +84,7 @@ nodes = {
|
|||
### The following settings are specific to the file node-type!! ###
|
||||
|
||||
in = {
|
||||
path = "logs/input.log", # These options specify the path prefix where the the files are stored
|
||||
uri = "logs/input.log", # These options specify the path prefix where the the files are stored
|
||||
mode = "r", # The mode in which files should be opened (see open(2))
|
||||
|
||||
epoch_mode = "direct" # One of: direct (default), wait, relative, absolute
|
||||
|
@ -98,7 +98,7 @@ nodes = {
|
|||
splitted = false
|
||||
},
|
||||
out = {
|
||||
path = "logs/output_%F_%T.log" # The output path accepts all format tokens of (see strftime(3))
|
||||
uri = "logs/output_%F_%T.log" # The output path accepts all format tokens of (see strftime(3))
|
||||
mode = "a+" # You might want to use "a+" to append to a file
|
||||
|
||||
split = 100, # Split output file every 100 MB
|
||||
|
|
|
@ -31,7 +31,7 @@ struct file {
|
|||
const char *mode; /**< libc: fopen() mode */
|
||||
const char *fmt; /**< Format string for file name. */
|
||||
|
||||
char *path; /**< Real file name */
|
||||
char *uri; /**< Real file name */
|
||||
|
||||
int chunk; /**< Current chunk number. */
|
||||
int split; /**< Split file every file::split mega bytes. */
|
||||
|
@ -44,7 +44,7 @@ struct file {
|
|||
EPOCH_ABSOLUTE
|
||||
} read_epoch_mode; /**< Specifies how file::offset is calculated. */
|
||||
|
||||
struct timespec read_first; /**< The first timestamp in the file file::path_in */
|
||||
struct timespec read_first; /**< The first timestamp in the file file::{read,write}::uri */
|
||||
struct timespec read_epoch; /**< The epoch timestamp from the configuration. */
|
||||
struct timespec read_offset; /**< An offset between the timestamp in the input file and the current time */
|
||||
|
||||
|
|
|
@ -41,13 +41,13 @@ static char * file_format_name(const char *format, struct timespec *ts)
|
|||
static FILE * file_reopen(struct file_direction *dir)
|
||||
{
|
||||
char buf[FILE_MAX_PATHLEN];
|
||||
const char *path = buf;
|
||||
const char *uri = buf;
|
||||
|
||||
/* Append chunk number to filename */
|
||||
if (dir->chunk >= 0)
|
||||
snprintf(buf, FILE_MAX_PATHLEN, "%s_%03u", dir->path, dir->chunk);
|
||||
snprintf(buf, FILE_MAX_PATHLEN, "%s_%03u", dir->uri, dir->chunk);
|
||||
else
|
||||
path = dir->path;
|
||||
uri = dir->uri;
|
||||
|
||||
if (dir->handle)
|
||||
fclose(dir->handle);
|
||||
|
@ -59,7 +59,7 @@ static int file_parse_direction(config_setting_t *cfg, struct file *f, int d)
|
|||
{
|
||||
struct file_direction *dir = (d == FILE_READ) ? &f->read : &f->write;
|
||||
|
||||
if (!config_setting_lookup_string(cfg, "path", &dir->fmt))
|
||||
if (!config_setting_lookup_string(cfg, "uri", &dir->fmt))
|
||||
return -1;
|
||||
|
||||
if (!config_setting_lookup_string(cfg, "mode", &dir->mode))
|
||||
|
@ -139,7 +139,7 @@ char * file_print(struct node *n)
|
|||
}
|
||||
|
||||
strcatf(&buf, "in=%s, epoch_mode=%s, epoch=%.2f, ",
|
||||
f->read.path ? f->read.path : f->read.fmt,
|
||||
f->read.uri ? f->read.uri : f->read.fmt,
|
||||
epoch_str,
|
||||
time_to_double(&f->read_epoch)
|
||||
);
|
||||
|
@ -150,7 +150,7 @@ char * file_print(struct node *n)
|
|||
|
||||
if (f->write.fmt) {
|
||||
strcatf(&buf, "out=%s, mode=%s, ",
|
||||
f->write.path ? f->write.path : f->write.fmt,
|
||||
f->write.uri ? f->write.uri : f->write.fmt,
|
||||
f->write.mode
|
||||
);
|
||||
}
|
||||
|
@ -187,15 +187,15 @@ int file_open(struct node *n)
|
|||
if (f->read.fmt) {
|
||||
/* Prepare file name */
|
||||
f->read.chunk = f->read.split ? 0 : -1;
|
||||
f->read.path = file_format_name(f->read.fmt, &now);
|
||||
f->read.uri = file_format_name(f->read.fmt, &now);
|
||||
|
||||
/* Open file */
|
||||
f->read.handle = file_reopen(&f->read);
|
||||
if (!f->read.handle)
|
||||
serror("Failed to open file for reading: '%s'", f->read.path);
|
||||
serror("Failed to open file for reading: '%s'", f->read.uri);
|
||||
|
||||
/* Create timer */
|
||||
f->read_timer = (f->read_rate)
|
||||
f->read_timer = f->read_rate
|
||||
? timerfd_create_rate(f->read_rate)
|
||||
: timerfd_create(CLOCK_REALTIME, 0);
|
||||
if (f->read_timer < 0)
|
||||
|
@ -252,8 +252,8 @@ int file_close(struct node *n)
|
|||
{
|
||||
struct file *f = n->_vd;
|
||||
|
||||
free(f->read.path);
|
||||
free(f->write.path);
|
||||
free(f->read.uri);
|
||||
free(f->write.uri);
|
||||
|
||||
if (f->read_timer)
|
||||
close(f->read_timer);
|
||||
|
|
Loading…
Add table
Reference in a new issue