# How to implement Ping Script via Gateway Timer Script \> Multiple Devices

**URL:** <https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [October 31, 2024, 9:12pm UTC](https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021 "2024-10-31T21:12:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![john.fleming](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@john.fleming](https://forum.inductiveautomation.com/u/john.fleming)\
**Post date:** [October 31, 2024, 9:12pm UTC](https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021/1 "2024-10-31T21:12:22Z")

</div>

Below is a dev script running on a Control Logix, still fairly new to Ignition was needing feedback from experienced folks. Would like to create a gateway timer script to read/write to OPC tag to coms drop locally and raise server alarm.

```python
type or paste code h# OPC Server and Tag Paths
opcServer = "Ignition OPC-UA Server"
itemPath = "ns=1;s=[AFSPL1RtRepair]OPC.Ping"
tag_path = "[Default]OPC/Assembly/L1/RTRPR/Ping"

isAlarmLogged = system.tag.readBlocking(['[Default]OPC/Assembly/L1/RTRPR/isAlarmLogged'])[0].value
isErrorLogged = system.tag.readBlocking(['[Default]OPC/Assembly/L1/RTRPR/isErrorLogged'])[0].value 
system.tag.writeBlocking(['[Default]OPC/Assembly/L1/RTRPR/isErrorLogged'], [False])

try:
    # Read the tag value and quality
    value = system.tag.readBlocking([tag_path])[0]
    tagValue = value.value
    tagQuality = value.quality

    # Check if the tag quality is good
    if tagQuality.isGood():
        if tagValue == True:
            writeOperationStatus = system.opc.writeValue(opcServer, itemPath, 0)
            if writeOperationStatus.isGood():
                pass # Successful OPC Write 0
        else:
            writeOperationStatus = system.opc.writeValue(opcServer, itemPath, 1)
            if writeOperationStatus.isGood():
                pass # Successful OPC Write 1
        # Reset active flags to False after a successful tag read/write operation
        if isAlarmLogged:
            system.tag.writeBlocking(['[Default]OPC/Assembly/L1/RTRPR/isAlarmLogged'], [False])
        
    else:
        # If "QUALITY IS BAD" 
        if isAlarmLogged == False:
            system.util.getLogger("L1RtRepair_PingQuality").error("BadQuality=[Default]OPC/Assembly/L1/RTRPR/Ping.Quality")
            system.tag.writeBlocking(['[Default]OPC/Assembly/L1/RTRPR/isAlarmLogged'], [True])

except Exception as e:
    # Log exception definiton defined by Igniton
    if not isErrorLogged:
       system.util.getLogger("L1RtRepair_Exception").error("Alarm: %s" % e) 
       system.tag.writeBlocking(['[Default]OPC/Assembly/L1/RTRPR/isErrorLogged'], [True])
       
       
     ere

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 31, 2024, 9:31pm UTC](https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021/2 "2024-10-31T21:31:57Z")

</div>

You might be reinventing the whale here. Have a look at Network Device Status by: Bao Nguyen available to download on the Ignition Exchange.

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2192/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

I think there was another one as well but I can't seem to find it right now.

---

<div class="post-metadata">

**Author:** ![john.fleming](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@john.fleming](https://forum.inductiveautomation.com/u/john.fleming)\
**Post date:** [October 31, 2024, 9:44pm UTC](https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021/3 "2024-10-31T21:44:03Z")

</div>

My main concern is when creating a timer script for each device I don't want to introduce any potential network issues. The ping is for the device to monitor for a local shutdown.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 31, 2024, 10:48pm UTC](https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021/4 "2024-10-31T22:48:28Z")

</div>

You would never create a timer script. You would use a gateway scheduled event.

You can also monitor any device's OPC status. Create a new tag with Value Source: OPC, Data Type: Boolean.

 ![OPC status](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/b/0b10c886d14971f9fb065c9763c9fb36e768d13b.png)

I haven't played with this for a while. You may need to monitor and see that it behaves in a fashion suitable for your purposes.

---

<div class="post-metadata">

**Author:** ![john.fleming](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@john.fleming](https://forum.inductiveautomation.com/u/john.fleming)\
**Post date:** [November 6, 2024, 4:40pm UTC](https://forum.inductiveautomation.com/t/how-to-implement-ping-script-via-gateway-timer-script-multiple-devices/98021/5 "2024-11-06T16:40:04Z")

</div>

If using a ping to monitor heartbeat in PLC why would why would use gateway scheduled event vs gateway timer event?
