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
% opts = '--engine=fastest';
%
% optinal:
% optional:
% (ssh only on unix with working ssh client)
% Settings.SSH.host = '<hostname or ip>'
% Settings.SSH.bin = '<path_to_openEMS>/openEMS.sh'
%
% Settings.LogFile = 'openEMS.log'
% Settings.Silent = 0
%
% RunOpenEMS(Sim_Path,Sim_File,opts,Settings)
%
@ -57,13 +58,13 @@ if (isfield(Settings,'SSH') && isunix)
else
append_unix = [];
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)
disp(result);
error('openEMS:RunOpenEMS','ssh openEMS failed!');
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 '/']);
if (stat~=0);
@ -78,8 +79,12 @@ if (isfield(Settings,'SSH') && isunix)
end
else
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);
elseif isfield(Settings,'Silent')
invoke_openEMS(args,[],Settings.Silent);
else
invoke_openEMS(args);
end

View File

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