BurtonPaper07

grapedraughtΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

81 εμφανίσεις

Development of MATLAB and Google Earth Components for the TCASE Framework

Northrop

Grumman & The TJHSST Computer Systems Lab

July 2006
-
January 2007

Lee R. Burton

Christopher D. Demaree


Abstract


This paper describes the the development of two
separate co
mponents for the TASC Component
Architecture and Simulation Environment
(TCASE) framework. One is the development of
a MATLAB web service in which MATLAB is
made accessible over the network by a Java web
service via XML service calls. The other is the
de
velopment of a prototype Google Earth
visualization service that currently has basic
three dimensional display and animation
features.


1 Introduction


MATLAB is a matrix math computing
environment and programing language. We have
made it available to the
TCASE framework so
that other components can preform MATLAB
operations without directly interfacing with
MATLAB, or even knowing where the
MATLAB operations are being preformed.


Google Earth is a visualization tool that allows
for arbitrary objects to b
e placed inside its
environment via KML. KML is a set of XML
guidelines put out by Google. Google Earth is
being explored as a possible three dimensional
visualization tool for the TCASE framework.


2 Background


The development of these components for
T
CASE framework is to expand an existing set
of components. MATLAB was used previously
to do offline analysis (such as create view sheds),
but this MATLAB component abstracts the way
that other services make can use of MATLAB
with interactive calls.


Curr
ently the TCASE framework is making use
of End
-
to
-
end Modeling PROving and
Visualization Environment (EMProVE) to do 2d
visualization. TCASE's predecessor, EENM
made use of nVisualizer from nanoTITAN, a 3
-
d
network visualization provider.


3 Creation of a

MATLAB Web service


The creation of a MATLAB web service was
done with the help of three existing pieces of
software: Apache Axis 2, Apache Tomcat, and
JMatLink. Axis 2 is a SOAP engine that we are
running on top of Tomcat, Apache's serverlet and
JSP imp
lementation. JMatLink connects Java to
MATLAB by using the Java Native Interface
(JNI). The MATLAB web service was created
by writing an Axis 2 application that used
JMatLink to communicate with MATLAB via its
JNI to MATLAB:

TCASE Framework <
-
> SOAP Traf
fic <
-
>
Tomcat <
-
> Axis 2 <
-
> MATLAB Service <
-
>
JMatLink <
-
> JNI <
-
> MATLAB


The Axis 2 SOAP engine is not fully
documented, but existing TCASE classes
allowed for easier data transport through Axis 2.
The TCASE envelope class allows a developer to
encap
sulate other objects into messages. It
handles the serialization and deserialization of
data for the service. After figuring out the quirks
of the preexisting envelope class it was fairly
simple to start to encapsulate Java Array and
Java Image objects i
nside of envelopes. All of
the methods in the MATLAB service return
something, so they are all of RawXMLINOut
Axis 2 messageReceiver type. We decided it
would be better to confirm the successful
execution of each method, even if it wouldn't
normally fail

or send data back. The methods in
the MATLAB web service are similar to that of
JMatLink with four additional methods
(Appendix A). One method is t_active, which
gives the current status of the MATLAB service.
The other three methods are related to the

transportation of Mfiles (MATLAB language
file). The t_getMFileLocation and the
t_getMFileLocation methods allow the
framework to get and set the directory in which
Mfiles are stored (hopefully where MATLAB
knows to look for the files). t_putMFile al
lows
for the framework to send the MATLAB service
a Mfile to put in the MFileLocation. This allows
more complex MATLAB code to be executed.


Currently the MATLAB service allows for:

* Putting M files into a specified location by
sending the full text to t
he service (t_putMFile)

* Putting Java arrays into MATLAB

* Getting MATLAB arrays into Java

* Getting MATLAB figures into Java Image
objects

* Putting Java Scalars into MATLAB

* Getting MATLAB scalars into Java

* Evaluating a MATLAB command (string)

* Gett
ing the MATLAB Output buffer


The MATLAB web service is meant primary as a
backend application, and all job
management/queuing of jobs will be handled by
the framework (with the help of the t_active
function).


3.1 Testing the MATLAB service without the
TC
ASE Architecture


To test the MATLAB service, we implemented a
test client that will eventually be developed into
code for the framework. The test code sets
MfileLocation, puts an Mfile, and then runs the
mfile. It then pulls the output (in this case the

surf(peaks) in Appendix B).


4 Prototyping of a Google Earth Visualization
Service


The first steps to prototyping a Google Earth
Visualization service was learning how to
interact with Google Earth, and Google
facilitates this with the KML XML guideli
nes.
Our testing Google earth code was mostly hand
-
written/generated KML with changing variables
to facilitate animation.


4.1 PHP/Apache Test Code & KML


KML allows for updates to be sent to update an
initial KML (see init.kml in Appendix D). To
have

these updates come automatically we load
in a KML with two “NetworkLink”'s one that
points to our init.kml, and one that points to our
PHP updater script (see tcase.kml in Appendix
D). The first thing our PHP updater script does
is create all the objects

for the simulation through
an Update and Create call:

<NetworkLinkControl>

<Update>


<Create>


<Document targetId="tcase">


<Placemark id="uav0">


<name>UAV</name>

On the next poll of the PHP updater, the updater
change
s the values for things such as altitude,
orientation, lat, lon to animate the objects. We
have successfully run this with 20 objects
moving at a 0.1 second update interval, and we
suspect that it will scale fairly well. It moves the
objects with a Updat
e and a Change call:

<Update>


<Change>


<Location targetId="uav0
-
loc">


<longitude><?php echo
$a;?></longitude>

Only objects with ID's can be changed, so we
gave pretty much everything an ID. As far as we
can tell, subobjects

(such as location object of the
UAV object) can not be changed without having
their own ID. At the end of a given a simulation,
the PHP script removes all the objects it created
in the beginning. A front end made with PHP/
AJAX allowed for control of t
he simulation
inside Google Earth via its integrated web
browser. Currently it allows for control of the
speed at which the objects move, and the time
step.


4.2 Google Earth KML Auto
-
generation

Currently Google doesn't provide a KML
specification, but ou
r XML data binding
solution, JiBX, doesn't need a XML
specification. JiBX makes use of binding files,
and allows you to “marshall” and “unmarshall”
XML files. The binding file is a translation of a
Java class representation of the data and the
XML repres
entation of the data. We have been
working on a JiBX binding file for KML so that
we can auto
-
generate entire KML documents
with Java and JiBX just by marshalling from a
Java class. The Google Earth Java class being
developed would be populated with data

by
asking the TCASE framework for XML updates.
The TCASE framework already has JiBX
binding, so after the Google Earth bindings are
completed, all that needs to be done is a
translation from the TCASE Java class to the
Google Earth Java class. The final

layout of the
Google Earth visualization service would look
something like this:

MySQL with state info <
-
> Framework <
-
>
Google Earth component <
-
> Google Earth


5 Conclusions


The Google Earth component will need to be
able to quickly serve Google Earth'
s requests,
while also, loading/preloading data from the
framework. It may be a good idea to have two
threads, and a separate data store for the
component, so that one thread serves Google
earth while the other adds more data to the data
store from the fr
amework.


The MATLAB service will be useful for other
services to use, but may need additional features
to be implemented. It may be possible to support
animations if we can find a good way to quickly
take Java Image's and encode them into a video
strea
m.


6 References and Appendixes


EENM Whitepaper (ARN:
1559424
)

Apache Axis 2 Documentation

Apache Tomcat Documentation

JMatLink Documentation

6.1 Appendix A: Annotated MATLAB services.xml


<serviceGroup name="Matlab">


<service name="MatlabService" scope=
"application">



<description>Matlab Service</description>



<parameter name="ServiceClass" locked="false">




com.tasc.matlab.MatlabService



</parameter>



<operation name="t_active"><!
--

Returns whether or not it is currently active
--
>




<messageRecei
ver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engEvalString"><!
--

Evaluate a string in MATLAB
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engClose"><!
--

Close MATLAB Engine
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engOpen"><!
--

Open MATLAB Engine
--
>




<messageReceiver
class="org.apache
.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engGetFigure"><!
--

Get a Figure from MATLAB (as a Java
Image)
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<ope
ration name="t_engGetArray"><!
--

Get an array from MATLAB
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engPutArray"><!
--

Put an array into MATLAB
--
>




<messageReceiver
clas
s="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_putMFile"><!
--

Put an Mfile into a directly in the path of
MATLAB
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



<
/operation>



<operation name="t_setMFileLocation"><!
--

Set the directory to put MFiles
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_getMFileLocation"><!
--

Get the directory Mf
iles are put into
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engGetCharArray"><!
--

Get a character Array from MATLAB
--
>




<messageReceiver
class="org.apache.axis2.receiver
s.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engGetOutputBuffer"><!
--

Get MATLAB's output buffer
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>



<operation name="t_engGetScal
ar"><!
--

Get a scalar from MATLAB
--
>




<messageReceiver
class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver" />



</operation>


</service>

</serviceGroup>




6.2 Appendix B: Example MATLAB Figure


6.3 Appendix C: Google Earth Screenshots

























6.4 Appendix D:

init.kml:

<?xml version="1.0" encoding="UTF
-
8"?>

<kml xmlns="http://earth.google.com/kml/2.1">

<Document id="tcase">

</Document>

</kml>

tcase.kml:

<?xml version="1.0" encoding="UTF
-
8"?>

<kml xmlns="http://earth.google
.com/kml/2.1">

<Document>

<NetworkLink>


<name>TCASESCN</name>


<description>TCASE Scenario</description>


<Link>


<href>http://mcp/~lee/init.kml</href>


</Link>

</NetworkLink>

<NetworkLink>


<name>TCASESCN UPDATER</name>


<descrip
tion>TCASE Scenario UPDATER</description>


<Link id="updater">


<href>http://mcp/~lee/scn.php</href>


<refreshMode>onInterval</refreshMode>


<refreshInterval>0.1</refreshInterval>


</Link>

</NetworkLink>

</Document>

</kml>