openc3 vscode - BETA
NOTE: This is not an official OpenC3 extension and is not maintained by the OpenC3 team. For bugs/feedback, use this Issue Tracker
This extension aims to assist in the local development of openc3/cosmos plugins/scripts.
Features
Works with many plugin directories in a single workspace/folder
Extension is not strict about structure/layout. Entire workspace is scanned and contextualized to generate cmd/tlm definitions etc.
Scripting completions/suggestions
Python:
- Suggestions/Autocompletions for most common api functions ie.
cmd,tlm,wait_check,etc.
- Full API stub injection with type info
load_utility('<plugin/path>')
dynamically resolves imports (if source exists in your workspace)
Ruby:
- Suggestions/Autocompletions for most common api functions ie.
cmd,tlm,wait_check,etc.
Configuration completions/suggestions and highlighting
Embedded Ruby Support (ERB)
Open from command palette with openc3.showERB
- or click the eye
icon in the top right
Adding missing/custom erb values (typically not required)
NOTE: The target_name
variable is automatically generated during compilation.
Create a file named openc3-erb.json
near your configuration files that require erb definitions. A workspace can contain any number of erb configuration files.
plugin/target/cmd_tlm/cmd.txt <-- file with unresolvable erb definitions
These are all valid
- plugin/target/cmd_tlm/openc3-erb.json <- Scoped to only what is in cmd_tlm directory
- plugin/target/openc3-erb.json <- Scoped to everything in the target
- plugin/openc3-erb.json <- Scoped to everything in the plugin
- openc3-erb.json <- Scoped to everything
Update the openc3-erb.json
with variables
and patterns
. If either is not required, simply assign it to an empty object like so "variables": {}
{
"variables": {
"var_name": "value"
},
"patterns": {
"<some-regex/string>": "replace with this"
}
}
The "variables"
object directly instantiates ruby variables by name, any erb in any configuration file within the scope will be able to reference these variables.
Example:
// plugin/cmd_tlm/openc3-erb.json
{
"variables": {
"my_variable": "COMMAND_MNEMONIC"
},
"patterns": {}
}
# plugin/cmd_tlm/cmd.txt
COMMAND <%= target_name %> <%= my_variable %> ...
# Becomes
COMMAND TARGET_NAME COMMAND_MNEMONIC
The "patterns"
object will simply replace whatever pattern is supplied with any other value. Useful if you have some custom preprocessor on top of your plugin generation workflow.
Example:
// plugin/openc3-erb.json
{
"variables": {},
"patterns": {
"%%target_hostname%%": "127.0.0.1"
}
}
# plugin/plugin.txt
VARIABLE host %%target_hostname%%
INTERFACE MY_INTERFACE openc3/interfaces/udp_interface.py <%= host %> ...
# Becomes
VARIABLE host '127.0.0.1'
INTERFACE MY_INTERFACE openc3/interfaces/udp_interface.py 127.0.0.1 ...
Requirements
NOTE: This extension will only activate if your workspace contains both:
- Plugin files (plugin.txt)
- Rakefiles (Rakefile)
Certain python scripting features will not work properly without the pylance extension.
This extension automatically generates pylance configuration settings in .vscode/settings.json
Extension Settings
This extension contributes the following settings:
openc3.ignoreDirectories
: list of directory names to ignore for context generation
openc3.autoGitignore
: Set to false to prevent .gitignore updates for scripting stubs
openc3.autoEditorHide
: Set to false to prevent editor from hiding generated .pyi stub files
Known Issues
There are probably tons, you are welcome to open issues here
Release Notes
0.0.1
Initial release, includes minimum set of features to be somewhat useful
0.1.2
Resolve quirky behavior in scripting autocompletions