Comments (7)
Hello,
Nodes on the server are not writable by default. If you want to write to a node, you must handle storing that value for later reads.
Implement this virtual method in your Application
:
https://github.com/nauful/LibUA/blob/837d0072a338e690d1c30ec32649499ae12ee10c/NET%20Core/LibUA/Application.cs#L474C4-L474C88
The default implementation returns BadNotWritable
for write attempts. If your node is writable, you can store the new value (to return on reads, possibly also store in a historical time series) and return Good
for that node. If your node isn't writable, you can return BadNotWritable
.
WriteValue
is determined here:
Line 5876 in 837d007
This includes
NodeId
and Value
.from libua.
To return the written value when a node is read, look at this:
LibUA/NET Core/TestServer/Program.cs
Line 276 in 837d007
And this is to handle historical reads:
LibUA/NET Core/TestServer/Program.cs
Line 305 in 837d007
from libua.
I return Good in the HandleWriteRequest method, the error no longer appears, but the value is still not displayed.
I didn't quite understand what it means to store the new value.
Could you share some example, please?
from libua.
I managed to write down the value in this way. Is this the right decision?
from libua.
Look at this sample code:
private Dictionary<NodeId, DataValue> writtenValues = new Dictionary<NodeId, DataValue>();
public override uint[] HandleWriteRequest(object session, WriteValue[] writeValues)
{
var respStatus = new UInt32[writeValues.Length];
for (int i = 0; i < writeValues.Length; i++)
{
if (writeValues[i].AttributeId == NodeAttribute.Value)
{
writtenValues[writeValues[i].NodeId] = writeValues[i].Value;
MonitorNotifyDataChange(writeValues[i].NodeId, writeValues[i].Value);
respStatus[i] = (UInt32)StatusCode.Good;
}
else
{
respStatus[i] = (UInt32)StatusCode.BadNodeAttributesInvalid;
}
}
return respStatus;
}
protected override DataValue HandleReadRequestInternal(NodeId id)
{
if (writtenValues.TryGetValue(id, out DataValue value))
{
return value;
}
Node node = null;
if (id.NamespaceIndex == 2 &&
AddressSpaceTable.TryGetValue(id, out node))
{
if (node == Node1D)
{
return new DataValue(new float[] { 1.0f, 2.0f, 3.0f }, StatusCode.Good, DateTime.Now);
}
else if (node == Node2D)
{
return new DataValue(new float[2, 2]
{
{ 1.0f, 2.0f },
{ 3.0f, 4.0f }
}, StatusCode.Good, DateTime.Now);
}
else
{
return new DataValue(3.14159265, StatusCode.Good, DateTime.Now);
}
}
return base.HandleReadRequestInternal(id);
}
You need to store the written value somewhere, publish data change, then return it on read.
from libua.
Thank you very much.
Why do I need to return a value in HandleReadRequestInternal?
Is my example incorrect?
from libua.
For read internal, you need to return the value of the node involved. This is the sent back to the client.
from libua.
Related Issues (20)
- Error monitoring HOT 19
- Improve library NodiId.TryParse HOT 1
- OPC UA PubSub via UDP HOT 1
- Unable to pass "null" as filter in MonitoredItemCreateRequest HOT 2
- Problem with freeOPAUA HOT 16
- How to create an ExtensionObject? HOT 1
- UaClient error to read a matrix HOT 7
- How to read an ExtensionObject? HOT 6
- Error DefaultAddressSpace HOT 1
- TranslateBrowsePath does not mark the final BrowsePathTarget correctly HOT 2
- Exception in MemoryBufferExtension.cs with a Prosys OPCUA Server HOT 16
- Nullreference Exception in Client Sample HOT 1
- LingerState: Unhandled Exception - Invalid Argument HOT 1
- Method calls are not executed HOT 5
- EUInformation and Range HOT 4
- Switch to use ArrayPool in memorybuffer to reduce allocation pressure HOT 1
- Browsing S7 OPCUA Server, Outputs not returned (FunctionalGroupType?) HOT 7
- Missing ServiceResult returns of CheckServiceFaultResponse() in Client.cs HOT 1
- BadAttributeIdInvalid when browsing Server HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libua.