Hello all,
Relatively new to designing in Ignition, so I want to apologize in advance if I come off as vague when discussing my project. I will be periodically checking this thread to answer any questions or provide feedback on the suggestions.
The Details of the Project
Here is the dashboard being displayed, the text is present showing the device name, I am only crossing it out for privacy reasons:
As the title suggests, I'm creating a view in perspective that will show all of our connected devices' current state (connected or not). This script that pings the device is set to run every 10 seconds via a previously configured gateway script that counts seconds, bound to a custom property called "Seconds" that modifies the value of another property called "PingEvery10":
here is the change script to determine every 10 second increment:
if self.custom.Seconds % 10 == 0:
self.custom.PingEvery10 = self.custom.PingEvery10 + 1
the change script of "PingEvery10" to reset to 0 after 1 day's worth of time has passed (6 time per minute * 60 * 24 = 8640 times), the custom property that every device component is referencing:
if self.custom.PingEvery10 > 8640:
self.custom.PingEvery10 = 0
Lastly, every device I currently have configured (only 7 devices in comparison to thousands that will be needed) is using a button component with two custom properties: "ip_Address" and "pinger". Every instance of "pinger" has a binding to the "PingEvery10" custom property on the view. Here is the change script that executes when "pinger"'s value changes, assigning a specified style class based on the result:
def ping(address):
import subprocess
command = 'ping', '%s' % address
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
process_out = process.communicate()[0].strip().split('\r\n')
print process_out[1:5]
if any("TTL" in word for word in process_out):
self.props.style.classes = "Connected"
elif any("Pinging" in word for word in process_out):
self.props.style.classes = "NoComms"
else:
self.props.text = "Ping Execution Error"
self.props.style.classes = ""
address = self.custom.ip_Address
ping("%s" % address)
The Problem
Now for the reasoning for the thread. When I first created this script I had one device to trial the script for success. The typical response time for changes to show up in the session view was about 30 - 40 seconds, which is satisfactory in terms of what I was expecting; however, as more devices are added, that time gets much longer. With 7 devices, the changes take about 3 minutes to show up. This makes me theorize that it is pinging every device before showing updates to any single one.
I've read some similar scenarios, most of which point to using a gateway script with a system.util.invokeasynchronous command. I have not yet tried this due to my lack of knowledge on gateway scripts.
Related Questions
- If the above-mentioned system utility is the way to resolve this, then how do I "pass" the "ip_Address" of each device button to the gateway script to be executed.
- If the response time is able to be faster, what ways could I improve it?
- If/When this is working, how would I "future proof " it for adding new devices? I'm assuming there would be a way in which to make an "Add New Device/Remove Device" tab that could collect information from the user and generate a button in the next available spot based on the details applied or conversely remove the device.
Thank you all in advance for your time! I am open to any other recommendations you might have to help me make this great.