Automated exporting of projects to XML

logi.CAD 3 provides a tool for the automated export of projects or rather their ST/FBD objects into an XML-file (= text file in XML-format).
Together with the tool for the automated import, you are able to generate templates by exporting existing objects in order to import these templates afterwards into existing projects.

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg The tool is intended for usage by an experienced user of logi.CAD 3.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg A condition for the successful usage of the tool is the knowledge of the action to be executed as it would be executed in the graphical user interface of logi.CAD 3.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg The output of the tool is in English only.

Preparation

  1. Make sure that logi.CAD 3 is installed. Have the following information prepared:

    • The path to the logi.CAD 3 installation directory

    • The path to a directory that will be used as the workspace
      In case the directory does not exist, the tool creates it. If the optional parameter -checkEmptyWorkspace is used (see the description of this parameter below), the directory must be empty.

    • The path to the project that should be exported

    • The path to the log configuration file (see below for more information)
      A sample configuration file is included in the installation of logi.CAD 3.

  2. Open a command line: e.g. cmd.exe under Windows and navigate to the logi.CAD 3 installation directory.

Invocation

Parameters that are placed within [] are optional. That means, if you skip the parameter, the default behavior is applied (see below under "Description of parameters"). When you want to use the parameter, do not enter the character [ and ] (see the below examples).

logiCAD3c --launcher.ini logiCAD3.ini -application com.logicals.lc32.export.application [-noSplash] -projectPath <PROJECTPATH> [-objectToExport <OBJECT_TO_EXPORT> -outputPath <OUTPUT_PATH> -outputFile <OUTPUT_FILE>]|[-workpackagePath <WORKPACKAGE_PATH>] [-checkEmptyWorkspace] -vmargs -Dlog4j.configuration=file:<LOG-CONFIGURATION>

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg Invoking the tool under Linux is not officially supported. However, if you want to try invoking the tool under Linux nevertheless, replace the part logiCAD3c --launcher.ini logiCAD3.ini -application of the above-mentioned invocation by logiCAD3 -application. The remaining part of the invocation is identical to the above-mentioned invocation.

Description of parameters:

Parameter

Description

Example

<PROJECTPATH>

absolute path to the project
If the project already exists within the workspace (e.g. because there was a previous automated import of the project ), it is also possible to specify the project name only.

C:\LC3Projects\MyProject

<OBJECT_TO_EXPORT>
<OUTPUT_FILE>
<OUTPUT_PATH>

the following data for the XML-file:

  • the object to be exported (incl. the project-relative path)
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg At present, the tool supports ST-objects and FBD-objects to be exported. Other objects are not exported.
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg If you specify an ST-object to be exported and this ST-object contains several language elements (e.g. one data type and one function block or 2 data types), mind that only the respective last language element is exported.
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg Other restrictions: The following Elements and/or settings are not exported:

  • absolute p ath where to create the XML-file

  • name of the XML-file to be created

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Always use these 3 parameters together. Or use the following parameter -workpackagePath <WORKPACKAGE_PATH> as alternative.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg If you do not specify these 3 parameters or -workpackagePath <WORKPACKAGE_PATH>, nothing will be exported.

src\program.iecst
C:\lc3
program.xml

<WORKPACKAGE_PATH>

absolute path to a CSV-file
This CSV-file is an alternative to the 3 parameters to be used together -objectToExport <OBJECT_TO_EXPORT> -outputPath <OUTPUT_PATH> -outputFile <OUTPUT_FILE>. By using the CSV-file, you are also able to specify several objects for the export.
The CSV-file must contain the following data (in this order) in each line – separate the data by , from each other:

  1. the object to be exported (incl. the project-relative path)

  2. absolute p ath where to create the XML-file

  3. name of the XML-file to be created

Example for the content of a CSV-file: 2 ST-objects are exported.
src\program.iecst,C:\lc3,program.xml
src\EnumType.iecst,C:\lc3,EnumType.xml

c:\LC3\workpackage.csv

<LOG-CONFIGURATION>

path to the log configuration file
All messages of the tool will be output to the device as specified in the log configuration file.

C:\LC3LogConfig\log4j.xml

  • The parameter -noSplash is optional. If it is not specified, the splashscreen of logi.CAD 3 is displayed after the invocation.

  • The parameter -checkEmptyWorkspace is also optional. Specify this parameter to check whether the specified workspace is empty. The logi.CAD 3 project will only be imported, if the workspace is empty.
    The default invocation (when this parameter is not specified) is that the logi.CAD 3 project is always imported into the workspace – regardless whether the workspace is empty or not. If the logi.CAD 3 project already exists within the workspace, the logi.CAD 3 project is imported anew.

  • The parameter -Dlog4j.configuration is also optional . However, logi.cals recommends to specify this parameter so that log events are output .

Example 1 for invocation: One ST-object is exported into one XML-file.
logiCAD3c --launcher.ini logiCAD3.ini -application com.logicals.lc32.export.application -noSplash -projectPath C:\LC3Projects\MyProject -objectToExport src\program.iecst -outputPath C:\lc3 -outputFile program.xml -vmargs -Dlog4j.configuration=file:C:\LC3LogConfig\log4j.xml
Example 2 for invocation: The objects are exported according to the CSV-file. The XML-files are created according to this CSV-file as well.
logiCAD3c --launcher.ini logiCAD3.ini -application com.logicals.lc32.export.application -noSplash -projectPath C:\LC3Projects\MyProject -workpackagePath c:\LC3\workpackage.csv -vmargs -Dlog4j.configuration=file:C:\LC3LogConfig\log4j.xml

Log configuration file

This file is needed to configure the log4j logging mechanism. The file specifies how log events are output.

Sample log configuration file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j='http://jakarta.apache.org/log4j/'>
<!-- This configuration logs to console. -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="target" value="System.out"/>
<param name="immediateFlush" value="true"/>
<param name="encoding" value="UTF-8"/>
<param name="threshold" value="info"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p: %m%n" />
</layout>
</appender>
 
<!-- This configuration logs to a file, with more information than for the console. -->
<appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="C:\\temp\\logfile.log" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{HH:mm:ss} %-5p [THREAD ID=%t] [Method:%M] %c{1}:%L - %m%n" />
</layout>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</root>
</log4j:configuration>

Troubleshooting

The file that is specified in the log configuration file contains information about the export. If the export has not been successful, fix the problem according to the following table.

Return code

Message on STDOUT or STDERR

Cause

Solution

0

Export successful (0)



13

<no message>

wrong value specified for -application

Invoke the tool as specified above.

-1

Export failed (Parameter Error, -1): Name

An argument or parameter is missing.

Invoke the tool as specified above.

-2

Export failed (-2): Project not found

The specified project does not exist.

Specify an existing project. Or invoke the tool with the absolute path for the project.

-6

Export failed (-6): Workspace not empty

The workspace already contains data (e.g. one or more logi.CAD 3 projects).

Use an empty workspace or remove all existing data from the current one.
Alternate: Invoke the tool without the parameter -checkEmptyWorkspace.

-127

Export (Details: exception message)

An unexpected error has occurred.

Contact logi.cals.