Final-report - application - mirror world - Chris Lesso

advertisement
Term Project – Final Report
CSCE 4313 Programming Languages – Fall 2008
Mirroring Positional Data into Second Life
Chris Lesso
Applications Team – Mirror Worlds
Overview: Background
I have worked to build the services that reflect real world data. This portion involves several
different layers of processes in order to place real time data within reach of the virtual world.
These layers included:
1. Reading the information (ITCS antenna array)
2. Storing data in an accessible database (Scanning Logs and writing to MySQL)
3. Creating a secure method of querying this information (Proxy Web service)
4. Building the back-end portion of the middleware (PHP/MySQL server)
Research & Development
Understanding the lowest layer, the ITCS antenna array, was the most time consuming part of
this project. Fortunately, I was eventually able to meet with an engineer who had some
knowledge of the system. This meeting was very beneficial since learned how to retrieve the
updated tag information from the ITCS software.
In the current version of the ITCS software, the data does not update the tables within the
MySQL database. Initially, I found this to be a problem; I could see no way of getting real data.
Fortunately, the newest version of ITCS allows data to be written to a log file. This file, a CSV
formatted file, will allow a simple background service to read the data and update a database.
Since the ITCS computer is running Windows, I chose to develop code for this service using the
.NET framework. This framework has many convenient features for creating Windows based
controls and services.
This Windows based service, the “ITCS to DB” service, can be executed on any computer with
updated copies of the CSV file; however, the computer running this program must have a
MySQL server instance running with the same configuration as the ITCS computer (*see MySQL
server configuration below)
In operation, the ITCS to DB program, polls a directory and triggers events at a specific interval.
Currently, it is not necessary to change any settings before running the program. The program
will automatically pick up the most recent CSV file created by the ITCS system. However, it is
necessary that one turn on the log to file option when initiating a scan to allow the ITCS software
to create a new CSV file. It is not necessary to restart the ITCS to DB program between scans; it
will automatically discover that its current file is not being updated and scan for a newer file.
Scans, however, must be initiated manually as there is no current method to trigger a scan
remotely; I do believe this is possible in the future.
Term Project – Final Report
CSCE 4313 Programming Languages – Fall 2008
In order to connect query the database without having to connect to the database, I have also
constructed a simple Web Service. This service allows external systems to execute stored
procedures on the database safely (see Web Service Description below). Though I have not been
able to set up a successful meeting with the RFID lab’s network technician, I believe they may
be able to make some simple adjustments to their firewall possibly allowing an external client to
access this service directly. If this is not possible, I have also considered that we may at least be
able to forward a copy of the ITCS CSV log file to another computer which will run the windows
service. This will be necessary if we need an additional IP address to access the RFID center; this
depends on their network configuration. Of course, depending on their configuration, it is also
possible to connect directly to the database. The current MySQL connection port is the standard
3306. With simple port forwarding it is possible to have both a connection to a web service
interface as well as a direct database connection.
Additionally, in future versions, I would like to create an option to simply forward a copy of the
CSV file to another computer rather than process it. This would allow another instance of the
ITCS to DB program to operate off site of the ITCS computer. The offsite computer would scan
the incoming file using the same program. This modification could be made quickly by adding
an FTP module. There are several advantages to this method. It would require less configuration
of the firewall, utilize less resource on the ITCS computer, and allow a central database to work
for the middleware. The central database would also contain the information related to the
objects within the virtual store as well as other data.
Technical Details
MySQL Server Configuration
As configured now, the ITCS to DB service requires an instance of MySQL server must be
configured on the local computer. A database catalog with the name “mirror_world” must exist
and contain a table named “tag_locations”. The following SQL command will create the table.
CREATE TABLE `mirror_world`.`tag_locations` (
`ID`
VARCHAR(64) NOT NULL COMMENT 'The RFID tag',
`Xpos`
VARCHAR(45) DEFAULT 0,
`Ypos`
VARCHAR(45) DEFAULT 0,
`Zpos`
VARCHAR(45) DEFAULT 0,
`Active`
BOOLEAN NOT NULL DEFAULT 0
COMMENT 'Updated for each item',
`time_last_active` DATETIME DEFAULT '2008/01/01',
PRIMARY KEY (`ID`))
ENGINE = MyISAM; *
*ENGINE = InnoDB (alternate configuration)
Web Service Description
In order to run this web service, the MySQL database must be configured properly (see above)
Also, the computer must have a web site service running (IIS 6) and the computer’s local
firewall port must be open for whichever port the web site is configured on. Consuming this web
site involves connecting to the WSDL description. Currently this service is using a SOAP
Term Project – Final Report
CSCE 4313 Programming Languages – Fall 2008
protocol. To learn how to connect to this service investigate “how to consume a SOAP web
service in (your language)”. Here is an example of how to consume a web service in PHP.
Example:
<?php
require_once ‘nusoap.php’
//connect to the web service description
$soap = new soapclient(http://localhost/WebSite1/MW_data.asmx?wsdl,
true);
//create a proxy class of the service
$proxy = $soap->getProxy();
//a call
$result = $proxy->GetIDs();
?>
A sample of the XML definitions: for the GetLocationByID(string ID) method:
(A full service description for each available method can be seen by entering the web service
address in a browser ie http://localhost/WebSite1/MW_data.asmx)
SOAP 1.2
The following is a sample SOAP 1.2 request and response. The placeholders shown need to be
replaced with actual values.
POST /WebSite1/MW_data.asmx HTTP/1.1
Host: localhost
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetLocationByID xmlns="http://Mirror_World.org/">
<ID>string</ID>
</GetLocationByID>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<GetLocationByIDResponse xmlns="http://Mirror_World.org/">
<GetLocationByIDResult>
<ID>string</ID>
<X>string</X>
<Y>string</Y>
<Z>string</Z>
Term Project – Final Report
CSCE 4313 Programming Languages – Fall 2008
</GetLocationByIDResult>
</GetLocationByIDResponse>
</soap12:Body>
</soap12:Envelope>
The HTTP post protocols: (second life supports this protocol)
The following is a sample HTTP POST request and response. The placeholders shown need to
be replaced with actual values.
POST /WebSite1/MW_data.asmx/GetIDs HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfString xmlns="http://Mirror_World.org/">
<string>string</string>
<string>string</string>
</ArrayOfString>
.NET Programming info
I created these programs using Visual Studio 2005 using the .NET framework. The primary
language used is VB for no reason other than that I am used to it. However, any modifications
may be in any .NET language ie. C#. I have separated most of the components of this project
into separate modules. This should allow for easy modification without having to alter other
modules.
I would like to make a note about the folders contained in the MW.zip file. In order to edit the
web service project “WebSite1” the folder structure must remain the intact. The csv2db folder
contains all of the modules for the CSV reader service; this folder is portable and may be moved
around without affecting the project’s links.
Download