15:08, EEST
June 21, 2016
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
16:00, EEST
April 3, 2012
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
16:54, EEST
April 3, 2012
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).
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
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
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: 737
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerleyModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1