|
@@ -33,9 +33,9 @@ public class DeJuRFIDService implements IService {
|
|
|
|
|
|
|
|
private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
|
|
private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
- private final AtomicBoolean isAlarm=new AtomicBoolean();
|
|
|
|
|
|
|
+ private AtomicBoolean isAlarm = new AtomicBoolean();
|
|
|
|
|
|
|
|
- private final ScheduledExecutorService scheduledExecutorService= SpringUtils.getBean("scheduledExecutorService");
|
|
|
|
|
|
|
+ private final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void start(RemoteLabHardware hardware) {
|
|
public void start(RemoteLabHardware hardware) {
|
|
@@ -67,17 +67,15 @@ public class DeJuRFIDService implements IService {
|
|
|
}
|
|
}
|
|
|
msgBaseSetPower.setDicPower(hashtable);
|
|
msgBaseSetPower.setDicPower(hashtable);
|
|
|
client.sendSynMsg(msgBaseSetPower);
|
|
client.sendSynMsg(msgBaseSetPower);
|
|
|
- if (0 == msgBaseSetPower.getRtCode()) {
|
|
|
|
|
- log.info("Power configuration successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.info("Power configuration error.");
|
|
|
|
|
|
|
+ if (0 != msgBaseSetPower.getRtCode()) {
|
|
|
|
|
+ log.error("Power configuration error.");
|
|
|
reset(client);
|
|
reset(client);
|
|
|
disconnect(hardware);
|
|
disconnect(hardware);
|
|
|
start(hardware);
|
|
start(hardware);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- log.info("Power configuration error.");
|
|
|
|
|
|
|
+ log.error("Power configuration error.");
|
|
|
reset(client);
|
|
reset(client);
|
|
|
disconnect(hardware);
|
|
disconnect(hardware);
|
|
|
start(hardware);
|
|
start(hardware);
|
|
@@ -102,10 +100,8 @@ public class DeJuRFIDService implements IService {
|
|
|
msgBaseInventoryEpc.setInventoryMode(EnumG.InventoryMode_Inventory);
|
|
msgBaseInventoryEpc.setInventoryMode(EnumG.InventoryMode_Inventory);
|
|
|
|
|
|
|
|
client.sendSynMsg(msgBaseInventoryEpc);
|
|
client.sendSynMsg(msgBaseInventoryEpc);
|
|
|
- if (0 == msgBaseInventoryEpc.getRtCode()) {
|
|
|
|
|
- log.info("Inventory epc successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.info("Inventory epc error.");
|
|
|
|
|
|
|
+ if (0 != msgBaseInventoryEpc.getRtCode()) {
|
|
|
|
|
+ log.error("Inventory epc error.");
|
|
|
reset(client);
|
|
reset(client);
|
|
|
disconnect(hardware);
|
|
disconnect(hardware);
|
|
|
start(hardware);
|
|
start(hardware);
|
|
@@ -115,13 +111,11 @@ public class DeJuRFIDService implements IService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void reset(GClient client){
|
|
|
|
|
- MsgAppReset msgAppReset=new MsgAppReset();
|
|
|
|
|
|
|
+ public void reset(GClient client) {
|
|
|
|
|
+ MsgAppReset msgAppReset = new MsgAppReset();
|
|
|
client.sendSynMsg(msgAppReset);
|
|
client.sendSynMsg(msgAppReset);
|
|
|
- if (0 == msgAppReset.getRtCode()) {
|
|
|
|
|
- log.info("Reset epc successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.info("Reset epc error.");
|
|
|
|
|
|
|
+ if (0 != msgAppReset.getRtCode()) {
|
|
|
|
|
+ log.error("Reset epc error.");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -130,46 +124,40 @@ public class DeJuRFIDService implements IService {
|
|
|
String ipAddress = hardware.getIpAddress();
|
|
String ipAddress = hardware.getIpAddress();
|
|
|
if (clientMap.containsKey(ipAddress)) {
|
|
if (clientMap.containsKey(ipAddress)) {
|
|
|
GClient client = clientMap.get(ipAddress);
|
|
GClient client = clientMap.get(ipAddress);
|
|
|
- changeGpo(0, client,0);
|
|
|
|
|
|
|
+ changeGpo(0, client, 0);
|
|
|
MsgBaseStop msg = new MsgBaseStop();
|
|
MsgBaseStop msg = new MsgBaseStop();
|
|
|
// 停止读卡,空闲态
|
|
// 停止读卡,空闲态
|
|
|
client.sendSynMsg(msg);
|
|
client.sendSynMsg(msg);
|
|
|
- if (0 == msg.getRtCode()) {
|
|
|
|
|
- log.info("Stop successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.info("Stop error.");
|
|
|
|
|
- }
|
|
|
|
|
- log.info("Close the connection");
|
|
|
|
|
client.close();
|
|
client.close();
|
|
|
clientMap.remove(ipAddress);
|
|
clientMap.remove(ipAddress);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void changeGpo(int state, GClient client,int delayTime) {
|
|
|
|
|
- MsgAppSetGpo msgAppSetGpo=new MsgAppSetGpo();
|
|
|
|
|
|
|
+ private void changeGpo(int state, GClient client, int delayTime) {
|
|
|
|
|
+ MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
|
|
|
msgAppSetGpo.setGpo1(state);
|
|
msgAppSetGpo.setGpo1(state);
|
|
|
msgAppSetGpo.setGpo2(state);
|
|
msgAppSetGpo.setGpo2(state);
|
|
|
|
|
|
|
|
client.sendSynMsg(msgAppSetGpo);
|
|
client.sendSynMsg(msgAppSetGpo);
|
|
|
String status = state == 1 ? "start" : "stop";
|
|
String status = state == 1 ? "start" : "stop";
|
|
|
if (0 == msgAppSetGpo.getRtCode()) {
|
|
if (0 == msgAppSetGpo.getRtCode()) {
|
|
|
- log.info("Gpo epc {} successful.",status);
|
|
|
|
|
- if (state==1){
|
|
|
|
|
- stopGpo(client,delayTime);
|
|
|
|
|
|
|
+ if (state == 1) {
|
|
|
|
|
+ stopGpo(client, delayTime);
|
|
|
|
|
+ } else {
|
|
|
isAlarm.set(false);
|
|
isAlarm.set(false);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- log.error("Gpo epc {} error.",status);
|
|
|
|
|
|
|
+ log.error("Gpo epc {} error.", status);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void stopGpo(GClient client,int delayTime){
|
|
|
|
|
|
|
+ public void stopGpo(GClient client, int delayTime) {
|
|
|
scheduledExecutorService.schedule(new TimerTask() {
|
|
scheduledExecutorService.schedule(new TimerTask() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
|
- changeGpo(0, client,0);
|
|
|
|
|
|
|
+ changeGpo(0, client, 0);
|
|
|
}
|
|
}
|
|
|
- },delayTime, TimeUnit.SECONDS);
|
|
|
|
|
|
|
+ }, delayTime, TimeUnit.SECONDS);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -180,12 +168,12 @@ public class DeJuRFIDService implements IService {
|
|
|
private void subscribeHandler(GClient client) {
|
|
private void subscribeHandler(GClient client) {
|
|
|
client.onTagEpcLog = (s, logBaseEpcInfo) -> {
|
|
client.onTagEpcLog = (s, logBaseEpcInfo) -> {
|
|
|
if (logBaseEpcInfo.getResult() == 0) {
|
|
if (logBaseEpcInfo.getResult() == 0) {
|
|
|
- log.info("===========》{}",logBaseEpcInfo.getbEpc());
|
|
|
|
|
|
|
+ log.info("===========》{}", logBaseEpcInfo.getbEpc());
|
|
|
//灯带设置
|
|
//灯带设置
|
|
|
- if (!isAlarm.get()){
|
|
|
|
|
|
|
+ if (!isAlarm.get()) {
|
|
|
scheduledExecutorService.execute(() -> {
|
|
scheduledExecutorService.execute(() -> {
|
|
|
isAlarm.set(true);
|
|
isAlarm.set(true);
|
|
|
- changeGpo(1, client,10);
|
|
|
|
|
|
|
+ changeGpo(1, client, 10);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
InventoryTag tag = new InventoryTag();
|
|
InventoryTag tag = new InventoryTag();
|