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 copy paste a customized line from the left pane to the right pane.
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.
For example :
- 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