Exemplo n.º 1
0
        /// <summary>
        /// 密码键盘异常时发送状态
        /// </summary>
        public static string SendZT598State()
        {
            string        port   = SysConfigHelper.readerNode("ZT598Port");
            StringBuilder info   = new StringBuilder(1024);
            int           handle = -1;

            for (int i = 1; i <= 2; i++)
            {
                handle = ZT598.TT_OpenDevice(new StringBuilder("COM" + port), new StringBuilder("9600"), new StringBuilder());
                if (handle == 0)
                {
                    break;
                }
            }
            int jubing = handle;

            if (handle == 0)
            {
                handle = ZT598.TT_GetDeviceStatus(info);
                if (handle != 0)
                {
                    return("02" + handle.ToString());
                }
            }
            else
            {
                return("02" + handle.ToString());
            }
            return(null);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 打开串口
 /// </summary>
 /// <param name="port"></param>
 /// <returns></returns>
 public bool OpenDevice(string port, string bote)
 {
     try
     {
         int status = GetDeviceStatus();
         if (status != 0)
         {
             StringBuilder info = new StringBuilder(1024);
             int           ret  = ZT598.TT_OpenDevice(new StringBuilder(port), new StringBuilder(bote), info);
             if (ret == 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("系统异常");
     }
 }