import java.io.*;
import java.util.*;
import javax.comm.*;
import javax.swing.*;
import java.awt.TrayIcon;
public class location implements Runnable, SerialPortEventListener {
static CommPortIdentifier portId;
static Enumeration portList;
static BufferedReader inputStream;
static SerialPort serialPort;
Thread readThread;
static String v="";
static String hj="";
static String b1="";
static String fq="";
static String ok="";
public void get() {
boolean portFound = false;
String defaultPort = "COM1";
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
if (portId.getName().equals(defaultPort)) {
System.out.println("Found port: "+defaultPort);
portFound = true;
init();
}
}
}
if (!portFound) {
System.out.println("port " + defaultPort + " not found.");
}
}
public void init() {
try {
serialPort = (SerialPort) portId.open("SimpleReadApp", 2000);
} catch (PortInUseException e) {}
try {
inputStream = new BufferedReader(new InputStreamReader(serialPort.getInputStream()));
} catch (IOException e) {}
try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}
serialPort.notifyOnDataAvailable(true);
try {
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e) {}
readThread = new Thread(this);
readThread.start();
}
public void run() {
try {
Thread.sleep(20000);
} catch (InterruptedException e) {}
}
public void serialEvent(SerialPortEvent event) {
switch (event.getEventType()) {
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
try
{
String to="";
v=inputStream.readLine();
System.out.println("GET="+v);
System.out.println("Next-"+inputStream.readLine());
System.out.println(v.length());
int len=v.length();
String val="";
for(int i=1;i<len;i++)
{
char c=v.charAt(i);
val=val+c;
}
System.out.println("Final-"+val);
System.out.println(v);
sub s=new sub();
message4 msg=new message4();
String a=s.twis(s.set(val));
System.out.println(a);
System.out.println(msg.mess(a));
String b1=msg.mess(a);
System.out.println("End3");
BareBonesBrowserLaunch b=new BareBonesBrowserLaunch();
b.openURL("http://localhost:8080/city_view_/personaldetails.jsp?id="+b1);
} catch (Exception e) {
System.out.println("End2-"+e);
}
break;
}
}
public void start()
{ /*location d=new location();
d.get();*/
}
}