## 4 Mapping YANG to OPC UA
### YANG Data Definition Mapping  
Data definition statements in the YANG Model represent the entity's configuration or state data, as well as the methods and notifications it supports. Table 4 summarizes the data definition mapping approach with reference to the code and images defined in the Appendix A Section. The module's data definition statements leaf, leaf-list, container, grouping, and list in YANG are mapped to the object type, variable type definitions, and other elements in the OPC UA model design XML file. * leaf statement: leaf is the simplest data definition in YANG, which is, at most, one instance with data values and has no child data definition statements. The leaf statement defines a scalar variable of a particular built-in or derived type. The config statement in the data definition identifies whether the definition represents the element's configuration or the state data. Any data definition defined as a config to true can be edited. Otherwise, it can only be observed. If the leaf statement is defined with config as \"true\", then in OPC UA, it is mapped to a variable node, and if it is described as \"false\", then it is mapped to a property node. * leaf-list statement: leaf-list statement is used to define an array of particular data types. leaf-list contains a list of unique leaves with a key that refers to their value. Like the leaf statement, the leaf-list is mapped to a property node or a variable node in OPC UA with the ValueRank attribute of the node set to OneDimension and the ModellingRule attribute set to \"ExposesItsArray\". * Container statement: container is a data definition that wraps one or more child data definition statements. The OPC UA address space model does not provide a node for \begin{table}
\begin{tabular}{c c c} \hline \hline
**YANG Statement** & **Mapped OPC UA Model Design XML Constructs** & **Visual Representation of the Mapping** \\ \hline leaf [ \(\ldots\) config false; \(\ldots\)] & \(<\)Property SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A8 \\ leaf [ \(\ldots\) config true; \(\ldots\)] & \(<\)Variable SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A9 \\ leaf-list \(\ldots\) [\(\ldots\)] & \(<\)Variable \(\ldots\) ModuleRule = “ExposesItsArray” & Figure A10 \\  & \(\ldots\) & \(\ldots\) \\ container\(\ldots\)[\(\ldots\)] & \(<\)ObjectType SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A11 \\ grouping \(\ldots\)[\(\ldots\)] & \(<\)ObjectType SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A12 \\ list \(\ldots\)[\(\ldots\)] & \(<\)ObjectType SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A13 \\ typedef \(<\)customtype\(>\) [\(\ldots\)] & \(<\)DataType SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A14 \\ rpc \(\ldots\)[\(\ldots\)] & \(<\)Method SymbolicName = “\(\ldots\)”\(\ldots\)\(>\) & Figure A15 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: YANG data definition statements to OPC UA model design XML constructs mapping. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Yang Built-in Data Type** & **Description** & **Mapped OPC UA Built-in Data Type** \\ \hline boolean & True or “false”. & Boolean \\ decimal64 & 64-bit signed decimal number & Double \\ empty & A leaf that does not have any value & BaseObjectType \\ enumeration & Enumerated strings & EnumValueType \\ int8 & 8-bit signed integer & SByte \\ int16 & 16-bit signed integer & Int16 \\ int32 & 32-bit signed integer & Int32 \\ int64 & 64-bit signed integer & Int64 \\ string & Human-readable string & String \\ uint8 & 8-bit unsigned integer & Byte \\ uint16 & 16-bit unsigned integer & UInt16 \\ uint32 & 32-bit unsigned integer & UInt32 \\ uint64 & 64-bit unsigned integer & UInt64 \\ date-and-time & Data and time & DateTime \\ Union & Represents a value that corresponds to one of the & union \\ Union & member types & union \\ \hline \hline \end{tabular}
\end{table} 
Table 3: _Cont._representing the container; hence, the container is emulated by generating a custom ObjectType and defining an object instance to the custom object type.