Manual 1.0.130Download PDF

Chapter 17Using LOGADEC from AI

LOGADEC has an entry point for AI (an API inside the page). Ask an AI that can operate the browser (for example an AI that runs as a Chrome extension) something like "With this test data, find the series that are closely related to the oil temperature". The AI then calls LOGADEC commands to read the data, change the view, analyze, and save the results to files.

LOGADEC itself does not communicate with the outside for this. The AI calls the commands from inside the same page as the screen.

17.1What the AI can do

Category Examples
Read The loaded files and series, statistics of a series (min, max, mean and so on), thinned waveforms, the current view range, the lists of tabs and presets
Change the view Show and hide series, X and Y ranges, overlay, stacked or FFT, create and switch tabs, apply presets, measurement cursors
Analysis and formulas Add formula series, tables of statistics, FFT peaks and correlation
Files List and load files in the folder you allowed, load CSV made by the AI, save data (CSV, TSV, XLSX), chart images (PNG) and reports (Chapter 16)

What the AI cannot do:

  • Delete data or files, or reset the settings
  • Anything about the license
  • Read files in a folder you have not allowed (by the rules of the browser, a person has to choose the folder)

17.2How to use

  1. Open LOGADEC and load the data (to let the AI load it, see "When the AI uses a folder" below)
  2. Tell the AI that it may operate LOGADEC on this page. If you opened the LOGADEC file by double-clicking it, allow access to file URLs in the settings of the AI extension
  3. Ask the AI. If you add "First read LOGADEC.guide() on this page", the AI reads the list of commands and a summary of the current data before it starts

Examples:

  • "Read LOGADEC.guide(), then find when Vibration RMS became large and which series moved with it"
  • "Add a formula for power from Current and Voltage, zoom to 300 s to 400 s, and save it as an image"
  • "Load run1.csv to run5.csv from the folder one by one and make a table of the maximum oil temperature of each"

17.3When the AI uses a folder

To read or save files, the AI needs a folder that a person has chosen and allowed. When the AI wants to use a folder, a bar appears at the top of the page.

The bar shown when the AI wants to use a folder
Figure 17-1The bar shown when the AI wants to use a folder
  1. 1What the AI wants to do
  2. 2Choose folder: opens the folder picker. The AI can read and write only inside the folder you choose
  3. 3Cancel: refuses (the AI is told that you refused)
  • The chosen folder is remembered. When you open LOGADEC again and the browser asks for permission again, press Allow on the bar once. Other folder chooses another folder
  • The bar goes away after about two minutes (the AI is told that there was no answer)
  • When no folder is allowed, files saved by the AI are downloaded. Some browsers ask before several downloads in a row
  • If a file with the same name is in the folder, it is not overwritten unless the AI asks to overwrite it
  • Loading a .lgd file replaces everything, so it is loaded only when the AI confirms it. .xls and .xlsm files need a confirmation on the screen, so the AI does not load them

17.4Undo

When the AI has changed the view, pressing undo on the toolbar once goes back to before that command. When the AI ran several commands together, one undo reverts all of them.

As with the screen, switching tabs and the measurement cursors are not recorded for undo. Loading data and saving files cannot be undone either.

17.5Free and paid

Commands that read (lists, statistics, thinned waveforms, the current view, the guide) work in the Free edition. Commands that change the view, analysis and formulas, and file commands are features of the paid edition. If they are called in the Free edition, the AI is told that the feature needs the paid edition.

Limits such as the number of series shown at once are the same as on the screen.

17.6WebMCP (experimental)

Chrome and Edge have an experimental feature that lets a page show "tools" to AI (WebMCP). In a browser with this feature, LOGADEC registers its commands as tools when it opens (such as logadec.series.stats). An AI that supports it can find and use the LOGADEC commands from the list of tools.

WebMCP is experimental and works only when it is turned on in the browser settings. In a browser without it, nothing happens.

17.7Command list

The AI reads the list of commands and their arguments with LOGADEC.guide(). This table summarizes it.

Command What it does Free
app.guide A guide for AI (how to call, rules, the list of commands, a summary of the current data) Yes
app.info, app.status, app.state Version and available commands / whether the app is busy / a summary of the state Yes
sources.list, series.list Loaded files / series Yes
series.stats, series.sample Statistics of a series / thinned waveform Yes
view.get, tabs.list, presets.list The current view / tabs / presets and report templates Yes
formula.list, analysis.list Formulas / available analyses Yes
series.show Show and hide series
view.setXRange, view.setYRange, view.setMode X and Y ranges / overlay, stacked, FFT
tabs.create, tabs.switch Create / switch tabs
presets.apply Apply a preset
cursor.set Place the measurement cursors and read the values
formula.add Add a formula series
analysis.run Tables of statistics, FFT peaks and correlation
steps.run Run several commands together (one undo) Yes *
files.grantFolder, files.list, files.load Ask for a folder / list / load
data.loadText Load CSV made by the AI
export.data, export.image, report.build Save data / a chart image / a report

* steps.run itself works in the Free edition, but each command in it follows its own rule.

17.8For developers

Call the commands from JavaScript in the page. Every command returns its result when it has finished, and never throws.

const r = await LOGADEC.run('series.stats', { series: 'Oil temp', from: 100, to: 200 });
// success: { ok: true, data: { count, min, max, mean, ... }, changed: [], warnings: [] }
// failure: { ok: false, error: { code: 'not_found', message: '...', candidates: [...] } }
await LOGADEC.runSteps([{ cmd: 'series.show', args: { series: ['Oil temp', 'Current'], only: true } },
                        { cmd: 'view.setXRange', args: { from: 100, to: 300 } }]);
  • Refer to series by name. When two files have the same name, use { name, source }
  • X values are in the same display units as the screen (after the X zero offset, minutes and so on). The unit is in xUnit of the result
  • Error codes (error.code): not_found, ambiguous, bad_args, paid_only, limit, busy, needs_confirm, canceled, unsupported, internal. The messages are in English