# Delay Gatway script

**URL:** <https://forum.inductiveautomation.com/t/delay-gatway-script/24299>\
**Category:** Ignition\
**Created:** [April 22, 2019, 7:45pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299 "2019-04-22T19:45:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xavier](https://avatars.discourse-cdn.com/v4/letter/x/2bfe46/32.png) [@Xavier](https://forum.inductiveautomation.com/u/Xavier)\
**Post date:** [April 22, 2019, 7:45pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299/1 "2019-04-22T19:45:55Z")

</div>

Hi All,  
Looking for some help on delaying a Gateway event script based off of Tag Change. I am new to scripting in ignition. We are logging test data after the test completes and moves the data block to the completed test in the plc. The scan time on the length of registers takes a few seconds for all the data to populate. without a delay we miss or duplicate data from the previous test. the Code is simple here is a shortened version of what we have.

API = system.tag.read(“Well Test data/API”).value  
Gas = system.tag.read(“Well Test data/Gas”).value  
Oil = system.tag.read(“Well Test data/OIL”).value  
Water = system.tag.read(“Well Test data/Water”).value  
TestDuration = system.tag.read(“Well Test data/TestDuration”).value  
TestTime = system.tag.read(“Well Test data/TestTime”).value  
WellName = system.tag.read(“Well Test data/WellName”).value

system.db.runPrepUpdate(“INSERT INTO Well1 (API,Gas,Oil,Water,TestDuration,TestTime,WellName) values (?,?,?,?,?,?,?)”,  
[API,Gas,Oil,Water,TestDuration,TestTime,WellName])  
system.util.invokeLater(1000)

I have tried using system.util.invokeLater(1000) but cant seem to get it to work

Here is the error I get  
Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 12, in AttributeError: ‘com.inductiveautomation.ignition.common.script.Imm’ object has no attribute ‘invokeLater’

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 22, 2019, 7:53pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299/2 "2019-04-22T19:53:29Z")

</div>

`system.util.invokeLater` only exists in the client/designer. You should create an asynchronous thread with system.util.invokeAsync, and run your code in that if you really need a delay.

However, you probably don’t actually need a delay- if it’s a timing sensitive operation, use [`system.opc.readValues()`](https://docs.inductiveautomation.com/display/DOC79/system.opc.readValues) to trigger a direct, blocking read from the PLC, rather than relying on the scan class to get you the values in time.

---

<div class="post-metadata">

**Author:** ![Xavier](https://avatars.discourse-cdn.com/v4/letter/x/2bfe46/32.png) [@Xavier](https://forum.inductiveautomation.com/u/Xavier)\
**Post date:** [April 22, 2019, 8:09pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299/3 "2019-04-22T20:09:19Z")

</div>

Thank you sir I will give this a try!!

---

<div class="post-metadata">

**Author:** ![Xavier](https://avatars.discourse-cdn.com/v4/letter/x/2bfe46/32.png) [@Xavier](https://forum.inductiveautomation.com/u/Xavier)\
**Post date:** [April 22, 2019, 9:32pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299/4 "2019-04-22T21:32:54Z")

</div>

I am having trouble grabbing multiple values.

Reading a single value works ok

server = “Ignition OPC-UA Server”  
path = “[WightUnit]HRF102”  
qualifiedValue = system.opc.readValue(server, path)  
print qualifiedValue.getValue()

I have tried

server = “Ignition OPC-UA Server”  
path = “[WightUnit]HRF102”,"[WightUnit]HRF104","[WightUnit]HRF106","[WightUnit]HRF108"  
qualifiedValues = system.opc.readValues(server, path)  
print qualifiedValues.getValues()

Error Traceback (most recent call last):  
File “”, line 4, in   
AttributeError: ‘array.array’ object has no attribute ‘getValues’

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 22, 2019, 9:46pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299/5 "2019-04-22T21:46:06Z")

</div>

> [@Xavier](#):
>
> `qualifiedValues = system.opc.readValues(server, path)`

Try  
`print [value.getValue() for value in qualifiedValues]`

---

<div class="post-metadata">

**Author:** ![Xavier](https://avatars.discourse-cdn.com/v4/letter/x/2bfe46/32.png) [@Xavier](https://forum.inductiveautomation.com/u/Xavier)\
**Post date:** [April 22, 2019, 9:51pm UTC](https://forum.inductiveautomation.com/t/delay-gatway-script/24299/6 "2019-04-22T21:51:51Z")

</div>

> [@paul-griffith](#):
>
> [value.getValue() for value in qualifiedValues]

Thank you for your help sir!!  
I also found this to work,  
Values = map(lambda qv: qv.getValue(), qualifiedValues)

your solution looks cleaner!
