# Alarming Loss of Comms to Devices

**URL:** <https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858>\
**Category:** Ignition\
**Created:** [November 9, 2021, 4:11am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858 "2021-11-09T04:11:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![craig.spring](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@craig.spring](https://forum.inductiveautomation.com/u/craig.spring)\
**Post date:** [November 9, 2021, 4:11am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/1 "2021-11-09T04:11:21Z")

</div>

This seems like a straight forward thing to want to do, but I can’t seem to find anything to tell me the best way to do it.

Firstly, I’m using version 8.1.11 of Ignition.

I have several devices connected using different protocols (OPC-UA, Modbus, DNP3). I want to issue an alarm when we lose comms to a device. It seems that the best way for OPC-UA devices is to alarm the System tag Gateway/OPC/Connections/_devicename_/Connected. Of course, we probably don’t want to alarm if the device is disabled.

For the Modbus and DNP3 devices, I’ve considered the System tag Gateway/Devices/_devicename_/Status. However, this is a text string and it seems strange to alarm on this tag (not)equal to a string.

What’s the Ignition way of alarming loss of comms to these devices? Thanks.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 9, 2021, 10:37am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/2 "2021-11-09T10:37:09Z")

</div>

Welcome, Craig!

You will find with Ignition there is no ‘one-way’ of doing things, there are multiple ways this can be done.

This is how I do it, note the version is 7.9 so scripts will need slight updates for best performance on 8.1.x

You seem to be concerned with loss to a single device, the following is for an overview of all devices but it might give you some ideas.

I have a tag that counts the total number of connected devices:

```auto
import system
		
cDS = system.dataset.toPyDataSet(deviceDataset)

c=0
for r in cDS:
	if r['State']=="Connected":
		c = c + 1

system.tag.write("Diagnostics/Devices_Connected", c)

```

I have an alarm set on this tag saying if below X count and for Y duration then send an email out.

Further to that I have a power table with a ‘refresh’ button with the following script:

```auto
deviceDataset = system.device.listDevices()
 
# Assign the deviceDataset to a Power Table. This example assumes
# the Power Table is in the same container as the component that called this script
event.source.parent.getComponent('Power Table').data = deviceDataset

```

This allows you to see at a glance what devices are connected/connecting/disconnected/disabled and the driver type, easier than the gateway status page as it is constantly refreshing.

Further to that I have a periodic script that pings each device and records the status to a DB, this then lets me see if there are drops in the diagnostic count which sites were not responding at that time historically;

```auto
def ping(address,timeout=2000):
	global pingStat
	from java.net import InetAddress
	ip = InetAddress.getByName(address)
	if ip.isReachable(timeout) == True:
		pingStat = 1
	elif ip.isReachable(timeout) == False:
		pingStat = 0

def dev_ping():
	dlist = system.device.listDevices()
	for row in range(dlist.getRowCount()):
		# Check if device uses ModbusTCP driver and device is enabled
		if dlist.getValueAt(row,3) == "ModbusTcp" and dlist.getValueAt(row,1) == 1:
			# Get device host name.
			devSite = dlist.getValueAt(row,0)
			print devSite
			devIP = system.device.getDeviceHostname(dlist.getValueAt(row,0))
			print devIP
			ping(devIP)
			if pingStat == 1:
				print "Dev ok"
				system.db.runSFPrepUpdate("insert into ign.dev_stat (dev_site, dev_ip, dev_state) values (?,?,?)",[devSite, devIP, pingStat],datasources=["MySQL"])
			
			elif pingStat == 0:
				print "no conn"
				system.db.runSFPrepUpdate("insert into ign.dev_stat (dev_site, dev_ip, dev_state) values (?,?,?)",[devSite, devIP, pingStat],datasources=["MySQL"])
				
dev_ping()

```

As usual, YMMV.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [November 9, 2021, 11:47am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/3 "2021-11-09T11:47:44Z")

</div>

If the end device is capable, we use a counter in the PLC that counts up every X amount of time. For ControlLogix based devices we use the WallClockTime, but the same can be done with a counter that rolls over in the PLC.

Then in Ignition we use two tags. One to read that counter that is running in the PLC and another that uses the [hasChanged - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/hasChanged) expression. If the expression returns false for X seconds then we assume that either we can’t communicate, or the PLC is not in run mode.

---

<div class="post-metadata">

**Author:** ![craig.spring](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@craig.spring](https://forum.inductiveautomation.com/u/craig.spring)\
**Post date:** [November 10, 2021, 12:28am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/4 "2021-11-10T00:28:13Z")

</div>

I appreciate the replies and suggestions, but I am very confused. Does Ignition not have a built in way of issuing an alarm to the operator when comms are lost to a device in the field? Seems like a fundamental thing that I’ve seen in other SCADA systems. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 10, 2021, 12:46am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/5 "2021-11-10T00:46:18Z")

</div>

Nope, there isn’t a standard way to do this. I normally create a UDT for each of my Device types (e.g. LogixDriver, AB Legacy, Modbus, etc.) using the Diagnostics tags provided by the OPC-UA server adding alarms to the comms status tags, then create instances of those UDTs for each device.  
The diagnostics tags usually also include other useful things like the IP address, processor info, etc.  
I also have Templates or View templates for each device type as well and popups for them to display all the info.

---

<div class="post-metadata">

**Author:** ![craig.spring](https://avatars.discourse-cdn.com/v4/letter/c/db5fbb/32.png) [@craig.spring](https://forum.inductiveautomation.com/u/craig.spring)\
**Post date:** [November 10, 2021, 2:17am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/6 "2021-11-10T02:17:50Z")

</div>

Is there any reason NOT to just alarm the “Connected” system tag for OPC-UA or the “Status” system tag for other devices?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [November 10, 2021, 2:34am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/7 "2021-11-10T02:34:57Z")

</div>

For an Ethernet I/P device the connected bit, as far as I understand it, only means that Ignition is connected to the first hop. So if you were communicating with a PLC over an Ethernet card the connected would only mean you are able to hit the Ethernet card.

And there are other things to think about… Just because you can communicate doesn’t mean that the device is active. Hence checking that the device is actually doing something.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [November 10, 2021, 7:05am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/8 "2021-11-10T07:05:18Z")

</div>

You're right, we also use a handshaked heartbeat as well to check for PLCs accidentally in programme mode. I like your method better though which combines the two into one, although I think I'd want to make these two fail states raise independent alarms as a 'no comms to PLC' alarm for a PLC in programme mode would be deceptive.

> [@craig.spring](#):
>
> Seems like a fundamental thing that I’ve seen in other SCADA systems

RE this, most other SCADA platforms i've used _ **do** _ raise hardware alarms when devices are disconnected, but none will raise an alarm if the PLC isn't actually running (is in programme mode).

While Ignition doesn't default to alarming on disconnected state, it offers the flexibility to configure this yourself. With great power comes great responsibility and sometimes out-of-the-box features are missed out on in favour of flexibility.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [November 10, 2021, 8:12am UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/9 "2021-11-10T08:12:42Z")

</div>

What are those diagnostics tags you’re talking about ?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [November 10, 2021, 12:19pm UTC](https://forum.inductiveautomation.com/t/alarming-loss-of-comms-to-devices/52858/10 "2021-11-10T12:19:36Z")

</div>

Most operators though don’t really understand the difference, and I don’t expect them too. We do show both errors though… we have an Ignition page that shows all the Ignitions stuff… OPC status, database status, and then device status from an Ignition view. Then on the system diagnostic details we use the heartbeat bit. Most operator Ignore the Ignition page and head to the system diagnostic, however when maintenance gets involved then they know where to look to start diagnosing. Or they just don’t even bother and call me at 2 am like today… for a networking issue by corporate. Oh well. 😃
