ソースを参照

added debug mode

publish
Wouter Horlings 8年前
コミット
c1f1a0103c
1個のファイルの変更17行の追加3行の削除
  1. +17
    -3
      OOequipment/subfiles/Equipment.m

+ 17
- 3
OOequipment/subfiles/Equipment.m ファイルの表示

@@ -11,6 +11,9 @@ classdef Equipment < handle
properties (Dependent, SetAccess=private) properties (Dependent, SetAccess=private)
error error
end end
properties (Hidden)
debugbool
end
methods methods
function ecq = Equipment(ipAddress,port,channel) function ecq = Equipment(ipAddress,port,channel)
@@ -23,6 +26,7 @@ classdef Equipment < handle
ecq.locked = false; ecq.locked = false;
ecq.channel = channel; ecq.channel = channel;
ecq.name = ecq.idn(); ecq.name = ecq.idn();
ecq.debugbool = false;
if channel >= 0 if channel >= 0
ecq.setPrologix; ecq.setPrologix;
end end
@@ -45,6 +49,10 @@ classdef Equipment < handle
ecq.write_unsafe('*rst'); ecq.write_unsafe('*rst');
end end
function debug(ecq)
ecq.debugbool = ~ecq.debugbool;
end
function flush(ecq) function flush(ecq)
flushinput(ecq.tcp); flushinput(ecq.tcp);
flushoutput(ecq.tcp); flushoutput(ecq.tcp);
@@ -142,7 +150,9 @@ classdef Equipment < handle
ecq.write_unsafe('++read'); ecq.write_unsafe('++read');
end end
output = fscanf(ecq.tcp); output = fscanf(ecq.tcp);
fprintf(['<< ',output]);
if ecq.debugbool
fprintf(['<< ',output]);
end
end end
function output = query(ecq,message) function output = query(ecq,message)
@@ -196,10 +206,14 @@ classdef Equipment < handle
%See also WRITE, QUERY %See also WRITE, QUERY
if ecq.channel >= 0 if ecq.channel >= 0
fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]); fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]);
fprintf(['>> ++addr ', num2str(ecq.channel),'\n']);
if ecq.debugbool
fprintf(['>> ++addr ', num2str(ecq.channel),'\n']);
end
end end
fprintf(ecq.tcp, message); fprintf(ecq.tcp, message);
fprintf(['>> ',message,'\n']);
if ecq.debugbool
fprintf(['>> ',message,'\n']);
end
end end
function write_noerror(ecq,message) function write_noerror(ecq,message)


読み込み中…
キャンセル
保存