JACOB调用IFACE702中控考勤机监控实时事件无反应

xujunhu33 2015-03-25 03:50:17
这个类connect,disConnect方法使用正常,能连接到设备。
DispatchEvents de = new DispatchEvents(ob,se); 这句代码中 se能接收到程序内部调用的实时事件,但如果是考勤机那边的实时事件,如开门,验证指纹等实时事件都无法接收到。

package cn;
import com.jacob.activeX.ActiveXComponent;

import com.jacob.com.Dispatch;
import com.jacob.com.DispatchEvents;
import com.jacob.com.Variant;

public class ZkemSDK
{
//静态加载zkemkeeper.dll, zkemkeeper.ZKEM.1为注册表中的ProgID数值
private static ActiveXComponent zkem = new ActiveXComponent("zkemkeeper.ZKEM.1");


/**
* 连接到考勤机
* @param address
* @param port
* @return
*/
public boolean connect(String address,int port)
{
boolean result = zkem.invoke("Connect_Net", address, port).getBoolean();
return result;
}

/**
* 断开考勤机连接
*/
public void disConnect()
{
zkem.invoke("Disconnect");
}

/**
* 监控考勤机实时事件
*/
public void regEvent(){
Variant v0 = new Variant(1);
Variant eventMask = new Variant(65535);
boolean result2 = zkem.invoke("RegEvent",v0,eventMask).getBoolean();
System.out.println("regEvent()===="+result2);

Dispatch ob =zkem.getObject();
SensorEvents se = new SensorEvents(this,"192.168.1.201");
DispatchEvents de = new DispatchEvents(ob,se);

System.out.println("注册开始====");
try {
EventThread es = new EventThread(de);
Thread t1 = new Thread(es);
t1.start();
} catch (Exception e) {
}
System.out.println("注册完成====");
}

public static void main(String[] args)throws Exception {
System.out.println(System.getProperty("java.library.path"));

ZkemSDK sdk = new ZkemSDK();
boolean connFlag = sdk.connect("192.168.1.201", 4370);
if(connFlag)
{
sdk.regEvent();
sdk.connect("192.168.1.201", 4370); //如果是程序调用的这里能监控到OnConnected 事件
}else
{
System.out.println("连接失败");
}
}

}
====================================================
这个类写了SDK中所有的实时事件
package cn;
import java.util.EventObject;

import com.jacob.com.Variant;

//public class SensorEvents {
public class SensorEvents extends EventObject {

private static final long serialVersionUID = 7585990581705430682L;

private String ip;

public String getIp() {
return ip;
}

public void setIp(String ip) {
this.ip = ip;
}

SensorEvents(Object source,String ip){
super(source);
this.ip=ip;
}

public void OnConnected(Variant[] arge){
System.out.println("当成功连接机器时触发该事件,无返回值===="+this.ip);
}
public void OnDisConnected(Variant[] arge){
System.out.println("当断开机器时触发该事件,无返回值"+this.ip);
}
public void OnAlarm(Variant[] arge){
System.out.println("当机器报警时触发该事件===="+arge);
}
public long OnDoor(Variant[] arge) {
System.out.println("OnDoorEvent===="+arge);
if(arge[0].getInt()==4){
System.out.println("开门===="+arge);
}else if(arge[0].getInt()==5){
System.out.println("关门===="+arge);
}else if(arge[0].getInt()==53){
System.out.println("出门了===="+arge);
}else if(arge[0].getInt()==1){
System.out.println("门被意外打开===="+arge);
}
return 1;
}
public void OnAttTransactionEx(Variant[] arge){
System.out.println("当验证通过时触发该事件===="+arge);
}
public void OnEnrollFingerEx(Variant[] arge){
System.out.println("登记指纹时触发该事件===="+arge);
}
public void OnFinger(Variant[] arge){
System.out.println("当机器上指纹头上检测到有指纹时触发该消息,无返回值");
}

public void OnFingerFeature(Variant[] arge){
System.out.println("登记用户指纹时,当有指纹按下时触发该消息===="+arge);
}
public void OnHIDNum(Variant[] arge){
System.out.println("当刷卡时触发该消息===="+arge);
}
public void OnNewUser(Variant[] arge){
System.out.println("当成功登记新用户时触发该消息===="+arge);
}
public void OnVerify(Variant[] arge){
System.out.println("当用户验证时触发该消息===="+arge);
}
public void OnWriteCard(Variant[] arge){
System.out.println("当机器进行写卡操作时触发该事件===="+arge);
}
public void OnEmptyCard(Variant[] arge){
System.out.println("当清空 MIFARE 卡操作时触发该事件===="+arge);
}
public void OnEMData(Variant[] arge){
System.out.println("当机器向 SDK 发送未知事件时,触发该事件===="+arge);
}

}
=================================================================

package cn;
import com.jacob.com.DispatchEvents;

public class EventThread implements Runnable {
private DispatchEvents de;

public EventThread(DispatchEvents de) {
this.de = de;
}

public void run() {
System.out.println("Thread开始====200秒等待设备实时事件" );
try {
Thread.sleep(200000);
} catch (InterruptedException e) {
}
System.out.println("Thread结束=====" );
}

}
...全文
992 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
YEUNG_LAU 2016-07-20
  • 打赏
  • 举报
回复
把以下代码 Dispatch.call(zkem, "RegEvent", new Variant(1l), new Variant(65535l)); STA sta = new STA(); sta.doMessagePump(); 替换到 System.out.println("注册开始===="); try { EventThread es = new EventThread(de); Thread t1 = new Thread(es); t1.start(); } catch (Exception e) { } System.out.println("注册完成===="); } 的位置就行了,因为缺少获取实时事件的方法
YEUNG_LAU 2016-07-20
  • 打赏
  • 举报
回复
楼主解决了没?
来年秋风乱。 2016-03-08
  • 打赏
  • 举报
回复
我一直连接失败怎么破?
qq_28644199 2015-12-23
  • 打赏
  • 举报
回复
求iface二次开发包 long245437@126.com 谢谢
码之魂 2015-12-01
  • 打赏
  • 举报
回复
然后呢?解决了?
xujunhu33 2015-03-26
  • 打赏
  • 举报
回复
怎么没人回复呀,顶上!

50,504

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧