Configuration
Restart SA Engine
To restart the SA Engine instance you open the Command Pallette (Ctrl+Shift+P
) and select "SA Engine: Restart current SA Engine".
Restart SA Engine with "SA Engine: Restart current SA Engine" in the Command Pallette.
Sometimes after having made changes to configuration files, SA Engine restart might not work. If you feel that you have provided correct settings but your changes do not take effect after restarting SA Engine, then restarting Visual Studio Code should fix the problem.
Extension settings
To access the SA VSCode settings:
- Go to the Extensions tab (
Ctrl+Shift+X
) on the Activity Bar - Scroll down to the sa-vscode extension
- Click on the cogwheel and choose "Extension settings"
SA VSCode settings.
By clicking "Edit in settings.json" you get to the settings.json
where you can specify various settings.
Set SA Engine binary
To specify which SA Engine binary the VSCode extension should run:
- Click "Edit in settings.json" under "Sa Engine: Load_dir" in the extension settings
- Write the path to the SA Engine bin folder in
"saEngine.load_dir": ""
(you need to escape "\
" in Windows paths)
SA Engine startup settings
You can specify some startup settings for SA Engine that will take effect whenever you restart the SA Engine instance. The settings need to be specified in a JSON file .sa_startup.json
, and the file needs to be in the root folder for your current Visual Studio Code workspace.
SA Engine startup settings file in the workspace root folder.
Some of the settings available are described in the following table:
SA Engine Startup Setting | Description |
---|---|
custom_flags | List of input parameters to SA Engine |
load_files | List of files to load when SA Engine starts |
SA_HOME | Set custom SA_HOME folder |
Pass input parameters to SA Engine
You can use the setting custom_flags
to pass input parameters to SA Engine.
For example, the following runs OSQL code that creates a function foo()
at startup:
{
"custom_flags": ["-o", "create function foo() -> charstring as 'Hello';"]
}
In the figure below we see that the function foo()
was created at startup by setting custom flags in .sa_startup.json
.
Set custom flags for SA Engine by setting "custom_flags" in .sa_startup.json
.
Load OSQL files on startup
You can use the setting load_files
to load OSQL files when SA Engine starts.
For example, the following loads the file start.osql
at startup:
{
"load_files": ["start.osql"]
}
In the figure below we see that the file start.osql
was loaded at startup by setting load_files
in .sa_startup.json
.
Load OSQL files on startup setting "load_files" in .sa_startup.json
.
Set custom SA_HOME folder
You can use the setting SA_HOME
to specify which folder you want to use as your SA_HOME.
For example, the following sets the SA_HOME folder to the SA/
folder in the workspace directory:
{
"SA_HOME": "SA"
}
Create a project folder somewhere in your user's home folder.
>mkdir C:\Users\my_user\my_project
In that folder, create an SA folder.
>cd C:\Users\my_user\my_project
>mkdir SA
Also in the project folder, create a file .sa_startup.json
with the following contents.
{
"SA_HOME": "SA"
}
Now your project folder should have an SA\
directory and a file .sa_startup.json
.
>dir
Volume in drive C is OS
Volume Serial Number is 48BE-CCC4
Directory of C:\Users\my_user\my_project
2024-05-23 11:17 <DIR> .
2024-05-23 11:17 <DIR> ..
2024-05-23 11:17 27 .sa_startup.json
2024-05-23 11:16 <DIR> SA
1 File(s) 27 bytes
3 Dir(s) 29 369 880 576 bytes free
Now start VSCode from the project folder (or open VSCode, select "Open Folder..." and select the my_project\
folder)
>code .
In the VSCode "EXPLORER" file explorer on the left you should see your project folder name as the top level, and the SA folder and .sa_startup.json
file below.
EXPLORER
v MY_PROJECT
> SA
{} .sa_startup.json
Now start an interactive OSQL window in VSCode (Ctrl-Shift-P
> "SA Engine: Create an Interactive OSQL Window"), and run the query sa_home();
, it should output the path to the SA folder in your project directory.
sa_home();
'c:/Users/my_user/my_project/SA/'
This means that whenever you open the project folder in VSCode, the SA Engine instance will use the local SA folder as your SA_HOME
(instead of the default SA_HOME
folder which is C:\Users\<username>\Documents\SA\
in Windows).
Now you can create a folder models/
in the SA folder, and copy (or move) all your project-specific models into this folder.
Benefits of this procedure:
Now you have a dedicated SA folder for this specific project and won't have to store your project models in your default SA folder, which can become cluttered. This makes for easier management of the files for the specific project. For example, the project directory could have its own git repository. This makes for easy version control of your model code related to the project.
You have convenient access to your model code in the VSCode file explorer. All files you need can be accessed inside the project folder in VSCode, e.g., there is no need to poke around in the
C:\Users\<username>\Documents\SA\
folder.When loading models in your local SA Engine instance you can use
models:load()
and it will load models from theSA\models\
directory in your project folder.You can deploy models (copy entire contents of models and run them) to edge devices with
models:deploy()
and it will deploy the models from theSA\models\
directory in your project folder.