On-line Simulations – Advanced Web-enabled services



Download 0.59 Mb.
Page5/7
Date28.05.2018
Size0.59 Mb.
#52346
1   2   3   4   5   6   7

4 Solution

After installing, configuring and learning how MWS works a test program was made. The starting point was to use MWS and that the MWS application should be implemented in the existing DDA application in a suitable way. The predestined way to store the DDA parameters is in .mat-files. According to this the solution to transmit data in files to and from MWS was a natural choice. On the other hand how the file transmission should be done was an open question. The wish was that the transmission should be as automatically as possible in both directions. From this test program the final result has been developed using the prototyping model, step-by-step getting the right design and functionality.


4.1 Installing, configuring and studying MWS


Last summer a trainee, Lisa Gelin, did a pilot study in the MWS. The first task was to take a look at her work; some instructions and a project map with files. As local server to the MWS she had downloaded OmniHTTPD. She gave us some tips, but in the end it turned out to be easier following MWS installation guide in order to get the MWS demo files to run. Finally after a couple of reinstallations the MWS could run the demos properly.
Next step was to study the MWS demo applications and Matlab in order to learn more about the programming. Having contact with Matlab support resulted in advice and more material how to do the programming part.

4.2 Making a test program


This part is divided into three parts; upload a file to the HTML page, establishing communication with MWS and finally get the result file back to the client.
      1. File uploading to a HTML page


One solution, doing a file upload, is to use PHP-script. Installation and configuration of PHP is necessary. Through the following lines of HTML code a file can be uploaded.





Configuring a form for file uploads requires setting two attributes in the tags in addition to use : “POST” and “multipart/form-data” (as in the example above). When the data is sent, the original name of the file is sent to the web server. enctype determines how the form data is encoded. Whenever data is transmitted from one place to another, there need to be an agreed upon means of representing that data.
A PHP-script is then able to move the uploaded file from the web page to a path on the MWS, give the file a unique ID and finally parse the file to MWS. File uploads allows sending an entire file from a client computer to the web server as part of the form input.
Another conceivable solution for file upload is for example to use FTP in combination with Visual Basic. This demands additionally investigations due to the internal data security policy at ABB.
      1. Establish communication with MWS


The standard procedure for establishing communication is this line of HTML code (in the input HTML document)

matweb.exe is a program that resides on the HTTP server and communicates with the MWS. It requires information found in matweb.conf to locate the MWS (which could be running on a different machine). matweb.exe is a client of MWS that uses CGI to get data from HTML forms. It transfers the information to MWS, which invokes matweb.m, which in turn runs the m-file mtest.m from this line of HTML code:

This line sets argument mlmfile to the value mtest. The mlmfile argument contains the name of the Matlab m-file to run. MWS uses the value of the mlmfile obtained from the matweb.m to run the Matlab application. However when a file is going to be uploaded to MWS the form tag must be

This in turn makes it necessary to call matweb.exe in another way than standard procedure. For example using the PHP-function virtual(), which also passes the string &filename to MWS with this line of PHP script:
virtual(“/cgi-bin/matweb.exe?mlmfile=mtest” . “&filename=” . $strFilename);
There were some problems with getting virtual() to run. It turned out to be an Apache specific function, meaning that a change of the original local server for MWS was necessary. After installation and configuration of the Apache server virtual() still did not work, information was found on the official homepage that virtual() did not run under Windows. Since PHP is an open-source code there are some difficulties to get support. Some other functions were tested to substitute virtual(), but none of them worked. Finally, after a lot of effort, the conclusion was that PHP was installed as a CGI-script instead of as a module. After reinstallation of PHP as a module virtual() was finally working.
Another solution was to use a link to start MWS, since this solution resulted in an extra mouse click the usability decreased and was therefore abandoned.
      1. Get a result file back to the client


The main issue in this part was how to get the result file back to the client’s computer. The standard procedure for output from the MWS is showing the result statically in the web browser. The mtest.m function uses the htmlrep command to places the computed values into the output HTML document (toutput.html) using the code
str = htmlrep(s, ‘toutput.html’);
Here s is a Matlab structure containing the results of the mtest computation. htmlrep extracts data from s and replaces variable fields in toutput.html with the results of Matlab computation. The completed toutput.html form is transmitted to the user’s browser.
Presenting the graphics in the browser with this method, there is no way of having a closer look into graphics the way it is possible under Matlab. The best solution for the client would be getting the result file back to his computer and using the client DDA application for showing the result.
One idea of how to get the result file back to the client’s computer, as well as to the server, was to use Java Sockets, but the idea failed because it was not possible to use the Matlab Compiler on files consisting of Java.
Another suggestion was to use GNU Wget, which is a free software package for retrieving files from the World Wide Web using HTTP and FTP, the two most widely used Internet protocols. Using Wget would imply installations at the client side and was therefore abandoned.
A simple solution is to have a link for download, consisting of the result file, in the user’s web browser. This way seemed to be the right way to go.
    1. Implementation in the DDA Application


To make the test program work from the DDA application on the client side a new function was needed. This function, named Webfun() was made to be a link between the DDA application and the test program (MWS). Some changes were also required in other functions in the DDA. The main one, Simulateandplot(), calls Webfun() if any parameter are changed (if calculations are needed by the MWS).
On the server side (ABB) some changes, made by Mattias Olsson, was required to simprocess() and functions called by simprocess(), the main function for simulations. At first the test program did not work running it through the MWS. The debugging part took quite some effort because it was not possible to use the debugger on m-files running through the MWS. The only way to debug simprocess() through MWS was line by line. Finally the problem was found; the MWS did not work if the functions used for simulations contained outputs to the command window in Matlab.
It is necessary that all files used for simulation are located in a hard drive on the same computer as MWS. To have the files in a network demands special settings and these settings requires a high administrator level out of our authority.
    1. Usability


Usability is an important part in all applications having a user interface.
      1. Input and Output HTML documents


Forming the client side interface, the input and output HTML documents, high usability was needed in order to minimise error occurring and make the interface as easy to use as possible. For this purpose default color used in ABBs homepage was chosen for link colors and logotype color. A picture from the DDA application was also inserted as a background into the input document in order for the client to get recognition (see figure 6). To minimise the number of errors in the file upload from the client side the filename is written out in the browse table in the input document. Choosing another file will result in an error message.




  1. The input and output HTML document view


      1. Download 0.59 Mb.

        Share with your friends:
1   2   3   4   5   6   7




The database is protected by copyright ©ininet.org 2024
send message

    Main page