ModelCompiler BaseType reference not valid|OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
ModelCompiler BaseType reference not valid
Avatar
John Cockrell
Member
Members
Forum Posts: 8
Member Since:
12/16/2020
sp_UserOfflineSmall Offline
1
08/06/2024 - 02:21
sp_Permalink sp_Print sp_EditHistory

Hi 

I am getting this error when compiling my model

“The BaseType reference for node MineSpectrometerType is not valid: AnalyserDeviceType.”

Can you tell me what is wrong please?

 
<?xml version=”1.0″ encoding=”utf-8″?>
<opc:ModelDesign
  xmlns:uax=”https://opcfoundation.org/UA/2008/02/Types.xsd”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:OpcUa=”https://opcfoundation.org/UA/”
xmlns:DI=”https://opcfoundation.org/UA/DI/”
xmlns:ADI=”https://opcfoundation.org/UA/ADI/”
xmlns:RXI=”http://mine.com/UA/RXI/”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
xmlns:opc=”https://opcfoundation.org/UA/ModelDesign.xsd”
TargetNamespace=”http://mine.com/UA/RXI/”
TargetXmlNamespace=”http://mine.com/UA/RXI/”
xmlns=”http://mine.com/UA/RXI/”
xmlns:ua=”https://opcfoundation.org/UA/”
TargetPublicationDate=”2021-02-12T00:00:00Z”>
 
<opc:Namespaces>
<opc:Namespace Name=”MineUaRxi” Prefix=”Mine.Ua.Rxi” XmlNamespace=”http://mine.com/UA/RXI/Types.xsd” XmlPrefix=”RXI”>http://mine.com/UA/RXI/</op…..ce&gt;
<opc:Namespace Name=”OpcUaAdi” Prefix=”Opc.Ua.Adi” XmlNamespace=”https://opcfoundation.org/UA/ADI/Types.xsd” XmlPrefix=”ADI” FilePath=”C:\code\opc\UA-Nodeset\ADI\OpcUaAdiModel” >https://opcfoundation.org/UA/AD…..ce&gt;
<opc:Namespace Name=”OpcUaDi” Prefix=”Opc.Ua.Di” XmlNamespace=”https://opcfoundation.org/UA/DI/Types.xsd” XmlPrefix=”DI” FilePath=”C:\code\opc\UA-Nodeset\DI\OpcUaDiModel” >https://opcfoundation.org/UA/DI…..ce&gt;
<opc:Namespace Name=”OpcUa” Prefix=”Opc.Ua” Version=”1.05″ PublicationDate=”2021-09-15T00:00:00Z” InternalPrefix=”Opc.Ua.Server” XmlNamespace=”https://opcfoundation.org/UA/2008/02/Types.xsd” XmlPrefix=”OpcUa”>https://opcfoundation.org/UA/&l…..ce&gt;
</opc:Namespaces>
  
  <opc:ObjectType SymbolicName=”RXI:MineSpectrometerType” BaseType=”ADI:AnalyserDeviceType”>
  <opc:Description>My Analyser</opc:Description>
    <opc:Children>
      <opc:Variable SymbolicName=”X” DataType=”ua:Int32″ ValueRank=”OneOrMoreDimensions” ArrayDimensions=”0,0″ ModellingRule=”Optional”/>
    </opc:Children>
  </opc:ObjectType>
 
</opc:ModelDesign>

 

 
 
 
 
 
My steps are:

Mode LastWriteTime Length Name
—- ————- —— —-
-a—- 06/08/2024 09:53 1988 model.xml
-a—- 06/08/2024 09:31 265578 Opc.Ua.Adi.Classes.cs
-a—- 06/08/2024 09:31 1267478 Opc.Ua.Adi.Constants.cs
-a—- 06/08/2024 09:31 14348 Opc.Ua.Adi.DataTypes.cs
-a—- 06/08/2024 09:31 452428 Opc.Ua.Adi.NodeSet2.xml
-a—- 06/08/2024 09:31 68410 Opc.Ua.Adi.PredefinedNodes.uanodes
-a—- 06/08/2024 09:31 899502 Opc.Ua.Adi.PredefinedNodes.xml
-a—- 06/08/2024 09:31 3657 Opc.Ua.Adi.Types.bsd
-a—- 06/08/2024 09:31 4857 Opc.Ua.Adi.Types.xsd
-a—- 06/08/2024 09:31 22529 Opc.Ua.Di.NodeIds.csv
-a—- 06/08/2024 09:31 7315 Opc.Ua.DI.NodeSet2.documentation.csv
-a—- 06/08/2024 09:31 285821 Opc.Ua.Di.NodeSet2.xml
-a—- 06/08/2024 09:31 4091 Opc.Ua.Di.Types.bsd
-a—- 06/08/2024 09:31 7348 Opc.Ua.Di.Types.xsd
-a—- 06/08/2024 09:31 323429 OpcUaAdiModel.csv
-a—- 06/08/2024 09:31 192129 OpcUaAdiModel.xml

  • docker run -v ${pwd}:/data –rm ghcr.io/opcfoundation/ua-modelcompiler:latest compile -d2 /data/Opc.Ua.Di.NodeSet2.xml,Opc.Ua.DI,DI -o2 /data/generated
  • docker run -v ${pwd}:/data –rm ghcr.io/opcfoundation/ua-modelcompiler:latest compile -d2 /data/model.xml -d2 /data/OpcUaAdiModel.xml -d2 /data/Opc.Ua.Di.NodeSet2.xml,Opc.Ua.DI,DI -o2 /data/generated

Version: 2.3.0.0
FileVersion: 2.3.2301.0846
Opc.Ua.Core: Opc.Ua.Core, Version=1.5.371.0, Culture=neutral, PublicKeyToken=bfa7a73c5cf4b6e8
[InvalidOperationException] The BaseType reference for node MineSpectrometerType is not valid: AnalyserDeviceType.

========================
at ModelCompiler.ModelCompilerValidator.FindNode(XmlQualifiedName symbolicId, Type requiredType, String sourceName, String referenceName) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 3701
at ModelCompiler.ModelCompilerValidator.ImportType(TypeDesign type) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 2701
at ModelCompiler.ModelCompilerValidator.Import(ModelDesign model, NodeDesign node, NodeDesign parent) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 2416
at ModelCompiler.ModelCompilerValidator.LoadModelDesign(String designFilePath, String identifierFilePath, Boolean generateIds) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 208
at ModelCompiler.ModelCompilerValidator.LoadDesignFile(List`1 namespaces, String designFilePath, String identifierFilePath, Boolean generateIds) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 1001
at ModelCompiler.ModelCompilerValidator.ValidateModel(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 1326
at ModelCompiler.ModelCompilerValidator.Validate(IList`1 designFilePaths, String identifierFilePath, Boolean generateIds) in /source/Opc.Ua.ModelCompiler/ModelDesignerValidator.cs:line 1024
at ModelCompiler.ModelGenerator2.ValidateAndUpdateIds(IList`1 designFilePaths, String identifierFilePath, UInt32 startId, String specificationVersion, Boolean useAllowSubtypes, IList`1 exclusions, String modelVersion, String modelPublicationDate, Boolean
releaseCandidate, Boolean extractIdentifiers) in /source/Opc.Ua.ModelCompiler/ModelGenerator2.cs:line 125
at ModelCompiler.ModelCompilerApplication.<>c__DisplayClass13_0.b__0() in /source/Opc.Ua.ModelCompiler/ModelCompilerApplication.cs:line 460
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at ModelCompiler.ModelCompilerApplication.Run(String[] args) in /source/Opc.Ua.ModelCompiler/ModelCompilerApplication.cs:line 31
at Program.

$(String[] args) in /source/Opc.Ua.ModelCompiler/Program.cs:line 24

 

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
08/08/2024 - 02:32
sp_Permalink sp_Print

I don’t see a definition for MineSpectrometerType. Where is it defined?

Avatar
John Cockrell
Member
Members
Forum Posts: 8
Member Since:
12/16/2020
sp_UserOfflineSmall Offline
3
08/09/2024 - 00:42
sp_Permalink sp_Print sp_EditHistory

Code seems to get mangled when I edit the post, I’ve fixed it. This is the line with the type.

 

I might have made progress, adding DI as a nodeset with namespace to the build command:

docker run -v ${pwd}:/data –rm ghcr.io/opcfoundation/ua-modelcompiler:latest compile -d2 /data/Model.xml -d2 /data/OpcUaAdiModel.xml -d2 /data/Opc.Ua.Di.NodeSet2.xml,Opc.Ua.DI,DI -cg AgilentUaTRSModel.csv -o2 /data/generated

This generates the C# classes, but then the generated classes won’t compile because the dependencies don’t seem to have the requires classes. For example, ADI requires DeviceState here

public partial class AnalyserDeviceState : DeviceState

Which is in UAModel.DI.NodeSet2.xml but not in any C# classes, the the above line doesn’t compile. If I generate the DI classes, they don’t have DeviceState. Adding opcfoundation.netstandard.opc.ua.core 1.5.374.78 doesn’t help. FunctionalGroupState is another I haven’t got. Do you know how I can get these .net dependencies for my generated C# classes? Thanks for any help.

Avatar
John Cockrell
Member
Members
Forum Posts: 8
Member Since:
12/16/2020
sp_UserOfflineSmall Offline
4
08/09/2024 - 08:07
sp_Permalink sp_Print sp_EditHistory

Creating my mode using ADI as a nodeset instead of using OpcUaAdiModel seemed to help. i.e. running 

docker run -v ${pwd}:/data –rm ghcr.io/opcfoundation/ua-modelcompiler:latest compile -d2 /data/model.xml -d2 /data/Opc.Ua.Adi.NodeSet2.xml,Opc.Ua.Adi,Adi -d2 /data/Opc.Ua.Di.NodeSet2.xml,Opc.Ua.DI,DI -cg model.csv -o2 /data/generated

I also had to update some types in my own partial classes e.g. AnalyserDeviceState to AnalyserDeviceTypeState

I am now having the same issue as this guy e.g. state machine states are null instead of powerup. Do you know why that would be?

opcfoundation.org/forum/opc-ua-implementation-stacks-tools-and-samples/adi-implementation-with-working-statemachine/

Thanks for any help.

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
5
08/11/2024 - 21:12
sp_Permalink sp_Print

What nodes are calling Machine states?

CurrentState Variable?

The State Objects do not appear on instances.

Avatar
John Cockrell
Member
Members
Forum Posts: 8
Member Since:
12/16/2020
sp_UserOfflineSmall Offline
6
08/15/2024 - 01:09
sp_Permalink sp_Print

I am looking at DeviceSet->SpectrometerDevice->AnalyserStateMachine->CurrentState->Value through the Sample Client node browser, where I would expect it to be at powerup. 

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
7
08/15/2024 - 01:35
sp_Permalink sp_Print

If you are expecting the ModelCompiler to instantiate the entire instance tree in the NodeSet then you may need to explicitly define the hierarchy you want to see in the Design file.

For an example look at the Server Object:

https://github.com/OPCFoundati…..dTypes.xml

<opc:Object SymbolicName=”Server” TypeDefinition=”ServerType” ModellingRule=”None” SupportsEvents=”true” PartNo=”5″ IsDynamic=”true”>

Optional Nodes have their ModellingRule changed to Mandatory with tells the tool to generate the Node.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online: Rafael Silva_1
Guest(s) 20
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4890