The XML Exchange Plugin allows reading and writing values in XML files (with a fixed structure).
The whole XML Exchange Plugin configuration is located in the node path /System/Exchange/XML Exchange
.
An XML Exchange Document (similar to a Channel for device plugins) represents an XML file.
The path to the XML file in the file system.
Specifies how the XML file is to be accessed:
Load
or Save
method in order to transfer the file content to the variables and vice versa.
To add a new XML Document (which corresponds to a Channel for device plugins), please follow these steps:
XML Exchange/Documents
, or right-click on the XML Exchange/Documents
node and select Add Document
.Add Document
dialog, specify the settings for the XML file.
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):
Path
property contains the name of the element; or, if it is empty, the name of the variable will be used as name for the XML element.String
. The Path
property can contain the following expressions:text()
: The variable maps to a XML text node./
(e.g. abc
): The variable maps to an XML attribute of the parent XML element with the specified name (in the example,"abc"
)./
(e.g. /*/A/B/text()[2]
): The variable represents an XPath query, which either returns a text as result (which means it cannot be written to), or an XML node set where then the first node is used (must be a text node, attribute node or comment node). When the XML file already exists, you can browse the Document (Channel) to automatically create the CoDaBix variables for the XML document structure.
<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:
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).
Bad
is written to the variables.Load
method:Load
method:Write Behavior:
Save
method:Good
is used as result of the write operation.Save
method: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.
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
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.
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=[] ...
Like every exchange plugin the XML Exchange Plugin extends the basic CoDaBix Exchange Model.
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.
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.
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. |
Type | Path | Usage |
---|---|---|
Assembly | [AssemblyFolder]/CoDaBix.XmlExchangePlugin.dll | The plugin's assembly file. |
Logging | [LoggingFolder]/XML Exchange.<ChannelName>.log | The log file. |
Date | 2020-02-06 |
---|---|
Version | 1.0 |
Name | XML Exchange Plugin |
---|---|
Node | /System/Exchange/XML Exchange |
Version | 1.0.0 |
Name | CoDaBix.XmlExchangePlugin.dll |
---|---|
Date | 2020-02-06 |
Version | 1.0.0.0 |