You won't need to worry too much about the
MyLibrary singleton that you created with your extension component. This singleton provides a way for the PLCnext runtime to create named instances of your ACF component(s).
Each shared object file must only contain one singleton that inherits
LibraryBase. This singleton can usually remain unchanged as you develop your components. The only time that this singleton must be modified is when you add or remove components from your library.
To add a component to the library:
Create the new component in your C++ project. These two source files contain the definition for a component named
MyOtherComponent, which you can add to the
srcdirectory of the project you created in the previous section:
Add the header file for
MyOtherComponentto the library
In the library constructor, add a call to the method
componentFactory.AddFactoryMethodto register the new component.
The new library source file can be downloaded here:
Rebuild the project and copy the resulting
.sofile to the target.
You can create an instance of MyOtherComponent by adding a new entry to the .acf.config file, as follows:
<Component name="MyOtherComponentInstance" type="MyNamespace::MyOtherComponent" library="MyProject" process="MyProcess" />
Copy the new configuration file to the target and restart the PLCnext runtime. You will now see these entries in the Output.log file:
INFO - Component 'MyComponentInstance' in process 'MainProcess' created. INFO - Component 'MyOtherComponentInstance' in process 'MainProcess' created.