Переглянути джерело

Merge branch 'master' of https://git.scintilla.utwente.nl/wouterh/Matlab-Prologix-scripts.git

keep-around/c5216e76cad262723738e350daf9fd25abbc8ea7
Mickey Derks 8 роки тому
джерело
коміт
f84467fccb
3 змінених файлів з 57682 додано та 71 видалено
  1. +57556
    -0
      Manuals/Scope/RTB_UserManual_en_04.pdf
  2. +102
    -71
      OOequipment/Equipment.m
  3. +24
    -0
      OOequipment/Oscilloscope.m

+ 57556
- 0
Manuals/Scope/RTB_UserManual_en_04.pdf
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 102
- 71
OOequipment/Equipment.m Переглянути файл

@@ -6,27 +6,113 @@ classdef Equipment < handle
name
tcp
channel
%lock
locked
end
properties (Dependent, SetAccess=private)
error
end
methods
function ecq = Equipment(name,ipAddress,port,channel)
ecq.name = name;
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)
%IDN Queries identificantion from device via '*IDN?'.
id = ecq.query_unsafe('*idn?');
end
function clear(ecq)
%CLEAR Sends clear command to device via '*CLS'.
ecq.write_unsafe('*cls');
end
function opc(ecq)
%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;
end
end
function idn(ecq)
fprintf(ecq.tcp,['++addr ',num2str(ecq.channel)]);
fprintf(ecq.tcp,'*idn?');
fprintf(ecq.tcp,'++read');
fprintf(fscanf(ecq.tcp));
function lock(ecq)
if ecq.channel >= 0
fprintf(ecq.tcp,'++llo');
ecq.locked = true;
else
warning('Device does not support locking')
end
end
function beep(ecq)
ecq.write('SYST:BEEP')
end
function delete(ecq)
%zorgen dat het device geunlocked is!
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
fprintf(ecq.tcp, message);
end
function output = read(ecq)
if ecq.channel >= 0
fprintf(ecq.tcp,'++read');
end
output = fscanf(ecq.tcp);
end
function output = query(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 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
methods (Static)
function tcpobject = getTCP(ipAddress,port)
@@ -57,6 +143,10 @@ classdef Equipment < handle
end
end
function bool = isnum(input)
bool = isnumeric(input)&&isscalar(input);
end
function iptest(ipAddress)
validip = regexp(ipAddress,'^(?:(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]))$', 'once');
if isempty(validip)
@@ -69,63 +159,4 @@ classdef Equipment < handle
structname = ['ip',ipmatch];
end
end
end

% classdef BankAccount < handle
% properties (Access = ?AccountManager)
% AccountStatus = 'open'
% end
% properties (SetAccess = private)
% AccountNumber
% AccountBalance
% end
% properties (Transient)
% AccountListener
% end
% events
% InsufficientFunds
% end
% methods
% function BA = BankAccount(accNum,initBal)
% BA.AccountNumber = accNum;
% BA.AccountBalance = initBal;
% BA.AccountListener = AccountManager.addAccount(BA);
% end
% function deposit(BA,amt)
% BA.AccountBalance = BA.AccountBalance + amt;
% if BA.AccountBalance > 0
% BA.AccountStatus = 'open';
% end
% end
% function withdraw(BA,amt)
% if (strcmp(BA.AccountStatus,'closed')&& BA.AccountBalance <= 0)
% disp(['Account ',num2str(BA.AccountNumber),' has been closed.'])
% return
% end
% newbal = BA.AccountBalance - amt;
% BA.AccountBalance = newbal;
% if newbal < 0
% notify(BA,'InsufficientFunds')
% end
% end
% function getStatement(BA)
% disp('-------------------------')
% disp(['Account: ',num2str(BA.AccountNumber)])
% ab = sprintf('%0.2f',BA.AccountBalance);
% disp(['CurrentBalance: ',ab])
% disp(['Account Status: ',BA.AccountStatus])
% disp('-------------------------')
% end
% end
% methods (Static)
% function obj = loadobj(s)
% if isstruct(s)
% accNum = s.AccountNumber;
% initBal = s.AccountBalance;
% obj = BankAccount(accNum,initBal);
% else
% obj.AccountListener = AccountManager.addAccount(s);
% end
% end
% end
% end
end

+ 24
- 0
OOequipment/Oscilloscope.m Переглянути файл

@@ -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


Завантаження…
Відмінити
Зберегти