matlab interface: added option 'silent' to RunOpenEMS.m

pull/1/head
Sebastian Held 2010-07-20 11:38:06 +02:00
parent e5930c7774
commit 7601a1fc9d
2 changed files with 27 additions and 8 deletions

View File

@ -8,12 +8,13 @@ function RunOpenEMS(Sim_Path, Sim_File, opts, Settings)
% Sim_File = 'helix.xml'; %should be created by WriteOpenEMS % Sim_File = 'helix.xml'; %should be created by WriteOpenEMS
% opts = '--engine=fastest'; % opts = '--engine=fastest';
% %
% optinal: % optional:
% (ssh only on unix with working ssh client) % (ssh only on unix with working ssh client)
% Settings.SSH.host = '<hostname or ip>' % Settings.SSH.host = '<hostname or ip>'
% Settings.SSH.bin = '<path_to_openEMS>/openEMS.sh' % Settings.SSH.bin = '<path_to_openEMS>/openEMS.sh'
% %
% Settings.LogFile = 'openEMS.log' % Settings.LogFile = 'openEMS.log'
% Settings.Silent = 0
% %
% RunOpenEMS(Sim_Path,Sim_File,opts,Settings) % RunOpenEMS(Sim_Path,Sim_File,opts,Settings)
% %
@ -57,13 +58,13 @@ if (isfield(Settings,'SSH') && isunix)
else else
append_unix = []; append_unix = [];
end end
status = unix(['ssh ' Settings.SSH.host ' "cd /tmp/' ssh_work_path ' && ' Settings.SSH.bin ' ' Sim_File ' ' opts '"' append_unix]) status = unix(['ssh ' Settings.SSH.host ' "cd /tmp/' ssh_work_path ' && ' Settings.SSH.bin ' ' Sim_File ' ' opts '"' append_unix]);
if (status~=0) if (status~=0)
disp(result); disp(result);
error('openEMS:RunOpenEMS','ssh openEMS failed!'); error('openEMS:RunOpenEMS','ssh openEMS failed!');
end end
disp(['Remote simulation done... copying back results and cleaning up...']); disp( 'Remote simulation done... copying back results and cleaning up...' );
[stat, res] = unix(['scp -r ' Settings.SSH.host ':/tmp/' ssh_work_path '/* ' pwd '/']); [stat, res] = unix(['scp -r ' Settings.SSH.host ':/tmp/' ssh_work_path '/* ' pwd '/']);
if (stat~=0); if (stat~=0);
@ -78,8 +79,12 @@ if (isfield(Settings,'SSH') && isunix)
end end
else else
args = [Sim_File ' ' opts]; args = [Sim_File ' ' opts];
if isfield(Settings,'LogFile') if isfield(Settings,'LogFile') && isfield(Settings,'Silent')
invoke_openEMS(args,Settings.LogFile,Settings.Silent);
elseif isfield(Settings,'LogFile')
invoke_openEMS(args,Settings.LogFile); invoke_openEMS(args,Settings.LogFile);
elseif isfield(Settings,'Silent')
invoke_openEMS(args,[],Settings.Silent);
else else
invoke_openEMS(args); invoke_openEMS(args);
end end

View File

@ -1,5 +1,5 @@
function invoke_openEMS( opts , logfile) function invoke_openEMS( opts, logfile, silent )
% function invoke_openEMS( opts ) % function invoke_openEMS( opts, logfile, silent )
% %
% internal method to invoke openEMS, use RunOpenEMS instead % internal method to invoke openEMS, use RunOpenEMS instead
% %
@ -12,6 +12,16 @@ function invoke_openEMS( opts , logfile)
if nargin < 1 if nargin < 1
error 'specify the xml file to simulate' error 'specify the xml file to simulate'
end end
if nargin < 3
silent = 0;
end
if (nargin < 2) || isempty(logfile)
if isunix
logfile = '/dev/null';
else
logfile = 'nul:';
end
end
% opts = [opts ' --disable-dumps']; % opts = [opts ' --disable-dumps'];
% opts = [opts ' --debug-material']; % opts = [opts ' --debug-material'];
@ -31,8 +41,12 @@ end
command = [openEMS_Path ' ' opts]; command = [openEMS_Path ' ' opts];
if (isunix && nargin>1) if ~silent
command = [command ' 2>&1 | tee ' logfile]; if (isunix && nargin>1)
command = [command ' 2>&1 | tee ' logfile];
end
else
command = [command ' > ' logfile ' 2>&1'];
end end
disp( ['invoking openEMS simulator: ' command] ); disp( ['invoking openEMS simulator: ' command] );