|
|
@@ -14,29 +14,37 @@ classdef Equipment < handle |
|
|
|
|
|
|
|
|
methods |
|
|
methods |
|
|
function ecq = Equipment(ipAddress,port,channel) |
|
|
function ecq = Equipment(ipAddress,port,channel) |
|
|
|
|
|
%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. |
|
|
|
|
|
% Name is queried from device via '*IDN?' command. |
|
|
ecq.tcp = Equipment.getTCP(ipAddress,port); |
|
|
ecq.tcp = Equipment.getTCP(ipAddress,port); |
|
|
ecq.locked = false; |
|
|
ecq.locked = false; |
|
|
ecq.channel = channel; |
|
|
ecq.channel = channel; |
|
|
ecq.name = ecq.idn(); |
|
|
ecq.name = ecq.idn(); |
|
|
end |
|
|
end |
|
|
function id = idn(ecq) |
|
|
function id = idn(ecq) |
|
|
id = ecq.query('*idn?'); |
|
|
|
|
|
|
|
|
%IDN Queries identificantion from device via '*IDN?'. |
|
|
|
|
|
id = ecq.query_unsafe('*idn?'); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function clear(ecq) |
|
|
function clear(ecq) |
|
|
ecq.write('*cls'); |
|
|
|
|
|
|
|
|
%CLEAR Sends clear command to device via '*CLS'. |
|
|
|
|
|
ecq.write_unsafe('*cls'); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function opc(ecq) |
|
|
function opc(ecq) |
|
|
ecq.query('*OPC?'); |
|
|
|
|
|
|
|
|
%OPC executes 'operation complete query' to device. |
|
|
|
|
|
%Function holds untill device returns '1'. Must be |
|
|
|
|
|
%used to avoid interrupting busy device. |
|
|
|
|
|
ecq.query_unsafe('*OPC?'); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function unlock(ecq) |
|
|
function unlock(ecq) |
|
|
if ecq.channel >= 0 |
|
|
if ecq.channel >= 0 |
|
|
fprintf(ecq.tcp,'++loc'); |
|
|
fprintf(ecq.tcp,'++loc'); |
|
|
ecq.locked = false; |
|
|
ecq.locked = false; |
|
|
else |
|
|
|
|
|
warning('Device does not support unlocking') |
|
|
|
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
@@ -54,12 +62,17 @@ classdef Equipment < handle |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function delete(ecq) |
|
|
function delete(ecq) |
|
|
%zorgen dat het device geunlocked is! |
|
|
|
|
|
%ecq.unlock; |
|
|
|
|
|
|
|
|
ecq.unlock; |
|
|
Equipment.getTCP(ecq.tcp.RemoteHost,-1); |
|
|
Equipment.getTCP(ecq.tcp.RemoteHost,-1); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function write(ecq,message) |
|
|
function write(ecq,message) |
|
|
|
|
|
ecq.opc; |
|
|
|
|
|
ecq.write_unsafe(message); |
|
|
|
|
|
ecq.error; |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function write_unsafe(ecq,message) |
|
|
if ecq.channel >= 0 |
|
|
if ecq.channel >= 0 |
|
|
fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]); |
|
|
fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]); |
|
|
end |
|
|
end |
|
|
@@ -74,12 +87,29 @@ classdef Equipment < handle |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function output = query(ecq,message) |
|
|
function output = query(ecq,message) |
|
|
write(ecq,message); |
|
|
|
|
|
|
|
|
ecq.opc; |
|
|
|
|
|
output = ecq.query_unsafe(message); |
|
|
|
|
|
ecq.error; |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function output = query_unsafe(ecq,message) |
|
|
|
|
|
ecq.write_unsafe(message); |
|
|
output = read(ecq); |
|
|
output = read(ecq); |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function e = get.error(ecq) |
|
|
|
|
|
e = ecq.query('SYSTem:ERRor?'); |
|
|
|
|
|
|
|
|
function errorlist = get.error(ecq) |
|
|
|
|
|
for i = 1:20 |
|
|
|
|
|
output = ecq.query_unsafe('SYSTem:ERRor?'); |
|
|
|
|
|
errorlist(i,1:(length(output))) = output; |
|
|
|
|
|
%errorcode = regexp(output,'\d*','match','once'); |
|
|
|
|
|
if str2double(regexp(output,'\d*','match','once'))==0 |
|
|
|
|
|
if i>1 |
|
|
|
|
|
warning('Error from device: %s %s',ecq.name,reshape(errorlist(1:i-1,:)',1,[])); |
|
|
|
|
|
ecq.clear; |
|
|
|
|
|
end |
|
|
|
|
|
break; |
|
|
|
|
|
end |
|
|
|
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|