Przeglądaj źródła

errorfunctie uitgebreid, begonnen met comments, Oscilloscope-subclass toegevoegd

keep-around/c5216e76cad262723738e350daf9fd25abbc8ea7
Wouter Horlings 8 lat temu
rodzic
commit
1114ff7f7e
2 zmienionych plików z 64 dodań i 10 usunięć
  1. +40
    -10
      OOequipment/Equipment.m
  2. +24
    -0
      OOequipment/Oscilloscope.m

+ 40
- 10
OOequipment/Equipment.m Wyświetl plik

@@ -14,29 +14,37 @@ classdef Equipment < handle
methods
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.locked = false;
ecq.channel = channel;
ecq.name = ecq.idn();
end
function id = idn(ecq)
id = ecq.query('*idn?');
%IDN Queries identificantion from device via '*IDN?'.
id = ecq.query_unsafe('*idn?');
end
function clear(ecq)
ecq.write('*cls');
%CLEAR Sends clear command to device via '*CLS'.
ecq.write_unsafe('*cls');
end
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
function unlock(ecq)
if ecq.channel >= 0
fprintf(ecq.tcp,'++loc');
ecq.locked = false;
else
warning('Device does not support unlocking')
end
end
@@ -54,12 +62,17 @@ classdef Equipment < handle
end
function delete(ecq)
%zorgen dat het device geunlocked is!
%ecq.unlock;
ecq.unlock;
Equipment.getTCP(ecq.tcp.RemoteHost,-1);
end
function write(ecq,message)
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
@@ -74,12 +87,29 @@ classdef Equipment < handle
end
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);
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


+ 24
- 0
OOequipment/Oscilloscope.m Wyświetl plik

@@ -0,0 +1,24 @@
classdef Oscilloscope < Equipment
%OSCILLOSCOPE Summary of this class goes here
% Detailed explanation goes here
properties
ch1
ch2
end
methods
function obj = Oscilloscope(inputArg1,inputArg2)
%OSCILLOSCOPE Construct an instance of this class
% Detailed explanation goes here
obj.Property1 = inputArg1 + inputArg2;
end
function outputArg = method1(obj,inputArg)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
outputArg = obj.Property1 + inputArg;
end
end
end


Ładowanie…
Anuluj
Zapisz