首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么zkemkeeper事件没有启动?

为什么zkemkeeper事件没有启动?
EN

Stack Overflow用户
提问于 2017-06-06 13:54:51
回答 1查看 1.1K关注 0票数 0

我有面部识别装置。这个设备有一个SDK。我使用它向设备发送命令,但它不会触发某些事件。不触发onConnected和OnDisconnected函数,但正在调用onAttendanceTransaction函数。为什么没有调用其他函数?

代码:

代码语言:javascript
复制
  public void init()
    {
        Thread machineActionListener = new Thread(() =>
        {
            connect();
            Application.Run();
        });

        machineActionListener.SetApartmentState(ApartmentState.STA);
        machineActionListener.Start();
    }

    private CZKEMClass getDeviceApi()
    {
        if(deviceApi == null)
        {
            deviceApi = new CZKEMClass();
        }
        return deviceApi;
    }

    private void connect()
    {
        Logger.log("Connecting to ...", machine.getMachineInfo());
        Boolean isConnected = getDeviceApi().Connect_Net(this.machine.ip, this.machine.port);
        if (isConnected)
        {
            connectionTryCount = 0;
            Logger.log("Connected!");

            if (getDeviceApi().RegEvent(this.machine.machineCode, 65535))
            {
                getDeviceApi().OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(onAttendanceTransaction);
                getDeviceApi().OnConnected += new _IZKEMEvents_OnConnectedEventHandler(onConnected);
                getDeviceApi().OnDisConnected += new _IZKEMEvents_OnDisConnectedEventHandler(onDisConnected);

            }
        }
        else
        {
            Logger.log("Could not be connected! Reconnecting...", machine.getMachineInfo());
            if(connectionTryCount < Config.CONNECTION_TRY_LIMIT)
            {
                connectionTryCount++;
                connect();
            }
            else
            {
                Logger.logAndMail("Cihaza " + Config.CONNECTION_TRY_LIMIT + " connection limit exceed!",
                    "Cihaz Bilgileri: " + machine.getMachineInfo());
            }
        }
    }

    private void onConnected()
    {
        Logger.log("Connected to device: " + machine.getMachineInfo());
    }

    private void onDisConnected()
    {
        Logger.log("Disconnected from device: " + machine.getMachineInfo());
        connect();
    }
EN

回答 1

Stack Overflow用户

发布于 2017-09-21 08:01:50

试一试:

代码语言:javascript
复制
        private void connect()
{
    Logger.log("Connecting to ...", machine.getMachineInfo());

    getDeviceApi().OnConnected += new _IZKEMEvents_OnConnectedEventHandler(onConnected);
    getDeviceApi().OnDisConnected += new _IZKEMEvents_OnDisConnectedEventHandler(onDisConnected);

    Boolean isConnected = getDeviceApi().Connect_Net(this.machine.ip, this.machine.port);
    if (isConnected)
    {
        connectionTryCount = 0;
        Logger.log("Connected!");

        if (getDeviceApi().RegEvent(this.machine.machineCode, 65535))
        {
            getDeviceApi().OnAttTransactionEx += new _IZKEMEvents_OnAttTransactionExEventHandler(onAttendanceTransaction);
        }
    }
}

RegEvent ->通过掩码注册事件:

  • 1 OnAttTransaction,OnAttTransactionEx
  • 2 OnFinger
  • 4 OnNewUser
  • 8个OnEnrollFinger
  • 16 OnKeyPress
  • 256号OnVerify
  • 512 OnFingerFeature
  • 1024 OnDoor,OnAlarm
  • 2048年OnHIDNum
  • 4096 OnWriteCard
  • 8192 OnEmptyCard
  • 16384 OnDeleteTemplate

事件OnConnected()和OnDisConnected()不需要RegEvent()并在连接之前添加

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44391994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档