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
Override standard Server node
October 5, 2021
17:38, EEST
Avatar
Xavier
Member
Members
Forum Posts: 43
Member Since:
March 26, 2014
sp_UserOfflineSmall Offline

Hi,

I would like to change the standard ServerRedundancy node (ServerRedundancyType type) of the Server Object with the NonTransparentRedundancyType type, but I cannot find a way to do it. Can you tell me how to do it?

Thanks

October 6, 2021
11:48, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

While not pretty, this should work. It would seem we have some sort of bug in deleteNode that it didn’t work as intended, thus this deletion is one-by-one instead of just removing the ServerRedundancy node.Also it would seem the base nodeset does contain all the Properties of ALL possible redundancy types, thus they are all deleted.

It is important that the nodes are made back with the same exact NodeIds, as they are fixed in the base information model and could be used by clients to read the info directly. Thus this required some extra steps.

Also, the UaServer.init must have been called before this code.

    NodeManagerRoot nm = server.getNodeManagerRoot();

    // Deleting the old nodes
    nm.deleteNode(Identifiers.Server_ServerRedundancy, true, false);
    nm.deleteNode(Identifiers.Server_ServerRedundancy_CurrentServerId, true, false);
    nm.deleteNode(Identifiers.Server_ServerRedundancy_RedundancySupport, true, false);
    nm.deleteNode(Identifiers.Server_ServerRedundancy_RedundantServerArray, true, false);
    nm.deleteNode(Identifiers.Server_ServerRedundancy_ServerNetworkGroups, true, false);
    nm.deleteNode(Identifiers.Server_ServerRedundancy_ServerUriArray, true, false);


    assertNull(nm.findNode(Identifiers.Server_ServerRedundancy));
    assertNull(nm.findNode(Identifiers.Server_ServerRedundancy_CurrentServerId));
    assertNull(nm.findNode(Identifiers.Server_ServerRedundancy_RedundancySupport));
    assertNull(nm.findNode(Identifiers.Server_ServerRedundancy_RedundantServerArray));
    assertNull(nm.findNode(Identifiers.Server_ServerRedundancy_ServerNetworkGroups));
    assertNull(nm.findNode(Identifiers.Server_ServerRedundancy_ServerUriArray));

    // Creating replacement nodes
    UaNodeBuilderConfiguration delegateConf = nm.getNodeBuilderConfiguration();
    UaNodeBuilderConfiguration conf = new JoinedNodeBuilderConfiguration(parameters -> {
      String name = parameters.getInstanceDeclaration().getNode().getBrowseName().getName();
      if (name.equals("ServerUriArray")) {
        return new DefaultInstantiationStrategy() {
          @Override
          public UaNode createInstance(InstantiationParameters params) {
            return params.getNodeManager().getNodeFactory().createNode(NodeClass.Variable,
                Identifiers.Server_ServerRedundancy_ServerUriArray, params.getBrowseName(), params.getDisplayName(),
                Identifiers.PropertyType);
          }
        };
      } else if (name.equals("RedundancySupport")) {
        return new DefaultInstantiationStrategy() {
          @Override
          public UaNode createInstance(InstantiationParameters params) {
            return params.getNodeManager().getNodeFactory().createNode(NodeClass.Variable,
                Identifiers.Server_ServerRedundancy_RedundancySupport, params.getBrowseName(), params.getDisplayName(),
                Identifiers.PropertyType);
          }
        };
      }
      return null; // not handled in this conf
    }, delegateConf);

    NodeBuilder nb =
        nm.createNodeBuilder(NonTransparentRedundancyTypeNode.class, conf);
    nb.setName("ServerRedundancy");
    nb.setNodeId(Identifiers.Server_ServerRedundancy);

    NonTransparentRedundancyTypeNode redundancyNode = nb.build();
    ServerTypeNode serverNode = nm.getServerData();
    serverNode.addComponent(redundancyNode);

    assertEquals(Identifiers.Server_ServerRedundancy, redundancyNode.getNodeId());
    assertEquals(Identifiers.Server_ServerRedundancy_ServerUriArray,
        redundancyNode.getServerUriArrayNode().getNodeId());
    assertEquals(Identifiers.Server_ServerRedundancy_RedundancySupport,
        redundancyNode.getRedundancySupportNode().getNodeId());

October 6, 2021
12:20, EEST
Avatar
Xavier
Member
Members
Forum Posts: 43
Member Since:
March 26, 2014
sp_UserOfflineSmall Offline

Thank you it works well 🙂

October 6, 2021
14:51, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Great!

Hmm … actually it is just that the newer nodeset we have in the SDK (versus Simulation Server’s release version I used to check the address space) has changed so that those extra Properties are no longer below that node (this is good in general), thus the delete didn’t work for them.

Regardless they (the extra properties) are still in the nodeset and also do have incorrect BrowseName to be used as is:

<UAVariable NodeId="i=11312" BrowseName="Server_ServerRedundancy_CurrentServerId" DataType="String">
<DisplayName>Server_ServerRedundancy_CurrentServerId</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="i=11313" BrowseName="Server_ServerRedundancy_RedundantServerArray" DataType="i=853" ValueRank="1" ArrayDimensions="0">
<DisplayName>Server_ServerRedundancy_RedundantServerArray</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="i=11314" BrowseName="Server_ServerRedundancy_ServerUriArray" DataType="String" ValueRank="1" ArrayDimensions="0">
<DisplayName>Server_ServerRedundancy_ServerUriArray</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>
<UAVariable NodeId="i=14415" BrowseName="Server_ServerRedundancy_ServerNetworkGroups" DataType="i=11944" ValueRank="1" ArrayDimensions="0">
<DisplayName>Server_ServerRedundancy_ServerNetworkGroups</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
</References>
</UAVariable>

i.e. the BrowseName must match to the one defined in the TypeDefinition (i.e. the “Server_ServerRedundancy_” prefix is wrong), since they would be part of the larger type (OR I’m not 100% sure anymore are these the Ids to use for these nodes, or maybe this is just a mistake in the nodeset).

Doesn’t change that what I said will work, but mainly why it didn’t work with just “nm.deleteNode(Identifiers.Server_ServerRedundancy, true, true);” I tried first…

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
13 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: 735

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1523

Posts: 6449

Newest Members:

rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16

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

Administrators: admin: 1