PHIDGET RFID reader to launch url when particular rfid tag is scanned
in
Integration and Hardware
•
1 year ago
Hi,
I am new to this stuff but I have managed to get as far as running the phidget reader so that it displays the scanned tag number. I want to make processing launch a particular url depending on what tag is scanned by the FID reader. I think I almost have it but when I run the process it continiously launches new tab in my browser instead of just doing it once. Sorry if this is a silly question but I am really struggling to sort it out. Any help would be much appreciated.
E.
P.S
the below code tends to crash my browser.
import com.phidgets.*;
import com.phidgets.event.*;
RFIDPhidget rfid = null;
PFont font;
String tag = "";
void setupReader() {
try {
rfid = new RFIDPhidget();
rfid.addAttachListener(new AttachListener() {
public void attached(AttachEvent ae)
{
try
{
((RFIDPhidget)ae.getSource()).setAntennaOn(true);
((RFIDPhidget)ae.getSource()).setLEDOn(true);
}
catch (PhidgetException ex) {
}
println("attachment of " + ae);
}
}
);
rfid.addDetachListener(new DetachListener() {
public void detached(DetachEvent ae) {
System.out.println("detachment of " + ae);
}
}
);
rfid.addErrorListener(new ErrorListener() {
public void error(ErrorEvent ee) {
System.out.println("error event for " + ee);
}
}
);
rfid.addTagGainListener(new TagGainListener()
{
public void tagGained(TagGainEvent oe)
{
System.out.println(oe);
tag = oe.getValue();
}
}
);
rfid.addTagLossListener(new TagLossListener()
{
public void tagLost(TagLossEvent oe)
{
System.out.println(oe);
tag = "";
}
}
);
rfid.addOutputChangeListener(new OutputChangeListener()
{
public void outputChanged(OutputChangeEvent oe)
{
System.out.println(oe);
}
}
);
rfid.openAny();
println("waiting for RFID attachment…");
rfid.waitForAttachment(1000);
System.out.println("Serial: "
+ rfid.getSerialNumber());
System.out.println("Outputs: "
+ rfid.getOutputCount());
System.out.println("Outputting events.");
}
catch (PhidgetException ex)
{
System.out.println(ex);
}
}
void closeReader() {
try {
System.out.print("closing…");
rfid.close();
rfid = null;
System.out.println(" ok");
if (false) {
System.out.println("wait for finalization…");
System.gc();
}
}
catch (PhidgetException ex)
{
System.out.println(ex);
}
}
void setup()
{
size(400, 100);
//Don’t forget to create the font in the tools menu above
font = loadFont("Verdana-20.vlw");
textFont(font);
fill(0);
// setup Reader
setupReader();
// close Reader: Should add a button or some other trigger to call this method
//closeReader();
}
void draw()
{
background(200);
text("Current Tag:"
+tag, 50, 50);
if (tag.equals("0104ff1286")); {
link("http://www.citynodes.freeiz.com/NODE1UPLOADER.php", "_new");
}
}
I am new to this stuff but I have managed to get as far as running the phidget reader so that it displays the scanned tag number. I want to make processing launch a particular url depending on what tag is scanned by the FID reader. I think I almost have it but when I run the process it continiously launches new tab in my browser instead of just doing it once. Sorry if this is a silly question but I am really struggling to sort it out. Any help would be much appreciated.
E.
P.S
the below code tends to crash my browser.
import com.phidgets.*;
import com.phidgets.event.*;
RFIDPhidget rfid = null;
PFont font;
String tag = "";
void setupReader() {
try {
rfid = new RFIDPhidget();
rfid.addAttachListener(new AttachListener() {
public void attached(AttachEvent ae)
{
try
{
((RFIDPhidget)ae.getSource()).setAntennaOn(true);
((RFIDPhidget)ae.getSource()).setLEDOn(true);
}
catch (PhidgetException ex) {
}
println("attachment of " + ae);
}
}
);
rfid.addDetachListener(new DetachListener() {
public void detached(DetachEvent ae) {
System.out.println("detachment of " + ae);
}
}
);
rfid.addErrorListener(new ErrorListener() {
public void error(ErrorEvent ee) {
System.out.println("error event for " + ee);
}
}
);
rfid.addTagGainListener(new TagGainListener()
{
public void tagGained(TagGainEvent oe)
{
System.out.println(oe);
tag = oe.getValue();
}
}
);
rfid.addTagLossListener(new TagLossListener()
{
public void tagLost(TagLossEvent oe)
{
System.out.println(oe);
tag = "";
}
}
);
rfid.addOutputChangeListener(new OutputChangeListener()
{
public void outputChanged(OutputChangeEvent oe)
{
System.out.println(oe);
}
}
);
rfid.openAny();
println("waiting for RFID attachment…");
rfid.waitForAttachment(1000);
System.out.println("Serial: "
+ rfid.getSerialNumber());
System.out.println("Outputs: "
+ rfid.getOutputCount());
System.out.println("Outputting events.");
}
catch (PhidgetException ex)
{
System.out.println(ex);
}
}
void closeReader() {
try {
System.out.print("closing…");
rfid.close();
rfid = null;
System.out.println(" ok");
if (false) {
System.out.println("wait for finalization…");
System.gc();
}
}
catch (PhidgetException ex)
{
System.out.println(ex);
}
}
void setup()
{
size(400, 100);
//Don’t forget to create the font in the tools menu above
font = loadFont("Verdana-20.vlw");
textFont(font);
fill(0);
// setup Reader
setupReader();
// close Reader: Should add a button or some other trigger to call this method
//closeReader();
}
void draw()
{
background(200);
text("Current Tag:"
+tag, 50, 50);
if (tag.equals("0104ff1286")); {
link("http://www.citynodes.freeiz.com/NODE1UPLOADER.php", "_new");
}
}
1