using System.Text; namespace EC.AutoWeightServer.IfManager.FingerPrint { /// /// 暂时只测试了 USB 接口 /// public class FingerPrintManager { //连接参数 private readonly FingerPrintParam _fpParam; //通讯句柄 private int _handle; //返回码 private int _ret; public FingerPrintManager() { _fpParam = new FpUsbParam(); } public FingerPrintManager(FingerPrintParam fpParam) { _fpParam = fpParam; } #region Start & Stop Server /// /// 开启服务 /// /// public bool StartServer() { _ret = TesoLiveSDK.TcCreateHDL(_fpParam.Port, _fpParam.NPort, _fpParam.NRidx, _fpParam.NSped); _handle = _ret; return _ret >= 0; } /// /// 停止服务 /// /// public bool StopServer() { if (!IsConnected()) return true; _ret = TesoLiveSDK.TcDeleteHDL(_handle); if (_ret < 0) return false; _handle = -1; return true; } #endregion Start & Stop Server #region Tool Methods /// /// 获取设备内核号 /// /// /// public bool GetDevKerNel(ref string data) { if (!IsConnected()) return false; var builder = new StringBuilder(); _ret = TesoLiveSDK.TcGetDevVsin(_handle, builder); data = _ret >= 0 ? builder.ToString() : string.Empty; return _ret >= 0; } /// /// 获取设备序列号 /// /// /// public bool GetDevSn(ref string data) { if (!IsConnected()) return false; var builder = new StringBuilder(); _ret = TesoLiveSDK.TcReadDevSn(_handle, builder); data = _ret >= 0 ? builder.ToString() : string.Empty; return _ret >= 0; } /// /// 注册窗体默认开启 /// /// /// public bool SetRegBoxAble(bool able) { if (!IsConnected()) return false; var nIdx = 16;//#define T_SHOWREG 16 弹出注册窗体 var nVal = able ? 1 : 0; _ret = TesoLiveSDK.TcExtnEntry(_handle, 0, nIdx, nVal, null); return _ret >= 0; } /// /// 认证窗体默认关闭 /// /// /// public bool SetVerBoxAble(bool able) { if (!IsConnected()) return false; var nIdx = 17;//#define T_SHOWVER 17 弹出认证窗体 var nVal = able ? 1 : 0; _ret = TesoLiveSDK.TcExtnEntry(_handle, 0, nIdx, nVal, null); return _ret >= 0; } /// /// 控制设备上的 LED 闪灯和 BUZZER 蜂鸣,声光同时提示 /// /// 0=短嘀,1=长嘀,2=嘀嘀 /// public bool SetBeepLight(int mode) { if (!IsConnected()) return false; mode %= 3; _ret = TesoLiveSDK.TcBeepLight(_handle, mode); return _ret >= 0; } /// /// 设置注册窗口等待时间 /// /// 超时量默认 30000 /// public bool SetRegTime(int msTime) { if (!IsConnected()) return false; var nIdx = 6;//#define T_REGTMOT 6 注册 ms 超时量=30000 _ret = TesoLiveSDK.TcExtnEntry(_handle, 0, nIdx, msTime, null); return _ret >= 0; } /// /// 设置认证窗口等待时间 /// /// 超时量默认 18000 /// public bool SetVerTime(int msTime) { if (!IsConnected()) return false; var nIdx = 7;//#define T_VERTMOT 7 认证 ms 超时量=18000 _ret = TesoLiveSDK.TcExtnEntry(_handle, 0, nIdx, msTime, null); return _ret >= 0; } /// /// 获取指纹模板 /// /// /// public bool GetRegFingerPrint(ref string regFp) { if (!IsConnected()) return false; var builder = new byte[513]; _ret = TesoLiveSDK.TcDoTemplet(_handle, builder); regFp = Encoding.ASCII.GetString(builder).Trim('\0'); return _ret >= 0; } /// /// 获取指纹特征 /// /// /// public bool GetVerFingerPrint(ref string verFp) { if (!IsConnected()) return false; var builder = new byte[513]; _ret = TesoLiveSDK.TcDoFeature(_handle, builder); verFp = Encoding.ASCII.GetString(builder).Trim('\0'); return _ret >= 0; } /// /// 对比指纹模板和特征 /// /// /// /// public bool MatchFingerPrint(string regFp, string verFp) { if (!IsConnected()) return false; if (string.IsNullOrEmpty(regFp) || string.IsNullOrEmpty(verFp)) return false; _ret = TesoLiveSDK.TcSafeMatch(_handle, verFp, regFp); return _ret >= 0; } /// /// 判断设备是否连接 /// /// public bool IsConnected() { var builder = new StringBuilder(); _ret = TesoLiveSDK.TcReadDevSn(_handle, builder); return _ret >= 0; } /// /// 返回函数运行返回码 /// /// 返回码 public int GetResultCode() { return _ret; } #endregion Tool Methods } }