示例#1
0
文件: Form1.cs 项目: juanron/zksdk
        private void bnOpen_Click(object sender, EventArgs e)
        {
            int ret = zkfp.ZKFP_ERR_OK;

            if (zkfp.ZKFP_ERR_OK != (ret = fpInstance.OpenDevice(cmbIdx.SelectedIndex)))
            {
                MessageBox.Show("OpenDevice fail, ret = " + ret);
                return;
            }
            bnInit.Enabled     = false;
            bnFree.Enabled     = true;
            bnOpen.Enabled     = false;
            bnClose.Enabled    = true;
            bnEnroll.Enabled   = true;
            bnVerify.Enabled   = true;
            bnIdentify.Enabled = true;
            RegisterCount      = 0;
            cbRegTmp           = 0;
            iFid = 1;
            for (int i = 0; i < 3; i++)
            {
                RegTmps[i] = new byte[2048];
            }
            FPBuffer = new byte[fpInstance.imageWidth * fpInstance.imageHeight];

            Thread captureThread = new Thread(new ThreadStart(DoCapture));

            captureThread.IsBackground = true;
            captureThread.Start();
            bIsTimeToDie = false;
            textRes.Text = "Open succ, device sn=" + fpInstance.devSn;
        }
示例#2
0
        /// <summary>
        /// 启动指纹仪
        /// </summary>
        /// <returns></returns>
        public bool OpenSensor()
        {
            bool result = true;

            try
            {
                int ret = zkfp.ZKFP_ERR_OK;
                if (zkfp.ZKFP_ERR_OK != (ret = fpInstance.OpenDevice(0)))
                {
                    return(false);
                }

                for (int i = 0; i < REGISTER_FINGER_COUNT; i++)
                {
                    RegTmps[i] = new byte[2048];
                }
                FPBuffer = new byte[fpInstance.imageWidth * fpInstance.imageHeight];
            }catch (Exception)
            { result = false; }
            return(result);
        }
示例#3
0
        static public void connect()
        {
            if (zkfp.ZKFP_ERR_OK == fpInstance.Initialize())  // Device Connect
            {
                if (FingerTap == 0)
                {
                    REGISTER_FINGER_COUNT = 1;
                }
                else
                {
                    REGISTER_FINGER_COUNT = 3;
                }
                DeviceConnected        = 1;
                openDeviceCallBackCode = fpInstance.OpenDevice(0); // Open Device
                if (zkfp.ZKFP_ERR_OK != openDeviceCallBackCode)    // In Build error code
                {
                    return;
                }
                for (int i = 0; i < 3; i++)
                {
                    RegTmps[i] = new byte[2048];
                }
                size = 4;
                fpInstance.GetParameters(1, paramValue, ref size);
                zkfp2.ByteArray2Int(paramValue, ref mfpWidth);

                size = 4;
                fpInstance.GetParameters(2, paramValue, ref size);
                zkfp2.ByteArray2Int(paramValue, ref mfpHeight);

                FPBuffer = new byte[mfpWidth * mfpHeight];
            }
            else
            {
                DeviceConnected = 0;
            }
        }
        // [ INITALIZE DEVICE ]
        private void bnInit_Click(object sender, EventArgs e) // PASO 2 INICIALIZA EL DISPOISTIVO
        {
            parentForm.statusBar.Visible = false;
            cmbIdx.Items.Clear();

            int initializeCallBackCode = fpInstance.Initialize();

            if (zkfp.ZKFP_ERR_OK == initializeCallBackCode)
            {
                int nCount = fpInstance.GetDeviceCount();
                if (nCount > 0)
                {
                    for (int i = 1; i <= nCount; i++)
                    {
                        cmbIdx.Items.Add(i.ToString());
                    }

                    cmbIdx.SelectedIndex = 0;
                    btnInit.Enabled      = false;

                    DisplayMessage(MessageManager.msg_FP_InitComplete, true);
                }
                else
                {
                    int finalizeCount = fpInstance.Finalize();
                    DisplayMessage(MessageManager.msg_FP_NotConnected, false);
                }



                // CONNECT DEVICE

                #region -------- CONNECT DEVICE --------

                int openDeviceCallBackCode = fpInstance.OpenDevice(cmbIdx.SelectedIndex);
                if (zkfp.ZKFP_ERR_OK != openDeviceCallBackCode)
                {
                    DisplayMessage($"Uable to connect with the device! (Return Code: {openDeviceCallBackCode} )", false);
                    return;
                }

                Utilities.EnableControls(false, btnInit);
                Utilities.EnableControls(true, btnClose, btnEnroll, btnVerify, btnIdentify, btnFree);

                RegisterCount = 0;
                regTempLen    = 0;
                iFid          = 1;

                //for (int i = 0; i < 3; i++)
                for (int i = 0; i < REGISTER_FINGER_COUNT; i++)
                {
                    RegTmps[i] = new byte[2048];
                }

                byte[] paramValue = new byte[4];
                int    size       = 4;

                //fpInstance.GetParameters

                fpInstance.GetParameters(1, paramValue, ref size);
                zkfp2.ByteArray2Int(paramValue, ref mfpWidth);

                size = 4;
                fpInstance.GetParameters(2, paramValue, ref size);
                zkfp2.ByteArray2Int(paramValue, ref mfpHeight);

                FPBuffer = new byte[mfpWidth * mfpHeight];

                //FPBuffer = new byte[fpInstance.imageWidth * fpInstance.imageHeight];

                captureThread = new Thread(new ThreadStart(DoCapture));
                captureThread.IsBackground = true;
                captureThread.Start();


                bIsTimeToDie = false;

                string devSN = fpInstance.devSn;
                lblDeviceStatus.Text = "Connected \nDevice S.No: " + devSN;

                DisplayMessage("You are now connected to the device.", true);



                #endregion
            }
            else
            {
                DisplayMessage("Unable to initailize the device. " + FingerPrintDeviceUtilities.DisplayDeviceErrorByCode(initializeCallBackCode) + " !! ", false);
            }
        }