|
|
|
@@ -368,9 +368,42 @@ classdef EquipmentClass < handle |
|
|
|
structname = matlab.lang.makeValidName(['ip',cleanip,'_',num2str(port)]); |
|
|
|
end |
|
|
|
|
|
|
|
function equipmentstruct = discover() |
|
|
|
|
|
|
|
|
|
|
|
function ipaddress = getInterfaceIP() |
|
|
|
if ispc |
|
|
|
% Code to run on Windows plaform |
|
|
|
[status,result]=system('ipconfig'); |
|
|
|
if ~(status == 0) |
|
|
|
error('Failed to find local IP address'); |
|
|
|
end |
|
|
|
ipaddress = regexp(result,'(?<=\n IPv4 Address[ \.]*: )([0-9]{1,3}\.?){4}','match'); |
|
|
|
elseif ismac |
|
|
|
% Code to run on Mac platform |
|
|
|
[status,result]=system('ifconfig'); |
|
|
|
if ~(status == 0) |
|
|
|
error('Failed to find local IP address'); |
|
|
|
end |
|
|
|
ipaddress = regexp(result,'(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])(?=\/)','match'); |
|
|
|
elseif isunix |
|
|
|
% Code to run on Unix platform |
|
|
|
[status,result]=system('ip addr show'); |
|
|
|
if ~(status == 0) |
|
|
|
error('Failed to find local IP address'); |
|
|
|
end |
|
|
|
ipaddress = regexp(result,'(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])(?=\/)','match'); |
|
|
|
else |
|
|
|
error('Platform not supported'); |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
function prologixIP = discoverPrologix() |
|
|
|
persistent stored_ipaddress; |
|
|
|
if ~isempty(stored_ipaddress) |
|
|
|
prologixIP = stored_ipaddress; |
|
|
|
return |
|
|
|
end |
|
|
|
ipaddress = getInterfaceIP() |
|
|
|
udpconnection = udp('255.255.255.255',3040); |
|
|
|
udpconnection.LocalHost = localhost; |
|
|
|
end |
|
|
|
end |
|
|
|
end |