I want to send this value to a specific Tag and use it as a setpoint. How can i achieve this? Have anyone of you done something Similar ?
Thank you in advance
Hi Omer , i have got the specific data from the API. I want to use that specific value to write it in a Tag using it as a setpoint. Still thank you for your fast response to this thread.
So... if that page isn't open then what do you want to happen? If you are only reading this on that page via a binding, then when that page isn't open then nothing will be happening.
However, if you are reading this value just into a label on a view, and that view isn't open then the API is being called to get the new value.
So you need to move your logic to access the API data to a gateway timer script and use the system.net.httpClient | Ignition User Manual scripting function to get the data, process that value and then write it to the tag you want via the system.tag.writeBlocking function.
Put this into it's own project scripting library. Something like project.api
httpAddress = "apiAddressHere"
tagPath = "fullTagPathHere"
# Create the JythonHttpClient.
client = system.net.httpClient()
def getSetpoint():
# Sent a GET request.
response = client.get(httpAddress)
if response.good:
# Do something with the response
setpoint = response.json['nested1']['value1']
print setpoint #Comment out this line when it is working
#system.tag.writeBlocking(tagPaths=[tagPath], values=[setpoint]) #Un commend this line when it is working
Edit the httpAddress and tagPath details.
Then in your scripting console call the project script.
project.api.getSetpoint()
You should get the setpoint from the API printed in the console.
If you don't post the error here.
And once it is all working, comment the
print setpoint
and uncomment the
system.tag.writeBlocking
and run it again. Then your tag should change to that setpoint.
Once you have that going, then move the call to a Gateway timer script that runs at the pace you want it to run to update it on the frequency you want.