This is a possible method with scripting. This is from a work in progress so it is a bit messy with commented out lines. It is fetching XML from a local server in the "onprepare" event. I'm not going to try to explain it right now since I am busy, but sometimes all someone needs is an example.
Dim fetcher as Object
Dim arr as Object
Dim rotx as Double
fetcher = CreateObject("MSXML2.XMLHTTP")
fetcher.open("GET","http://10.1.1.101/cgi-bin/z_getcam4.py",false)
'fetcher.setRequestHeader("Cache-Control","no-cache, must-revalidate")
'fetcher.setRequestHeader("Pragma","no-cache")
fetcher.send()
'Engine.WriteToLog(fetcher.responseText)
Dim Cam as xpBaseObject
Self.GetObjectByName("CameraControl",Cam)
Try
arr = fetcher.responseXML.SelectNodes("//axis[@name='rotx']")
Dim c as Object
Engine.WriteToLog("Do Loop")
For Each c In arr
Engine.WriteToLog("-tick")
'If c.getAttribute("name") And c.getAttribute("calc") Then
'Engine.WriteToLog(c.getAttribute("calc"))
Engine.WriteToLog("RotX--" & c.getAttribute("calc"))
Double.TryParse(c.getAttribute("calc"),rotx)
Cam.RotX=-rotx
Engine.WriteToLog("RotX" & Cam.RotX)
'End If
Next
Catch oops as Exception
Engine.WriteToLog(oops.Message)
'Engine.WriteToLog("V")
End Try
'Engine.WriteToLog("x")
fetcher = Nothing
You can do JSON also and put the script in a loop instead if you wanted.
Note the commented out lines for caching. The no-caching headers NEED to come from the server. If those headers are NOT in the data then the data will NOT change from the initial request. That was a painful learning experience.
Hope this is helpful or inspirational!
------------------------------
Azathoth
Son of Cthulhu
------------------------------