Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate code from UaNodeset file #6

Closed
MaartenBE opened this issue Nov 15, 2016 · 7 comments
Closed

Generate code from UaNodeset file #6

MaartenBE opened this issue Nov 15, 2016 · 7 comments

Comments

@MaartenBE
Copy link

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?

@mpostol
Copy link
Contributor

mpostol commented Nov 15, 2016

You can easily do it using the demo version of the OPC UA Address Space Model Designer.

Always it is reverse engineering (disassembler) process, so some details may be lost.

Because it is hard to prepare UANodeSet file manually, my advice is to use ModelDesign schema as the source code to be compiled and produce all required deliverables (including UANodeSet) all together.
More about deploying the OPC UA Information Model you can find in the whitepaper:
OPC UA INFORMATION MODEL DEPLOYMENT.

Unfortunately the ModelCompiler in this repository fits only partially to the whole process.

@MaartenBE
Copy link
Author

I am in the situation where another company has delivered the OPC UA model in UaNodeSet format (XML) and the proprietary .ua format of Unified Automation's UaModeler. I want to use the same model that we use to generate and develop in C to be used for our testing framework that uses the C#.NET SDK.

I tried to load the base model in the Address Space Model Designer but I cannot get the build to finish. The resulting output is:

Building the solution ...
***********************************
------ Building project: Project: gen_requirement. ------
Build started at: 16/11/2016 11:48:04.

C:\Users\Maarten\AppData\Local\Apps\2.0\PXT0AEO4.EK1\D4Z81JGV.TEX\cas...tion_432daad65bc0ee4c_0003.0014_206f2a4c1b631ccc\exe\Cas.Opc.Ua.ModelCompiler.exe -d2 "C:\Users\Maarten\AppData\Local\Apps\2.0\PXT0AEO4.EK1\D4Z81JGV.TEX\cas...tion_432daad65bc0ee4c_0003.0014_206f2a4c1b631ccc\gen_requirement.xml"  -cg "C:\Users\Maarten\AppData\Local\Apps\2.0\PXT0AEO4.EK1\D4Z81JGV.TEX\cas...tion_432daad65bc0ee4c_0003.0014_206f2a4c1b631ccc\gen_requirement.csv" -o "C:\Users\Maarten\AppData\Local\Apps\2.0\PXT0AEO4.EK1\D4Z81JGV.TEX\cas...tion_432daad65bc0ee4c_0003.0014_206f2a4c1b631ccc\gen_requirement" -console

!ERROR!
The following has occurred:
Object reference not set to an instance of an object.
   at Opc.Ua.ModelCompiler.ModelCompilerValidator.Validate2(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds)
   at Opc.Ua.ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList`1 designFilePaths, String identifierFilePath, UInt32 startId)
   at Opc.Ua.ModelCompiler.Program.ProcessCommandLine2(List`1 tokens)

The build cannot be continued.
Build ended at: 16/11/2016 11:48:12.

I agree that when designing a model that it makes sense to start with the ModelCompiler format. However I don't have the time to fully convert the existing model into this format since manually converting this is tedious work and error prone.

@mpostol
Copy link
Contributor

mpostol commented Nov 16, 2016

Object reference not set to an instance of an object is error generated by the ModelCompiler, which is embeded in the CAS Model Designer. Maybe it is the site effect of the model error. This compiler is not perfect but I don’t know any better application.

Have you got any errors while importing the NodeSet model? The list of error is in the application log file and displayed in the debug window. The location of the log file is in the help menu.
For further technical support related to OPC UA Model Designer contact me directly at mpostol@cas.eu.

@aliridha1510
Copy link

any news ?

@JayeshThamke
Copy link

@aliridha1510 I tried generating code from OpcUaDiModelv11.xml and OpcUaDiModelv11.csv file. Playing with ModelCompiler source code I could generate ansic code. I tried following input tokens/args to Opc.Ua.ModelCompiler.exe

.\Bin\Release\Opc.Ua.ModelCompiler.exe -d2 ".\Test1\model\OpcUaDiModelv11.xml" -c ".\Test1\model\OpcUaDiModelv11.csv" -o2 ".\Test1\out\" -ansic ".\Test1\out\AnsiC\" -useXmlIn itializers -console

the help text for

-ansic

does not provide any information about output directory as an input argument after -ansic

I have checked it in my repository, from where you can download all of them:
https://github.com/JayeshThamke/opcua_ansic_files.git

@NichtEuler
Copy link

Hi,

As there is no definitive answer: How can I turn my UaNodeset.xml in a ModelDesign.xml without using a modeldesigner?
Is there a way to extract a ModelDesign.xml from my server (https://github.com/OPCFoundation/UA-.NETStandard)?
Would be really awesome to be able to create your own Modeldesigns without buying those modeldesigners.

@mpostol
Copy link
Contributor

mpostol commented Dec 17, 2018

@NichtEuler I understand your point, but the question is how to compensate for the development effort. It is possible and easy to expand the project:

https://github.com/mpostol/OPC-UA-OOI/tree/master/SemanticData

and add the converter code I have in my commercial product, but the question is about motivation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants