Item state file writer (JSON/CSV)

Allows to write item states into JSON/CSV text files.

The files can be rotated with any external tool or manually. As soon as the file is rotated, a new one is created automatically.

Setup

Use the template EVA_DIR/share/svc-tpl/svc-tpl-filewriter.yml:

# Event-to-file writer service
command: svc/eva-svc-filewriter
bus:
  path: var/bus.ipc
config:
  file_path: /tmp/1.csv
  # flush data after each block (slow, but more reliable)
  auto_flush: false
  # use DOS-style CR/LF
  dos_cr: false
  # csv or json for NDJSON
  format: csv
  # periodically submit all item states
  interval: null
  # ignore real-time events
  ignore_events: false
  # event queue size
  queue_size: 8192
  # auto-rotation, a cron-like schedule:
  # second minute hour day month weekday year
  #
  # rotates the output file by renaming it to file_path.TIME_RFC3339
  #
  # the year field can be omitted
  # to run rotation every N, use */N
  #
  # the example below rotates the output file every hour
  #auto_rotate: "0 0 * * * *"
  #
  # item OIDs / OID masks
  oids:
    - "#"
# make sure the user has create/write access for the output file
user: eva

Create the service using eva-shell:

eva svc create eva.svc.fwriter1 /opt/eva4/share/svc-tpl/svc-tpl-filewriter.yml

or using the bus CLI client:

cd /opt/eva4
cat DEPLOY.yml | ./bin/yml2mp | \
    ./sbin/bus ./var/bus.ipc rpc call eva.core svc.deploy -

(see eva.core::svc.deploy for more info)

EAPI methods

See EAPI commons for the common information about the bus, types, errors and RPC calls.

flush

Description

Flushes the output file immediately

Parameters

none

Returns

nothing

rotate

Description

Rotates the output file, by renaming it to file_path.TIME_RFC3339

Parameters

none

Returns

nothing