# CODESYS

## Overview

Copia provides support for **CODESYS v3.5 SP 11-21**, with advanced feature support for the following:

* [Graphical Display and Differences](#graphical-display-and-differences)
* [Rung Commenting for Code Review](#rung-commenting-for-code-review)
* [Integration with the CODESYS Project Comparison Tool for Conflict Resolution](#integration-with-the-codesys-project-comparison-tool-for-conflict-resolution)&#x20;

## Configuration

Copia supports CODESYS project files, with rendering for `.project` , `.library` and `.export` files.

### Configuring Project Files (recommended)

Since `.project` and `.library` files are the standard working file, it is the recommended format for storage in Copia.

To get set up, simply store the file in a Copia repository. Once you perform the appropriate [commit and push](https://docs.copia.io/docs/basic/making-changes/saving-changes#commit--push-a-change) operations, you'll be able to see your project file and all of its data from both the Web App and Desktop App.

### Configuring Export Files

You can alternatively choose to generate `.export` files from CODESYS by clicking the *Export* button under the *Project* dropdown.

![](https://3704730939-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4lSQNVI3DZ15V7kjkMCA%2Fuploads%2Fg1NV0Ck0EIvKkUuG9leI%2FCodesys_Export.png?alt=media\&token=222c3b21-9937-4ad4-afe8-02e820ace9f6)

While you can export a subset of your project, we recommend that you export everything. Highlight all content and press *OK* to continue.

![](https://3704730939-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4lSQNVI3DZ15V7kjkMCA%2Fuploads%2F1SWIF7Z2UC9X1dVvgENy%2FCodesys_ExportConfirm.png?alt=media\&token=902ff3b8-4871-4df8-8258-c3d2caf73ee1)

As with the process outlined for `.project` and `.library` files, place your `.export` file in a Copia repository and perform the required [commit and push](https://docs.copia.io/docs/basic/making-changes/saving-changes#commit--push-a-change) operations to store it on the Copia system.

## Graphical Display and Differences

### General

When the exported project file is selected in the Web App or Desktop App, Copia displays the project tree structure in a way that's familiar to users of CODESYS based software. This way, you can easily navigate to a project item or identify differences.

![](https://3704730939-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4lSQNVI3DZ15V7kjkMCA%2Fuploads%2F9YfkRVTUjYYFieRqhz5d%2FCODESYS_GraphicalDisplay.png?alt=media\&token=56126c8d-b2b4-4cbb-9fa5-3ba2f08223db)

### Supported Types

The following CODESYS types are currently supported for graphical rendering and change detection:

* Ladder (LAD)
* Function Block Diagram (FBD)
* Sequential Function Chart (SFC)
* Structured Text (ST)
* Continuous Function Chart (CFC)
  * Only the classic CFC language is supported. The Page-Oriented CFC language is not supported at this time.
* Tasks
* UDT
* Global Variable List
* Libraries

{% hint style="warning" %}
Note: CODESYS `.compiled-library` files are not supported at this time.
{% endhint %}

Copia also supports the following types:

* PLC Device
* Alarm Configuration
* Application
* Communication Manager
* Data Sources Manager
* DUT
* Global Variable List (tasklocal)
* Interface
* Network Variable List (Receiver)
* Network Variable List (Sender)
* Persistent Variables
* POU's to include:
  * Action
  * Method
  * Property
  * Transition
* Recipe Manager
* Task Configuration
  * Task
* Trace
* Trend Recording Manager

{% hint style="warning" %}
Copia will fail to render any projects that are Password-Protected or contain any Password-Protected project items. You must remove Password-Protection in order for Copia to render your projects.
{% endhint %}

## Code Commenting for Code Review

Copia supports rung commenting for CODESYS for Ladder Logic, Structured Text, Function Block Diagram (FBD), Sequential Function Chart (SFC), and Continuous Function Chart (CFC) .

Code Commenting enhances the Code Review process once someone generates a Pull Request to merge a Branch. During the review process, users can add comments directly to the supported parts of the code.

![](https://3704730939-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4lSQNVI3DZ15V7kjkMCA%2Fuploads%2F05enSVtElLE7srGqSdDN%2FCODESYS_Review.png?alt=media\&token=4a3eedc5-17a1-4694-9cac-bdeef864e1d6)

You can watch an overview of rung commenting in the video below.

{% embed url="<https://www.youtube.com/watch?v=NNKmwXw-wfA>" %}

{% hint style="info" %}
The product version in the video may be older than the current release, but the process is still applicable.
{% endhint %}

## Integration with the CODESYS Project Comparison Tool for Conflict Resolution

While the Copia Web App has no merge tool available for conflict resolutions in Pull Requests, the Desktop App can be configured to launch a user's local [CODESYS IDE Project Comparison tool](https://content.helpme-codesys.com/en/CODESYS%20Development%20System/_cds_struct_project_comparison.html) to resolve merge conflicts within a project. This provides users an alternative to manually resolving conflicts between project versions.

### Requirements & Limitations

This option is available only if a supported version of the CODESYS IDE is installed on the same user computer that the Copia Desktop App is installed. RSLCompare must be installed on the same host OS as the Copia Desktop App. Users must enable this feature in the Copia Desktop App's settings. The level of granularity with which the CODESYS tool is able to resolve conflicts is outside the control of Copia. Local merges may not be possible if a repository has branch protections requiring Code Approval.

{% hint style="info" %}
The CODESYS Project Comparison tool does not perform conflict resolutions in the traditional Git 3-way merge. Instead, it compares only the two files from the target and source branches.
{% endhint %}

### Setup

This feature needs to be enabled in the Copia Desktop App's settings before use. Follow the instructions below to enable the feature:

1. In the Copia Desktop App, open the Advanced Settings by clicking *File* > *Options* > *Advanced*
2. Click the *Enable Codesys Merge Tool* checkbox
3. Enter the local path to the CODESYS IDE version that you wish to use to launch your resolution
   1. Note: If you have multiple versions of CODESYS installed on your system, be sure to select the version with which you'd like to resolve your conflicts

<figure><img src="https://3704730939-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4lSQNVI3DZ15V7kjkMCA%2Fuploads%2FIHwYK6fXAiYSsLLYQQLm%2FCODESYS-merge-setting.png?alt=media&#x26;token=1195b610-011d-42fe-9e12-d921cf95aa67" alt="" width="556"><figcaption></figcaption></figure>

### Instructions

Follow the steps below when using the CODESYS Project Comparison tool to resolve merge conflicts in the Copia Desktop App. A video demonstration can be found at the end of the list.

1. Important: Close any active instances of CODESYS that have the project file in question open before proceeding with the following steps.
2. Ensure both the target and source branches are locally available
   1. Identify the branch that needs to merge into current branch from the branch list by clicking Desktop Application -> View -> Branch List
   2. Select that branch so that it is fetched to the local repo. If this step is skipped a warning dialog box will pop up during the merge process branch missing locally with recommended step to fetch the branch
3. Switch back to the current (source) branch
4. Start merge by clicking **Application** -> **Branch** -> **Merge into current branch**, or click the branch dropdown selector and click the **Choose a branch to merge into&#x20;*****\<branch\_name>*** button
5. Click on branch that needs to merged into
6. Select Merge button
7. Click Resolve button on `.project` and `.library` files containing conflicts
8. To use the Project Comparison tool that is installed with CODESYS, click "Resolve with Codesys Compare Tool"
   1. This will launch the CODESYS IDE and the compare tool. This may take some time.
9. Once the merge tool completes loading, select the appropriate elements to merge and click **Save**
   1. Note: Do not use **Save As**.&#x20;
10. Select **Yes** when the CODESYS dialog box appears asking if you want to commit the changes you made in the diff view.
11. After saving the CODESYS IDE should automatically close. Close it manually if it doesn't.
12. Return to the Copia Desktop Application. The file that was merged will be removed from the list of conflicts and will be marked as resolved in the repository view
13. Perform the same action if there are conflicts in other supported file types&#x20;
14. Commit the merge

{% embed url="<https://files.copia.io/w2OqfO9P>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.copia.io/docs/git-based-source-control/supported-vendors/codesys.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
