Explorar el Código

read, write, query, error, (un)lock, functie

keep-around/c5216e76cad262723738e350daf9fd25abbc8ea7
Wouter Horlings hace 8 años
padre
commit
2fc8108e61
Se han modificado 1 ficheros con 41 adiciones y 70 borrados
  1. +41
    -70
      OOequipment/Equipment.m

+ 41
- 70
OOequipment/Equipment.m Ver fichero

@@ -6,27 +6,57 @@ 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)
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?');
end
function idn(ecq)
fprintf(ecq.tcp,['++addr ',num2str(ecq.channel)]);
fprintf(ecq.tcp,'*idn?');
fprintf(ecq.tcp,'++read');
fprintf(fscanf(ecq.tcp));
function unlock(ecq)
end
function lock(ecq)
end
function delete(ecq)
%zorgen dat het device geunlocked is!
%ecq.unlock;
Equipment.getTCP(ecq.tcp.RemoteHost,-1);
end
function write(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)
write(ecq,message);
output = read(ecq);
end
function e = get.error(ecq)
e = ecq.query('SYSTem:ERRor?');
end
end
methods (Static)
function tcpobject = getTCP(ipAddress,port)
@@ -69,63 +99,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

Cargando…
Cancelar
Guardar