Use generated packages¶
A generated package exposes the types and instances from your NodeSet. Importing it registers the namespace identity; adding it to a server publishes its nodes. For model imports and server configuration, see the official o6\Python documentation.
Ship the package¶
Keep the generated folder intact, including __init__.py and any .pyi files.
The code needs a compatible o6\Python runtime and its
dependency packages at the import paths declared during generation.
ncc is only needed to generate the files, not to use them.
Keep handwritten code outside the generated package
Regeneration overwrites generated files and deletes additional .py and .pyi
files directly inside the package directory, including handwritten modules.
File layout¶
| File | Public content |
|---|---|
__init__.py |
Namespace registration and category imports. Import the package through this entry point. |
reftypes.py |
Reference types. |
datatypes.py |
Datatypes, including structures, enums and unions. |
datatypes.pyi |
Type signatures for editors and type checkers; ship beside datatypes.py. |
vartypes.py |
Variable types. |
objtypes.py |
Object types. |
instances.py |
Object, variable and method instance declarations. |
Files for empty categories are omitted.
Structure initial values¶
ncc turns structure values from your NodeSet XML into Python constructors,
using field definitions from the model and its dependency XML.
Nested structures, inherited fields and arrays are supported.
For example, a Range with Low=1.5 and High=9.5 produces this value expression
in the generated package:
- Missing fields use runtime defaults; absent optional fields stay unset.
- Explicit XML
xsi:nil="true"becomesNonewhere the datatype allows it. - Empty arrays become
[]; nil arrays becomeNone. Empty strings stay empty. - Unions select at most one member.
Invalid values generally fail generation with node and field context. Some published models contain schema placeholders or mismatched numeric datatypes; these values are omitted with a warning so the runtime can supply a typed default.
Composite initial values¶
Composite values preserve their XML types and explicitly supplied fields:
| XML value | Generated Python value |
|---|---|
| Variant | Its payload, with typed numeric constructors to preserve width and signedness. |
| ExtensionObject | A concrete structure when its type is known; otherwise an opaque binary or XML body is retained. |
| DataValue or DiagnosticInfo | A constructor containing only the fields present in XML, including explicit zero and empty values. |
For example, a DataValue containing a UInt32 value of 7 and a status code of 0
produces:
Omitting the status code in XML leaves it out of the constructor, preserving the runtime's default and presence flag.