10:09, EET
January 27, 2012
I want to extend the OffNormalAlarmType with one of my own. The class looks like this:
private final NodeId MyOwnAlarmTypeId;
private LocalizedText ownVariable;
public MyOwnAlarmType(NodeManagerUaNode nmun, NodeId nodeid, String string, Locale locale) {
super(nmun, nodeid, string, locale);
MyOwnAlarmTypeId = new NodeId(getNodeManager().getNamespaceIndex(), MyNodeManagerImpl.getNextTypeNodeId());
}
public MyOwnAlarmType(NodeManagerUaNode nmun, NodeId nodeid, QualifiedName qn, LocalizedText lt) {
super(nmun, nodeid, qn, lt);
MyOwnAlarmTypeId = new NodeId(getNodeManager().getNamespaceIndex(), MyNodeManagerImpl.getNextTypeNodeId());
}
@Override
protected NodeId getDefaultTypeDefinition() {
return MyOwnAlarmTypeId;
}
@Override
protected void initEventFields() throws SecurityException, NoSuchMethodException, StatusException {
super.initEventFields();
NodeId myOwnVariableId = new NodeId(getNodeManager().getNamespaceIndex(), MyNodeManagerImpl.getNextObjectNodeId());
registerReflectiveInstanceProperty("OwnVariable", myOwnVariableId, MyNodeManager.getOwnVariableType().getNodeId());
}
public LocalizedText getOwnVariable) {
return ownVariable;
}
public void setStatusFunctional(int index) {
LocalizedText[] aStatus = MyNodeManager.getOwnVariableType().getEnumStrings();
this.ownVariable = aStatus[index];
}
}
This Alarm should be part of a class:
private CacheVariable status;
private static MyOwnAlarmType myOwnAlarmType;
public MyStatusObjectNode(NodeManagerUaNode nmun, NodeId nodeid, String string, Locale locale) throws StatusException {
super(nmun, nodeid, string, locale);
initialize();
}
public MyStatusObjectNode(NodeManagerUaNode nmun, NodeId nodeid, QualifiedName qn, LocalizedText lt) throws StatusException {
super(nmun, nodeid, qn, lt);
initialize();
}
private void initialize() throws StatusException {
setTypeDefinition(MyParentNode.getStatusTypeDefinition());
int nsIdx = MyNodeManagerImpl.getNsIdx();
status = new CacheVariable(nodeManager,
new NodeId(nsIdx, MyNodeManagerImpl.getNextVariableNodeId()), "Status", Locale.ENGLISH);
status.setDataType(MyNodeManager.getOwnVariableType());
LocalizedText[] actStatus = MyNodeManager.getOwnVariableType().getEnumStrings();
status.updateValue(actStatus[MyStatusTypeNode.OK]);
addComponent(status);
MyOwnAlarmType = new MyOwnAlarmType(nodeManager,
new NodeId(nsIdx, MyNodeManagerImpl.getNextObjectNodeId()), "MyOwnAlarmType", Locale.ENGLISH);
MyOwnAlarmType.setSource(this);
MyOwnAlarmType.setInput(status);
MyOwnAlarmType.setStatusFunctional(MyStatusTypeNode.ERROR);
MyOwnAlarmType.setEnabled(true);
addComponent(MyOwnAlarmType);
}
}
When the constructor of class MyOwnAlarmType is called, the super constructor is called and raises a NullPointerException. What have I done wrong?
Thanks for any help.
Exception in thread “main” java.lang.NullPointerException
at com.prosysopc.ua.server.nodes.UaInstanceNode.registerOverridePlainMethod(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.ConditionType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AcknowledgeableConditionType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AlarmConditionType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.OffNormalAlarmType.initEventFields(Unknown Source)
at abc.opcuaserver.events.MyOwnAlarmType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.BaseEventType.a(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.BaseEventType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.ConditionType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AcknowledgeableConditionType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AlarmConditionType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.DiscreteAlarmType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.OffNormalAlarmType.(Unknown Source)
at abc.opcuaserver.events.MyOwnAlarmType.(Unknown Source)
11:22, EET
December 21, 2011
fred said
…
public MyOwnAlarmType(NodeManagerUaNode nmun, NodeId nodeid, String string, Locale locale) {
super(nmun, nodeid, string, locale);MyOwnAlarmTypeId = new NodeId(getNodeManager().getNamespaceIndex(), MyNodeManagerImpl.getNextTypeNodeId());
}public MyOwnAlarmType(NodeManagerUaNode nmun, NodeId nodeid, QualifiedName qn, LocalizedText lt) {
super(nmun, nodeid, qn, lt);MyOwnAlarmTypeId = new NodeId(getNodeManager().getNamespaceIndex(), MyNodeManagerImpl.getNextTypeNodeId());
}@Override
protected NodeId getDefaultTypeDefinition() {
return MyOwnAlarmTypeId;
}@Override
protected void initEventFields() throws SecurityException, NoSuchMethodException, StatusException {
super.initEventFields();NodeId myOwnVariableId = new NodeId(getNodeManager().getNamespaceIndex(), MyNodeManagerImpl.getNextObjectNodeId());
registerReflectiveInstanceProperty("OwnVariable", myOwnVariableId, MyNodeManager.getOwnVariableType().getNodeId());
}…
When the constructor of class MyOwnAlarmType is called, the super constructor is called and raises a NullPointerException. What have I done wrong?
Thanks for any help.
Exception in thread “main” java.lang.NullPointerException
at com.prosysopc.ua.server.nodes.UaInstanceNode.registerOverridePlainMethod(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.ConditionType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AcknowledgeableConditionType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AlarmConditionType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.OffNormalAlarmType.initEventFields(Unknown Source)
at abc.opcuaserver.events.MyOwnAlarmType.initEventFields(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.BaseEventType.a(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.BaseEventType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.ConditionType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AcknowledgeableConditionType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.AlarmConditionType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.DiscreteAlarmType.(Unknown Source)
at com.prosysopc.ua.server.nodes.opcua.OffNormalAlarmType.(Unknown Source)
at abc.opcuaserver.events.MyOwnAlarmType.(Unknown Source)
The base constructor is trying to assign the TypeDefinitionId, but MyOwnAlarmTypeId is not initialized yet at this point, so getDefaultTypeDefinition() returns null. I suggest that you initialize it in getDefaultTypeDefinition() , if it is not done yet.
11:35, EET
January 27, 2012
Thank you this solved this issue.
However, now another exception is raised: Exception in thread “main” java.lang.RuntimeException: ExternalNode does not support getBrowseName()
Is it raised because the type of my ReflectiveInstanceProperty has no getBrowseName() method implemented?
This type extends UaDataTypeNode.
13:18, EET
December 21, 2011
7:57, EET
January 27, 2012
Jouni Aro said
It might be. ExternalNode is used (internally) for nodes that are referred, but which are not found from the address space.
Have you added your OwnDataType to the noed manager already?
I have changed the reflectiveInstanceProperty to be of boolean type, but with the same effect. The error itself is raised from super.initEvents(), thus before creating my instance property.
Additional information: When I use OffNormalAlarmType instead of MyOwnAlarmType (which extends OffNormalAlarmType), it works without any error. Of course, without this OwnVariable I added to MyOwnAlarmType.
new NodeId(nsIdx, MyNodeManagerImpl.getNextObjectNodeId()), "MyOwnAlarmType", Locale.ENGLISH);
10:21, EET
December 21, 2011
10:38, EET
January 27, 2012
Most Users Ever Online: 1919
Currently Online:
19 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: 727
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
gabriellabachus, Deakin, KTP25Zof, Wojciech Kubala, efrennowell431, wilfredostuart, caitlynfajardo, jeromechubb7, franciscagrimwad, adult_galleryModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1