R client

EVA ICS machine learning kit R library can work both with and with no server installed. If there is no server installed, data is processed on the client side.

EVA ICS ML kit R client inside R-studio

EVA ICS ML kit R client inside R-studio

Installation

With remotes/devtools

install.packages("remotes")
remotes::install_github("eva-ics/eva-ics-ml-R")

Manual

In the system shell type:

git clone https://github.com/eva-ics/eva-ics-ml-R
cd eva-ics-ml-R
(
cat << EOF
install.packages("curl")
install.packages("httr")
install.packages("jsonlite")
install.packages("readr")
install.packages('.', repos=NULL, type='source', dependencies=TRUE)
EOF
) | R --no-save

Querying data

Note

When used with ML kit server, R client downloads data using CSV streams only.

library(evaics)
session <- eva.session('http://127.0.0.1:7727',
    user='admin', password='xxx', mlkit='http://localhost:8811')
req <- eva.history.request()
req <- eva.history.append_oid(req, 'sensor:tests/temp', value='temp1')
data <- eva.history.fetch(session, req,
    t_start='2023-02-22 23:23:34',
    t_end='2023-02-23 03:33:19', fill='15T')

If Machine learning kit server is used with a front-end and API methods are mapped to the same port, the argument “mlkit” of eva.session function can be just set to TRUE. If Machine learning kit server is not installed, do not set this argument or set it to FALSE.

A client can read mapping from a CSV file with fields “oid”, “status”, “value” and “database” (can be omitted if ML kit server is used):

req <- eva.history.request('params.csv')

Uploading data

Prepare a request the same way as querying (database parameter for OIDs is ignored). Then use “push” method to push a file. The file extension must match:

  • .arrows for Arrow streams

  • .arrow for Arrow files

  • .csv for CSV files

Instead of a file, a data frame can be submitted (in this case the data is uploaded as a CSV stream). The database service can be specified in a short manner (e.g. “id” for “eva.db.id”) or in full. Example:

eva.history.push(session, req, '/path/to/file.csv', database='mydb')

Module API

eva.session

Create a new EVA ICS session

Description

Create a new EVA ICS session

Usage

eva.session(
  url = "http://localhost:7727",
  user = NULL,
  password = NULL,
  key = NULL,
  timeout = 120,
  mlkit = FALSE
)

Arguments

Argument

Description

url

HMI or front-end server URL

user

user login (for login/password authentication)

password

user password

key

API key (for API key authentication)

timeout

timeout for HTTP requests

mlkit

if ML Kit server is installed: TRUE (if front-end server is used) or ML Kit server URL

eva.authenticate

Authenticate the session (usually not called manually)

Description

Authenticate the session (usually not called manually)

Usage

eva.authenticate(session)

Arguments

Argument

Description

session

eva.call

Perform a RPC call on HMI service

Description

Perform a RPC call on HMI service

Usage

eva.call(session, method, params = list())

Arguments

Argument

Description

session

method

RPC method

params

method params

eva.credentials

Set session credentials for login/password authentication

Description

Set session credentials for login/password authentication

Usage

eva.credentials(session, user, password)

Arguments

Argument

Description

session

user

user login

password

user password

eva.test

Execute “test” RPC method on HMI service

Description

Execute “test” RPC method on HMI service

Usage

eva.test(session)

Arguments

Argument

Description

session

eva.history.request

Create a new item state history request

Description

Create a new item state history request

Usage

eva.history.request(params_csv = NULL)

Arguments

Argument

Description

params_csv

Load oid map params from a CSV file

eva.history.append_oid

Append item OID mapping to a request

Description

Append item OID mapping to a request

Usage

eva.history.append_oid(
  request,
  oid,
  status = FALSE,
  value = FALSE,
  database = NULL,
  xopts = NULL
)

Arguments

Argument

Description

request

oid

item OID

status

status mapping: TRUE or col name

value

value mapping: TRUE or col name

database

database service to load state from

xopts

extra database request options

eva.history.fetch

Fetch state history data

Description

Fetch state history data

Usage

eva.history.fetch(
  session,
  request,
  t_start = NULL,
  t_end = NULL,
  fill = NULL,
  limit = NULL,
  database = NULL,
  xopts = NULL,
  t_col = "keep",
  tz = NULL
)

Arguments

Argument

Description

session

request

Request object

t_start

start time: date/time or unix timestamp

t_end

end time: date/time or unix timestamp

fill

fill: NX, where X: S for seconds, T for minutes, H for hours, D for days, W for weeks, e.g. 15T

limit

limit result records to

database

database service to perform request on

xopts

extra options

t_col

time column processing: keep (default) or drop

tz

time zone

eva.history.push

Push data to a database service

Description

Push data to a database service

Usage

eva.history.push(session, request, data, database = "default")

Arguments

Argument

Description

session

request

request object

data

file path or a data frame

database

database to push data to (default: default)