from
Ideal Rankine Cycle Builder for .NET Component in C# Application
by David Forstot
Calculate thermodynamic properties of ideal Rankine cycle: MATLAB and C# - Using MWStructArray.
|
| build_mcode.m |
%% Build Script
% This script will build the mcode for the Rankine Web demo.
%
% This demo shows .NET deployment of MATLAB using Builder for .NET.
% See the included readme.doc for more information.
%
% The bulk of the demo is written in C# and referenced in the
% Visual Studio project. The example MATLAB code used,
% "rankine.m," was created my Mike Agostini.
%
% David Forstot
% Copyright 2006 The MathWorks, Inc.
% This code is provided for example only.
%% Determine path names
workdir = pwd();
basedir = fileparts(workdir);
outdir = fullfile(basedir, 'Output');
dnetdir = fullfile(workdir, 'rankine_dotnet');
%% Determine file names
mfile_rankine = fullfile(workdir, 'rankine.m');
mfile_steam = fullfile(workdir, 'XSteam.m' );
dnetdll = fullfile(dnetdir, 'rankine_dotnet.dll');
%% Verify mfiles can be found
if (exist(mfile_rankine, 'file') ~= 2)
error('Unable to find mfile rankine.m');
end
if (exist(mfile_steam, 'file') ~= 2)
error('Unable to find mfile XSteam.m');
end
%% Create directories if needed
if (exist(outdir, 'dir') ~= 7)
mkdir(outdir);
end
if (exist(dnetdir, 'dir') ~= 7)
mkdir(dnetdir);
end
%% Build .NET Assembly
disp('Compiling .NET Assembly...');
eval(['mcc -d ' dnetdir ' -W ''dotnet:rankine_dotnet,' ...
'rankine_dotnet_class,0.0,private'' -T link:lib ' mfile_rankine]);
% verify assembly was created
if ( (exist(dnetdll, 'file') ~= 2) )
error('Failed to successfully compile .NET assembly.');
else
fprintf('\tDone\n');
end
%% Copy .NET Assembly to Output
Copy1 = copyfile(dnetdll, fullfile(outdir, 'rankine_dotnet.dll'));
if Copy1 ~= 1
error('Unable to copy .NET Assembly to output directory.');
end
%% Clean up
clear Copy1 basedir dnetdir dnetdll ...
mfile_rankine mfile_steam outdir workdir;
|
|
Contact us at files@mathworks.com