diff --git a/GUIs/GuiLogger.mlapp b/GUIs/GuiLogger.mlapp index 36f63ca..d4e0f75 100644 Binary files a/GUIs/GuiLogger.mlapp and b/GUIs/GuiLogger.mlapp differ diff --git a/Local/runDiodeLaserScan.m b/Local/runDiodeLaserScan.m index ffe55ad..f2b384d 100644 --- a/Local/runDiodeLaserScan.m +++ b/Local/runDiodeLaserScan.m @@ -1,17 +1,17 @@ %show_in_daq=true function runDiodeLaserScan() - if ~isValidBaseVar('Collector') - runCollector(); - end - Collector = evalin('base','Collector'); + % Get the unique instance of MyCollector + C = MyCollector.instance(); name='DiodeLaserScan'; - if ~ismember(name, Collector.running_instruments) + if ~ismember(name, C.running_instruments) + % Create an instrument instance Instr=DiodeLaserScan('Scope','DPO4034_2','Laser','ECDL850He3',... 'name','DiodeLaserScan'); - addInstrument(Collector, Instr, 'name', name); + % Add instrument to Collector + addInstrument(C, Instr); else warning('DiodeLaserScan is already running') end end diff --git a/Utility functions/App utilities/deleteInstrGui.m b/Utility functions/App utilities/deleteInstrGui.m index 934ecaa..9f270fc 100644 --- a/Utility functions/App utilities/deleteInstrGui.m +++ b/Utility functions/App utilities/deleteInstrGui.m @@ -1,23 +1,38 @@ % Delete Instrument object, clearing the global variable corresponding to % gui name and then delete gui itself function deleteInstrGui(app) %Deletes listeners try lnames=fieldnames(app.Listeners); for i=1:length(lnames) - delete(app.Listeners.(lnames{i})); + try + delete(app.Listeners.(lnames{i})); + catch + fprintf(['Could not delete the listener to ''%s'' ' ... + 'event.\n'], lnames{i}) + end end catch - warning('Unable to delete listeners') end + try - delete(app.Instr); + % Check if the instrument object has appropriate method. This + % is a safety measure to never delete a file by accident if + % app.Instr happens to be a valid file name. + if ismethod(app.Instr, 'delete') + delete(app.Instr); + else + fprintf(['app.Instr of class ''%s'' does not have ' ... + '''delete'' method.\n'], class(app.Instr)) + end catch + fprintf('Could not delete the instrument object.\n') end + try evalin('base', sprintf('clear(''%s'')', app.name)); catch end delete(app) end