opcfoundation / ua-modelcompiler Goto Github PK
View Code? Open in Web Editor NEWModelCompiler converts XML files into C# and ANSI C
License: MIT License
ModelCompiler converts XML files into C# and ANSI C
License: MIT License
The generated code for public override bool IsEqual(IEncodeable encodeable)
does not call "if (!base.IsEqual(encodeable)) return false;
" for some generated classes.
This seems to happen for classes without private members declared.
e.g.
/// <summary cref="IEncodeable.IsEqual(IEncodeable)" />
public override bool IsEqual(IEncodeable encodeable)
{
if (Object.ReferenceEquals(this, encodeable))
{
return true;
}
InstanceNode value = encodeable as InstanceNode;
if (value == null)
{
return false;
}
return true;
}
/// <summary cref="IEncodeable.IsEqual(IEncodeable)" />
public override bool IsEqual(IEncodeable encodeable)
{
if (Object.ReferenceEquals(this, encodeable))
{
return true;
}
TypeNode value = encodeable as TypeNode;
if (value == null)
{
return false;
}
return true;
}
The model compiler by default generates a Predefined Nodes XML file where NodeIds have numerical identifiers like so
<uax:Identifier>ns=1;i=15301</uax:Identifier>
.
I have a use case for string identifiers like
<uax:Identifier>ns=1
;s=myThing</uax:Identifier>
Now, the model design XML file offers a StringId attribute element but this doesn't produce a string nodeId. I would suggest that use of this attribute produce a nodeId with string identifier rather than a numeric identifier.
Bob
I've declared the enum:
<opc:DataType SymbolicName="SiemensPlcType" BaseType="ua:Enumeration">
<opc:Fields>
<opc:Field Name="Common" Identifier="0" />
<opc:Field Name="S7_1200" Identifier="1" />
<opc:Field Name="S7_1500" Identifier="2" />
<opc:Field Name="LOGO" Identifier="3" />
</opc:Fields>
</opc:DataType>
Generated C# code is next:
public enum SiemensPlcType
{
/// <summary>
/// A description for the Common field.
/// </summary>
[EnumMember(Value = "Common_0")]
Common = 0,
/// <summary>
/// A description for the S7_1200 field.
/// </summary>
[EnumMember(Value = "S7_1200")]
S7_1200 = 1200,
/// <summary>
/// A description for the S7_1500 field.
/// </summary>
[EnumMember(Value = "S7_1500")]
S7_1500 = 1500,
/// <summary>
/// A description for the LOGO field.
/// </summary>
[EnumMember(Value = "LOGO_3")]
LOGO = 3,
}
Mistakes are in lines:
S7_1200 = 1200,
...
S7_1500 = 1500,
Should be:
S7_1200 = 1,
...
S7_1500 = 2,
How can I set the Value attribute of an object type I define in a model xml file?
I am using the Model Compiler to create Object Types which contain hierarchies including Variables, I would like to set the Value on the object instances based on the model. I am setting DefaultValue in the model. When instantiating the object and initializing with NodeState.Create, Value does not get set. Should it be set to DefaultValue? Is there some way to set Value from the model? It seems to be prevented from the initialization string. Is there something I am missing?
(Moving this issue here from the UA-.NETStandard repository as requested.)
ModelCompiler generates initialization strings with invalid ValueRanks. This happens when NodeState has a ValueRank Any (-2). There is a check in GetAttributesToSave method of BaseVariableTypeState and BaseVariableState that if the ValueRank is -2 then it won't be stored in initialization string. When creating the state and the ValueRank is missing from the initialziation string then it is initialized to value 0. So all states with ValueRank -2 are incorrectly initialized with ValueRank 0.
To fix the bug, the check should be that if ValueRank is OneOrMoreDimensions (0) then it can be omitted from the initialization string.
Patch to fix the bug can be found as an attachment.
fix.txt
I get the following error when the attached xml file is loaded.
Error parsing file D:\ModelCompiler\ReducedCI874TypesTest.xml
at Opc.Ua.ModelCompiler.ModelCompilerValidator.Validate2(IList1 designFilePaths, String identifierFilePath, Boolean generateIds) in D:\UA-ModelCompiler-master\ModelCompiler\ModelDesignerValidator.cs:line 1001 at Opc.Ua.ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList
1 designFilePaths, String identifierFilePath, UInt32 startId, String specificationVersion) in D:\UA-ModelCompiler-master\ModelCompiler\ModelGenerator2.cs:line 96 at Opc.Ua.ModelCompiler.Program.ProcessCommandLine2(List1 tokens) in D:\UA-ModelCompiler-master\ModelCompiler\Program.cs:line 424 There is an error in XML document (2, 2). at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader) at Opc.Ua.Schema.SchemaValidator.LoadFile(Type type, String path) in D:\UA-ModelCompiler-master\Core\Types\Schemas\SchemaValidator.cs:line 254 at Opc.Ua.ModelCompiler.ModelCompilerValidator.Validate2(IList
1 designFilePaths, String identifierFilePath, Boolean generateIds) in D:\UA-ModelCompiler-master\ModelCompiler\ModelDesignerValidator.cs:line 991
There is an error in XML document (2, 2).
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) at System.Xml.Serialization.XmlSerializer.Deserialize(TextReader textReader) at Opc.Ua.Schema.SchemaValidator.LoadFile(Type type, Stream stream) in D:\UA-ModelCompiler-master\Core\Types\Schemas\SchemaValidator.cs:line 272 at Opc.Ua.CodeGenerator.TypeDictionaryValidator.Validate(Stream stream) in D:\UA-ModelCompiler-master\ModelCompiler\StackGenerator\Validators\TypeDictionaryValidator.cs:line 147 at Opc.Ua.ModelCompiler.ModelCompilerValidator.ImportTypeDictionary(Stream stream, String resourcePath) in D:\UA-ModelCompiler-master\ModelCompiler\ModelDesignerValidator.cs:line 632 at Opc.Ua.ModelCompiler.ModelCompilerValidator.ImportTypeDictionary(String filePath, String resourcePath) in D:\UA-ModelCompiler-master\ModelCompiler\ModelDesignerValidator.cs:line 624 at Opc.Ua.ModelCompiler.ModelCompilerValidator.Validate2(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in D:\UA-ModelCompiler-master\ModelCompiler\ModelDesignerValidator.cs:line 997
The Save and GetAttributesToSave methods of BaseVariableState and BaseVariableTypeState won't serialize ValueRank if it's value is -2 (Any). This causes Update method to not initialize ValueRank at all, leaving it's value to default int value 0 (OneOrMoreDimensions). This can be fixed by omitting ValueRank from the serialization if it's value is 0 (OneOrMoreDimensions) instead of -2 (Any).
This issue causes invalid initialization strings for types which default ValueRank is Any when generating Opc.Ua.Classes file.
Hi,
UA-ModelCompiler fails to build models it was capable of building before.
current git commit ID: c75b5bf
last working commit ID: 3754f9b ( tag: UA-1.04.7-2020-07-15)
PS C:\UA-ModelCompiler\Bin\Release> .\Opc.Ua.ModelCompiler.exe -d2 C:\opcua-animal-cs\animalModel.xml -cg C:\opcua-animal-cs\animalModel.csv -o C:\opcua-animal-cs\output -console
Error parsing file C:\opcua-animal-cs\animalModel.xml
at ModelCompiler.ModelCompilerValidator.Validate2(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in C:\UA-ModelCompiler\ModelCompiler\ModelDesignerValidator.cs:line 1115
at ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList`1 designFilePaths, String identifierFilePath, UInt32 startId, String specificationVersion) in C:\UA-ModelCompiler\ModelCompiler\ModelGenerator2.cs:line 99
at ModelCompiler.Program.ProcessCommandLine2(List`1 tokens) in C:\UA-ModelCompiler\ModelCompiler\Program.cs:line 424
I am testing with
https://github.com/Pro/opcua-modeling-tutorial
https://github.com/Pro/opcua-animal-cs
I need to use a Structure Data Type defined in a 3rd party companion specification in my model. The companion specification is available as NodeSet2.xml file.
I have declared the companion specification as an additional namespace in my model but I still get an error form the model compiler:
The DataType reference for node My_Node is not valid: CustomDataType.
How can I use the custom DataType in my Model. The goal is to generate a Nodeset2.xml file.
UA-ModelCompiler should be available as .Net Standard Project referencing the already existing Opc Ua Core Standard Project. Is there a possibility to implement that any time soon?
Recompiling is unique way?
So where are the ModelDesign XML reference?
Hi, I am from GE, one of the members of OPCFoundation.
Last week there was a Repo called UA-TypeRepository. I was using the README's to learn OPCUA hierarchy.
Where did it go? Can you bring it back?
UA-ModelCompiler/ModelCompiler/ModelDesignerValidator.cs has mistake at lines 5180..5184 at commit 647dda2 (and earlier):
if (hierarchyNode.Identifier is uint)
{
hierarchyNode.Instance.NumericId = (uint)hierarchyNode.Identifier;
hierarchyNode.Instance.NumericIdSpecified = false;
}
IT should be hierarchyNode.Instance.NumericIdSpecified = true;
there.
The license file license.md
shall be added to the project.
I know, the model compiler does require the corresponding *model.xml file in order to create the NodeSet2.xml file and proxy classes.
Since companion specs must not provide the valid model.xml file, the UA-ModelCompiler is useless in that case. Unless we write the companion spec model by ourselves.
I am talking about the machinery companion spec, which can be found here: https://github.com/OPCFoundation/UA-Nodeset/tree/v1.04/Machinery
My question is, is there any official OPCFoundation tool which is capable in creating the c# proxy classes based on the NodeSet2.xml files? or will there be support in the UA-ModelCompiler?
What i see is that we seem to be forced to used any commercial sdk which creates different proxy classes incompatible to the official OPCFoundation c# stack.
So whats the purpose of the C# Stack on github, by providing an incomplete toolchain?
If somebody has any information about the intention/current sate, i would be very thankful!
In the meantime we have managed to write the corresponding model for a few companion specs we want to support. But once the companion specs changes, we need to manually adjust those models...
The local library Core contains functionality not required by the compiler. It seems similar to the library Core included in the project OPCFoundation/UA-.NET. It causes code synchronization and maintenance issues. We have also problem with license compatibility.
Proposal:
I am currently trying to create an information model using UA-ModelCompiler. When I create my own Structured DataType I see that in the generated NodeSet file is preventing the FreeOPC-UA https://github.com/FreeOpcUa/python-opcua server to be able to get an "object" of that type (get_ua_class
). When I create the same DataType using UAModeler it works.
After comparing and hacking into the NodeSet files I found that the reason for that is the missing HasDescription
reference on the Types>DataTypes>OPC Binary>[NAMESPACE_DIC]>[DATA_TYPE]
<UAVariable NodeId="ns=1;i=15013" BrowseName="1:versionDataType" ParentNodeId="ns=1;i=15009" DataType="String">
<DisplayName>versionDataType</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=69</Reference>
<!-- added manually start... -->
<Reference ReferenceType="HasDescription" IsForward="false">ns=1;i=15008</Reference>
<!-- ... added manually end -->
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=15009</Reference>
</References>
<Value>
<String xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">versionDataType</String>
</Value>
</UAVariable>
where ns=1;i=15008
is the DeafultBinary Object.
When I manually set it it works.
'''So my question is: what is necessary to make in the ModelDesign in order to get that reference?'''
regards
Is it possible to overwite a method from a BaseType? Let's say I have an object who's base type is TemporaryFileTransferType, can I overwrite it's method GenerateFileForRead?
<ObjectType SymbolicName="MyNS:SubTypeObj" BaseType="ua:TemporaryFileTransferType" >
<Children>
<Method SymbolicName="MyNS:GenerateFileForRead" TypeDefinition="MyNS:GenerateFileForReadMethodType" ModellingRule="Mandatory">
</Method>
</Children>
</ObjectType>
I would like to do this so I can provide a method definition like so:
<Method SymbolicName="MyNS:GenerateFileForReadMethodType">
<InputArguments>
<Argument Name="GenerateOptions" DataType="ua:String"></Argument>
</InputArguments>
<OutputArguments>
<Argument Name="FileNodeId" DataType="ua:NodeId"></Argument>
<Argument Name="FileHandle" DataType="ua:UInt32"></Argument>
<Argument Name="CompletionStateMachine" DataType="ua:NodeId"></Argument>
</OutputArguments>
</Method>
But when I try to do this, in the generated NodeSet2, the MethodDeclarationId is the id for the GenerateFileForRead in the TemporaryFileTransferType.
The reason for asking is because the machine vision companion specification asks to overwrite these methods and I would like to know how this could be done through a UA Model Design
In case GUI is required it shall be added as separate project. In this case WPF is recommended as the Forms is obsolete technology.
Hi,
I want to compile the ModelDesign of an empty namespace but it fails with
PS C:\UA-ModelCompiler\Bin\Release> .\Opc.Ua.ModelCompiler.exe -d2 C:\opcua-modeling-tutorial\FooFltModel.xml -cg C:\opcua-modeling-tutorial\FooFltModel.csv -o C:\opcua-modeling-tutorial\FooFltModel -console
Object reference not set to an instance of an object.
at Opc.Ua.ModelCompiler.ModelCompilerValidator.Validate2(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in C:\UA-ModelCompiler\ModelCompiler\ModelDesignerValidator.cs:line 1099
at Opc.Ua.ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList`1 designFilePaths, String identifierFilePath, UInt32 startId, String specificationVersion) in C:\UA-ModelCompiler\ModelCompiler\ModelGenerator2.cs:line 95
at Opc.Ua.ModelCompiler.Program.ProcessCommandLine2(List`1 tokens) in C:\UA-ModelCompiler\ModelCompiler\Program.cs:line 422
Here is the ModelDesign file I am trying to compile.
<?xml version="1.0" encoding="utf-8"?>
<ModelDesign
xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ua="http://opcfoundation.org/UA/"
xmlns:FooZbrFlt="https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
TargetNamespace="https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/"
TargetVersion="0.9.0"
TargetPublicationDate="2020-05-01T00:00:00Z"
xmlns="http://opcfoundation.org/UA/ModelDesign.xsd">
<Namespaces>
<!--No space allowed at the beginning of the namespace URL!
Prefix sets the filenames of the generated files. -->
<Namespace Name="FooZbrFlt" Prefix="FooFlt">https://new.foo.com/zebra-compression/flattening-and-subspacefolding/UA/</Namespace>
<Namespace Name="OpcUa" Version="1.03" PublicationDate="2013-12-02T00:00:00Z">http://opcfoundation.org/UA/</Namespace>
</Namespaces>
<!-- Instantiate at least one variable (or object, or view, or ...) in namespace.
Compiling an empty namespace will fail with error message:
Object reference not set to an instance of an object.
Uncomment to following view and the ModelDesign will compile successfully. -->
<!--
<View SymbolicName="FooZbrFlt:MyView">
<Description>Dummy view.</Description>
<References>
<Reference IsInverse="true">
<ReferenceType>ua:Organizes</ReferenceType>
<TargetId>ua:ObjectsFolder</TargetId>
</Reference>
</References>
</View>
-->
</ModelDesign>
The model design file will compile successfully, if the view is uncommented and the namespace therefore is not empty.
Is this a bug of UA-ModelCompiler?
Methods children defined as "Draft" in ModelDesign files are added in generated code without corresponding MethodState
definition.
An example is GetEncryptingKeyMethodType
defined in StandardTypes.xml.
This causes a compilation error in Opc.Ua.Classes.cs :
<opc:Method SymbolicName="GetEncryptingKeyMethodType" PartNo="12" ReleaseStatus="Draft">
<opc:InputArguments>
<opc:Argument Name="CredentialId" DataType="ua:String" />
<opc:Argument Name="RequestedSecurityPolicyUri" DataType="ua:String" />
</opc:InputArguments>
<opc:OutputArguments>
<opc:Argument Name="PublicKey" DataType="ua:ByteString"></opc:Argument>
<opc:Argument Name="RevisedSecurityPolicyUri" DataType="ua:NodeId"></opc:Argument>
</opc:OutputArguments>
</opc:Method>
<opc:ObjectType SymbolicName="KeyCredentialConfigurationType" BaseType="ua:BaseObjectType" PartNo="12">
<opc:Children>
<opc:Property SymbolicName="ResourceUri" DataType="ua:String" ValueRank="Scalar" ModellingRule="Mandatory" />
<opc:Property SymbolicName="ProfileUri" DataType="ua:String" ValueRank="Scalar" ModellingRule="Mandatory" />
<opc:Property SymbolicName="EndpointUrls" DataType="ua:String" ValueRank="Array" ModellingRule="Optional" />
<opc:Property SymbolicName="ServiceStatus" DataType="ua:StatusCode" ValueRank="Scalar" ModellingRule="Optional" />
<opc:Method SymbolicName="GetEncryptingKey" TypeDefinition="GetEncryptingKeyMethodType" ModellingRule="Optional" ReleaseStatus="Draft" />
<opc:Method SymbolicName="UpdateCredential" TypeDefinition="KeyCredentialUpdateMethodType" ModellingRule="Optional" />
<opc:Method SymbolicName="DeleteCredential" ModellingRule="Optional" />
</opc:Children>
</opc:ObjectType>
Hi
How is it possible to describe in ModelDesign format a DataTypes which contains Optional Fields. So for instance in in the NodeSet2 format i have something like that (from the VDMA Machine Vision companion specification
> <UADataType IsAbstract="true" NodeId="ns=1;i=3019" BrowseName="1:BinaryIdBaseDataType">
> <DisplayName>BinaryIdBaseDataType</DisplayName>
> <References>
> <Reference ReferenceType="HasSubtype" IsForward="false">i=22</Reference>
> <Reference ReferenceType="HasEncoding">ns=1;i=5027</Reference>
> <Reference ReferenceType="HasEncoding">ns=1;i=5271</Reference>
> </References>
> <Definition Name="1:BinaryIdBaseDataType">
> <Field DataType="TrimmedString" Name="Id">
> <Description>Id is a system-wide unique name for identifying the recipe.</Description>
> </Field>
> <Field **IsOptional**="true" DataType="TrimmedString" Name="Version">
> <Description>Represents an optional version number of the identified recipe. It is recommended to be of the format Major.minor.patch.build or a subset thereof, but the actual format is implementation defined.</Description>
> </Field>
> <Field **IsOptional**="true" DataType="ByteString" Name="Hash">
> <Description>Represents an optional hash of the binary content of the actual recipe (as it would be transmitted by the transfer methods).
> The hash is supposed to be provided by the environment if existing. The environment shall use the same hash function on all recipes so that a difference in the hash indicates a difference in the recipe. It is recommended to use the SHA-256 algorithm for computing the hash, however, the actual algorithm is implementation-defined.</Description>
> </Field>
> <Field **IsOptional**="true" DataType="String" Name="HashAlgorithm">
> <Description>Name of the hash function used. Required if internally and externally computed hashes are to be compared.</Description>
> </Field>
> <Field **IsOptional**="true" DataType="LocalizedText" Name="Description">
> <Description>Optional short human readable description of the configuration.</Description>
> </Field>
> </Definition>
> </UADataType>
So in the model design format do we have something to describe that fields are optional. The problem is that the encoders/decoders are not generated correctly in C# since it is written in part 6 we should generate a 4 bytes (UInt32) at the beginning of the encoding.
Is there something missing in the modelcompiler?
Thanks
OPC 10001-7: Interfaces and AddIns 9 Release 1.04 states:
The HasAddIn ReferenceType is a concrete ReferenceType and can be used directly. It is a subtype of the HasComponent ReferenceType.
So the BaseType here:
UA-ModelCompiler/ModelCompiler/Design.v104/StandardTypes.xml
Lines 2081 to 2083 in cf99bfa
Should be HasComponent
instead of NonHierarchicalReferences
Hi,
I recently am experimenting for my university project on OPC UA DI nodeset and I wonder if I could give new feature like OPC UA PubSub to my UA Server application. I want to integrate both NodeSet to make my UA Server PubSub enabled. However, for that as per my knowledge I need to prepare a new NodeSet which collaborates both DI and PubSub NodeSets. How can I do this collaboration with UA Model-Compiler? Thanks and please correct me if I misunderstood the technology.
@randy-armstrong thanks for merging #36
After that it would make sense that you enable automated docker container builds for your own OPCF account. Otherwise the Readme still links to my docker builds:
https://github.com/OPCFoundation/UA-ModelCompiler/blame/master/README.md#L34
Its very easy and can be done in 5 minutes.
OPCFoundation
would make sense here as a nameUA-ModelCompiler
Here are the Settings I'm using, you can just use the same and you are done:
Branch: master
Tag: latest
You can also contact me directly if you have further issues or if I can support you in that direction
https://opcua.rocks/contact/
Is it planned to add ISA-95 design model files (.csv, .xml) into Design folders?
The BuildStandardTypes.bat uses ModelCompiler.Design.v104. Commit Fix 1.04 vs 1.05 duplication includes removal of the ModelCompiler.Design folder and defaulting to v104 for BuildStandardTypes.bat. The master branch of UA-Nodeset is v1.05 according to the readme.md so where is the Design.v105 folder used to create this or am I missing something? I wanted to check before doing something stupid like recreating the design folder by extracting the files from the UA-Nodeset repository and stripping out copyrights info added by scripts.
The UA Model Design.xsd specifies that the AccessLevel type can adopt one of "none", "Read", "Write", "ReadWrite".
However, the OPC-UA specification, part 3, paragraph 8.57 also specifies fields HistoryRead (bit 2) and HistoryWrite (bit 3) and some more. The HistoryWrite bit
"Indicates if the history of the value is writable. It also indicates if the history of the Variable is available via the OPC UA Server."
I wish to activate historizing and would therefore want to activate HistoryRead and HistoryWrite.
I'm aware of the "historizing" XML-attribute of the VariableTypeDesign. However, this would implement the OPC-UA attribute "historizing" which indicates that (paragraph 5.6.2.) :
...the Server is actively collecting data for the history of the Variable. This differs from the AccessLevel Attribute which identifies if the Variable has any historical data. A value of TRUE indicates that the Server is actively collecting data
Presently, my server refuses to historise data and I don't know how to activate it.
Yours,
Bob
The only difference between -c
and -cg
is that -c
throws an exception if the specified CSV file is not found. -cg
reads the specified CSV if exists as well as -c
. "instead of reading it" is wrong. Please improve the explanations.
At the 'Building model Provisioning' stage
Looking for OpcUaProvisioningModel. Can't find it in Github in the Design folder.
Regards
I am new to OPC-UA. I have created basic XML file for the following hierarchy but I am getting parsing Error can you please identify my mistake.
(Nodes Hierarchy )
Plant
Line Number
Sensor1
Voltage A
Voltage B
Following is my XML code.
<?xml version='1.0' encoding='utf-8'?> <UANodeSet xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <NamespaceUris> <Uri>http://opcfoundation.org/UA/Sensor/</Uri> </NamespaceUris> <Aliases> <Alias Alias="Float">i=10</Alias> <Alias Alias="Organizes">i=35</Alias> <Alias Alias="HasTypeDefinition">i=40</Alias> <Alias Alias="HasProperty">i=46</Alias> </Aliases> <UAObject BrowseName="0:Plant" NodeId="i=20001" ParentNodeId="i=85"> <DisplayName>Plant</DisplayName> <Description>Plant</Description> <References> <Reference IsForward="false" ReferenceType="Organizes">i=85</Reference> <Reference ReferenceType="HasTypeDefinition">i=61</Reference> <Reference ReferenceType="Organizes">i=20002</Reference> </References> </UAObject> <UAObject BrowseName="0:LineNumber" NodeId="i=20002" ParentNodeId="i=20001"> <DisplayName>LineNumber</DisplayName> <Description>LineNumber</Description> <References> <Reference IsForward="false" ReferenceType="Organizes">i=20001</Reference> <Reference ReferenceType="HasTypeDefinition">i=61</Reference> <Reference ReferenceType="Organizes">i=20003</Reference> </References> </UAObject> <UAObject BrowseName="0:Sensor1" NodeId="i=20003" ParentNodeId="i=20002"> <DisplayName>Sensor1</DisplayName> <Description>The base type for all object nodes.</Description> <References> <Reference IsForward="false" ReferenceType="Organizes">i=20002</Reference> <Reference ReferenceType="HasTypeDefinition">i=58</Reference> <Reference ReferenceType="HasProperty">i=20004</Reference> <Reference ReferenceType="HasProperty">i=20005</Reference> </References> </UAObject> <UAVariable BrowseName="0:VoltageA" DataType="Float" NodeId="i=20004" ParentNodeId="i=20003"> <DisplayName>VoltageA</DisplayName> <Description>VoltageA</Description> <References> <Reference IsForward="false" ReferenceType="HasProperty">i=20003</Reference> <Reference ReferenceType="HasTypeDefinition">i=68</Reference> </References> <Value> <uax:Float>9.99</uax:Float> </Value> </UAVariable> <UAVariable BrowseName="0:VoltageB" DataType="Float" NodeId="i=20005" ParentNodeId="i=20003"> <DisplayName>VoltageB</DisplayName> <Description>VoltageB</Description> <References> <Reference IsForward="false" ReferenceType="HasProperty">i=20003</Reference> <Reference ReferenceType="HasTypeDefinition">i=68</Reference> </References> <Value> <uax:Float>9.99</uax:Float> </Value> </UAVariable> </UANodeSet>
I will also attach screenshot of error message I am getting.
Hello,
I want to generate C# source files with the ModelCompiler out of an InformationModel that was compiled as .xml using the UANodeSet.xsd. According to the description the ModelCompiler should be able to do that.
Following the instructions and the help file to generate the files, I get the follow Exception:
The XML file starts like this:
I marked the line, that causes the Exception.
Did I miss something?
I would appreciate any help on this.
Thanks in advance!
Best regards
I download the zip file,and openthe extracted folder,there's no file "MeasurementUnits.cs ",and I can't compile the project,can you give any help?
Don't understand how to use this software, do you have instructions
Hello, we're using UA-ModelCompiler and actually we're solving issues with Enumerations.
Here's our XML description, focus on
<opc:DataType SymbolicName="TestEnum" BaseType="ua:Enumeration">
<opc:Fields>
<opc:Field Name="State1" Identifier="1" Value="1"></opc:Field>
<opc:Field Name="State2" Identifier="2" Value="2"></opc:Field>
<opc:Field Name="State3" Identifier="3" Value="3"></opc:Field>
<opc:Field Name="State4" Identifier="4" Value="4"></opc:Field>
<opc:Field Name="State5" Identifier="5" Value="5"></opc:Field>
</opc:Fields>
</opc:DataType>
...
<opc:Method SymbolicName="TestVoidEnumMethodType">
<opc:Description>test method</opc:Description>
<opc:InputArguments>
<opc:Argument Name="testEnum" DataType="TestEnum"> </opc:Argument>
</opc:InputArguments>
</opc:Method>
...
<opc:ObjectType SymbolicName="PluginExample" BaseType="CpiServerDeviceBaseType">
<opc:Description>Description from model.txt for PluginExample</opc:Description>
<opc:Children>
<opc:Object SymbolicName="ExampleObject" TypeDefinition="ExampleObjectType" SupportsEvents="true" MinimumSamplingInterval="500">
<opc:DisplayName>ExampleObject</opc:DisplayName>
</opc:Object>
<opc:Variable SymbolicName="testString" DataType="ua:String" MinimumSamplingInterval="1000" AccessLevel="ReadWrite"></opc:Variable>
<opc:Variable SymbolicName="testInt" DataType="ua:Int32" MinimumSamplingInterval="1000" AccessLevel="ReadWrite"></opc:Variable>
<opc:Variable SymbolicName="testLong" DataType="ua:Int64" MinimumSamplingInterval="1000" AccessLevel="ReadWrite"></opc:Variable>
<opc:Variable SymbolicName="testDouble" DataType="ua:Double" MinimumSamplingInterval="1000" AccessLevel="ReadWrite"></opc:Variable>
<opc:Variable SymbolicName="testEnum" DataType="TestEnum" AccessLevel="ReadWrite" MinimumSamplingInterval="500"></opc:Variable>
<opc:Property SymbolicName="arrayOfInt" DataType="ua:Int32" ValueRank="Array" AccessLevel="Read" MinimumSamplingInterval="500"/>
<opc:Method SymbolicName="Test" TypeDefinition="ExampleTestMethodType" ModellingRule="Optional"></opc:Method>
<opc:Method SymbolicName="TestVoidStringMethod" TypeDefinition="TestVoidStringMethodType" ModellingRule="Optional"></opc:Method>
<opc:Method SymbolicName="TestVoidVoidMethod" TypeDefinition="TestVoidVoidMethodType" ModellingRule="Optional"></opc:Method>
<opc:Method SymbolicName="TestVoidWithEnum" TypeDefinition="TestVoidEnumMethodType" ModellingRule="Optional"></opc:Method>
</opc:Children>
</opc:ObjectType>
This leads to defining new enum type:
First issue is with Variable testEnum:
I supposed that it should be Enum type, so changing value should suggest combobox with enum values or something like that.
But nevermind, this is not critical.
Second and for our purpose critical issue is method with enum argument:
Argument is again filled with number (no combobox) and what's more whole method can't be invoked, because UA Expert "Could not convert argument 0 to variant type TestEnum".
Are we missing something?
I would be glad for any help or point to correct this.
Thank You
Martin
I am trying to generate C#.NET code from a model defined as a XML file conforming to the "UANodeSet.xsd" format. Since this is the standard format for describing an OPC UA model I would expect that it is possible to generate code using the XML file as input. However the ModelCompiler expects an XML file conforming to the "UA Model Design.xsd".
Is there an easy way of converting a UaNodesSet XML file to a UA Model Design XML file. Or is there any other way to generate C#.NET code from a UaNodeSet XML file?
When I run this batch file, there will always be a hint that the
The SymbolicId is already used by another node: CurrencyUnitType.
I make sure I download it alright.
Unified Automation have a UAModeller tool is their a tool that is used by the UA-ModelCompiler to generate the xml and csv file that will ultimately be used to generate the C# code. Can i ask to be pointed in the direction of the tool that is used to generate the xml and csv files that are consumed by UA-ModelCompiler?
UAModeller does not give me an xml file with the correct structure can you point me at what tool everyone is using in order to get xml in the correct format so UA-ModelCompiler can generate C#
thanks
The ModelDesign schema is used as the syntax definition of a language used to represent the UA Information Model. Each language must have also semantics definition that couples together the meaning (knowledge how to apply the text) and syntax constructs. Someone could say that the spec is a good description of the semantics. Partially it is true, but how to learn using the spec what it means TaypeDefinition attribute for the Method element in the example below:
<Method SymbolicName="ADI:SetConfiguration" TypeDefinition="ADI:AnalyserDeviceTypeSetConfigurationMethodType">
<Description>Write the complete configuration of the AnalyserDevice and all of its components to the analyzer server and make the new configuration active.</Description>
</Method>
From my experience, I know that it is required for the compiler to generate arguments and return value.
FYI, the topic model life-cycle is covered by the section of my ebook available for free:
Address Space Model Life-cycle
It seems there are the following options:
The precise definition of the compiler language is important for the recovery process (disassembly) based on the UANodeSet in case the UANodeSet xml file must be customized. In other words, the recovery process makes sense only in the case we know the target we are going to restore.
I will appreciate any your opinion.
in the methode GetDefaultValue by default false is used for the nullable bool, but then "true" is returned as default value.
UA-ModelCompiler/ModelCompiler/ModelGenerator2.cs
Line 4619 in 647dda2
The built in help text at
https://github.com/OPCFoundation/UA-ModelCompiler/blob/master/ModelCompiler/HelpFile.txt
seems to be inconsistent or incomplete.
Example command indicates possible use of -oi
which is not explained. In what case is -oi
preferable over -o
?
Example command indicates possible use of -oe
which is not explained. What does it do?
No explanation for -ansic
No explanation for -stack
No explanation for -useXmlInitializers
-version
According to the example document in the help, -version
seems to be an optional flag. Which values is the default value, if the flag is not set?
Kind regards
Is it possible set the children of 'ua:AnalogItemType' in the xml file? Such as EURange, unit, etc..
How would I add a method with arguments to an Object.
I tried two ways, but the compiler omits either the arguments or the references. Please see the comments in the following file.
RobotServer.xml.txt
The Ua Defined Types.xml in ModelCompiler/Design/UA Defined Types.xml has wrong supertypes for PermissionType and EventNotifierType. As the issues are the same the current NodeSet2 has, I will refer to the issues raised in that project:
PermissionType: OPCFoundation/UA-Nodeset#8
EventNotifier: OPCFoundation/UA-Nodeset#9
The EventNotifier is in my opinion quite critical, see my comments on the UA-Nodeset project issues. But both should be fixed.
Hi
I tried to create an EUInformation property. It seems to me that either I did a mistake or the compiler is not generating the code for the Units not correctly.
In case I did something wrong, it would be great to add an example to the existing models.
It tested it with the following snippet:
<opc:Variable SymbolicName="SetPoint1" DataType="ua:Double" AccessLevel="ReadWrite" Historizing="true" TypeDefinition="ua:BaseVariableType" WriteAccess="0">
<opc:Children>
<opc:Property SymbolicName="ua:EngineeringUnits" DataType="ua:EUInformation" ModellingRule="Mandatory">
<opc:Fields>
<opc:Field Name="ua:NamespaceUri" DataType="tns:String">http://www.opcfoundation.org/UA/units/un/cefact</opc:Field>
<opc:Field Name="ua:UnitId" DataType="tns:String" Value="4408652">4408652</opc:Field>
<opc:Field Name="ua:DisplayName" DataType="tns:String">°C</opc:Field>
</opc:Fields>
</opc:Property>
</opc:Children>
</opc:Variable>
The command line usage message should include the parameters -version and -exclude (and potentially other parameters)
Where is the UA Model Design Tool?
Are there any sources of help or tutorials on using the XML Schema Explorer available?
Hello everyone
I use the model compiler to create dynamically an object from a generated type.
From what I understood, if I create a type in the xml, let's say EquipmentServiceType, the software automatically generates a c# class named EquipmentServiceState that will be used to create an instance of the object.
When I try to use it, the EquipmentServiceType node in the Address Space and the object EquipmentServices that have EquipmentServiceState as typeDefinition have the same NodeId.
Here is the code I wrote:
`
var equipmentService = new EquipmentServiceState(null);
// The equipment service type node has a NodeId of 1048, I checked before
// nodeId not given yet
equipmentService.Create(SystemContext, null, new QualifiedName("Equipment Services", NamespaceIndex), null, true);
// if i check the nodeid of the equipment service, it is also 1048
// Add references to the node so that it can be seen in the Address Space
IList<IReference> references = null;
if (!externalReferences.TryGetValue(Opc.Ua.ObjectIds.ObjectsFolder, out references))
{
references = new List<IReference>();
externalReferences[Opc.Ua.ObjectIds.ObjectsFolder] = references;
}
equipmentService.AddReference(ReferenceTypeIds.Organizes, true, Opc.Ua.ObjectIds.ObjectsFolder);
references.Add(new NodeStateReference(ReferenceTypeIds.Organizes, false, equipmentService.NodeId));
// store it and all of its children in the pre-defined nodes dictionary for easy look up.
AddPredefinedNode(SystemContext, equipmentService);`
What did I do wrong ?
protected override NodeId GetDefaultTypeDefinitionId(NamespaceTable namespaceUris)
{
return Opc.Ua.NodeId.Create(Boiler.ObjectTypes.GenericSensorType, Boiler.Namespaces.Boiler, namespaceUris);
}
In this code NodeId
and the Opc.Ua.NodeId
are the seme type.
It makes the real problem if the code is not to be used in the Opc.Ua
environment where the referenced classes are replaced by different once.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.