VSCode IDE for WarpScript
Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is free and open source. We developed a plugin for WarpScript files (.mc2 extension).
You can find more information here: https://marketplace.visualstudio.com/items?itemName=senx.warpscript-language
After installing VS Code, launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install senx.warpscript-language
Click install and restart VS Code.
Create a randomgts.mc2 file with your warpscript:
//create a new gts with random data [0.0,1.0] NEWGTS 'random data' RENAME //one point per second, 5 min from now NOW NOW 5 m + <% 1 s + %> <% NaN NaN NaN RAND ADDVALUE %> FORSTEP
If the extension is correctly loaded, you now have:
- Syntax highlighting
- Code completion
- Remote execution
- Hover definition
- Workspace macros
By default, VSCode extension will execute WarpScript on localhost API (http://127.0.0.1:8080/api/v0/exec). To change the Warp 10 server address, open the VSCode preferences (Ctrl+Shift+P, type "settings", press enter), search for "warpscript", and change the Warp10URL option.
Press Ctrl+Alt+E to run the warpscript.
JSON result will be displayed on the right part of the editor. You can beautify the JSON with VSCode "format document" command (Ctrl+Shift+P, type "format", press enter).
In the output, you can see useful information, such as execution time on the server, number of data point fetched in the storage, filename and endpoint.
VSCode WarpScript plugin will also open a GTS Preview tab. Click on this tab, select the GTS you want to view.
Warp 10 allow you to create images on the server side with Processing lib. These images are encoded as base64 strings on the stack output.
Copy paste a Processing example, run it. VSCode plugin will parse the stack output. If there is some images, it creates a new tab. Click on the Image Preview tab to see images.
Local Macro Substitution
By default, Warp 10 server reloads its macro directory every 60s. Your Warp 10 server might be remote, or managed by another team, so you cannot access the macro directory easily. In these case, developing and testing macros may be painful. VSCode plugin will try to find local macro in your working directory and insert them in your code before sending it to Warp 10 endpoint.
- a/b/macro.mc2 exists
- a/b/c/othermacro.mc2 refer to @a/b/macro
- test/mytest.mc2 refer to @a/b/c/othermacro
When executing mytest in VSCode, recursive substitutions will be done. Later, when your macros will be ready, you can deploy directory 'a' to Warp 10 macro directory.
If you want to deactivate this local substitution, add this special comment line at the top of your file:
// @localmacrosubstitution false
- Setup convenient shortcuts. Up to your keyboard, you can choose close letters for WarpScript execution and JSON format.
- Once fluent in WarpScript, autocompletion may annoy you. If so, delay the completion, using VSCode preference
"editor.quickSuggestionsDelay": 1000(for a 1s delay). (Ctrl+Shift+P, type "settings", press enter)
- When playing with several Warp 10 instances, you can specify the endpoint in a special comment line placed at the top of your file:
// @endpoint http://192.168.1.135/api/v0/exec
- Save one click: if you want to show the GTS Preview tab instead of the raw Json, you can set the Preview Tabs setting, or you can specify it in a special comment line placed at the top of your file:
// @preview gts
- Default Warp 10 platform unit is microsecond. If you set it to ms, the GTS preview will remain in microsecond. You can change the behavior either with the Default Time Unit setting, or you can specify it in a special comment line placed at the top of your file:
// @timeunit ns
- When you work with irregular time series, turn on the dots on the gts preview output with the Show Dots option. It will help you to spot missing data: