| | |
| | | private int readerType; |
| | | private int readerLogOn_Off; |
| | | private String mode; |
| | | private boolean isConnect = false; |
| | | |
| | | @Setter |
| | | private Consumer<ApplicationEvent> eventConsumer; |
| | |
| | | |
| | | |
| | | public void start() { |
| | | log.info("ip:{},port:{},readerType:{},log:{}", ip, port, readerType, readerLogOn_Off); |
| | | log.info("ip:{},port:{},readerType:{},log:{}", this.ip, this.port, this.readerType, this.readerLogOn_Off); |
| | | reader = new CReader(ip, port, readerType, readerLogOn_Off); |
| | | |
| | | int conn = reader.Connect(); |
| | | if (conn != 0) { |
| | | log.error("连接UF3设备失败,返回码={}", conn); |
| | | this.isConnect = false; |
| | | return; |
| | | } |
| | | log.info("UF3 Reader设备连接成功:{}:{}", ip, props.getPort()); |
| | | |
| | | this.isConnect = true; |
| | | //0x00关闭蜂鸣器,0x01打开蜂鸣器 |
| | | reader.SetBeepNotification(0x00); |
| | | |
| | | ReaderParameter param = new ReaderParameter(); |
| | | try { |
| | | param.SetAntenna(0x09); |
| | | param.SetSession(0); |
| | | param.SetReadType(0); |
| | | reader.SetInventoryParameter(param); |
| | | } catch (Exception e) { |
| | |
| | | } catch (Exception e) { |
| | | log.warn("断开连接异常:{}", e.getMessage()); |
| | | } |
| | | this.isConnect = false; |
| | | log.info("已停止并断开UF3设备连接"); |
| | | } |
| | | } |
| | | |
| | | public boolean isOnline() { |
| | | return reader != null; |
| | | return reader != null && isConnect; |
| | | } |
| | | |
| | | @Override |