BadNotWritable error in OPC UA Server|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
BadNotWritable error in OPC UA Server
Avatar
OPCUA USER
Member
Members
Forum Posts: 53
Member Since:
01/07/2022
sp_UserOfflineSmall Offline
1
05/13/2024 - 22:13
sp_Permalink sp_Print

Hi,

I have developed OPC UA SERVER application using CSharp(C#) language.

I am using Nodeset2 XML file for loading address space.

I am trying to write variable value after creation of address space. I am getting error in application.

Error: BadNotWritable

NodeSet XML:

<UAVariable NodeId="ns=1;i=1952" BrowseName="1:number" ParentNodeId="ns=1;i=1567" DataType="String">

Code:

public static void WriteNode(string identifier, string nodevalue, DateTime cTsDateTime)
{
WriteValue valueToWrite = new WriteValue();
uint identifiernumber = 0;
if (uint.TryParse(identifier, out identifiernumber))
{
valueToWrite.NodeId = new NodeId(Convert.ToUInt32(identifier), 2);
}
else
{
valueToWrite.NodeId = new NodeId("ns=2;s=" + identifier);
}
valueToWrite.AttributeId = Opc.Ua.Attributes.Value;
if (ParseString(nodevalue) == dataType.System_Boolean)
{
valueToWrite.Value.Value = Convert.ToBoolean(nodevalue);
}
else if (ParseString(nodevalue) == dataType.System_Int32)
{
valueToWrite.Value.Value = Convert.ToInt32(nodevalue);
}
else if (ParseString(nodevalue) == dataType.System_Int64)
{
valueToWrite.Value.Value = Convert.ToInt64(nodevalue);
}
else if (ParseString(nodevalue) == dataType.System_Double)
{
valueToWrite.Value.Value = Convert.ToDouble(nodevalue);
}
else if (ParseString(nodevalue) == dataType.System_String)
{
valueToWrite.Value.Value = nodevalue;
}

valueToWrite.Value.StatusCode = StatusCodes.Good;
valueToWrite.Value.SourceTimestamp = cTsDateTime;
var nodesToWrite = new WriteValueCollection();
nodesToWrite.Add(valueToWrite);

StatusCodeCollection results = null;
DiagnosticInfoCollection diagnosticInfos = null;
var operationContext = new Opc.Ua.Server.OperationContext(new RequestHeader(), Opc.Ua.Server.RequestType.Write);
Server.masterNodeManager.Write(operationContext, nodesToWrite, out results, out diagnosticInfos);
if (results[0].ToString().ToUpper() == "GOOD")
{
Logger._log4net.Info("Writing completed for " + identifier);
}
else
{
Logger._log4net.Error("Writing failure for " + identifier + " -" + results[0].ToString().ToUpper());
}
}

Please help me

Avatar
Randy Armstrong
Admin
Forum Posts: 1568
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
05/14/2024 - 19:17
sp_Permalink sp_Print
Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4861