将读到的电子标签存放到code.text里

nanjing-yancao-rfid
QuShuailong 3 years ago
parent f5ae3d9505
commit 8878705305

@ -97,7 +97,7 @@ public class PlcCmdInfo {
} }
} }
//针对单双伸货架 单的是空,双伸且为外侧为 Out //针对单双伸货架 单的是空,双伸且为外侧为 Out
public String getInOutStr(int times){ public String getInOutStr(int times){
if (times <= 2) { if (times <= 2) {
return separation1 == 1 ? "" : "-Out"; return separation1 == 1 ? "" : "-Out";

@ -4,6 +4,7 @@ import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.io.*; import java.io.*;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.util.*; import java.util.*;
@ -30,6 +31,10 @@ public class RFIDSocket {
private int index; private int index;
private static File file;
private static FileWriter fw;
/** /**
* code * code
*/ */
@ -53,8 +58,6 @@ public class RFIDSocket {
log.error("RFIDSocket time out,ip:{},info:{}",ip,e); log.error("RFIDSocket time out,ip:{},info:{}",ip,e);
close(); close();
} }
} }
@ -80,7 +83,6 @@ public class RFIDSocket {
log.error("disconnect"); log.error("disconnect");
} }
if(i == -1){ if(i == -1){
break; break;
} }
int count = 0; int count = 0;
@ -101,6 +103,11 @@ public class RFIDSocket {
while (buffer.size()> 0){ while (buffer.size()> 0){
String code = readTag(); String code = readTag();
if(code != null){ if(code != null){
if(!tags.contains(code))
{
fw.write(code+"\n");
fw.flush();
}
tags.add(code); tags.add(code);
} }
} }
@ -228,11 +235,22 @@ public class RFIDSocket {
} }
public static void main(String[] args) throws IOException, InterruptedException { public static void main(String[] args) throws IOException, InterruptedException {
RFIDSocket rfid = new RFIDSocket("172.16.0.220",4001); RFIDSocket rfid = new RFIDSocket("10.43.26.124",4001);
file = new File("F:\\Leaper\\Programs\\Java\\backend-duoji-monitor\\logs\\code.txt");
fw = new FileWriter(file, true);
fw.write("\n");
rfid.startCheck(); rfid.startCheck();
rfid.readData(); rfid.readData();
Thread.sleep(30000); Thread.sleep(1000*30000);
rfid.close(); rfid.close();
System.out.println(rfid.getTags()); System.out.println(rfid.getTags());
// fw.write("\n");
// fw.flush();
// for(String tag : rfid.getTags())
// {
// fw.write(tag+"\n");
// fw.flush();
// }
fw.close();
} }
} }

Loading…
Cancel
Save