| @@ -14,7 +14,7 @@ classdef Equipment < handle | |||
| methods | |||
| function ecq = Equipment(ipAddress,port,channel) | |||
| %EQUIPMENT Construct an instance of this class | |||
| %EQUIPMENT Construct an instance of this class. | |||
| % This functions opens the required TCP connection | |||
| % for this device. Channel is GPIB-channel on prologix | |||
| % converter if used, otherwise set channel to -1. | |||
| @@ -24,6 +24,7 @@ classdef Equipment < handle | |||
| ecq.channel = channel; | |||
| ecq.name = ecq.idn(); | |||
| end | |||
| function id = idn(ecq) | |||
| %IDN Queries identificantion from device via '*IDN?'. | |||
| id = ecq.query_unsafe('*idn?'); | |||
| @@ -42,6 +43,8 @@ classdef Equipment < handle | |||
| end | |||
| function unlock(ecq) | |||
| %UNLOCK Sets the device back to 'local control' | |||
| %This function only supports devices via the Prologix. | |||
| if ecq.channel >= 0 | |||
| fprintf(ecq.tcp,'++loc'); | |||
| ecq.locked = false; | |||
| @@ -49,6 +52,8 @@ classdef Equipment < handle | |||
| end | |||
| function lock(ecq) | |||
| %UNLOCK Sets the device back to 'remote control' | |||
| %This function only supports devices via the Prologix. | |||
| if ecq.channel >= 0 | |||
| fprintf(ecq.tcp,'++llo'); | |||
| ecq.locked = true; | |||
| @@ -58,28 +63,26 @@ classdef Equipment < handle | |||
| end | |||
| function beep(ecq) | |||
| %BEEP Sends the beep command to the device | |||
| ecq.write('SYST:BEEP') | |||
| end | |||
| function delete(ecq) | |||
| ecq.unlock; | |||
| Equipment.getTCP(ecq.tcp.RemoteHost,-1); | |||
| end | |||
| function write(ecq,message) | |||
| %WRITE Sends a command to the channel. | |||
| %The function will first check if the device is ready to | |||
| %recieve a command via the OPC function. Then send the command | |||
| %and eventually check if the device has thrown an error via | |||
| %the ERROR function. | |||
| % | |||
| %See also QUERY | |||
| ecq.opc; | |||
| ecq.write_unsafe(message); | |||
| ecq.error; | |||
| end | |||
| function write_unsafe(ecq,message) | |||
| if ecq.channel >= 0 | |||
| fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]); | |||
| end | |||
| fprintf(ecq.tcp, message); | |||
| end | |||
| function output = read(ecq) | |||
| %READ Extracts recieved data from the TCP-buffer. | |||
| %This | |||
| if ecq.channel >= 0 | |||
| fprintf(ecq.tcp,'++read'); | |||
| end | |||
| @@ -92,11 +95,6 @@ classdef Equipment < handle | |||
| ecq.error; | |||
| end | |||
| function output = query_unsafe(ecq,message) | |||
| ecq.write_unsafe(message); | |||
| output = read(ecq); | |||
| end | |||
| function errorlist = get.error(ecq) | |||
| for i = 1:20 | |||
| output = ecq.query_unsafe('SYSTem:ERRor?'); | |||
| @@ -111,9 +109,29 @@ classdef Equipment < handle | |||
| end | |||
| end | |||
| end | |||
| end | |||
| methods (Access = protected, Hidden) | |||
| function write_unsafe(ecq,message) | |||
| if ecq.channel >= 0 | |||
| fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]); | |||
| end | |||
| fprintf(ecq.tcp, message); | |||
| end | |||
| function output = query_unsafe(ecq,message) | |||
| ecq.write_unsafe(message); | |||
| output = read(ecq); | |||
| end | |||
| function delete(ecq) | |||
| %DELETE Destructs the current object. | |||
| ecq.unlock; | |||
| Equipment.getTCP(ecq.tcp.RemoteHost,-1); | |||
| end | |||
| end | |||
| methods (Static) | |||
| function tcpobject = getTCP(ipAddress,port) | |||
| persistent tcpconnection; | |||