B&R Automation ToolsB&R Automation Tools is an extension for Visual Studio Code to program and build B&R Automation Studio projects. The B&R Automation Tools extension is NOT a product of B&R Industrial Automation GmbH, it is a privately written and inofficial experiment. Therefore B&R Industrial Automation GmbH does not offer any support for this extension. For any bugs or feature requests please open a Github issue. ScopeThis extension does not intend to replace Automation Studio as the main IDE for B&R PLC projects. The main goal is to offer a good code editing experience for B&R projects within VS Code. The current development focus lays on C/C++ programs and libraries. B&R ressources such as executuable binaries etc. are not provided by this extension. Features which require such ressources are only available if the ressources are installed on your system. Readme contents
How to run the extensionFor non developersFrom VS Code marketplaceYou can download the extension in the VS Code marketplace. From VSIX installer
If you don't want to test the extension in your productive VS Code environment, consider to have a separate portable VS Code instance. For developers / To test the most recent source changesYou will need node.js installed on your computer
FeaturesAuto completion for C/C++ programs and librariesThe B&R Automation Tools extension provides information to the C/C++ extension specific to an Automation Studio project. This enables to use IntelliSense within C/C++ programs and libraries of Automation Studio projects. IntelliSense is also provided for variables, types, functions and function blocks within IEC files (_.var, _.typ, *.fun). Additional includes and compiler defines configured in the Automation Studio project are also included in the IntelliSense information. Currently the extension uses the header files created during an Automation Studio build to provide this information. Therefore after adjusting any of the IEC files, you need to build your project to get proper IntelliSense. A build of the cross reference is sufficient to create the header files. See Build B&R Automation Studio projects for further information. Detecting B&R Automation Studio projects in the workspace foldersAll Automation Studio projects within all opened workspace folders are detected by the B&R Automation Tools extension. This information is used to provide information for other features, such as build, code completion... When adding or removing a folder to the workspace, the information is automatically updated by the extension. Detecting and changing the active configurationSome settings like e.g. additional includes are PLC configuration specific. The active configuration is evaluated from the LastUser.set file in the root of your AS project. If no LastUser.set file is found in your project root, the first configuration is selected as the active configuration. The active configuration can be changed in two ways:
Build B&R Automation Studio projects
The B&R Automation Tools extension provides tasks which execute BR.AS.Build.exe. This makes it possible to build the project directly within VS Code. The tasks can be configured for a normal build, a build for a simulation target, creating an RUC package, cleaning the configuration and building the cross reference. You can start the tasks by executing the VS Code will then show a list with all possible task providers. Select The B&R Automation Tools extension will then provide a list of all standard tasks. Select one to directly execute it, or click the gear icon on the right side to configure it in your workspace. Configured tasks will be added to the tasks.json in the .vscode folder at the root of your workspace. There you can configure further options for your tasks, like e.g. the used build mode. VS Code will provide auto completion and descriptions for all available options. ExamplesA configured tasks.json file could look like this:
Check out the VS Code documentation for further information about tasks. Show errors and warnings of Automation Studio build in source codeThe B&R Automation Tools extension shows the error and warning output of a build task. The errors and warnings will show up in the Problems window, in the workspace browser and in the editor of the file where the issue was detected. Detecting installed B&R Automation Studio versionsB&R Automation Tools finds Automation Studio versions installed on the developer PC. The information of the installed Automation Studio versions is used to provide information for other features, such as build, code completion... The directory in which the Automation Studio versions are searched must be configured with the setting The setting needs to have the same value(s) as the install path selected during Automation Studio installation. No recursive search is done. After changing the installation path setting, the installed versions can be refreshed via the B&R Tools: Refresh installed AS version information ( ExampleIf Automation Studio V4.6.x and V4.7.x are installed in
For this case the setting Transfer the project to a PLC or ArSim
The B&R Automation Tools extension provides tasks which execute PVITransfer.exe. This makes it possible to transfer a project to a PLC or ArSim directly from VS Code. The tasks can be configured with various transfer settings which are usually available in the Runtime Utility Center or Automation Studio. You can start the tasks by executing the VS Code will then show a list with all possible task providers. Select The B&R Automation Tools extension will then provide a list of all standard tasks. Select one to directly execute it, or click the gear icon on the right side to configure it in your workspace. Configured tasks will be added to the tasks.json in the .vscode folder at the root of your workspace. There you can configure further options for your tasks, like e.g. the used transfer mode. VS Code will provide auto completion and descriptions for all available options.
ExamplesA configured tasks.json file could look like this:
Check out the VS Code documentation for further information about tasks. Detecting installed B&R PVI versionsB&R Automation Tools finds PVI versions installed on the developer PC. The information of the installed PVI versions is used to provide information for other features, such as the transfer of projects to a PLC or ArSim. The directory in which the PVI versions are searched must be configured with the setting After changing the setting, a reload of the VS Code window is required. ExampleIf PVI V4.6.x and V4.9.x are installed in
For this case the setting LoggingThe extension logs information, warnings and errors which occur to the output window. This can help you as a user to see if something went wrong and is also important information for us developers to find bugs. You can see all messages in the output window, when you select the Some of the log entries contain additional data in JSON format. With the default settings, this data is printed at the end of the same line.
This data can be pretty printed which makes it easier to analyze by setting
UI ElementsStatus BarBusy indicatorThe busy indicator in the status bar is shown whenever the extension is busy with a longer running task such as parsing the Automation Studio projects in the workspace. When hovering the indicator with the mouse pointer, a tooltip shows which tasks are currently executing. At the moment this indicator is only shown during extension activation. CommandsThe VS Code command promptWith the key combination The search is quite smart, so you don't have to know the start of the command name. Some text from within the name is sufficient. Commands provided by the extensionTODO List of commands with descriptions. Settings
RequirementsThe B&R Automation Tools extension requires the C/C++ extension for auto completion. It will be automatically installed during installation of the B&R Automation Tools extension. Known IssuesTransfer task workflowThe transfer task workflow is currently prompting multiple times for the configuration. Also there is no detection, if a build of the configuration to transfer was executed recently. It would be possible to improve this workflow. If you would like to see improvements on this, please write a comment on the GitHub Issue Support for IEC languagesThe B&R Automation Tools extension currently does not support auto completion or syntax highlighting for IEC language files. Some extensions for IEC languages are already existing and you can use them in combination with this extension. One examples is the Structured Text language Support extension by Sergey Romanov. It provides syntax highlighting, code folding and snippets for IEC structured text syntax. To use this syntax highlighting within B&R IEC files (.var, .typ, .fun, ...), you can add the file extensions to the The configured setting in
OthersCheck out our GitHub issues for a list of all open requests. |