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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
|
------------------------------------------------------------------------------
lxi-tools Lua API
------------------------------------------------------------------------------
Both the lxi tool and lxi-gui tool add the following lua functions in addition
to the standard lua library functions.
------------------------------------------------------------------------------
Function
device = lxi_connect(address, port, name, timeout, protocol)
Description
Connect to LXI compatible device
Parameters
address: Address of remote device to connect [string]
port: Port of remote device [integer] (only used for RAW connections)
name: Name of remote device [string] (only used for VXI11 connection,
best use nil to default to "inst0")
timeout: Timeout in milliseconds [integer]
protocol: Communications protocol to use [VXI11, RAW]
Returns
device: Handle of device
------------------------------------------------------------------------------
Function
response = lxi_scpi(device, command, timeout)
Description
Send SCPI command and receive response if expected
Parameters
device: Handle of connected device
command: SCPI command to send [string]. A response is expected if the
command ends with "?".
timeout: Timeout in milliseconds [integer]
Returns
response: Returns response [string] if command string ended with "?". If an
error (timeout etc.) occurs the response is nil.
------------------------------------------------------------------------------
Function
lxi_disconnect(device)
Description
Disconnect connected device
Paramters
device: Handle of device
------------------------------------------------------------------------------
Function
lxi_sleep(time)
Description
Sleep for specified amount of time
Parameters
time: Time to sleep in seconds [integer]
------------------------------------------------------------------------------
Function
lxi_msleep(time)
Description
Sleep for specified amount of time
Parameters
time: Time to sleep in milliseconds [integer]
------------------------------------------------------------------------------
Function
clock = lxi_clock_new()
Description
Create new clock resource
Returns
clock: Handle of new clock
------------------------------------------------------------------------------
Function
time = lxi_clock_read(clock)
Description
Read out the elapsed time of the clock since first clock_read() call
Paramters
clock: Handle of clock
Returns
time: Time in seconds since last call [double]. If first call it will
return 0 and the clock will start ticking.
------------------------------------------------------------------------------
Function
lxi_clock_reset(clock)
Description
Reset clock so that it stops ticking. First clock_read() will make the
clock tick again.
Paramters
clock: Handle of clock
------------------------------------------------------------------------------
Function
lxi_clock_free(clock)
Desription
Release clock resource
Parameters
clock: Handle of clock
------------------------------------------------------------------------------
Function
log = lxi_log_new()
Description
Create new log resource
Returns
log: Handle of new log
------------------------------------------------------------------------------
Function
lxi_log_add(log, ...)
Description
Log data to log.
This is a variadic function which means that it can take a variable number
of arguments and log them. Each log argument can be of any type.
Example:
log_add(log, 42, "hello", 4242).
The resulting line in the CSV output file will look like this:
42,"hello",4242
Parameters
log: Handle of log
------------------------------------------------------------------------------
Function
lxi_log_save_csv(log, filename)
Description
Save log data to CSV formatted (RFC 4180) log file.
Parameters
log: Handle of log
filename: Name of CSV file [string]
------------------------------------------------------------------------------
Function
lxi_log_free(log)
Desription
Release log resource
Parameters
log: Handle of log
------------------------------------------------------------------------------
Additionally, the lxi-gui tool adds the following lua functions to present and
manage data via the GUI.
NOTE: These functions can only be used when running scripts via lxi-gui.
------------------------------------------------------------------------------
Function
chart = lxi_chart_new(type, ...)
Description
Create and present a new chart. The chart is opened in a new window.
Parameters
type: Chart type [string]
The type can be any of the following:
"line"
"scatter"
"number"
"angular-gauge"
"linear-gauge"
The number of parameters following the first parameter depends on
which type of chart is requested:
"line", "scatter":
title: Title [string]
x_label: Label of x-axis [string]
y_label: Label of y-axis [string]
x_max: Maximum value of x-axis [double]
y_max: Maximum value of y-axis [double]
width: Width of window in pixels [integer]
"number":
title: Title [string]
label: Label [string]
width: Width of window in pixels [integer]
"angular-gauge", "linear-gauge":
title: Title [string]
label: Label [string]
value_min: Minimum value [double]
value_max: Maximum value [double]
width: Width of window in pixels [integer]
Returns
chart: Handle of chart
------------------------------------------------------------------------------
Function
lxi_chart_plot(chart, x, y)
Description
Plot x and y value to chart
Paramters
chart: Handle of chart
x: X value [double]
y: Y value [double]
------------------------------------------------------------------------------
Function
lxi_chart_save_csv(chart, filename)
Description
Save plotted data to CSV file
Paramters
chart: Handle of chart
filename: Name of CSV file [string]
------------------------------------------------------------------------------
Function
lxi_chart_save_png(chart, filename)
Description
Save image of plotted chart to PNG file
Paramters
chart: Handle of chart
filename: Name of PNG file [string]
------------------------------------------------------------------------------
Function
lxi_chart_close(chart)
Description
Close chart window
Paramters
chart: Handle of chart
------------------------------------------------------------------------------
Function
version = lxi_version()
Description
Get version of lxi-tools
Returns
version: Version of lxi-tools [string]
------------------------------------------------------------------------------
Function
ip = lxi_selected_ip()
Description
Get IP of device selected in GUI
Returns
ip: IP of device selected in GUI [string]. Returns nil if none selected.
------------------------------------------------------------------------------
Function
id = lxi_selected_id()
Description
Get ID of device selected in GUI
Returns
id: ID of device selected in GUI [string]. Returns nil if none selected.
------------------------------------------------------------------------------
|