Manually Building a SmartComponent
The following example provides information on how a SmartComponent can be built using a single XML file. It also describes how a batch file can be used to simplify this process. SmartComponents created in Visual Studio can be compiled by executing the "Build Project" command.
This topic considers that one or more SmartComponent projects created from Visual Studio exists. Refer to the topic Creating a SmartComponent on how to create one.
Building SmartComponents from an XML file
Create an XML file and name it "Master.xml". Add the following code in the XML which are Library XML of other SmartComponents. The reference to Library XML files like "Expression.xml", etc as seen below are just examples and can be changed. The reference to Library XML files included in "Master.xml" must be present in the same folder.
<?xml version="1.0" encoding="utf-8"?> <LibraryCompiler xmlns="urn:abb-robotics-robotstudio-librarycompiler"> <!-- Master include file for all SmartComponents--> <Include source="Expression.xml"/> <Include source="Logic.xml"/> <Include source="Actions.xml"/> <Include source="Other.xml"/> </LibraryCompiler>
The "LibraryCompiler.exe" takes "Master.xml" as input and executes to create SmartComponents. We can build a batch file that automates this process by following the next steps:
With any text editor, create a Batch file in the same directory as the SmartComponent. This Batch file will contain the commands needed to build the SmartComponent.
Copy the produced binaries to the projects directory by adding the following command:
copy /y "$(TargetPath)" "$(ProjectDir)"
where "$(TargetPath)" is the path where the binaries are located and "$(ProjectDir)" is the current directory where the other SmartComponent files reside.
The Library Compiler needs to be invoked from our batch script to process our XML file and yield a SmartComponent. To do so, add the following commands to the batch file:
"%ProgramFiles(x86)%\ABB\RobotStudio <version>\bin\LibraryCompiler.exe" "$(ProjectDir)\Master.xml"
Note
If needed, the Library Compiler may be invoked with many configuration flags that customize the produced SmartComponent in many different ways. Some of them are "[/optimize]", "[/detail]", etc.
Execute the Batch file form the command line or as an external command called from another part of your development tool-chain.
Note
If needed, Steps 2 and 3 can be invoked several times to Build several SmartComponents
Invoking the batch file will create:
- Expression.rslib
- Logic.rslib
- Actions.rslib
- Other.rslib
Dynamic Link Library (.dll) files.
When building a SmartComponent that makes use of an external library, it is necessary to place the Dynamic Link Library (.dll files) in a directory in which RobotStudio can find them.
Locate the produced .dll files (usually in the "bin" folder of the Visual Studio project).
Copy the .dll files to the Libraries folder of RobotStudio (C:\Users\USERNAME\Documents\RobotStudio\Libraries) on a default RobotStudio installation.
Tip
It is possible to move the .dll files to the "bin" folder in RobotStudio's installation path. Nonetheless, the "Libraries" folder inside the User's RobotStudio's files is recommended over this method.
Embedding other assets.
In many cases, it will be necessary to embed other files that are necessary for the correct execution of the smart component, such as external data files or even 3D models. In this case, the external assets can be embedded in the XML file in a similar way as the dynamic linked libraries.
Locate the necessary assets and put them in a directory that is easily accessed by the SmartComponent. Remember that the library compiler uses relative paths, the same directory as the component or a subdirectory are good choices.
In the SmartComponent's XML file, use the
<Asset name=""/>
XML element.<Assets> <Asset source="SmartComponent1.dll"/> <Asset name="model3d.dxf"/> <!-- 3D model --> <Asset name="data_points.txt"/> <!-- Data file --> </Assets>