Introduction: Custom Libraries for Logi.CAD 3 (inofficial)

This step-by-step tutorial shows how to add your own custom libraries to logi.CAD 3.
It shows how to create a library bundle with C source code for your own system functions, which can be integrated into logi.CAD 3.

This is an inofficial guide, and some of the interfaces may not work in later releases!

Furthermore, you will need the "secret" "vendor-libraries.zip" to succeed. (Don´t ask me for it.)
C Programming skills are required. No java programming skills are required.

Do not only read the instructions, also watch the screenshots carefully!
Click on the screenshots to show them with more detail.

Make no use of this information. Have fun!

Step 1: Download Eclipse and Logi.CAD3

Download Eclipse from www.eclipse.org
"Eclipse for RCP and RAP Developers" is the right package.
The current release "Eclipse Kepler" will be perfectly fine.

Of course you will also need logi.CAD 3 V1.0.0, which can be obtained here
http://www.logicals.com/products/logi.CAD_3/

Step 2: Import Project Into Eclipse

Open eclipse, and select a workspace folder.
Within the empty "Package Explorer", select "Import..."
Select "Existing Maven Projects", and hit "Next".
Now hit "Browse..." and select the folder "vendor-libraries" from the extracted "vendor-libraries.zip".
Hit "Next" button.



Step 3: Finish Importing the Project

Hit the button "Finish".
Next, you will be asked to install tycho.
Proceed as shown in the screenshots.
Be sure to accept the license agreement, and accept the security warning.



Step 4: Restart Eclipse

Next, you will be asked to restart eclipse.
Be sure to select the same workspace as before when starting again.
The new library bundle will now be shown within the package explorer, but with many errors.

Step 5: Fix Errors

Select "Import.." again, but now use "Existing Projects into Workspace" (instead of "Existing Maven Projects").
Select the folder "libs" within "vendor-libraries" from the "vendor-libraries.zip".
Click "Finish" to proceed.
If everything is correct, the tab "Problems" whithin Eclipse should now be empty.



Step 6: Hacking the Library

Within IOLibrary.java, you may change LIBRARY_ID and LIBRARY_NAME.
Note: "*.1wire" (as shown within the screenshots) will not be a valid name. Use ".onewire" instead.
ST code for your vendor blocks needs to be placed within the folder "iecst".
The C-Code for the vendor-blocks must be edited within the folder "code".

Step 7: Use Refactoring for Renaming the Library

Before the library gets exported, we need to give it a proper new name.
Make sure to change the library name at all occurrences as shown within the screenshots.
Use "Rename/Recfactor" (Alt-Shift-R) to give the inernal bundles starting with "com.logicals.library" a new name.

It is very important to rename the library also within the files within "META-INF" and "OSGI-INF".
One mistake here, and the library won´t load!
Use the "Bowse" button to fix the name of the "class" within both xml-files.
The library name should also be changed within "OSGI-INF/ln10".



Step 8: Export the Library Bundle

After all renaming and refactoring has been done, open "MANIFEST.MF" again and select "Export Wizard" on the bottom right of the "Overview" page.
Select a target-folder and hit "finish".

Step 9: Insert New Library Bundle to Logi.CAD3 Installation

Find the "plugins" folder within the logi.CAD installation and copy the .jar file there.
This step need to be done every time the library is changed.
Of course the library can also be exported directly there, but make sure logi.CAD is not running while exporting the library from Eclipse.

Step 10: Activate the New Library Bundle

Find the file "configuration\org.eclipse.equinox.simpleconfigurator\bundles.info" within the logi.CAD installation folder and edit it with a text editor.
Insert a line for the new library bundle, example:
com.logicals.library.raspberrypi.i2c,0.0.1,plugins/com.logicals.library.raspberrypi.i2c_0.0.1.jar,4,false
Make sure to use exactly the named used before when refactoring within eclipse.

Step 11: Check Library Installation

Now start logi.CAD3 and select "Help/About logi.CAD3 compact".
Click "installation details" and switch to the "plugins" tab.
If your new library is shown within the installed plug-in-bundles, everything is fine.
If not, have fun finding out where the mistake has been made.



Step 12: Test the New Library

Create a new "Raspberry PI" project.
At the moment, the "iecst" contents of the new library do not get copied automatically within the project.
So you need to copy the contents of the *.iecst files of your library manually to the "src" folder.
If the library with the new name can be used without showing an error within the "library pragma" (see screenshot), then everything is fine.
Use a vendor block from your new library within the program, open the "PLC" view and hit "upload".



Step 13: Troubleshooting the New Library

Of course, the first attempty will almost never be successful.
It is very likely the you will get compile errors.

To analyze the errors, proceed as following:
Click the small triangle right beside and select "Customize View".
Uncheck the filter for "src-gen" and "target" to make these folders visible.
Within a sub-folder of "target" you will find a file named "comile_result.txt"
Note: It may be necessary to hit F5 to refresh the folder before the contents are shown.
Open this file an find the reason for the compile errors.

At this point, you will need your experience and skill as a C programmer.
The C source code for your new vendor block should be located within the sys-gen folder.

Step 14: Fix the Library

Now close logi.CAD3 and go back to Eclipse.
Fix the problems which caused the compile-error, and export the library bundle .jar file again. (Step 8)
Make sure logi.CAD is not running then copying the .jar file into the "plugins" folder.

Repeat these steps until there are no more errors when hitting the "upload" button.

GOOD LUCK!

Step 15: