Research Article
Logical Sensor Network: An Abstraction of Sensor Data Processing over Multidomain Sensor Network
Listing 4
Source code for construction and update for logical sensor network in Java.
public class MicroForecast implements LSNListener, GPSListener{ | private LSNClient client; | public MicroForecast(double lat, double lng) throws Exception{ | client = new LSNClient(“lsnoperator.org”, 12345, 22345); | client.setListener(this); | //Create LSN instance on a remote server. | client.create(“org.RainForecastNetwork”,“lsn.jar”); | //Connect LSN instance on the remote server. | client.connect(new Location(lat, lng)); | } | 11 @Override | public void dataArrived(LSNDataPacket packet) { | 13 //Process data using packet. (Main Logic) | 14 } | @Override | public void gpsUpdated(double lat, double lng) { | //Let the remote server know about context update. | client.update(new Location(lat,lng)); | } | } |
|