在 WINDEV 上使用 OPC UA 将实数数组写入 Siemens 1500

问题描述

(抱歉我用法语写英语的方式)

嗨, 经过对网络和文档的大量研究,我无法解决我的问题

我尝试使用 OPC UA 向西门子写入 150 个实数的数组:

PROCÉDURE WriteArrayToNode(NodeIdTxt is string)

Trace("lets write")


myNodeId        is NodeId(gsNotreBD+"."+NodeIdTxt)
nodesToWrite    is WriteValueCollection <- new WriteValueCollection()
nodetoWrite     is WriteValue           <- new WriteValue()
nodetoWrite.NodeId                  = myNodeId
nodetoWrite.AttributeId             = Attributes.Value

Trace(Attributes.ValueRank,Attributes.Value,Attributes.ArrayDimensions)

vTemp is Opc.Ua.variant(gTab_W_Para)   //gTab_W_Para is the array of 150 real i trying to write
clDataValue1 is DataValue <- new DataValue(vTemp);

nodetoWrite.Value=clDataValue1
nodetoWrite.Indexrange="1:150"

nodesToWrite.Add(nodetoWrite);

clRequestHeader is RequestHeader <- new RequestHeader()
myResults is StatusCodeCollection dynamic = new StatusCodeCollection
myDiagsInfo is DiagnosticInfoCollection dynamic = new DiagnosticInfoCollection
request is RequestHeader dynamic =  new RequestHeader

gmySession.Write(request,nodesToWrite,myResults,myDiagsInfo)

Trace(myDiagsInfo.get_Count())

Trace("scribe ? ")
RETURN True
Trace(" yes scribe ")

CASE ERROR:
Trace("erreur",ExceptionInfo)
RETURN False
CASE EXCEPTION:
Trace("exception",ExceptionInfo)
RETURN False

TRACE 给出:

lets write      //start of process
15 13 16        // Attributes.ValueRank,Attributes.ArrayDimensions  I don't understand :
                // With doc,I admit it say Attributes is 15 dimensional array with value of 13 ? and 16 
                // index,but who is Attributes ? I never use array like that
0               
scribe ?        //it return true,so there is no error ?

但是在 siemens 中我的数组不会改变,所以写入不起作用? 我尝试在许多示例中使用变体和数据值,但我不确定它的好方法。 如果有人可以帮助我提前感谢他

解决方法

可能您对 IndexRange 的使用是错误的。

假设您只使用 OneDimensional S7 Array REAL[1..150](其中 dataVariable 指示属性 ValueRank 和 ArrayDimensions)

不要将 S7 范围语法与 OPC UA IndexRange 一起使用!

  1. 来自 UA 规范:

“所有索引都从 0 开始。任何索引的最大值都比维度的长度小 1。”

因此,“1:150”表示服务器上不存在的范围。 “0:149”是正确的。

  1. 如果您对整个数组进行寻址,则根本不要使用 IndexRange。事实上,这会对服务器产生一些性能问题。

  2. 也许 S7-1500 OPC Server 在写入时根本不支持 IndexRange。但它应该返回一个错误。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...