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 ( This setting allows to add special placeholders for time and date values. See strftime(3) for a list of supported placeholder. Example:
will create a file called:
|
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": {
- "epoch": 0,
- "epoch_mode": "direct",
- "rate": 0,
- "eof": "rewind",
- "buffer_size": 0,
- "signals": [
- {
- "name": "tap_position",
- "type": "integer",
- "init": 0
}, - {
- "name": "voltage",
- "type": "float",
- "unit": "V",
- "init": 230
}
], - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "out": {
- "flush": true,
- "buffer_size": 0,
- "vectorize": 0,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
]
}, - "vectorize": 1,
- "hooks": [
- "print",
- {
- "type": "limit_rate",
- "rate": 1000
}
], - "builtin": true
}Example
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
}
}
}