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
how to set engUnits of OPC tag in ProsysOPCUA?
December 18, 2019
15:26, EET
Avatar
angel
Member
Members
Forum Posts: 5
Member Since:
December 18, 2019
sp_UserOfflineSmall Offline

we use UaServer for get value of tag.

We use following method to add node of type float

PlainVariable tagVariable = new PlainVariable(this, nodeId, nameOnLevel, LocalizedText.NO_LOCALE);
tagVariable.setDataTypeId(Identifiers.Float);
tagVariable.setValue(0);
UaNode.addComponent(tagVariable);

I would like to set Engineering Unit for this node to “kVAR”

How can do this?

December 19, 2019
14:43, EET
Avatar
Markus Johansson
Member
Members
Forum Posts: 42
Member Since:
August 6, 2019
sp_UserOfflineSmall Offline

A basic Variable of BaseDataVariableType in OPC UA doesn’t have any Attribute or Property to define the Engineering Unit. For your solution I would recommend for example using an AnalogItemType Variable (see OPC UA Specification, Part 8), which defines a Property for setting the Engineering Unit.

December 21, 2019
15:29, EET
Avatar
angel
Member
Members
Forum Posts: 5
Member Since:
December 18, 2019
sp_UserOfflineSmall Offline

Thank you very much for your quick response.

I have tried to understand how to use AnalogItemType variable using OPC UA Specificiation and also tried google to get more details

Unfortunately I didn’t enough information which help me to set EngUnit.

Could you please share any examples or link where Engineering Unit is set for UaNode?

Thanks in advance

January 2, 2020
16:38, EET
Avatar
Markus Johansson
Member
Members
Forum Posts: 42
Member Since:
August 6, 2019
sp_UserOfflineSmall Offline

Sorry for not so quick response.

Yes, I can provide an example for creating AnalogItem with EngineeringUnits. Use the below method in your custom NodeManager:

private AnalogItemType createAnalogItem() throws StatusException, NodeBuilderException {
NodeBuilderConfiguration conf = new NodeBuilderConfiguration();
conf.addOptional(Identifiers.BaseAnalogType_EngineeringUnits);
AnalogItemType analogItem = createNodeBuilder(AnalogItemType.class, conf).setName(“AnalogItem”).build();
String namespaceUri = “http://www.example.com/”;
Integer unitId = -1;
LocalizedText displayName = new LocalizedText(“tu”, Locale.ENGLISH);
LocalizedText description = new LocalizedText(“test units”, Locale.ENGLISH);
analogItem.setEngineeringUnits(new EUInformation(namespaceUri, unitId, displayName, description));
return analogItem;
}

Of course, in the method, all the information is only used as an example and you should replace the namespaceUri, unitId, displayName and description with the appropriate values. Check OPC UA Specification, Part 8, Section 5.6.3 for instructions on what the values should be.

January 22, 2020
13:04, EET
Avatar
angel
Member
Members
Forum Posts: 5
Member Since:
December 18, 2019
sp_UserOfflineSmall Offline

Thanks, Markus for share an Example of AnalogItemType.

I am able to create AnalogItemType with below method
private AnalogItemType createAnalogItem() throws StatusException, NodeBuilderException {
try {
NodeBuilderConfiguration conf = new NodeBuilderConfiguration();
conf.addOptional(Identifiers.AnalogItemType_EngineeringUnits);
AnalogItemType analogItem = createNodeBuilder(AnalogItemType.class, conf).setName(“AnalogItem”).build();
String namespaceUri = “http:// http://www.opcfoundation.org/U…../un/cefact“;
int unitId = -1;
LocalizedText displayName = new LocalizedText(“A”, Locale.ENGLISH);
LocalizedText description = new LocalizedText(“Current”, Locale.ENGLISH);
analogItem.setEngineeringUnits(new EUInformation(namespaceUri, unitId, displayName, description));
return analogItem;
} catch (Exception e) {
logger.error(” AnalogItemType contains an exception..” + e.toString());
return null;
}
}
Question: I create UaNode with following code:
PlainVariable tagVariable = new PlainVariable(this, nodeId, nameOnLevel, LocalizedText.NO_LOCALE);
tagVariable.setDataTypeId(Identifiers.Float);
try {
tagVariable.setValue(0);
} catch (StatusException statusException) {
logger.error(“can not set default value for > ” + nodeId.toString() + ” > ” + dataType,
statusException);
}
How can i set Engeeniring Unit for tagVariable?
could you please share Examples, If you have.

January 23, 2020
15:40, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

If I may ask, why are you trying to do that?

Generally speaking, in practice, only the AnalogItemTypes have that Property in OPC UA (well in the standard model anyway). There are a few other VariableTypes that have defined it, but normally, unless a Property has been defined for a VariableType, I haven’t seen expectations that a node would have that, i.e. clients would typically look the nodes based on its TypeDefinition, and if that doesn’t include it, it might not as well exist. Note that you can define that Property in any VariableType. But if you make a PlainVariable, then you would do only nodes of the BaseVariableType, which by itself doesn’t define any Properties in it’s TypeDefinition.

Now then, technically any node can be made to contain any property by just creating the node for the Property and adding that with HasProperty Reference to the Variable node for which you would like to have it (tough Property nodes are Variables itself, they cannot contain Properties). So you can make a PlainProperty with the BrowseName “EngineeringUnits” and add that via addProperty method of the PlainVariable. For some examples on Properties, see MyNodeManager.createMyEnumNode in the sampleconsoleserver example.

Additionally it should be stated that, yes, per the OPC UA Specification 1.04 Part 3 section 5.6.2 Variable NodeClass Table 13 does list a “Standard Property” “EngineeringUnits” as Optional with the text:

Only used for DataVariables having a Number DataType.
This optional Property indicates the engineering units for the
value of the DataVariable (e.g. hertz or seconds). Details about
the Property and what engineering units should be used are
defined in
Part 8. The DataType EUInformation is also defined in Part 8.

but I have never seen any server to have _any_ of those standard properties used, except “NodeVersion”. Also it is somewhat interesting that these are not in the TypeDefinition of the BaseVariableType, but that is how it is currently.

January 29, 2020
6:33, EET
Avatar
angel
Member
Members
Forum Posts: 5
Member Since:
December 18, 2019
sp_UserOfflineSmall Offline

Hi Bjarne,

I have understood that instead of using PlainVariable , I should use AnalogItemType or I should Create PlainProperty and add it to PlainVariable object.

I have tried following :

PlainVariable tagVariable = new PlainVariable(this, nodeId, “Name Of Node”, LocalizedText.NO_LOCALE);
tagVariable.setDataTypeId(Identifiers.Float);
tagVariable.setValue(0);
tagVariable.setTypeDefinitionId(Identifiers.BaseDataVariableType);

PlainProperty enumStringsProperty = new PlainProperty(this, nodeId,
new QualifiedName(“Name of Node”), new LocalizedText(“Name Of Node”, LocalizedText.NO_LOCALE));
enumStringsProperty.setBrowseName(new QualifiedName(“MVAR”));
enumStringsProperty.addReference(Identifiers.HasProperty, Identifiers.HasProperty, false);
tagVariable.addProperty(enumStringsProperty);

With this changes I am getting runtime an error as ” java.lang.IllegalArgumentException: Cannot add property nodes to a Property node(BrowseName=MVAR NodeId=ns=2;s=STATISTICS_Processor1″

I am not sure what I am missing there.

I have a simple requirement that I would like to create a Node with Datatype, Initial Value, Name and Engineering Unit.
I have a json file with this information to create nodes.

I am able to achieve this with PlainVariable except for Engineering Unit.

Could you please let me know best approach to do this?

Do you have any sample example to create node with above requirements.

Thanks in advance

January 29, 2020
15:58, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1032
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Generally we do offer consulting for application design as a separate service, https://www.prosysopc.com/services/.

Using the proper information model instead of raw nodes of base types is advisable, thus AnalogItemType would probably be better.

We do not provide samples for every possible case, as that would be _impossible_ due to scope of OPC UA, i.e. even explaining what I would consider the basics takes 3 full workshop days. You are expected to know OPC UA and/or learn it yourself to some degree in order to use the SDK, i.e. you must understand at least in general what you are trying to do with the code in OPC UA terms.

I’m not sure why you have added the line “enumStringsProperty.addReference(Identifiers.HasProperty, Identifiers.HasProperty, false);” that doesn’t make any sense. It’s javadocs states:

Adds a new reference of the specified type to the specified node. If a similar referencealready exists, does not add a new, but returns a reference to the existing reference.

Specified by: addReference(…) in UaNode
Parameters:

nodeId The target node of the reference

referenceTypeId The reference type

isInverse Whether the reference is an inverse reference (or forward, if isInverse=false)Returns:the reference that was added (or existed already) or null, if the reference type is notsupported by the node (i.e. UaProperty may only have inverse HasProperty references).

You are trying to add a Property to the Property node (this is not allowed in OPC UA, explained above, thus the error) and the target you are trying to add as the Property is the ReferenceType of the HasProperty referencetype itself. If you just delete that line it should work, as the addProperty on the next line will add it.

January 30, 2020
9:23, EET
Avatar
angel
Member
Members
Forum Posts: 5
Member Since:
December 18, 2019
sp_UserOfflineSmall Offline

Thanks Bjarne for your detailed reply.

I have delete below line:
enumStringsProperty.addReference(Identifiers.HasProperty, Identifiers.HasProperty, false);

Now I am getting the below error

Data type not found : SCC1_STATISTICS_late_messages_per_second, java.lang.IllegalArgumentException: Cannot add property nodes to a Property node(BrowseName=MVAR NodeId=ns=2;s=SCC1_STATISTICS_late_messages_per_second

Could you please point me on how to create AnalogItemType to set Datatype, name and Engineering Unit as annther option to do this

January 30, 2020
13:30, EET
Avatar
Jimmy Ni
Moderator
Members

Moderators
Forum Posts: 26
Member Since:
February 1, 2019
sp_UserOfflineSmall Offline

Thank you for evaluating our SDK. Your question is very good and is frequently asked.

However, the forum is mainly used to discuss general topics and is NOT meant for debugging users’ codes. In other words, we are glad to provide users with proper suggestions in this forum, but we don’t have time to go through users’ codes. If you need specific assistance on your implementations, we are at your disposal for any further help which will be provided as professional services. Please contact sales@prosysopc.com for more information about our professional services.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

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

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

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

Administrators: admin: 1