Table of Contents

XML Exchange Plugin

The XML Exchange Plugin allows reading and writing values in XML files (with a fixed structure).

Configuration

The whole XML Exchange Plugin configuration is located in the node path /System/Exchange/XML Exchange.

Document

An XML Exchange Document (similar to a Channel for device plugins) represents an XML file.

Settings

File Path

The path to the XML file in the file system.

Exchange Mode

Specifies how the XML file is to be accessed:

  • Implicit: The XML file will be read once one or more variables are read; and the XML file will be written once one or more variables are written.
  • Explicit: No file access occurs when reading or writing variables. The file needs to be read or written explicitely, by calling the Load or Save method in order to transfer the file content to the variables and vice versa.

Adding a Document (Channel)

Adding a new XML Document

To add a new XML Document (which corresponds to a Channel for device plugins), please follow these steps:

  1. Add a Folder Node within the node XML Exchange/Documents, or right-click on the XML Exchange/Documents node and select Add Document.
  2. In the Add Document dialog, specify the settings for the XML file.
  3. After clicking on “Save”, the document node is created.
  4. You can start the channel by selecting the document node and clicking the start button.

Variables

Within the DocumentElement node you can create variables (nodes) which correspond to the structure of the XML document (which means the tree structure of the CoDaBix variables corresponds to the structure of the XML nodes):

When the XML file already exists, you can browse the Document (Channel) to automatically create the CoDaBix variables for the XML document structure.

Example

example.xml
<Root>
  <A>Test</A>
  <B>
    <C x="Hello" y="World">
      12345
      <D />
      67890
    </C>
  </B>
</Root>

After browsing the document, the following node structure is created in CoDaBix:

Read/Write

For read operations as well as for write operations, the CoDaBix variables will be mapped to XML nodes by using their position within the node tree. When you write values and there are variables in CoDaBix which cannot be found in the XML file (which also happens e.g. if the XML file doesn't exist yet), the corresponding nodes will be created in the XML file.

Read Behavior (depending on the set Exchange Mode in the settings).

Write Behavior:

Diagnostics

The XML Exchange Plugin provides different status information depending on the layer to inspect. In general the document-based diagnostic information is produced by the access status of the XML file. The variable-based diagnostic information is produced during the read/write access of the different variables.

Channel

To monitor and diagnose the status of a XML Document (Channel), take a look at the following image:

The image above depicts the XML Document's Control Panel which displays all status relevant information. The control panel will automatically update its status information when a new status is available.

Status Circle

Color Meaning
The channel is stopped. Click the button to start it.
The channel is currently in the progress of starting or stopping or is waiting to establish a connection.
The channel is ready for doing read/write operations. You can stop it by clicking the button.
The channel is running, but the connection is currently in an error state. Please check the status text for more information.

Variables

To monitor and diagnose the status of the different XML variables, take a look at the variable's Status property displayed in CoDaBix. If the Exchange Mode is set to “Implicit”, use the button “Read actual Value” to read the values from the PLC and store the result into the variables. Otherwise, you can call the Load method to verify if the file can be read correctly.

Log file

All channel related status information is also logged into the channel-specific log file stored in the [LoggingFolder]. Each log file is named in the naming scheme XML Exchange.<ChannelName>.log.

The content of such a log file can look as follows:

...
2018-04-11 11:32:37.0 +2: [Error] Error (Severity=High): Code=[-1], Text=[The operation has timed-out.], Details=[]
...

Entities

Like every exchange plugin the XML Exchange Plugin extends the basic CoDaBix Exchange Model.

Like every exchange plugin the XML Exchange Plugin extends the basic CoDaBix Exchange Model.

Exchange

The plugin's exchange type XmlExchange also defines the XmlExchangeDocument and therefore extends the basic CodabixExchange and CodabixExchangeChannel entities. While the XmlExchange just represents a concretization of the CodabixExchange, the XmlExchangeDocument extends the CodabixExchangeChannel with the XML Variable Entities.

Channel

Each channel is handled by a channel worker which access an XML file using file system operations.

By default, the worker does not read any values. When the Exchange Mode is set to Implicit and a client or plugin requests a synchronous read of the channel's variables in CoDaBix (e.g. using the CoDaBix Web Configuration's function “Read actual value”), the channel worker reads them from the underlying PLC and then writes them into the corresponding CoDaBix Nodes.
If the Exchange Mode is set to Explicit, the worker reads values as soon as the Load method of the channel is called.

Similarly, the channel worker will write values to file when a client or plugin writes values into the channel's variables (“Implicit”) or when the channel's Save method is called (“Explicit”).

To have an XML Exchange Variable being read steadily (when using mode “Implicit”), you can edit the Node in the CoDaBix Web Configuration and set “History Options” to Yes (which will create an internal subscription), or you can use e.g. a OPC UA Client connected to the OPC UA Server plugin and create a subscription for the XML variable nodes. In these cases, the channel worker reads the variables from the XML file at a regular interval and, if the value of one of the variables has changed, writes the new value into the corresponding CoDaBix nodes.

Folders & Files

Folders

Content Path Usage
AssemblyFolder <CodabixInstallDir>/plugins/XmlExchangePlugin/ Contains the plugin's assembly file.
ConfigFolder <CodabixProjectDir>/plugins/XmlExchangePlugin/ Contains the plugin's configuration file.
LoggingFolder <CodabixProjectDir>/log/ Contains the plugin's log files.

Files

Type Path Usage
Assembly [AssemblyFolder]/CoDaBix.XmlExchangePlugin.dll The plugin's assembly file.
Logging [LoggingFolder]/XML Exchange.<ChannelName>.log The log file.

About Versions

This Document

Date 2020-02-06
Version 1.0

Plugin

Name XML Exchange Plugin
Node /System/Exchange/XML Exchange
Version 1.0.0

Assembly

Name CoDaBix.XmlExchangePlugin.dll
Date 2020-02-06
Version 1.0.0.0