# Model Compiler #
The [OPC Foundation](https://opcfoundation.org) Model Compiler will generate C# and ANSI C source code from XML files which include the UA Services, data-types, error codes, etc.; and numerous CSV files that contain NodeIds, error codes, and attributes etc.
The input format for the tool is a file that conforms to the schema defined in UA Model Design.xsd.
**2022-10-15: the tool now supports Part 6 Annex F (a.k.a. NodeSet2) as a syntax for the input files [see schema](https://github.com/OPCFoundation/UA-Nodeset/blob/latest/Schema/UANodeSet.xsd).**
The output of the tool includes:
1. A NodeSet which conforms to the schema defined in Part 6 Annex F;
2. An XSD and BSD (defined in Part 3 Annex C) that describes any datatypes;
3. Class and constant definitions suitable for use with the .NET sample libraries;
4. Other data files used to load an information model into a Server built with the .NET sample libraries;
5. A CSV file which contains numeric identifiers.
The [UA Model Design.xsd](https://github.com/OPCFoundation/UA-ModelCompiler/blob/master/Opc.Ua.ModelCompiler/UA%20Model%20Design.xsd) has more information about the schema itself.
The .NET sample libraries has [a sample Model Design file](https://github.com/OPCFoundation/UA-.NET/blob/master/SampleApplications/Samples/Common/Sample/SampleDesign.xml) that illustrate how to create a user defined model.
This [batch file](https://github.com/OPCFoundation/UA-.NET/blob/master/SampleApplications/Samples/Common/BuildDesign.bat) is used to regenerate the files used in the sample after changes.
The tool only produces ANSI C output for the stack.
All of the standard outputs are published in the [Nodeset GitHub repository](https://github.com/OPCFoundation/UA-Nodeset)
Developers should never need to build the standard outputs themselves.
**2022-10-15: out of date due to changes needed to support NodeSet2 as an input format**<br/>
Tutorial by Stefan Profanter [here](https://opcua.rocks/custom-information-models/).
Command line parameters for ModelDesigns or NodeSets:
```
Takes an OPC UA ModelDesign file and generates a NodeSet and code for the .NETStandard stack.
Usage: ModelCompiler compile [options]
Options:
-?|-h|--help Show help information.
-d2 The path to the ModelDesign or NodeSet2 file which contains the UA information model. The first
file specified is the model to generate. The rest are included models. The file path may be
followed by the namespace prefix and a short name for model. Commas seperate each field.
-c The path to the CSV file which contains the unique identifiers for the types defined in the UA
information model. Not used if the target is a NodeSet2 file.
-cg Creates the identifier file if it does not exist (used instead of the -c option).
-o2 The output directory for the generated files.
-ansic The path to use when generating ANSI C stack code (internal use only).
-stack The path to use when generating .NET stack code (internal use only).
-version Selects the source for the input files. v103 | v104 | v105 are supported.
-useAllowSubtypes When subtypes are allowed for a field, C# code with the class name from the model is created
instead of ExtensionObject. No effect when subtypes are not allowed.
-id The first identifier to use when assigning new ids to nodes.
-exclude Comma seperated list of ReleaseStatus values to exclude from output.
-mv The version of the model to produce.
-pd The publication date of the model to produce.
-rc Indicates that a release candidate nodeset is being generated.
```
Example
```
Opc.Ua.ModelCompiler compile -d2 .\Opc.Ua.Machinery.NodeSet2.xml,Opc.Ua.Machinery,Machinery -d2 Opc.Ua.Di.NodeSet2.xml,Opc.Ua.DI,DI -version v105 -exclude Draft -o2 .\output
```
Command line parameters for NodeSets based on URIs rather than files:
```
Searches a directory tree for nodesets and generates code for the specified model URIs.
Usage: ModelCompiler compile-nodesets [options]
Options:
-?|-h|--help Show help information.
-input The path to the directory containing the nodesets.
-o2 The path to the directory to use to write the generated files.
-uri The URI of the model to generate.
```
Example
```
Opc.Ua.ModelCompiler compile-nodesets -input .\v105\ -o2 .\Tests -uri http://opcfoundation.org/UA/Machinery/ -uri http://opcfoundation.org/UA/IA/ -uri http://opcfoundation.org/UA/DI/
```
## Version History ##
|Version|Changes|
|--|--|
|2.0|Intial release with version tracking and .NET 5.0 support.|
|2.1|Added UA 1.05.00 support.<br/>Switched to Microsoft.Extensions.CommandLineUtils.<br/>Arguments are the same, however, the command 'compile' must be specified.<br/>Use --help for more details.<br/>Fixed bug in generating the 'uanodes' input for the .NET codebase.|
|2.2|Added UA 1.05.02 support.<br/>Added support for NodeSet2 input format.<br/>Added DisplayName to enumeration fields.<br/>Add Union/OptionalFields Support.<br/>Add IJsonEncodeable interface.<br/>Remove unnecessary descriptions in autogenerated code.<br/>Add -compile-nodesets command|
|2.3|Added UA 1.05.03 support.<br/>Numerous fixes needed for 1.05.03.<br/>Upgrade to .NET 8.0.<br/>Generate constants in TypeScript.|
The executable file version has the form 2.0.YYMM.DDHH where the last two fields are based on the time that it was built.
## About this Repository ##
This repository contains *sub-modules*, which are independently tracked. Please clone this repository as shown:
```
git clone https://github.com/OPCFoundation/UA-ModelCompiler --recursive
```
**If access to the submodules is denied then leave --recursive flag off and only use the 'ModelCompiler Solution.sln' which uses NuGet packages instead of the submodules.**
This repository is not updated directly. All changes are first made in a member-only version that can be found [here](https://github.com/OPCF-Members/UA-ModelCompiler).
The version in the member-only repository includes content that is only available to OPC Foundation members such as draft versions of the specifications. When a new version of the OPC UA specification is released, the member-only content is removed and copied to the public repository.
In many cases, updates to the UA-ModelCompiler will require updates to [UA-.NETStandard](https://github.com/OPCFoundation/UA-.NETStandard) codebase. This means a complete release of the UA-ModelCompiler will need to wait for a update to UA-.NETStandard NuGet packages. The member only version links to a member only fork of [UA-.NETStandard](https://github.com/OPCF-Members/UA-.NETStandard-Prototypes) allows the changes to be viewed before they are merged with the public baseline.
The public repository is updated as frequently as the OPC UA Specification (once every 3-5 months). When a release starts, all issues reported on the public repository will be reviewed and, if appropricate, incorporated into the member-only codebase. This includes any pull requests to this public repository, which are subject to the [OPC Foundation Contributor License Agreement (CLA)](https://cla-assistant.io/OPCFoundation/UA-ModelCompiler). When the process completes all accepted public contributions will be merged back into the public codebase along with updates from the member-only codebase.
## License Model ##
The ModelCompiler code is [MIT license](https://github.com/OPCFoundation/UA-ModelCompiler/blob/master/license.md), however, it links to the UA-.NETStandard NuGet packages which is covered under the [OPC Foundation Redistributables licence](https://opcfoundation.org/license/redistributables/1.3/index.html).
## Docker Build
A Docker build with the UA Model Compiler is available in GitHub as [ua-modelco
没有合适的资源?快使用搜索试试~ 我知道了~
ModelCompiler converts XML files into C# and ANSI C.zip
共320个文件
cs:114个
xml:71个
csv:34个
需积分: 5 0 下载量 193 浏览量
2024-01-01
15:53:21
上传
评论
收藏 1.36MB ZIP 举报
温馨提示
ModelCompiler converts XML files into C# and ANSI C
资源推荐
资源详情
资源评论
收起资源包目录
ModelCompiler converts XML files into C# and ANSI C.zip (320个子文件)
BuildStandardTypes.bat 11KB
BuildEngineeringUnits.bat 2KB
PublishModel.bat 1KB
CompileNodeSets.bat 1KB
PublishNodeSet.bat 1KB
TestNodeSets.bat 1KB
UpdateLicense.bat 655B
BuildModel.bat 624B
BuildSchema.bat 502B
BuiltInTypes.bsd 13KB
BuiltInTypes.bsd 12KB
Opc.Ua.Scheduler.Types.bsd 11KB
Opc.Ua.Onboarding.Types.bsd 6KB
DemoModel.Types.bsd 4KB
ServiceExtendedAsync.c 5KB
Service.c 4KB
ComplexType.c 3KB
Service.c 3KB
File.c 2KB
File.c 2KB
File.c 2KB
servicetable.c 2KB
hfentries.c 1KB
EnumeratedType.c 469B
complexparserfunction.c 324B
enumparser.c 317B
serviceparserfunction.c 278B
enumregisterinfo.c 138B
EnumeratedValue.c 123B
ServiceType.c 105B
NuGet.config 366B
packages.Opc.Ua.ModelCompiler.Debug.config 273B
packages.Opc.Ua.ModelCompiler.config 273B
app.config 71B
ModelDesignerValidator.cs 258KB
ModelGenerator2.cs 223KB
Opc.Ua.Onboarding.Constants.cs 134KB
Opc.Ua.Onboarding.Classes.cs 100KB
Opc.Ua.Scheduler.DataTypes.cs 87KB
NodeSetToModelDesign.cs 75KB
DotNetGenerator.cs 67KB
UA Model Design.cs 65KB
AnsiCGenerator.cs 57KB
DemoModel.DataTypes.cs 56KB
Opc.Ua.Scheduler.Constants.cs 51KB
Opc.Ua.Scheduler.Classes.cs 47KB
Opc.Ua.Onboarding.DataTypes.cs 46KB
OpenApiExporter.cs 35KB
Wireshark.cs 34KB
ModelCompilerApplication.cs 31KB
DemoModel.Constants.cs 30KB
UA Type Dictionary.cs 27KB
JsonSchemaExporter.cs 27KB
XmlSchemaGenerator.cs 25KB
Template.cs 21KB
ConstantsGenerator.cs 21KB
TypeDictionaryValidator.cs 18KB
DemoModel.Classes.cs 16KB
BaseSchemaExporter.cs 16KB
BinarySchemaGenerator.cs 15KB
SchemaGenerator.cs 15KB
CodeGenerator.cs 14KB
StackGenerator.cs 10KB
ModelDesign.cs 10KB
UAServer.cs 10KB
MeasurementUnits.cs 9KB
XmlSchemaValidator.cs 7KB
XmlSchemaValidator.cs 6KB
HeaderUpdateTool.cs 6KB
Method.cs 5KB
Context.cs 4KB
VariableTypeValue.cs 4KB
Union.cs 4KB
VariableType.cs 4KB
NodeDocumentationReader.cs 3KB
ClassWithOptionalFields.cs 3KB
Program.cs 3KB
ReferenceNodeManager.cs 3KB
XmlMethodAsync.cs 3KB
Class.cs 3KB
Service.cs 3KB
ObjectType.cs 3KB
DerivedClass.cs 3KB
Class.cs 3KB
Method.cs 3KB
Namespaces.cs 3KB
ClassCollection.cs 2KB
BinaryMethodAsync.cs 2KB
ConstantsFile.cs 2KB
TypedVariableType.cs 2KB
EnumerationCollection.cs 2KB
MethodType.cs 2KB
TypeDictionary.cs 2KB
DataTypes.cs 2KB
Identifiers.cs 2KB
File.cs 2KB
ServiceSet.cs 2KB
EventType.cs 2KB
File.cs 2KB
VariableTypeValueField.cs 2KB
共 320 条
- 1
- 2
- 3
- 4
资源评论
暮苍梧~
- 粉丝: 41
- 资源: 258
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功