Function Rs = Mtest(H, Outfile)

CODE

Link m-file between DDA application and MWS

Webfun.m

function Webfun(ParList,menuchoice,menuitems,returnfilename)

% DDA application m-file for the link to Matlab Web Server

% Authors Inger Bolin & Maria Borg

% Date: 2002-03-08

%Give the file a static name

sendfile='c:\temp\ABBfile.mat';

%Save all parameters needed for calculations

save(sendfile, 'ParList','menuchoice','menuitems','returnfilename');

%Start the HTML input document

stat = web('http://C4000129/indexphp.php?filename=ABBfile.mat&filepath= C:/temp/ABBfile.mat', '-browser');

Input HTML document

indexphp.php

<html>

<head<title>Drive Dynamics Analyzer Calculation</title</head>

<body background="/icons/bakgrund.jpg">

<img src="/icons/ABB_Logo.gif" width="74" height="29">

<br<br<br<br>

<!--img src="/icons/valsvinkel.jpg" width="200" height="230" align="right"-->

<form enctype="multipart/form-data" method="POST" >

<table bgcolor ="#FFF1A1" class="table" border="1" cellpadding="0" cellspacing="0" width="400">

<tr<td colspan="4" height="23"> <strong> &nbsp;Browse to upload this file:

<?echo $filepath;?</strong</td</tr>

<tr>

<td colspan="2" align="right" height= "23"> <input type="file" name="file" size="30" class="input" </td<br>

</tr>

</table<br>

<p<font color="#000000" size="3" face="Arial">

Click button to send file!

<p<font color="#164781" size="4" face="Arial">

<p<input type="submit" name="Submit" value="Send file"</p</font>

<br>

<p<font color="#000000" size="3" face="Arial">

Please then wait for result file to download</font>

<br>

<?php

if($REQUEST_METHOD == "POST") {

if(($HTTP_POST_FILES['file']['name'])==$filename){

$strPath = "C:/Matlab6p1_web/toolbox/webserver/wsdemos/";

$strFilename = uniqid ("")."_" .$HTTP_POST_FILES['file']['name'];

if (! file_exists($strPath . $strFilename)){

if ((move_uploaded_file($file, $strPath . $strFilename))) {

virtual("/cgi-bin/matweb.exe?mlmfile=mtest" . "&filename=" . $strFilename);

}

else {?<strong<font color="#FF0000" size="3" face="Arial">

File upload error!</strong<?

}

}

}

else {?<strong<font color="#FF0000" size="3" face="Arial">

Attempt to upload the wrong file!</strong<?

}

}?>

</form>

</body>

</html>

MWS application m-file for calculation

mtest.m

function rs = mtest(h, outfile)

% MWS application m-file for the compiled DDA application, advanced calculations

% through a web server

% Authors Inger Bolin & Maria Borg

% Date: 2002-03-08

% Set to MWS directory

cd(h.mldir);

% Save input file to local variable

filename = h.filename;

% Load .mat-file into workspace

load(filename);

% Delete the input file from MWS directory

delete(filename);

% Call to simprocess() for calculation

if isempty(ParList)

data=simprocess('', menuchoice, menuitems, data);

else

data=simprocess(ParList, menuchoice, menuitems);

end

% Call to datahistory()

datahistory(data);

data_history=evalin('base','data_history');

% Make an unique result file using parameter from customer

resfile=returnfilename;

% Save in structure ready for plotting

if exist('data_history')

Session.DataHistory=data_history;

else

error ('Failed updating data_history');

end

% Save workspace to result file

save(resfile,'Session');

% Save to output structure

s.filename = resfile;

s.mlid=h.mlid;

s.mldir=h.mldir;

% Output the output structure to output HTML document

path = which('output.html');

if(nargin == 1)

rs = htmlrep(s, path);

elseif(nargin == 2)

rs = htmlrep(s, path, outfile);

end

Output HTML document

output.html

<html>

<body link="#4A94D5" alink="#426997" vlink="#9A3464">

<br<br<br>

<strong>Result file successfully executed!

<br<br>

<p align="left">Download <a href="$filename$">$filename$</a> to your disc</strong>

</body>

</html>

CONFIGURATION FILES

To connect with MWS matweb.exe requires information stored in matweb.conf

matweb.conf

[mtest]

mlserver=127.0.0.1

mldir=C:/matlab6p1_web/toolbox/webserver/wsdemos

Initial settings for MWS

matlabserver.conf

-m 1

1