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
Writing to SDK standard types
June 21, 2016
15:08, EEST
Avatar
matthias
New Member
Members
Forum Posts: 1
Member Since:
June 21, 2016
sp_UserOfflineSmall Offline

Hi everyone,

I am trying to make some of the Attributes of the LimitAlarmType writable but I am struggling in doing so.
Here is what I am doing so far:

UaInstance newNode=nodeManager.createInstance(Identifiers.ExclusiveLimitAlarmType,name); // TypeId beeing ExclusiveLimitAlarmType for example
LimitAlarmType limit=(LimitAlarmType) newNode;
limit.getLowLimitNode().setAccessLevel(AccessLevel.READWRITE);

As expected, the Attribute is shown as Read/Write in UaExpert, but if I attempt to write I see the following error message in the console:

ERROR [Blocking-Work-Executor-39] com.prosysopc.ua.server.nodes.InstanceVariable – Cannot write attribute 13

Is there any trick I need to know to make this attribute (and others) writable?

Your help is greatly appreciated.

Best regards

Matthias

June 21, 2016
16:00, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

This is a known issue. With current roadmap it will be fixed for 2.3.0.

The issue is that UaNodes that are based on InstanceVariable do not currently allow writing Attributes from the client side. InstanceVariable and subclasses are a lightweight implementation that keeps own AccessLevel field, Value via field (or callback/reflection depeding on subclass) and refers other Attributes from an InstanceDeclaration node that is part of a TypeDefinition. They are used mainly for keeping memory usage of EventType (that have huge number of Properties) instances low. After this is fixed it should allow writing to the Value field.

Options are
1. Wait for 2.3
2. Send mail to uajava-support@prosysopc.com to try beta where this is fixed (not yet done, but doesn’t look that hard)
3. Try workaround that uses “full” UaNode implementations (takes a bit time to explain, will do so in follow-up post)

– Bjarne

June 21, 2016
16:54, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

For the workaround you could configure that normal (“full”) UaNode implementations should be used instead of the instance ones. To do this, you need to create a UaNodeBuilderConfiguration (by default NodeManagerUaNode uses the DefaultNodeBuilderConfiguration).

package com.prosysopc.ua.samples.server;

import org.opcfoundation.ua.core.Identifiers;

import com.prosysopc.ua.server.DefaultInstantiationStrategy;
import com.prosysopc.ua.server.DefaultNodeBuilderConfiguration;
import com.prosysopc.ua.server.InstantiationStrategy;
import com.prosysopc.ua.server.JoinedNodeBuilderConfiguration;
import com.prosysopc.ua.server.NodeBuilderConfiguration;
import com.prosysopc.ua.server.UaNodeBuilderConfiguration;

public class AlarmFullPropertyConfiguration implements UaNodeBuilderConfiguration {

private static class Helper extends NodeBuilderConfiguration {

public Helper() {
setInstantiationStrategy(Identifiers.LimitAlarmType_LowLowLimit, new DefaultInstantiationStrategy());
setInstantiationStrategy(Identifiers.LimitAlarmType_LowLimit, new DefaultInstantiationStrategy());
setInstantiationStrategy(Identifiers.LimitAlarmType_HighLimit, new DefaultInstantiationStrategy());
setInstantiationStrategy(Identifiers.LimitAlarmType_HighHighLimit, new DefaultInstantiationStrategy());
}
}

private final UaNodeBuilderConfiguration delegate;

public AlarmFullPropertyConfiguration() {
delegate = new JoinedNodeBuilderConfiguration(new Helper(), new DefaultNodeBuilderConfiguration());
}

@Override
public InstantiationStrategy getInstantiationStrategy(InstantiationStrategySearchParameters parameters) {
return delegate.getInstantiationStrategy(parameters);
}

}

Call NodeManagerUaNode.setNodeBuilderConfiguration before calling createInstance (call again with (new DefaultNodeBuilderConfiguration()) to reset)

The default logic is contained in DefaultNodeBuilderConfiguration. We want to override that (the class is final, not sure if it was the best decision back then..), so we create a new implementation (called Helper here), and create a JoinedNodeBuilderConfiguration with our overrides from the Helper class (they are searched in order given in the constructor) and uses the default one when there is no override. To keep this example as one class solution delegate pattern is used to contain everything inside the AlarmFullPropertyConfiguration class.

The overrides

setInstantiationStrategy(Identifiers.LimitAlarmType_LowLowLimit, new DefaultInstantiationStrategy());

return the instantiation logic back to the default (i.e. full nodes are created if nothing is specified, the DefaultNodeBuilderConfiguration overrides some of those).

Please ask if there is something unclear (we have plans to improve the documentation in this area for the 2.3 release)

– Bjarne

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
21 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: 730

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1529

Posts: 6471

Newest Members:

PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466, zkxwilliemae, gabriellabachus

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

Administrators: admin: 1