[英]Write an Array (of real) to an Siemens 1500 with OPC UA on WINDEV
(對不起我用法語寫英文的方式)
嗨,經過對網絡和文檔的大量研究,我無法解決我的問題
我嘗試使用 OPC UA 向 siemens 寫入 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.Value,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 ?
但是在西門子我的數組沒有改變,所以寫入不起作用? 我嘗試像在許多示例中一樣使用變體和 Datavalue,但我不確定它是否是好方法。 如果有人可以幫助我提前感謝他
可能您對 IndexRange 的使用是錯誤的。
假設您只使用 OneDimensional S7 Array REAL[1..150](dataVariable 表示屬性 ValueRank 和 ArrayDimensions)
不要將 S7 范圍語法與 OPC UA IndexRange 一起使用!
“所有索引都從 0 開始。任何索引的最大值都比維度的長度小一。”
所以“1:150”地址范圍,在服務器上不存在。 “0:149”是正確的。
如果您尋址整個數組,則根本不要使用 IndexRange。 實際上,這會在服務器上產生一些性能問題。
寫入時,可能 S7-1500 OPC Server 根本不支持 IndexRange。 但它應該返回一個錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.