Skip to main content

Working with queries and models

You build models and interact with edges by running OSQL queries on the OSQL tab (see figure below).

  1. OSQL queries are written in OSQL query editor windows.
  2. Each editor window has a tab showing which device the query is run on, the name of the OSQL file, and if there are any unsaved changes (*).
  3. The output of the query is shown in the output window.
  4. The play button runs all queries in the query window.
  5. The output window button toggles visibility of the output window.
  6. The device selector specifies which device the query runs on.
  7. The output selector determines how the output is visualized.
  8. The model index lists all system and user models.

Queries are written in query editor windows (1). You can open multiple windows and navigate between them by using the window tabs (2). Each editor window can be saved as an OSQL file by using the save file icon in the top right corner. Saved files will end up as separate entries in the model index (8).

To run all queries in an editor window you press the play button (4). If you only want to run a specific query and not all queries in a window you can put the cursor on a query and press F2. Or you can select the query and press Ctrl+Return.

caution

When pressing the play button (4) you run ALL queries in the active editor window. If there are many and/or complex queries, this can put a considerable load on the device and result in SA Studio feeling unresponsive. In situations like this it is best to wait until all queries are done before continuing to operate SA Studio. When working with large code buffers it is recommended practice to do one of the following:

  1. Distribute the code across multiple buffers. For example, put all queries for system setup in one buffer and queries that require repeated evaluation in a separate buffer.
  2. Run the queries one at a time (using F2 or selecting a query and pressing Ctrl-Return).
  3. Save the buffer as a master.osql file in a new model and deploy the model to run the file.

Running a query generally generates some output in the output window (3). Whenever you stop a continuous query the output window closes. You can press the output window button (5) to toggle the visibility of the output window.

To select which device you want to run the query on, you pick a device from the device list (6) (see figure below). To run queries on the server you select “Server”, and to run queries on your edge device you select the name you gave it when you connected it to the server. “Local” should only be used in SA Studio Desktop, which is run locally on workstations, and is not part of SA Studio Community Edition.

You select the output format the same way by picking a format from the list of output types (7) (see figure below).

The OSQL tab also has a model index (8) which works like a file tree. The model index contains system models -- such as k-means, DBSCAN, and CAN bus -- and user models that you either create yourself or import from file.

New models can be created by right-clicking “User models” and selecting “Create new model” (see figure below). This will add a new folder to the model index under “user models” with a master.osql file and an auto-generated documentation file docs.md. In the master.osql file is where you write your model code.

Models can be deployed on any device by using the “deploy” button (up arrow) next to the model’s name. This will load and run master.osql on the device. It will also load any documentation provided with the model onto the device.