Highlights from
Embedded Coder Support Package for Green Hills MULTI IDE (R2012b)

image thumbnail

Embedded Coder Support Package for Green Hills MULTI IDE (R2012b)

by

 

Embedded Coder integration for creating models that run directly in Green Hills MULTI IDE

multistartserver(multidir, startupscriptpath, portnum, autoshutdownflag, logtotemp)
function varargout = multistartserver(multidir, startupscriptpath, portnum, autoshutdownflag, logtotemp)
%MULTISTARTSERVER (Private) Starts the IDE Link Service.
%
% See also GHSMULTI, GHSMULTICONFIG.

%   MULTISTARTSERVER(MULTIDIR, STARTUPSCRIPTPATH, PORTNUM, AUTOSHUDOWN,
%   LOGTOTEMP) Starts the IDE Link Service in MULTI(R) 5.0 or higher. 
%   
%   MULTIDIR - directory where MULTI is installed.
%
%   STARTUPSCRIPTPATH - full path name of the startup script file name
%
%   PORTNUM - port on which the server is expected to listen
%
%   AUTOSHUTDOWNFLAG - a boolean value of 'true' or 'false' specifying if
%   the server should shutdown when the last client closes.
%   
%   LOGTOTEMP - (for internal use only).
%
%   Example:
%   multistartserver('c:\ghs\multi50.0\', [matlabroot
%   '\toolbox\idelink\extensions\ghsmulti\scripts\startmwmultistub.py'], 4444, true, true)
%
% See also GHSMULTI, GHSMULTICONFIG.

%   Copyright 2006-2011 The MathWorks, Inc.
%   $Revision: 1.1.6.1 $ 
%   $Date: 2012/04/02 21:36:38 $


if (multidir(end) ~= filesep)
    multidir = [multidir filesep];
end

if exist(multidir, 'dir') ~= 7
   error(message('GHSMULTIEXT:util:DirDoesNotExist', multidir));
end

if exist(multidir, 'dir') ~= 7
   error(message('GHSMULTIEXT:util:DirDoesNotExist', multidir));
end

if (ispc())
    mpythonexename = 'mpythonrun.exe';
else
    mpythonexename = 'mpythonrun';
end
if exist(fullfile(multidir, mpythonexename), 'file') ~= 2
   error(message('GHSMULTIEXT:util:FileDoesNotExist', multidir));
end 

if logtotemp
    tempfilename = ['"' tempname '"'];
    %disp(['#Server output logged to ''' tempfilename '''.']);
else
    tempfilename = ' ';
end

autoshutdown = 'False';
if autoshutdownflag
    autoshutdown = 'True';
end

[filepath filename filext] = fileparts(startupscriptpath);
if ispc()
    %command = [multidir 'mpythonrun -script ' startupscriptpath ' -args ' filepath ' ' num2str(portnum, '%d') ' -prompt no &'];  
    command = ['"' multidir 'mpythonrun" -prompt no -script "' startupscriptpath '" -args "' filepath '" ' num2str(portnum, '%d') ' ' autoshutdown ' ' tempfilename ' &'];
    [s, w] = dos(command);
else
    command = [multidir 'mpythonrun -prompt no -script ' startupscriptpath ' -args ' filepath ' ' num2str(portnum, '%d') ' ' autoshutdown ' ' tempfilename ' &'];
    [s, w] = system(command);
    if (s ~= 0)
       error(message('GHSMULTIEXT:util:ErrorStartingService'));
    end     
end    

switch(nargout)
    case 1,
        varargout(1) = {tempfilename};
    otherwise,
        if logtotemp
            disp(['#Server output logged to ''' tempfilename '''.']);
        end
end

Contact us