Wouter Horlings hace 8 años
padre
commit
370fe834c3
Se han modificado 4 ficheros con 154 adiciones y 15 borrados
  1. +103
    -9
      OOequipment/Channel.m
  2. +15
    -4
      OOequipment/Equipment.m
  3. +8
    -2
      OOequipment/Oscilloscope.m
  4. +28
    -0
      OOequipment/Trigger.m

+ 103
- 9
OOequipment/Channel.m Ver fichero

@@ -3,20 +3,114 @@ classdef Channel
% Detailed explanation goes here
properties
Property1
scope
channelnumber
end
properties (Dependent)
state
coupling
bandwidth
scale
offset
probe
label
end
methods
function obj = Channel(inputArg1,inputArg2)
%CHANNEL Construct an instance of this class
% Detailed explanation goes here
obj.Property1 = inputArg1 + inputArg2;
function ch = Channel(scope,channelnumber)
ch.channelnumber = channelnumber;
ch.scope = scope;
end
function s = get.state(ch)
s = ch.scope.query(ch.CHAN('state?'));
end
function out = get.coupling(ch)
out = ch.scope.query(ch.CHAN('coup?'));
end
function out = get.bandwidth(ch)
out = ch.scope.query(ch.CHAN('band?'));
end
function out = get.offset(ch)
out = ch.scope.query(ch.CHAN('offs?'));
end
function out = get.scale(ch)
out = ch.scope.query(ch.CHAN('scal?'));
end
function out = get.label(ch)
out = ch.scope.query(ch.CHAN('lab?'));
end
function ch = set.state(ch,in)
ch.scope.write(ch.CHANsend('state',in));
end
function ch = set.coupling(ch,in)
ch.scope.write(ch.CHANsend('coup',in));
end
function ch = set.bandwidth(ch,in)
ch.scope.write(ch.CHANsend('band',in));
end
function ch = set.offset(ch,in)
ch.scope.write(ch.CHANsend('offs',in));
end
function ch = set.scale(ch,in)
ch.scope.write(ch.CHANsend('scal',in));
end
function ch = set.label(ch,in)
ch.scope.write(ch.CHANsend('lab',in));
end
function out = frequency(ch)
out = str2double(ch.MEAS('freq'));
end
function out = peak2peak(ch)
out = str2double(ch.MEAS('peak'));
end
function out = period(ch)
out = str2double(ch.MEAS('per'));
end
function out = amplitude(ch)
out = str2double(ch.MEAS('ampl'));
end
function out = mean(ch)
out = str2double(ch.MEAS('mean'));
end
function out = rms(ch)
out = str2double(ch.MEAS('rms'));
end
function out = phase(ch)
out = str2double(ch.MEAS('phas'));
end
end
methods (Hidden, Access = private)
function c = CHAN(ch,string)
c = ['CHAN',num2str(ch.channelnumber),':',string];
end
function c = MEAS(ch,string)
c = ch.scope.query(['MEAS',num2str(ch.channelnumber),':RES:ACT?',string]);
end
function outputArg = method1(obj,inputArg)
%METHOD1 Summary of this method goes here
% Detailed explanation goes here
outputArg = obj.Property1 + inputArg;
function c = CHANsend(ch,string,in)
c = ['CHAN',num2str(ch.channelnumber),':',string,' ',in];
end
end
end

+ 15
- 4
OOequipment/Equipment.m Ver fichero

@@ -23,6 +23,9 @@ classdef Equipment < handle
ecq.locked = false;
ecq.channel = channel;
ecq.name = ecq.idn();
if channel >= 0
ecq.setPrologix;
end
end
function id = idn(ecq)
@@ -85,9 +88,10 @@ classdef Equipment < handle
%This function sends the '++read'-command to the Prologix if
%needed. Will always read the TCP-buffer in matlab.
if ecq.channel >= 0
write_unsafe('++read');
ecq.write_unsafe('++read');
end
output = fscanf(ecq.tcp);
fprintf(['<< ',output]);
end
function output = query(ecq,message)
@@ -120,7 +124,7 @@ classdef Equipment < handle
if i>1 %check for more than one error message.
warning('Error from device: %s %s',ecq.name,reshape(errorlist(1:i-1,:)',1,[]));
end
ecq.clear;
ecq.clear;
break;
end
end
@@ -137,8 +141,10 @@ classdef Equipment < handle
%See also WRITE, QUERY
if ecq.channel >= 0
fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]);
fprintf(['>> ++addr ', num2str(ecq.channel),'\n']);
end
fprintf(ecq.tcp, message);
fprintf(['>> ',message,'\n']);
end
function output = query_unsafe(ecq,message)
@@ -154,10 +160,15 @@ classdef Equipment < handle
end
methods (Access = protected, Hidden)
function setPrologix(ecq)
fprintf(ecq.tcp, '++mode 1'); %set device in controller mode
fprintf(ecq.tcp, '++auto 0'); %disable automatic datapull. this avoids errors on equipment.
end
function delete(ecq)
%DELETE Destructs the current object.
ecq.unlock;
Equipment.getTCP(ecq.tcp.RemoteHost,-ecp.tcp.RemotePort);
Equipment.getTCP(ecq.tcp.RemoteHost,-ecq.tcp.RemotePort);
end
end
@@ -214,7 +225,7 @@ classdef Equipment < handle
function num = forceNum(input)
%FORCENUM Throws an error if the input is not numeric.
if ~isnum(input)
if ~Equipment.isnum(input)
error('Input should be a (single) number.');
end
num = input;


+ 8
- 2
OOequipment/Oscilloscope.m Ver fichero

@@ -1,8 +1,14 @@
classdef Oscilloscope < Equipment
classdef Oscilloscope < Equipment & dynamicprops
%OSCILLOSCOPE Summary of this class goes here
% Detailed explanation goes here
properties
nchannels
horizontalPosition
ch1
ch2
ch3
ch4
end
methods
@@ -11,7 +17,7 @@ classdef Oscilloscope < Equipment
% Detailed explanation goes here
obj@Equipment(ipAddress,port,-1);
for i = 1:nchannels
obj.(['ch',num2str(i)]) = Channel(inputArg1,inputArg2);
obj.(['ch',num2str(i)]) = Channel(obj,i);
end
end


+ 28
- 0
OOequipment/Trigger.m Ver fichero

@@ -0,0 +1,28 @@
classdef Trigger
%TRIGGER Summary of this class goes here
% Detailed explanation goes here
properties
mode
type
source
slope
level
coupling
end
methods
function obj = Trigger(inputArg1,inputArg2)
%TRIGGER 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


Cargando…
Cancelar
Guardar