Integrate GPS adapters using WebSphere RFID solutions, Part 1: Use the RFID Device Developer Kit and WebSphere RFID infrastructure to get connected

In the first of this two-part series, you'll learn how to implement a GPS adapter on an IBM® RFID edge controller using the WebSphere® Studio Device Developer RFID Device Development Kit, and how to verify it on the IBM RFID middleware toolkit using a GPS simulator.

Share:

Rebecca Chen, Staff Software Engineer, IBM

Rebecca Chen photoRebecca Chen is a Staff Software Engineer at the IBM China Software Development Lab in Taipei, Taiwan. She joined IBM in 2000. Rebecca has experience in software design, development, and testing. She holds a Masters degree in Computer Science and Information Engineering from National Dong Hwa University. Her areas of expertise include the Global Security Toolkit, WebSphere Application Server, WebSphere Everyplace Access, WebSphere Everyplace Deployment, pervasive computing, and networking. She currently focuses on IBM IMS (IP Multimedia Subsystem) Solutions. She has a Cisco Certified Network Associate (CCNA) certification and is also a certified Project Management Professional.



Rick Wu (rickwu@tw.ibm.com), Software Engineering Manager, IBM

Rick Wu photoRick Wu is a Software Engineering Manager at IBM China Software Development in Taipei, Taiwan. His areas of expertise include pervasive computing, telecom solutions, and RFID solutions. He is now working on Lotus Expeditor development and test.



13 September 2006

Also available in Russian

Overview

The IBM RFID Device Development Kit (hereafter called RFID DDK) is a powerful toolkit for developing RFID reader adapters on IBM RFID middleware solutions. It includes sample projects and a new runtime device simulator that allows you to execute agents based on the templates without the hardware previously required. In this article, you'll get an introduction to IBM RFID middleware, which includes the WebSphere RFID Device Infrastructure and WebSphere Premises Server. You'll learn a little about the RFID DDK and go step-by-step through the process of developing a GPS adapter and running it on the IBM RFID middleware toolkit. In part 2 of this series, you'll learn how to deploy the code to the IBM RFID middleware, WebSphere RFID Device Infrastructure and WebSphere Premises Server with a real GPS device on a PDA.

What you'll learn

After reading the article, you will:

  1. Understand IBM RFID middleware, including WebSphere RFID Device Infrastructure and WebSphere Premises Server.
  2. Know more about the IBM sensors and actuators (RFID) solutions.
  3. Know how to use the RFID DDK to develop adapters for the sensors.
  4. Know how to implement a data collector on embedded devices, such as PDA or On Board Units (OBU) using IBM RFID middleware.

WebSphere RFID Device Infrastructure and the IBM WebSphere Premises Server

A RFID solution consists of many kinds of sensor and actuator devices such as RFID tags and readers, visual indicators, switches and sensors. In this article, we'll deal with GPS devices, a type of sensor that can provide location information. In order to connect and communicate with GPS devices, you need a controller to manage them. In this article, we'll use the RFID edge controller. IBM uses Workplace Client Technology Micro Edition technology, based on Open Service Gateway initiative (OSGi) technology, to implement the RFID edge controller, which is also called the WebSphere RFID Device Infrastructure. The WebSphere RFID Device Infrastructure (or edge controller) can connect, communicate, and manage sensor and actuator devices, get raw data from them, aggregate the raw data, filter out unnecessary data, and send the data to the WebSphere RFID Premises Server (hereafter called Premises Server) reliably and consistently, even when the network between the RFID edge controller and the Premises Server is not stable. The underlying technology used to transmit the data is WebSphere Connection Server Micro Edition.

The RFID edge controller transmits the data to the Premises Server, which acts as an intermediary between the edge devices and the enterprise servers. The premises server processes the data and translates it into meaningful business events defined by the users. The business events are then sent to the business integration server via the WebSphere Enterprise Service Bus. WebSphere Premises Server is a Java™2, Extended Edition (J2EE) application that uses IBM software such as WebSphere Application Server, DB2 Universal Database Workgroup Server (or Oracle), WebSphere MQSeries, WebSphere Connection Server Micro Edition, Services Management Framework, and a Web application for the administrative console.

The Premises Server sends the business events to a business integration server, which coordinates the backend servers such as Enterprise Resource Planning (ERP), Warehouse Management System (WMS), Supply Chain Management (SCM), and Manufacturing Execution System. (MES). The business integration server in the RFID solution is just like the integration server in other solutions, so you can use any type of integration server you are familiar with. For example, you can use IBM WebSphere Business Integration to integrate the backend servers.

Between the RFID edge controller and the backend servers is a message bus consisting of WebSphere Connection Server Micro Edition and Enterprise Service Bus. With this architecture, data and business events are transmitted from the RFID edge controller to the backend servers reliably and consistently.

Figure 1 shows a typical high-level architecture for RFID solutions.

Figure 1. Typical architecture for RFID solution
Typical architecture for RFID solution

For more information about IBM RFID sensors and actuators, see Resources.


RFID Device Development Kit

Many devices or machines define requests and responses to allow users to control or operate them. These requests and responses are in a data stream format designed by the manufacturer. If you want to write programs to interact with these devices, you need to write code to do the following:

  1. Enable communication channels such as TCP/IP or RS232 COM port.
  2. Submit requests (or commands) to the devices.
  3. Listen to response data streams from the devices.
  4. Aggregate and parse response data streams and then fire the corresponding triggers for the specific response.

Most of this code is reusable for different devices. Therefore, it helps to use a modeling tool to generate the reusable code and simplify the device control programming. You can use the IBM RFID DDK, part of WebSphere Studio Device Developer (hereafter called Device Developer), or available as a free download, for this purpose.

RFID DDK is a good toolkit for modeling the communication channels (connection and transport layers), request and response data streams (device data stream layer), and triggers corresponding to the response data streams into XML. We call this type of XML Control Markup Language (CML). In the CML, you can can define the parameters of communication channels with the devices, commands to control the devices, and responses from the devices.

With the RFID DDK, you don't need to worry about how to write code to enable the communication channels, send the commands to the devices, receive and parse the response data stream from the devices, and drive the triggers corresponding to the response data stream. You just need to focus on studying and understanding the programming specifications for how to control and operate the devices by sending requests to the devices and receiving and parsing the responses from the devices. Once you become familiar with the specifications, you can start to define the CML file. After that, you can use the RFID DDK, an Eclipse plug-in of WebSphere Studio Device Developer to generate the necessary code.

Figure 2 shows how this works:

Figure 2. RFID DDK Device Adapter data flow
RFID DDK Device Adapter data flow
  1. The application gets a command and signal from the device and registers interest in the signal.
  2. The application tells the command to execute.
  3. The command writes a message to the transport.
  4. The transport translates the message into a format that the hardware device can understand and writes the translated message to the connection.
  5. The connection writes bytes to the class library and OS layer.
  6. The class library and OS layer write bytes to the hardware.
  7. The class library and OS layer read bytes to the hardware.
  8. The connection reads bytes from the class library and OS layer.
  9. The transport monitors the byte stream being sent by the connection and parses the bytes back into messages that the transport understands.
  10. The transport notifies the devices that are listening of the messages received.
  11. When a signal matches the messages received from the transport, the measurement is notified that the signal was received.
  12. When a signal matches the messages received from the transport, the application is notified that the signal was received.

In this article, we'll use a GPS device as a sensor, which generates location information. We'll define a CML file for the GPS device according to the GPS National Marine Electronics Association (NMEA) specifications, and then use the RFID DDK to generate the Java code to interact with the GPS device. You'll see how easy it is to write a program to interact with a GPS device. You won't need to write much Java code; you only need to learn how to write the CML, which includes the parameters of communication channels with devices and the request and response data stream to interact with the devices. The DDK generates the necessary Java codes for you. Figure 3 shows a high-level architecture of the solution you'll create in ths article. RFID DDK uses CML to generate the GPS Adapter, which interacts with the GPS device. RFID DDK also generates the GPS Agent, which interacts with the message bus in the edge controller.

Figure 3. Solution architecture of the sample scenario we will develop later
Solution architecture of the sample scenario we will develop later

Set up your environment

You need the following hardware and software before you start:

Software

For the development machine (which also acts as the RFID edge controller), you need:

  • WebSphere Studio Device Developer 5.7.1
  • RFID DDK

For the Premises Server machine, you need IBM WebSphere Premises Server 1.0.2, which includes:

  • DB2 8.1.4 Workgroup edition
  • WebSphere MQSeries 5.3 + CSD8 or upper (CSD9, CSD10).
  • WebSphere Application Server 5.1 + fixpack 1

Or, if you don't want to install WebSphere Premises Server, you can run the premises simulator on another desktop or laptop PC. See Start Kimono premises simulator or the Resources section for more information on setting up a premises simulator. In this article, we'll use a premises simulator instead of WebSphere Premises Server.

Hardware

  • A GPS device that supports NMEA message format. (You can use a GPS simulator for trial purposes. Several simulators are available for trial download. See Resources for more information.
  • A desktop or laptop PC to run RFID DDK. (We recommend you have at least 512K RAM and ensure that it can run WebSphere Studio Device Developer 5.7.1.)
  • A desktop or laptop PC to run WebSphere Premises Server. (We recommend at least 2 GB RAM. However, in this article, we'll use a premises simulator instead of WebSphere Premises Server. If you do this, you only need one desktop or laptop PC with at least 512K RAM.)

Step 1: Create a new workspace

Launch WebSphere Studio Device Developer and create a new workspace, such as C:\IBM\wsdd571\workspace\gps, as seen in Figure 4:

Figure 4. Create a workspace
Create a workspace

Step 2: Develop the GPS adapter

Use the IBM RFID DDK to develop a GPS adapter.

Create a new RFID Device Agent project

To create a RFID Device Agent project, do the following:

  1. From the workbench, select File => New => Other.
  2. In the Select a wizard dialog, select RFID Device Development Kit on the left and Device Agent Project on the right, then click Next, as shown in Figure 5:
    Figure 5. New Project dialog
    New Project dialog
  3. In the Create a New Device Agent project dialog, do the following:
    1. For Name, enter GpsNmea.
    2. For Package Base, enter com.ibm.gps.nmea.
    3. For Agent Type, select Reader Agent. (We'll treat the GPS as a RFID reader, and the location data as RFID tags.)
    4. Device Kit Device, select New Device Template
    5. Device Kit Transport, select New Transport Template
    6. Click Next.
    Figure 6. New Device Agent Project dialog
    New Device Agent Project dialog
  4. You'll be prompted to create Kimono example projects required by the generated code. Click Yes.
  5. The Kimono Projects dialog appears, as shown in Figure 7. Click Finish.
    Figure 7. Sample Kimono projects list
    Sample Kimono projects list

Once the Kimono sample projects are installed, the rest of the code is generated. This will take some time, so be patient. After the wizard completes, you'll see the new GpsNmeaReaderAgent project, as shown in Figure 8.

Figure 8. The new GpsNmeaReaderAgent project and Sample Kimono projects
The new GpsNmeaReaderAgent project and Sample Kimono projects

GpsNmeaReaderAgent is the new customized Reader Agent generated by the wizard. You'll need to modify this project so that it can function within the edge controller architecture or simulated environment. You'll learn how to do this in Modify GpsNmeaReaderAgent and ControllerAgent.

Create a CML file for the GPS Nmea device layer

The RfidIbmTutorialReaderDevice project is generated by the RFID DDK when you selected New Adapter Template in the New Device Agent wizard. Because it's only a template, you need to modify the content of this CML file for our GPS adapter by doing the following:

  1. Expand RfidIbmTutorialReaderDevice project, then RfidIbmTutorialReaderDeviceDevelopment, as seen in Figure 9.
    Figure 9. Generated RfidIbmTutorialReaderDevice.cml file
    Generated RfidIbmTutorialReaderDevice.cml file
  2. Open RfidIbmTutorialReaderDevice.cml with a text editor. Sample CML for a GPS adapter is shown in the code snippet below, which is a fragment of the NMEA GPSCML. As you can see, the content for GPRMC is separated by “,” or “*”.
    $GPRMC,220516,A,5133.82,N,00042.24,W,173.8,231.8,130694,004.2,W*70
    220516Time Stamp
    AValidity - A-ok, V-invalid
    5133.82Current Latitude
    NNorth/South
    Current LongitudeCurrent Longitude
    WEast/West
    173.8Speed in knots
    231.8True course
    130694Date Stamp
    004.2Variation
    WEast/West
    *70Checksum
    <signal id="GPRMC">
    	<rate>1000</rate>
    	<message id="GPRMCMessage">
    		<ascii>$GPRMC</ascii>
    		<tokens>,*\n</tokens>
    		<parameters type="Map"> 
    			<parameter type="numericstring">
    				<key>Time</key>
    				<field>1</field>
    			</parameter>
    			<parameter>
    				<key>Status</key>
    				<field>2</field>
    			</parameter>
    			<parameter type="numericstring">
    				<key>Latitude</key>
    				<field>3</field>
    			</parameter>
    			<parameter>
    				<key>HemisphereNorthSouth</key>
    				<field>4</field>
    			</parameter>
    			<parameter type="numericstring">
    				<key>Longitude</key>
    				<field>5</field>
    			</parameter>
    			<parameter>
    				<key>HemisphereEastWest</key>
    				<field>6</field>
    			</parameter>
    			<parameter type="numericstring">
    				<key>SpeedKnots</key>
    				<field>7</field>
    			</parameter>
    			<parameter type="numericstring">
    				<key>TrueCourse</key>
    				<field>8</field>
    			</parameter>
    			<parameter>
    				<key>Date</key>
    				<field>9</field>
    			</parameter>
    			<parameter type="numericstring">
    				<key>Variation</key>
    				<field>9</field>
    			</parameter>
    		</parameters> 
    		<filter idref="Filter0"/>
    	</message>
    </signal>
  3. In Device Developer, select RfidIbmTutorialReaderDevice.cml, then select Device Kit => Generate, as shown in Figure 10. The RFID DDK generates the necessary device layer Java code in the RfidIbmTutorialReaderDevice project. You don't need to write any Java code yourself.
    Figure 10. Generate device layer Java codes with RfidIbmTutorialReaderDevice.cml
    Generate device layer Java codes with RfidIbmTutorialReaderDevice.cml

Create a CML file for the GPS NMEA transport layer

The RfidIbmTutorialReaderTransport project is the generated DDK transport adapter that mediates between the DDK adapter device and the physical or simulated reader or device. It is only a template, so you need to change the content of the CML file for your GPS adapter.

  1. Expand the RfidIbmTutorialReaderTransport project, then select RfidIbmTutorialReaderTransportDevelopment, as seen in Figure 11.
    Figure 11. The generated RfidIbmTutorialReaderTransporte.cml file
    The generated RfidIbmTutorialReaderTransporte.cml file
  2. Open RfidIbmTutorialReaderTransport.cml in a text editor. A sample transport CML file for a GPS adapter is shown in below. The values for the TCP/IP host and remoteport are the defaults used by the GPS adapter to communicate with the GPS simulator. These values are replaced by the values defined in the configuration XML (edge-configuration-E1.xml) downloaded from the premises server or premises simulator, so you don't need to fill in the actual IP and port of the GPS simulator here.
    <?xml version="1.0"?>
    <cml packagebase="com.ibm.esc"
    	 format="hex">
    	<version>3.2.0</version>
    	<vendor>IBM</vendor>
    	<transport id="RfidIbmTutorialReaderTransport"
    		 bundle="RfidIbmTutorialReaderTransport"
    		 implementation="RfidIbmTutorialReaderTransport"
    		 abstract="false">
    		<description>Rfid Ibm Tutorial Reader Transport</description>
    		<spec id="Specification">
    			<specdate>2005-08-25</specdate>
    			<spectitle>IBM Tutorial</spectitle>
    			<specvendor>IBM</specvendor>
    			<specversion>Version 3.2.0</specversion>
    		</spec>	
    		<tcpip>
    			<host>localhost</host>
    			<remoteport>2323</remoteport>
    		</tcpip>
    	</transport>
    </cml>
  3. Right-click RfidIbmTutorialReaderTransport.cml and select Device Kit => Generate as seen in Figure 13. RFID DDK generates the transport layer Java code in the RfidIbmTutorialReaderTransport project. In the next step, you'll need to implement code to process the data from the GPS device. The code accumulates the data from the device. When there is enough data to parse, it is passed to the device layer. Using NMEA GPS as an example, when it hits the new line character (\n), it can send the accumulated data to the device layer. See the next step for more details.
    Figure 12. Generate RfidIbmTutorialReaderTransport.cml code
    Generate RfidIbmTutorialReaderTransport.cml code
  4. Modify the generated RfidIbmTutorialReaderTransport.java file as shown below. Pay attention to the comments.
    Sample RfidIbmTutorialReaderTransport.java file for GPS adapter
    protected int processInput(final byte[] bytes, final int length) throws Exception {
    	Object timestamp = null;
    	int i;
    	nt index=0;
    	//Since the NMEA GPS device does not have a hello string, we
    	//force the transport state to "STARTED" the first time.
    	if (this.getState()<TransportService.STARTED){
    startupMessageReceived(this, getCurrentTimestamp(),RfidIbmTutorialReaderTransportMessages.
    getVersionReportMessage());
    	}
    	//Go through the data from the device and check whether it is enough for the device 
    	//layer parser. According to the NMEA GPS specification, the new line character ("\n") 
    	//is the token. 
    	for (i=0;i<length;i++) {
    		if ((bytes[i]=='\n')&& (i>1)){
    			byte[] rfidBytes = new byte[i - index + 1];
    			System.arraycopy(bytes,index,rfidBytes,0,rfidBytes.length);
    			final RfidIbmTutorialReaderMessage message = 
    				new RfidIbmTutorialReaderMessage(rfidBytes);
    			if (timestamp == null) {
    				timestamp = getCurrentTimestamp(); /* set the timestamp */
    			}
    			//send the data to the device layer
    			fireMessageReceived(timestamp, message); 
    				/* notify message received */
    			index=i+1;
    		} else {
    			//Do nothing here.  You need to wait until the next "\n" comes from the 
    			//device. The data will be accumulated to the next round.
    		}
    	}
    	return index;
    }
  5. Now you need to re-compute the required package to be imported in the MANIFEST.MF file. Open the MANIFEST.MF file and expand Import Packages, then click Compute. The com.ibm.esc.data packages are added, as shown in Figure 13.
    Figure 13. Re-compute the MANIFEST.MF file for the RfidIbmTutorialReaderTransport project
    Re-compute the MANIFEST.MF file for the RfidIbmTutorialReaderTransport project

Modify GpsNmeaReaderAgent and ControllerAgent

The reader agent codes generated by the RFID DDK are designed for RFID readers that collaborate with switch, motion sensor, light tree, and IO devices. For GPS devices, you don't need such complex functions, so you need to modify GpsNmeaReaderAgent and ControllerAgent to remove unnecessary code, as shown below.

GpsNmeaReader.java code
	…
	…
private SignalService gprmc;
	private SignalService gpgga;
	private SignalService gpgsa;
	…
public void autonomousModeOff() {
		LogUtility.logInfo(this,"autonomousModeOff()");
		//if (readerDevice.getState() == DeviceService.STARTED)
		//	autonomousModeOff.execute();
		gprmc.removeSignalListener(this);
		gpgsa.removeSignalListener(this);
		gpgga.removeSignalListener(this);
}
	public void autonomousModeOn() {
		LogUtility.logInfo(this,"autonomousModeOn()");
		gprmc.addSignalListener(this);
		gpgsa.addSignalListener(this);
		gpgga.addSignalListener(this);
//if (readerDevice.getState() == DeviceService.STARTED)
//	autonomousModeOn.execute();
	}
	
private void getDeviceControls() {
		LogUtility.logInfo(this,"getDeviceControls()");
		gprmc = readerDevice.getSignal(RfidIbmTutorialReaderDeviceService.GPRMC);
		gpgsa = readerDevice.getSignal(RfidIbmTutorialReaderDeviceService.GPGSA);
		gpgga = readerDevice.getSignal(RfidIbmTutorialReaderDeviceService.GPGGA);
	}
	protected void readerCameUp() {
		LogUtility.logInfo(this,"readerCameUp()");
		turnOffAllOutputs();
		//readerNameMeasurement.executeWrite(readerId);
		//autonomousModeOff.execute();
		autonomousModeOn();
		notifyHealthy();
	}
	private void setOutputs() {
		LogUtility.logInfo(this,"setOutputs()");
//  if (readerDevice.getState() == DeviceService.STARTED)
//	digitalOutput.executeWrite("F" + Integer.toHexString(lightState)); //$NON-NLS-1$
//	digitalOutput.executeWrite(new Integer(lightState)); //$NON-NLS-1$
	}
	//Handle the received signals here
	public void signalOccurred(SignalService source, Object timestamp, Object data) {
		LogUtility.logInfo(this, "Signal occurred: " + source + " = " + data); 
			//$NON-NLS-1$ //$NON-NLS-2$
		//To make things simple, we only care about GPRMC signal
		if (source.equals(gprmc)) {
			System.out.println("Get GPS GPRMC Data" + data.toString());
			String tagString = data.toString();
			byte btag[] = tagString.getBytes();
			RfidService tag = Rfid.createRfid(btag);
			RfidMap tagMap = new RfidMap(7);
			int count = 1;
			int antenna = -1;
			long timestampLong = ((Number) timestamp).longValue();
			RfidRead rfidRead = new RfidRead(readerId, timestampLong, 
				antenna, count); //$NON-NLS-1$
			RfidReads rfidReads = new RfidReads();
			rfidReads.addRfidRead(rfidRead);
			tagMap.put(tag, rfidReads);
			notifyTagRead(tagMap);		
		} else {
			//For other signals, we just dump them to the console.
			System.out.println("Get None GPRMC Data" + data.toString());
		}
	}

	protected DeviceService createDevice() {
		LogUtility.logInfo(this,"createDevice()");
		ConnectionService connection;
		DeviceService readerDevice = new RfidIbmTutorialReaderDevice(); // Here
		RfidIbmTutorialReaderTransport tutorialTransport = new RfidIbmTutorialReaderTransport();
		//Get the connection type (TCPIP or COM) from the 
		//edge-configuration-E1.xml downloaded from the
		//premises server or premises simulator. We will use TCPIP.
		String connectionType = getProperty
			(GpsNmeaReaderAgentConstants.GPSNMEA_CONNECTION_TYPE);
		//Although we define the host and remoteport in the transport CML file, 
		//we will use the host and port defined in edge-configuration-E1.xml.
		tutorialTransport.setConnection(tutorialTransport.getDefaultConnection());
		readerDevice.setTransport(tutorialTransport);
		tutorialTransport.start();
		return readerDevice;
	}
ControllerAgent.java in KimonoControllerAgent project
ControllerAgent.java in KimonoControllerAgent project
	protected String[] getSubscriptions() {
		if (selfTestMode) {
			//No-op the Controller in Self Test Mode
			return new String[] {};	
		} else {
			return new String[] {
				readerSignalTopic,
				//Comment out the subscription topic because we 
				//don't want the controller agent to
				//get the GPS location information and publish 
				//more data to the WebSphere Connection Server 
				//Micro Edition.
				//For the RFID reader, when the controller agent 
				//gets the tag id, it will publish a 
				//"BEEP" topic to the WebSphere Connection 
				//Server Micro Edition to trigger the I/O 
				//to make a beep sound. 
				//We will not need the function here.
				//readerTagsTopic,
				palletFeedbackTopic,
				switchSignalTopic,
				motionSensorSignalTopic,
				portalCommandTopic };
		}
	}

Convert GpsNmeaReaderAgent to a bundle project

Before you can submit your bundle to the bundle server, you need to convert the GpsNmeaReaderAgent project to a bundle project. To do this, complete the following steps:

  1. Switch to the SMF perspective as seen in Figure 14.
    Figure 14. Switch to SMF perspective
    Switch to SMF perspective
  2. Right-click GpsNmeaReaderAgent, then select New => Bundle Folder as shown in Figure 15.
    Figure 15. Create a bundle folder (1)
    Create a bundle folder (1)
  3. In the New Bundle Folder dialog, select GpsNmeaReaderAgent. Uncheck Create IVEATTRS.XML and Create IVERES.XML as shown in Figure 16, and click Finish.
    Figure 16. Create a bundle folder (2)
    Create a bundle folder (2)
  4. Open the MANIFEST.MF file and expand Import Packages. Click Compute to add the list of bundles the GPS Reader Agent requires to run. The results of this computation are shown in Figure 17.
    Figure 17. Compute packages that need to be imported
    Compute packages that need to be imported
  5. Expand Import Services and click Add to display the available services to import. Select com.ibm.kimono.edge.configuration.service.EdgeConfigurationService, as shown in Figure 18 and click OK.
    Figure 18. Select the service to be imported
    Select the service to be imported
  6. Save and close the MANIFEST.MF file.
  7. Rebuild your reader project by selecting it in the Package Explorer, and selecting Project => Rebuild Project as shown in Figure 19.
    Figure 19. Rebuild the GpsNmeaReaderAgent project
    Rebuild the GpsNmeaReaderAgent project

Prepare the bundle loader

Bundle loaders are special bundles used to load other bundles. They do this by telling the SMF server runtime what other bundles to instantiate. Once they've accomplished their task, they uninstall themselves from the SMF runtime. You need a loader to bring up the pieces you need, including the GPS reader agent. To prepare the bundle loader, do the following:

  1. From the Package Explorer view, open the RfidIbmTutorialReaderSimulationLoader project.
  2. Open the RfidIbmTutorialSimulationLoader folder, then the package com.ibm.esc.rfid.ibm.tutorial.reader.simulation.loader.bundle to find Activator.java.
  3. Open Activator.java and tremove the entries in the list., as shown below:

    Click to see code listing

    public class Activator extends BundleInstallerActivator {
    
    	protected String[] getBundleNames() {
    		return new String[] { "LogService", //$NON-NLS-1$
    			...
    			...
    			//added bridge because we want to run edge controller and premises simulator on
    			//two different machines
    			"MBAF_Bridge_Admin", 
    			//The following are for the premises simulator. Comment them out 
    			//because we just want to run edge controller on this machine
    			// "KimonoPremisesSimulatorAgent", //$NON-NLS-1$
    			// "KimonoPremisesSimulatorServlet", //$NON-NLS-1$
    			// "KimonoPremisesSimulatorHmi", //$NON-NLS-1$
    			...
    			//Comment out the reader simulator bundles because we don't need them.
    			// "RfidIbmTutorialReaderSimulatorTransport", //$NON-NLS-1$
    			// "RfidIbmTutorialReaderSimulatorDevice", //$NON-NLS-1$
    			// "RfidIbmTutorialReaderSimulator",
    			.......
    			//Replace RfidIbmTutorialReaderAgent with GpsNmeaReaderAgent because we will use a
    			//GPS device instead of a RFID reader.
    			//"RfidIbmTutorialReaderAgent",
    			"GpsNmeaReaderAgent",
    			…
    			//We will not need light tree so comment them out.
    			//"KimonoLightTreeSimulatorHmi",
    			//"KimonoLightTreeAgent", //$NON-NLS-1$
    			//"KimonoLightTreeSimulator",
    			…
    			//We don’t need the RFID tag filter
    			//"KimonoDuplicatesFilter", //$NON-NLS-1$
    			…
    			//"KimonoIoSimulatorAgent", //$NON-NLS-1$
    			}; //$NON-NLS-1$}; //$NON-NLS-1$
    	}
    }
  4. Rebuild the RfidIbmTutorialReaderSimulationLoader project by selecting it in the Package Explorer and selecting Project => Rebuild Project .

Step 3: Test the application

Following the steps in this section to test your application.

Start Kimono premises simulator on the premises simulator machine

  1. Repeat the steps in Create a new RFID Device Agent project to create a sample Kimono project on the Kimono premises server simulator machine.
  2. Open the KimonoAbstractReaderVersionTransitionSupport project in your Package Explorer view.
  3. Expand the tree as shown in Figure 20.
    Figure 20. Find the patch and configuration file
    Find the patch and configuration file
  4. Copy and paste PremisesSimulatorAgent.java and asnTags.dat from the KimonoAbstractReaderVersionTransitionsupport project into the KimonoPremisesSimulator project, overwriting the originals.
  5. In the KimonoAbstractReaderVersionTransitionsupport project in the KimonoVersion1.0.2Changes directory, locate edge-configuration-TUTORIAL.xml. Copy this file into the KimonoPremisesSimulator project in the com.ibm.kimono.premises.simulator.servlet folder, as shown in Figure 21.
    Figure 21. Edge configuration for Kimono premises simulator
    Edge configuration for Kimono premises simulator
  6. Rename the edge-configuration-TUTORIAL.xml file to edge-configuration-E1.xml and modify the following:
    <propertyset id="MicroBrokerConfigurationAgent">
    …
    //Put the IP or host name of your premises simulator machine here
    <property key="server.ip" value="pvc17.tw.ibm.comt"/>
    </propertyset>
    //Change the RfidIbmTutorialReaderAgent to GpsNmeaReaderAgent here
    <propertyset id="GpsNmeaReaderAgent">
      <property key="portal.id" value="P1"/>
      <property key="reader.id" value="R1"/>
      <property key="transport.connection" value="com.ibm.esc.tcpip.connection.
    	  TcpipConnection"/>
    //Put the IP/host name and the port of your GPS simulator here
    <property key="transport.host" value="pvc18.tw.ibm.com"/> 
      <property key="transport.remoteport" value="2323"/> 
      ……
     </propertyset>
  7. Rebuild the KimonoPremisesSimulator project by selecting it in the Package Explorer and selecting Project => Rebuild Project.
  8. Select Run => Run, then create a new bundle server, by selecting SMF Bundle Server and clicking New, as shown in Figure 22.
    Figure 22. Create an SMF bundle server
    Select create a SMF bundle server
  9. In the SMF Bundle Server dialog, accept the default values and click Run as shown in Figure 23.
    Figure 23. Run the SMF bundle server
    Run the SMF bundle server
  10. In the Package Explorer, select all Kimono packages. Right-click on one of the selected packages and select SMF => Submit Bundle as shown in Figure 24.
    Figure 24. Submit bundles to the SMF Bundle Server
    Submit bundles to the SMF Bundle Server
  11. To import the edge controller bundles, switch to the SMF perspective and select the SMF Bundle Servers tab.
  12. Right-click Bundles under Adminlocalhost:8080/smf and select Import Bundles, as shown in Figure 25.
    Figure 25. Import the edge controller bundles
    Import the edge controller bundles
  13. In the Import bundles dialog, select the the necessary bundles to import, and ensure that Replace Bundle is checked, then click Finish as seen in Figure 26.
    Figure 26. Import edge controller bundles from the file system
    Import edge controller bundles from the file system
  14. Select Run => Run, then create an SMF runtime as shown in Figure 27.
    Figure 27. Create an SMF runtime (1)
    Create an SMF runtime (1)
  15. In the SMF Runtime dialog, accept the default values and click Run as shown in Figure 28:
    Figure 28. Create an SMF runtime (2)
    Create an SMF runtime (2)
  16. Switch to the SMF perspective and click the SMF Bundle Servers tab.
  17. Expand the bundles tree, right-click kimonoConsoleLog and select Install.
  18. Right-click KIMONO_PREMISES_SUMILATOR_LOADERand selectinstall , as shown in Figure 29.
    Figure 29. Submit Kimono premises simulator loader
    Submit Kimono premises simulator loader

Start the edge controller (with the GPS adapter) on the RFID DDK machine

  1. Select Run => Run. Then create an SMF bundle server.
  2. In the SMF Bundle Server dialog, accept the default values and click Run.
  3. Select all of the Kimono packages, the RfidIbmTutorialReader packages, and the GpsNmeaReaderAgent project. Then right-click on one of the selected packages and select SMF => Submit Bundles, as shown in Figure 30.
    Figure 30. Submit bundles to the SMF bundle server
    Submit bundles to the SMF bundle server
  4. To import the edge controller bundles, switch to the SMF perspective and click the SMF Bundle Servers tab. Right-click on the Adminlocalhost:8080/smf bundle server and select Import Bundles as shown in Figure 31..
  5. In the Import Bundles dialog, select the necessary bundles to import and make sure Replace Bundle is checked, then click Finish.
  6. Select Run => Run, then create an SMF runtime.
  7. When the SMF Runtime dialog appears, accept the default values and click Run as shown in Figure 31.
    Figure 31. Create an SMF runtime
    Create an SMF runtime
  8. Switch to the SMF perspective and click the SMF Bundle Servers tab. Expand the bundles tree, right-click RFID_IBM_TUTORIAL_READER_SIMULATION_LOADER, and select Install, as shown in Figure 32.
    Figure 32. Submit RFID_IBM_TUTORIAL_READER_SIMULATION_LOADER bundle
    Submit RFID_IBM_TUTORIAL_READER_SIMULATION_LOADER bundle
  9. Start your TCP/IP GPS simulator.

Check the results

You need to turn on the trace logs to check the results on the premises simulator and edge controller. To do this:

  1. Add the esc.properties file under the <WSDD_HOME> directory as shown in Figure 33 on the premises simulator and edge controller machines.
    Figure 33. esc.properties file and file structure
    esc.properties file and file structure
  2. In the esc.properties file, specify esc.tracelevel=10.
  3. Restart Device Developer to make the configuration effective.
  4. Repeat the steps in Start Kimono premises simulator. You should see the Premises Simulator console window as seen in Figure 34.

    You can see that the edge controller downloads the configurations (edge-configuration-E1.xml) from the premises simulator. Then the premises simulator gets tags from reader R1. (Actually, we encoded the location data as a long hex-code string and treat it as a RFID tag ID. We named the GPS device R1 in edge-configuration-E1.xml.). Finally, the premises simulator sends the REJECTED string back to the edge controller, because the encoded location string is not one of the predefined RFID tags in asnTags.dat. This is only a demo to shown you that the premises server simulator can not only receive data from the edge controller but can send it back to the edge controller.

    Figure 34. Trace logs in the console windows for Kimono premises simulator
    Trace logs in the console windows for Kimono premises simulator
    [INFO] 2006-08-09 10:33:16.796 - PremisesSim: Publish arrived: 
    	receiving/portal/P1/signal/tags
    [INFO] 2006-08-09 10:33:16.796 - PremisesSim: Got tags from reader: R1
    [DEBUG] 2006-08-09 10:33:16.796 - PremisesSim: Publishing: 
    	receiving/portal/P1/command/feedback = REJECTED
    [INFO] 2006-08-09 10:33:16.796 - PremisesSim: REJECTED{7b48656d6973706865726545617
    374576573743d452c20566172696174696f6e3d39303830362c205374617475733d412c2054
    696d653d32333334352c204c617469747564653d302c2053706565644b6e6f74733d302c204
    8656d697370686572654e6f727468536f7574683d4e2c204c6f6e6769747564653d302c20446
    174653d3039303830362c2054727565436f757
    273653d307d=[{R1:1155090825218:-1:1}]}
  5. Repeat the steps in Start the edge controller. You should see the edge controller console window as seen in Figure 35.

    The edge controller parses the GPGGA, GPGSA, and GPRMC data from the trace logs. After that, it encodes the GPRMC data into a hex-code string and publishes it to WebSphere Connection Server Micro Edition. The location string is then sent to the RFID tag filtering module, CaseTagFilter. Our case is not in case tag string format, so it will not be filtered out. The location string is then sent to the premises server simulator. Because the premises simulator sends the REJECTED string back, we can see that the edge controller receives the REJECTED string.

    Figure 35. Trace logs in the console windows for GPS adapter simulator
    Trace logs in the console windows for GPS adapter simulator
    GPRMC = {HemisphereEastWest=E, Variation=90806, Status=A, Time=23345, Latitude=0,
    	SpeedKnots=0, HemisphereNorthSouth=N, Longitude=0, Date=090806, 
    	TrueCourse=0}
    [DEBUG] 2006-08-09 10:33:45.234 - GpsNmeaRead-P1: Publishing: 
    	device/reader/P1/signal/tags = {7b48656d6973706865726545617374576573743d452c20566172
    	696174696f6e3d39303830362c205374617475733d412c2054696d653d32333334352c204c6174
    	69747564653d302c2053706565644b6e6f74733d302c2048656d697370686572654e6f727468536
    	f7574683d4e2c204c6f6e6769747564653d302c20446174653d3039303830362c2054727565436f
    	757273653d307d=[{R1:1155090825218:-1:1}]}

Summary

In the future, the world will be full of sensors that can be used to gather useful information for business intelligence. All of these sensors will have different programming and communication interfaces. Integrating these sensors quickly will be critical for business solutions. The WebSphere RFID DDK proves the powerful tools you need to develop and test the glue code easily and efficiently.

One example of how you can use the sample code in this article in fleet management solutions. You can run the sample code in the On Board Units (OBUs) to interact with the GPS devices on cars or trucks, and then send the location information back to a data center. If there are other sensors in on the cars or trucks, such as temperature sensors, RFID readers, anti-theft sensors, and so on, you can use the same concepts and process to develop device adapters and agents for these sensors. The OBU then becomes a data collector that gathers useful information on the cars or trucks. After reading this article, you can begin to think about even more innovative and interesting ways to use RFID technology in different lines of business with the RFID DDK and IBM RFID middleware.

In Part 2, you'll learn how to deploy the code to the RFID middleware, WebSphere RFID Device Infrastructure, and WebSphere Premises Server with a real GPS device on a PDA.


Download

DescriptionNameSize
Sample code for this articlesource.zip11KB

Resources

Learn

Get products and technologies

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere
ArticleID=158818
ArticleTitle=Integrate GPS adapters using WebSphere RFID solutions, Part 1: Use the RFID Device Developer Kit and WebSphere RFID infrastructure to get connected
publish-date=09132006