Skip to main content

File

The file node-type can be used to log or replay samples to / from disk.

Prerequisites

This node-type does not have any special library dependencies. It is always available.

Implementation

The source code of the node-type is available here: https://github.com/VILLASframework/node/blob/master/lib/nodes/file.cpp

Configuration

Every file node can be configured to only read or write or to do both at the same time. The node configuration is divided into two sub-groups: in and out.

Format Object (object) or Format Name (string) (format_spec)
uri
string <uri>

Specifies the URI to a file from which is written to or read from depending in which group (inor out) is used.

This setting allows to add special placeholders for time and date values. See strftime(3) for a list of supported placeholder.

Example:

uri = "logs/measurements_%Y-%m-%d_%H-%M-%S.log"

will create a file called:

./logs/measurements_2015-08-09_22-20-50.log
object (Input configuration (received by VILLASnode))
object (Output configuration (sent out by VILLASnode))
vectorize
integer
Default: 1

This setting allows to send multiple samples in a single message to the destination nodes.

The value of this setting determines how many samples will be combined into one packet.

Array of Hook Object (object) or Hook Name (string) (hook_list)
builtin
boolean (Builtin hook functions)
Default: true

By default, each node and paths has a couple of default hooks attached to them. With this setting the attachment of built-in hooks can be disabled.

{
  • "format": "villas.human",
  • "in": {
    },
  • "out": {
    },
  • "vectorize": 1,
  • "hooks": [
    ],
  • "builtin": true
}

Example

node/etc/examples/nodes/file.conf
nodes = {
file_node = {
type = "file"

# These options specify the URI where the the files are stored
# The URI accepts all format tokens of (see strftime(3))
uri = "logs/input.log"
# uri = "logs/output_%F_%T.log"

format = "csv"

in = {
# One of: direct (default), wait, relative, absolute
epoch_mode = "direct"

# The interpretation of this value depends on epoch_mode (default is 0)
# Consult the documentation of a full explanation
epoch = 10

# A constant rate at which the lines of the input files should be read
# A missing or zero value will use the timestamp in the first column
# of the file to determine the pause between consecutive lines
rate = 2.0

# Rewind the file and start from the beginning
eof = "rewind"

# Creates a stream buffer if value is positive
buffer_size = 0
}

out = {
# Flush or upload contents of the file every time new samples are sent
flush = false

# Creates a stream buffer if value is positive
buffer_size = 0
}
}
}