next up previous contents
Next: Qualified Names (QNames) and Up: Representation of OPC XML-DA Previous: Global OPC XML-DA options   Contents

The ItemContainer Object

The ItemContainer object is used to store all local, item-specific OPC XML-DA data, such as the item value and item-specific local options. This information is stored in the object as object attributes and may be accessed as shown in listing 4.

language=C
\begin{lstlisting}[caption={Accessing the PyOPC ItemContainer Object}
,label=ex...
...',
MaxAge=500)
item.ItemName='other_name'
maxage = item.MaxAge
\end{lstlisting}

At the beginning of the example listing, the appropriate Python module is imported that contains the ItemContainer class. In line 2, item specific options are set at initialization time of the ItemContainer object, while line 4 and 5 show how to directly set and retrieve object attributes.

[OPCXMLDA] defines numerous, sometimes complex local options. Therefore errors due to misspellings can easily happen. To prevent such errors, the ItemContainer class defines all possible options via class attributes. In addition, an ItemContainer object will not allow the setting of undefined object attributes. If the developer accidentally tries to set a misspelled or unknown attribute, the PyOPC framework raises a Python AttributeError.



Hermann Himmelbauer 2006-11-07