Hello,
I am trying to build an OPC UA Server with a custom datatype, that has two properties (Value, Timestamp). I used the UA Modeler to create it and loaded it in my OPC UA Server.
So far so good. I create the node with the custom datatype like that
NodeId variableId = new NodeId("ComplexObject", this.DefaultNamespaceIndex);
CreateVariableSettings setting = new CreateVariableSettings()
{
ParentNodeId = createdNode,
ReferenceTypeId = ReferenceTypeIds.HasSubtype,
RequestedNodeId = variableId,
BrowseName = new QualifiedName("ComplexObject", this.DefaultNamespaceIndex),
DataType = Demo.OPCUA.DataTypeIds.OpcUaBaseValue.ToNodeId(Server.NamespaceUris),
ValueRank = ValueRanks.Scalar,
ValueType = NodeHandleType.ExternalPush,
AccessLevel = AccessLevels.CurrentRead,
Value = "",
MinimumSamplingInterval = 1000
};
var variableNode = this.CreateVariable(Server.DefaultRequestContext, setting);
I can see the node via UAExpert and can monitor it. It even shows the correct datatype.
At the moment I hava a 30 second timer to simulate changes and push the values like this
Demo.OPCUA.OpcUaBaseValue value = new Demo.OPCUA.OpcUaBaseValue() { Value = 0, Timestamp = DateTime.Now }
DataValue dv = new DataValue(new Variant(value, null), DateTime.Now.ToUniversalTime());
dv.StatusCode = StatusCodes.Good;
item.Callback(Server.DefaultRequestContext, item.ItemHandle, dv, true);
item is just a container holding the parameters from StartDataMonitoring
The source/servertimestamps in UA Expert are changing. Again so far so good.
But when double clicking on the value, for looking at the properties, I only get an empty box with the buttons write/cancel.
What do I have to do, to see the actual values on the properties of my custom datatype Demo.OPCUA.OpcUaBaseValue?
Any help would be appreciated. Thanks in advance
Complex datatype in custom OPC UA Server
Moderator: uasdknet
- Support Team
- Hero Member
- Posts: 3213
- Joined: 18 Mar 2011, 15:09
Re: Complex datatype in custom OPC UA Server
Hi,
We could not reproduce the issue.
We assume that the custom structured DataType is generated with UaModeler. Is this correct?
UaExpert will only display values of structured DataTypes in the DA View if the DataType current value is the same DataType or a subtype that the DataType attribute of the node.
We could not reproduce the issue.
We assume that the custom structured DataType is generated with UaModeler. Is this correct?
UaExpert will only display values of structured DataTypes in the DA View if the DataType current value is the same DataType or a subtype that the DataType attribute of the node.
Best regards
Unified Automation Support Team
Unified Automation Support Team
-
- Jr. Member
- Posts: 3
- Joined: 16 Oct 2020, 07:59
Re: Complex datatype in custom OPC UA Server
Hello,
Yes, I created the structured datatype with the UAModeler. That is why I am so surprised, it does not work.
I add the datatype to the factory on startup of the nodeManager like this:
Server.MessageContext.Factory.AddEncodeableType(typeof(DEMO.OPCUA.OpcUaBaseValue));
Are there any specific settings required in the ServerManager or NodeManager in order for it to work?
Or are there settings that could even prevent the data from showing up on a client?
Yes, I created the structured datatype with the UAModeler. That is why I am so surprised, it does not work.
I add the datatype to the factory on startup of the nodeManager like this:
Server.MessageContext.Factory.AddEncodeableType(typeof(DEMO.OPCUA.OpcUaBaseValue));
Are there any specific settings required in the ServerManager or NodeManager in order for it to work?
Or are there settings that could even prevent the data from showing up on a client?
-
- Jr. Member
- Posts: 1
- Joined: 19 Nov 2024, 09:40
Re: Complex datatype in custom OPC UA Server
Hello,
I am working on a similar problem for displaying some sensor data via an object with just two properties at the moment: Degree, Timestamp.
I created this data type using the UA Modeler, and successfully loaded it into my server.
My Code for creating the node:
NodeId nodeId = new NodeId("Sensor", this.DefaultNamespaceIndex);
CreateVariableSettings nodeSetting = new CreateVariableSettings()
{
ParentNodeId = createdNode,
ReferenceTypeId = ReferenceTypeIds.HasSubtype,
Value = 0.0,
MinimumSamplingInterval = 500
RequestedNodeId = nodeId,
ValueRank = ValueRanks.Scalar,
ValueType = NodeHandleType.ExternalPush,
BrowseName = new QualifiedName("Sensor", this.DefaultNamespaceIndex),
DataType = Test.OPC.DataTypeIds.SensorItem.ToNodeId(Server.NamespaceUris),
AccessLevel = AccessLevels.CurrentRead,
};
CreateVariable(Server.DefaultRequestContext, nodeSetting);
I can see the node in my testclient
Test.OPC.SensorItem sensorItem = new Test.OPC.SensorItem() { Value = 10.0, Timestamp = DateTime.Now };
DataValue dv = new DataValue(new Variant(sensorItem, null), DateTime.Now.ToUniversalTime());
dv.StatusCode = StatusCodes.Good;
Callback(Server.DefaultRequestContext, item.ItemHandle, dv, true);
The source and server timestamps in my testclient are updating.
However the properties (Degree and Timestamp) do not appear.
Where does it go wrong?
I am working on a similar problem for displaying some sensor data via an object with just two properties at the moment: Degree, Timestamp.
I created this data type using the UA Modeler, and successfully loaded it into my server.
My Code for creating the node:
NodeId nodeId = new NodeId("Sensor", this.DefaultNamespaceIndex);
CreateVariableSettings nodeSetting = new CreateVariableSettings()
{
ParentNodeId = createdNode,
ReferenceTypeId = ReferenceTypeIds.HasSubtype,
Value = 0.0,
MinimumSamplingInterval = 500
RequestedNodeId = nodeId,
ValueRank = ValueRanks.Scalar,
ValueType = NodeHandleType.ExternalPush,
BrowseName = new QualifiedName("Sensor", this.DefaultNamespaceIndex),
DataType = Test.OPC.DataTypeIds.SensorItem.ToNodeId(Server.NamespaceUris),
AccessLevel = AccessLevels.CurrentRead,
};
CreateVariable(Server.DefaultRequestContext, nodeSetting);
I can see the node in my testclient
Test.OPC.SensorItem sensorItem = new Test.OPC.SensorItem() { Value = 10.0, Timestamp = DateTime.Now };
DataValue dv = new DataValue(new Variant(sensorItem, null), DateTime.Now.ToUniversalTime());
dv.StatusCode = StatusCodes.Good;
Callback(Server.DefaultRequestContext, item.ItemHandle, dv, true);
The source and server timestamps in my testclient are updating.
However the properties (Degree and Timestamp) do not appear.
Where does it go wrong?
- Support Team
- Hero Member
- Posts: 3213
- Joined: 18 Mar 2011, 15:09
Re: Complex datatype in custom OPC UA Server
Hi,
We can not reproduce, the Properties show up just fine.
Please create a support ticket (including all versions of all our software that you use) and send us the UaModeler project including the models and the server application code snipped that you use for creating the instance.
We can not reproduce, the Properties show up just fine.
Please create a support ticket (including all versions of all our software that you use) and send us the UaModeler project including the models and the server application code snipped that you use for creating the instance.
Best regards
Unified Automation Support Team
Unified Automation Support Team