Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
codegen EUROMAP 82.1
December 28, 2021
16:49, EET
Avatar
Francesco Zambon
Member
Members
Forum Posts: 83
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

Hello,

I am trying to create a temperature control device (TCD EUROMAP 82.1).

But the classes generated by codegen not being compiled correctly.
start examples ————————————————————————————
/test1/src/com/prosysopc/ua/types/euromap83/server/DrivesTypeNodeBase.java
The return type is incompatible with BaseNode.getNodeVersion()

/test1/src/com/prosysopc/ua/types/euromap83/client/MouldTypeImplBase.java
The return type is incompatible with UaNodeImpl.getDescription()

/test1/src/com/prosysopc/ua/types/euromap83/VariableIds.java
Duplicate field VariableIds.TemperatureZoneCycleParametersType_ActualTemperature_EngineeringUnits

The return types are incompatible for the inherited methods UaNode.getNodeVersion(), ExternalChannelsTypeNodeBase.getNodeVersion()
/test1/src/com/prosysopc/ua/types/euromap82_1/server/ExternalChannelsTypeNode.java
end examples ————————————————————————————

I used the codegen tool.
Version:
prosys-opc-ua-sdk-for-java-4.6.2-1636-evaluation
Command:

.\bin\codegen.bat -c.\configexamples\TCD.xml

start TCD.xml ————————————————————————–

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<codegenConfiguration>

<namespaceMappings>
<namespaceMapping>
<uri>http:// opcfoundation.org/UA/PlasticsRubber/TCD/</uri>
<packageName>com.prosysopc.ua.types.euromap82_1</packageName>
</namespaceMapping>
<namespaceMapping>
<uri>http:// opcfoundation.org/UA/PlasticsRubber/GeneralTypes/</uri>
<packageName>com.prosysopc.ua.types.euromap83</packageName>
</namespaceMapping>
<namespaceMapping>
<uri>http:// opcfoundation.org/UA/DI/</uri>
<packageName>com.prosysopc.ua.types.di</packageName>
</namespaceMapping>
</namespaceMappings>

<modelSources>
<modelSource>${app.home}/models</modelSource>
</modelSources>

<generates>
<generate>
<targets>all</targets>
<uris>
<!–uri>http:// opcfoundation.org/UA/PlasticsRubber/TCD/</uri–>
<!–uri>http:// opcfoundation.org/UA/PlasticsRubber/GeneralTypes/</uri–>
<!–uri>http:// opcfoundation.org/UA/DI/</uri–>
</uris>
<outputs>
<!–code>${app.home}/OUTPUT/output_code</code–>
<resources>${app.home}/OUTPUT/output_resources</resources>
</outputs>
</generate>
</generates>
</codegenConfiguration>

end TCD.xml ————————————————————————–

information models:

EUROMAP 82.1 DOC:
https://www.euromap.org/euromap82-1

Could you help me, please?

Thanks,
Francesco

December 28, 2021
17:09, EET
Avatar
Francesco Zambon
Member
Members
Forum Posts: 83
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

UPDATE
formatted text

December 29, 2021
14:38, EET
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, unfortunately some of the names in these models clash with similar names in the base objects. The recommended solution at the moment is to rename the generated methods manually after the code generation. I hope that we will find a more suitable solution to this in future.

Please, take a look at https://www.prosysopc.com/blog/nodeset-file-importing/ – it explains the currently known problems and describes some ways to overcome them.

The Euromap (Plastics & Rubber Machines) specific problems are listed here:

https://www.prosysopc.com/blog/nodeset-file-importing/#plastics-and-rubber-machinery

January 3, 2022
13:38, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Assuming the clash is with a node that is not a Method (NodeClass Method I mean) node, preferably I would exclude it from the generation rather than rename the generated method (either will work, but subtyping might require you to do that in more places etc. and can be complicated). This is explained in the Codegen manual, section “4.5.4. Excluding sub-nodes under a Type node from generation”.

For example, the NodeVersion can be exclude via:

<configuration>

<excludes>
<instanceDeclarations>
<instanceDeclaration>SEE BELOW</instanceDeclaration>
</instanceDeclarations>
</excludes>
</configuration>

(and in the SEE BELOW use “http://opcfoundation.org/UA/:NodeVersion” without quotes…. we should really update this to have better formatting options……)

Note that “the node is still there” in the address space, this just removes the generated accessors (get/set/nodeget) methods from the output. They can be found “manually” via UaNode.getComponent/getProperty etc. And for the NodeVersion it also happens to be that the core SDK API already has a method (from before we had a Codegen) to receive it (hence the clash).

Note that for Method nodes it would also remove the server side stubs for that method and the routing logic to that stub. Technically an implementation could be plugged via listeners (see MyMethodManagerListener in sampleconsoleserver), though that is a bit more complicated way than the generated stub (or the interface generated for the Method which can be plugged via the static methods of the generated XXXTypeNode). So if the clash is between a Method node and another node in the model, exclude the other node. If the clash is between SDK’s own methods then no can do and the “manual” way must be done.

P.S.
Personally I say to a degree that naming a node “Description” is sort of a modelling error, since OPC UA has already an Attribute named Description. Though, that is hard to change for the companion models or well, any model that you do not control.

Some of the newer SDK’s API methods, such as e.g. Structure.specification() etc. intentionally do not use get/set conventions to make that “space” suitable for generation (if some day a Structure would have a field name Specification for example). But most of the methods are from an era before we had a codegen, so they will clash.

Also, the generated output doesn’t have the UA namespace in the methods, thus a subnode with same BrowseName name part, but different index would clash. So far we have not had good ways to use it there (but these clashes have been luckily rare).

January 11, 2022
15:51, EET
Avatar
Francesco Zambon
Member
Members
Forum Posts: 83
Member Since:
December 20, 2021
sp_UserOfflineSmall Offline

Hello and thank you all for your support,

I generated the classes using the following configuration:

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
<codegenConfiguration>

 <namespaceMappings>
  <namespaceMapping>
   <uri>http://opcfoundation.org/UA/PlasticsRubber/TCD/</uri>
   <packageName>com.prosysopc.ua.types.tcd</packageName>
  </namespaceMapping>
  <namespaceMapping>
   <uri>http://opcfoundation.org/UA/PlasticsRubber/GeneralTypes/</uri>
   <packageName>com.prosysopc.ua.types.generaltypes</packageName>
  </namespaceMapping>
  <namespaceMapping>
   <uri>http://opcfoundation.org/UA/DI/</uri>
   <packageName>com.prosysopc.ua.types.di</packageName>
  </namespaceMapping>
  
  
 </namespaceMappings>

 <modelSources>
  <modelSource>${app.home}/euromap82_1/models</modelSource>
 </modelSources>

 <generates>
  <generate>
   <targets>all</targets>
   <uris>
    <uri>http://opcfoundation.org/UA/PlasticsRubber/TCD/</uri>
    <uri>http://opcfoundation.org/UA/PlasticsRubber/GeneralTypes/</uri>
    <uri>http://opcfoundation.org/UA/DI/</uri>
   </uris>
   <outputs>
    …
   </outputs>
  </generate>
 </generates>

 <enhancements>
  <fileHeader>
   <line>Generated from EUROMAP 82.1</line>
   <line>by Prosys OPC UA Java SDK Codegen</line>
  </fileHeader>
 </enhancements>

 <!– WORKAROUND –>
 <excludes>
  <instanceDeclarations>
   <instanceDeclaration>http://opcfoundation.org/UA/:NodeVersion</instanceDeclaration>
   <instanceDeclaration>http://opcfoundation.org/UA/PlasticsRubber/GeneralTypes/:Components</instanceDeclaration>
   <instanceDeclaration>http://opcfoundation.org/UA/PlasticsRubber/GeneralTypes/:Description</instanceDeclaration>
  </instanceDeclarations>
 </excludes>
</codegenConfiguration>

and then I created some TCD instances:

package project1;

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import com.prosysopc.ua.ApplicationIdentity;
import com.prosysopc.ua.ModelException;
import com.prosysopc.ua.SecureIdentityException;
import com.prosysopc.ua.StatusException;
import com.prosysopc.ua.UaApplication.Protocol;
import com.prosysopc.ua.UserTokenPolicies;
import com.prosysopc.ua.nodes.UaInstance;
import com.prosysopc.ua.nodes.UaNode;
import com.prosysopc.ua.server.NodeBuilderException;
import com.prosysopc.ua.server.NodeManagerUaNode;
import com.prosysopc.ua.server.ServiceContext;
import com.prosysopc.ua.server.UaServer;
import com.prosysopc.ua.server.UaServerException;
import com.prosysopc.ua.server.instantiation.NodeBuilder;
import com.prosysopc.ua.server.instantiation.NodeBuilderConfiguration;
import com.prosysopc.ua.stack.builtintypes.ExpandedNodeId;
import com.prosysopc.ua.stack.builtintypes.LocalizedText;
import com.prosysopc.ua.stack.builtintypes.NodeId;
import com.prosysopc.ua.stack.cert.PkiDirectoryCertificateStore;
import com.prosysopc.ua.stack.core.ApplicationDescription;
import com.prosysopc.ua.stack.core.ApplicationType;
import com.prosysopc.ua.stack.core.Identifiers;
import com.prosysopc.ua.stack.transport.security.SecurityMode;
import com.prosysopc.ua.types.tcd.server.OperationTypeNode;
import com.prosysopc.ua.types.tcd.server.OperationTypeNodeBase;
import com.prosysopc.ua.types.tcd.server.OperationTypeSwitchOnMethod;
import com.prosysopc.ua.types.tcd.server.TCD_InterfaceTypeNode;

public class Main {

private static Logger logger = LoggerFactory.getLogger(Main.class);

public static void main(String[] args) throws UaServerException, SecureIdentityException, IOException, SAXException,
ModelException, URISyntaxException, StatusException, NodeBuilderException {

// ———————————————————————
// create server
logger.info("create server…");
UaServer server = new UaServer();

// ———————————————————————
// protocol
logger.info("protocol…");
server.setPort(Protocol.OpcTcp, 4040);
server.setServerName("OPCUA/SimpleServer");

// ———————————————————————
// security
logger.info("security…");
server.getSecurityModes().add(SecurityMode.NONE);
server.addUserTokenPolicy(UserTokenPolicies.ANONYMOUS);

// ———————————————————————
// identity
logger.info("identity…");
String applicationName = "SimpleServer";
ApplicationDescription appDescription = new ApplicationDescription();
appDescription.setApplicationName(new LocalizedText(applicationName + "@hostname"));
appDescription.setApplicationUri("urn:hostname:OPCUA:" + applicationName);
appDescription.setProductUri("urn:prosysopc.com:OPCUA:" + applicationName);
appDescription.setApplicationType(ApplicationType.Server);

final PkiDirectoryCertificateStore applicationCertificateStore = new PkiDirectoryCertificateStore("PKI/CA");
File privatePath = new File(applicationCertificateStore.getBaseDir(), "private");
int[] keySizes = new int[] { 2048 };
final ApplicationIdentity identity = ApplicationIdentity.loadOrCreateCertificate( //
appDescription, //
"Sample Organisation", //
"opcua", //
privatePath, //
null, //
keySizes, //
true);

server.setApplicationIdentity(identity);

// ———————————————————————
// init
logger.info("init…");
server.init();

// ———————————————————————
// address space
logger.info("address space…");

// ———————————————————————
// Register generated classes
// server.registerModel(com.prosysopc.ua.types.opcua.server.ServerInformationModel.MODEL);

// Automatic Discovery of Generated Models
// /project1/src/META-INF/services/com.prosysopc.ua.server.ServerCodegenModelProvider

// server.registerModel(com.prosysopc.ua.types.di.server.ServerInformationModel.MODEL);
// server.registerModel(com.prosysopc.ua.types.generaltypes.server.ServerInformationModel.MODEL);
// server.registerModel(com.prosysopc.ua.types.tcd.server.ServerInformationModel.MODEL);

// ———————————————————————
// Load the information model
// name space index 2
// uri http://opcfoundation.org/UA/DI/
String informatioModel = "/com/prosysopc/ua/types/di/server/Opc.Ua.Di.NodeSet2.xml";
URI informatioModelURI = Main.class.getResource(informatioModel).toURI();
System.out.println("loading model " + informatioModelURI + "…");
server.getAddressSpace().loadModel(informatioModelURI);

// name space index 3
// uri http://opcfoundation.org/UA/PlasticsRubber/GeneralTypes/
informatioModel = "/com/prosysopc/ua/types/generaltypes/server/Opc.Ua.PlasticsRubber.GeneralTypes.NodeSet2.xml";
informatioModelURI = Main.class.getResource(informatioModel).toURI();
System.out.println("loading model " + informatioModelURI + "…");
server.getAddressSpace().loadModel(informatioModelURI);

// name space index 4
// uri http://opcfoundation.org/UA/PlasticsRubber/TCD/
informatioModel = "/com/prosysopc/ua/types/tcd/server/Opc.Ua.PlasticsRubber.TCD.NodeSet2.xml";
informatioModelURI = Main.class.getResource(informatioModel).toURI();
System.out.println("loading model " + informatioModelURI + "…");
server.getAddressSpace().loadModel(informatioModelURI);

// ———————————————————————
// create TCD by generated classes
NodeManagerUaNode nodeManager = ((NodeManagerUaNode) server.getAddressSpace().getNodeManager(4));

NodeBuilderConfiguration conf = new NodeBuilderConfiguration();
ExpandedNodeId expNodeId = com.prosysopc.ua.types.tcd.Ids.TCD_InterfaceType_DeviceZone_ActualProcessPower;
conf.addOptional(expNodeId);
expNodeId = com.prosysopc.ua.types.tcd.Ids.TCD_InterfaceType_DeviceZone_ActualProcessPower_EngineeringUnits;
conf.addOptional(expNodeId);

NodeBuilder<TCD_InterfaceTypeNode> nodeBuilder = //
nodeManager.createNodeBuilder(TCD_InterfaceTypeNode.class, conf);
nodeBuilder.setName("TCD_man1_sn1");

TCD_InterfaceTypeNode tcd = nodeBuilder.build();

tcd.getDeviceZoneNode().setActualProcessPower(12.3);

// UaNode deviceSet = nodeManager.getNode(new NodeId(2, 5001));
int index = server.getAddressSpace().getNodeManager("http://opcfoundation.org/UA/DI/&quot;).getNamespaceIndex();
UaNode deviceSet = nodeManager.getNode(new NodeId(index, 5001));

deviceSet.addReference(tcd, Identifiers.Organizes, false);

// ———————————————————————
// methods
OperationTypeNodeBase.setSwitchOnMethodImplementation(new OperationTypeSwitchOnMethod() {

@Override
public void switchOn(ServiceContext serviceContext, OperationTypeNode node) throws StatusException {
logger.info("switchOn node: " + node);
}
});

// ———————————————————————
// create TCD by information model

NodeBuilder<UaInstance> nodeBuilder2 = nodeManager.createNodeBuilder(new NodeId(4, 1012), conf);
nodeBuilder2.setName("TCD_man1_sn2");
UaInstance tcd2 = nodeBuilder2.build();

deviceSet.addReference(tcd2, Identifiers.Organizes, false);

// ———————————————————————
// start
logger.info("start…");
server.start();

}

}

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 728

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

ellis87832073466, zkxwilliemae, gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0

Administrators: admin: 1