From c1f1a0103c2fde83cd3b7726e6e39a127ff96ff1 Mon Sep 17 00:00:00 2001 From: Wouter Horlings Date: Sat, 9 Dec 2017 15:47:36 +0100 Subject: [PATCH] added debug mode --- OOequipment/subfiles/Equipment.m | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/OOequipment/subfiles/Equipment.m b/OOequipment/subfiles/Equipment.m index d5002df..332fc35 100644 --- a/OOequipment/subfiles/Equipment.m +++ b/OOequipment/subfiles/Equipment.m @@ -11,6 +11,9 @@ classdef Equipment < handle properties (Dependent, SetAccess=private) error end + properties (Hidden) + debugbool + end methods function ecq = Equipment(ipAddress,port,channel) @@ -23,6 +26,7 @@ classdef Equipment < handle ecq.locked = false; ecq.channel = channel; ecq.name = ecq.idn(); + ecq.debugbool = false; if channel >= 0 ecq.setPrologix; end @@ -45,6 +49,10 @@ classdef Equipment < handle ecq.write_unsafe('*rst'); end + function debug(ecq) + ecq.debugbool = ~ecq.debugbool; + end + function flush(ecq) flushinput(ecq.tcp); flushoutput(ecq.tcp); @@ -142,7 +150,9 @@ classdef Equipment < handle ecq.write_unsafe('++read'); end output = fscanf(ecq.tcp); - fprintf(['<< ',output]); + if ecq.debugbool + fprintf(['<< ',output]); + end end function output = query(ecq,message) @@ -196,10 +206,14 @@ classdef Equipment < handle %See also WRITE, QUERY if ecq.channel >= 0 fprintf(ecq.tcp,['++addr ', num2str(ecq.channel)]); - fprintf(['>> ++addr ', num2str(ecq.channel),'\n']); + if ecq.debugbool + fprintf(['>> ++addr ', num2str(ecq.channel),'\n']); + end end fprintf(ecq.tcp, message); - fprintf(['>> ',message,'\n']); + if ecq.debugbool + fprintf(['>> ',message,'\n']); + end end function write_noerror(ecq,message)