iks: Control the IKS Aquastar computer from within R

Description Usage Arguments Value Author(s) See Also Examples

Description

Connect to an IKS Aquastar through a serial (com) port and control it.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## S3 method for class 'iksdata'
print(x, ...)

iks_process(msg, iks_name = "iks")

iks_get_all()

iks_get_name(port = getOption("iks_port"))

iks_get_data(port = getOption("iks_port"), iks_name = NULL)

iks_set_data(data, port = getOption("iks_port"), iks_name = NULL)

iks_open(
  port = getOption("iks_port"),
  iks_name = "iks",
  probes_names = paste("p0", 1:8, sep = ""),
  sockets_names = sprintf("s%02d", 1:16),
  procfun = iks_process
)

iks_close(port = getOption("iks_port"))

iks_cmd(code, port = getOption("iks_port"), new_line = TRUE)

iks_info(port = getOption("iks_port"), wait = 500)

iks_get_config(port = getOption("iks_port"), wait = 500)

Arguments

x

An iksdata object.

...

Further arguments passed to the print() method.

msg

The message send back from the IKS Aquastar.

iks_name

The name you want to use for the IKS Aquastar module.

port

A serial port such as "com1", or its number such as 1. For iks_close(), you can also specify "all" to close all IKS ports.

data

The IKS data to record (this is a list with components name, port, version, config, probes, units, triggers, sockets, sockets_ctrl and time.

probes_names

The name to use for the eight IKS probes.

sockets_names

The name to use for the 16 IKS sockets.

procfun

An R function used to process data returned by the IKS Aquastar.

code

Code to send to the IKS Aquastar.

new_line

Do we add a newline after the code send (yes by default)?

wait

Time to wait between characters send to the IKS Aquastar (500ms by default). Do not use too low values, or the device will not receive all code correctly.

Value

iks_open() returns TRUE in case of success, FALSE otherwise.

iks_close() returns the com port(s) that was/were closed.

iks_cmd() and iks_info() return nothing. They are used for their side effects of triggering some response by the IKS Aquastar. That response is treated in an asynchronous way by the procfun provided to iks_open().

iks_get_all() gets the list of all currently connected IKS Aquastars (a vector of characters with corresponding com ports, and with names as specified in the iks_name argument of iks_open()).

iks_get_name() gets the name of an IKS Aquastar, providing the com port it is connected to.

iks_get_data() and iks_set_data() are used to retrieve or set the current state of the IKS. iks_set_data() should not be used in a different context than an iks_process() and should update the IKS data according to what is received from the IKS Aquastar trough the com port.

iks_get_config() triggers a dumping of the complete configuration of the IKS Aquastar... it takes a couple of seconds to complete! After this command, the whole current config is stored in binary format in the config component and the current state of sockets is updated.

iks_process() is the default workhorse function to process incoming IKS data. It can be replaced by you own custom function, but it is already pretty flexible. The default function allows to call custom events in the form of R functions that accept two arguments, data and iks_name. They must be saved in the TempEnv environment and have predefined names, depending on the event that should trigger them: iks_date_proc() when the date is received from the IKS, indicating a complete cycle of data sending, iks_socket_proc() on receiving socket config data, and iks_config_proc() on receiving IKS config data.

Author(s)

Philippe Grosjean Philippe.Grosjean@umons.ac.be

See Also

wtw_open(), gce8_open()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
iks_get_all()
iks_open(port = "com1") # Change to the port where your IKS is connected!
iks_get_all()
iks_get_name()

# To debug exchanges with the IKS aquastar:
options(debug_iks = TRUE)

iks_get_data()   # Current data as recorded in the IKS
iks_get_config() # Get the whole IKS config
iks_get_data()   # Should be visible now!

# Stop the connection with the IKS
iks_close()
iks_get_all()

## End(Not run)

EcoNum/econum documentation built on May 9, 2020, 3:57 a.m.