XML schema
Data emitted from OPC and PI nodes conforms to an XML schema.
Details
This XML schema is available as a tagData.xsd file in the schema definition that is created when you create an instance of the "Manufacturing: Factory Publication" pattern, see Pattern supplied in IBM Integration Bus Manufacturing Pack.
For any TagData that is received, the OPC or PI nodes output data in an XML format. The data for each tag is restricted to the following elements:
- Name
- The name of the tag.
- Value
- The data.
- SourceTimeStamp
- The time when the reading was given. This value is given in coordinated universal time (UTC).
- Quality
- Indicates the status of the information. The status can be Good, Uncertain, or Bad, depending on the connection to the device.
The following code is an example of the TagData that is output:
<NS1:TagData xmlns:NS1="com.ibm.manufacturing.tagData/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServerName>opc.tcp://<servername:port>/Quickstarts/DataAccessServer</ServerName><Sequence>0</Sequence>
<Tag>
<Name>/2:Assets/2:Sensors/2:Flow/2:Pipe1001/2:Measurement</Name>
<Value>1.08E+2</Value>
<SourceTimeStamp>2014-06-18T10:54:48.205</SourceTimeStamp>
<Quality>Good</Quality>
</Tag>
</NS1:TagData>
As the example shows, the TagData has a namespace identifier: "com.ibm.manufacturing.tagData/v1.0"
To perform a transformation on this data, the TagData must be addressed with its namespace.
For an example of how to use this schema in a Graphical Data Mapping editor, create an instance of the "Manufacturing: Factory Publication" pattern, see Pattern supplied in IBM Integration Bus Manufacturing Pack.
The following code shows
a Java example:
MbXPath xp = new MbXPath("/NS1:TagData/Tag/?Update[set-value('" + "read" + "')]");
xp.addNamespacePrefix("NS1", "com.ibm.manufacturing.tagData/v1.0");
outMessage.getRootElement().evaluateXPath(xp);
The following code shows an example of the ESQL statement
to address the TagData:
DECLARE NS1 NAMESPACE 'com.ibm.manufacturing.tagData/v1.0';
SET OutputRoot.DataObject.NS1:TagData.Tag.Update = 'read';
Note: The
output message shows a server name, which, for the PI nodes, is the
connection name.
TagData schema
The following code is the tagData.xsd:
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="com.ibm.manufacturing.tagData/v1.0" elementFormDefault="unqualified" >
<xsd:element name="TagData">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ServerName" type="xsd:string"/>
<xsd:element name="Sequence" minOccurs="0" type="xsd:unsignedInt"/>
<xsd:element name="Tag" minOccurs="0" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="Value" maxOccurs="unbounded" minOccurs="1" nillable="true"/>
<xsd:element name="SourceTimeStamp" type="xsd:dateTime" nillable="true"/>
<xsd:element name="Quality" type="xsd:string" nillable="true"/>
<xsd:element name="StatusCode" minOccurs="0" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name" minOccurs="0" type="xsd:string"/>
<xsd:element name="Description" minOccurs="0"/>
<xsd:element name="SubCode" minOccurs="0" type="xsd:integer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>