I have a main customer that I have finally got to switch over to Ignition for HMI use. (yay!)
Currently running Ignition Edge 7.9.13.
These are installed on a PC touch panel (gateway and client.)
I have a client event script that I am trying to run only in the client installed on the same hardware as the gateway. (Not on the secondary remote client.)
I’m syncing time with the PLC and don’t want a remote machine in a different timezone to send it’s time info.
I thought the easiest way would be to get the gateway IP address and the client IP address and check if they are the same. But I’m not seeing any good way to get the gateway IP address. Everything in system.net seems to only get client info.
I know I could just create a static string tag with the IP of the gateway, but I’m trying to design this once and not have to remember to change the tag from project to project.
I’d venture a guess that System/Client/Network/GatewayAddress doesn’t include “localhost” on the remote client. If your local client launcher has the app added with the gateway IP address or host name (rather than localhost), I expect the gateway address tag would also reflect tthat. Something like this should work regardless of whether client connects to gateway via localhost, IP, or host name:
ip, host = system.net.getIpAddress(), system.net.getHostName()
if any([x in system.util.getGatewayAddress() for x in [ip, host, 'localhost']]):
print "Client is running on gateway."
print "Client is remote."
After opening a designer and playing around with the GatewayAddress tag i came to the same conclusion. This would also be beneficial because you would be able to reuse the same code elsewhere without manually setting a static IP on each machine and matching it in the code.
Vision clients have access to more information about the local network environment than just an IP address. Consider using the myMacIds() function from this post:
and compare the result to running that function in the gateway, perhaps inside a message handler for sendRequest(). Pass the client’s list of MAC Ids to sendRequest(), and return true/false to indicate whether they match the gateway. This approach works even if a client on the gateway connects via the gateway’s IP address instead of localhost.
I did think about using the Mac address also, as it’s easily available for the client in the tag System/Client/Network/MACAddress.
But can I use the method you mentioned with Edge where there is no Gateway scripts?