Ejemplo n.º 1
0
        public bool OpenDevice()
        {
            this.CloseDevice();
            bool result;

            try
            {
                this.porthandle = FRRAPT.OpenCardReader(this.port, this.baud);
                if (!this.ISConnected())
                {
                    this.errmsg = "打开读写器串口失败!";
                    result      = false;
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                this.porthandle = IntPtr.Zero;
                this.errmsg     = ex.ToString();
                result          = false;
            }
            return(result);
        }
Ejemplo n.º 2
0
 public void Beep(int times, int timespan)
 {
     if (this.ISConnected())
     {
         try
         {
             for (int i = 0; i < times; i++)
             {
                 FRRAPT.RFReaderBeep(this.porthandle);
                 Thread.Sleep(timespan);
             }
         }
         catch (Exception exception)
         {
             this.errmsg = exception.ToString();
         }
     }
 }
Ejemplo n.º 3
0
 public bool OpenDevice()
 {
     this.CloseDevice();
     try
     {
         this.porthandle = FRRAPT.OpenCardReader(this.port, this.baud);
         if (!this.ISConnected())
         {
             this.errmsg = "打开读写器串口失败!";
             return(false);
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.porthandle = IntPtr.Zero;
         this.errmsg     = exception.ToString();
         return(false);
     }
 }
Ejemplo n.º 4
0
 public void Lamp(int lamppos, int times)
 {
     if (this.ISConnected())
     {
         try
         {
             for (int i = 0; i < times; i++)
             {
                 VehIC_Device.FRRAPT.RFReaderLed(this.porthandle, lamppos, 1);
                 Thread.Sleep(500);
                 FRRAPT.RFReaderLed(this.porthandle, lamppos, 0);
                 Thread.Sleep(500);
             }
         }
         catch (Exception exception)
         {
             this.errmsg = exception.ToString();
         }
     }
 }
Ejemplo n.º 5
0
        public bool CloseDevice()
        {
            bool flag;

            try
            {
                FRRAPT.CloseCardReader(this.porthandle);
                this.porthandle = IntPtr.Zero;
                flag            = true;
            }
            catch (Exception exception)
            {
                this.errmsg = exception.ToString();
                flag        = false;
            }
            finally
            {
                this.porthandle = IntPtr.Zero;
            }
            return(flag);
        }
Ejemplo n.º 6
0
        public bool CloseDevice()
        {
            bool result;

            try
            {
                FRRAPT.CloseCardReader(this.porthandle);
                this.porthandle = IntPtr.Zero;
                result          = true;
            }
            catch (Exception ex)
            {
                this.errmsg = ex.ToString();
                result      = false;
            }
            finally
            {
                this.porthandle = IntPtr.Zero;
            }
            return(result);
        }
Ejemplo n.º 7
0
        public string Excute()
        {
            if (!this.Available())
            {
                return(string.Empty);
            }
            try
            {
                string str     = string.Empty;
                byte[] bufData = new byte[0x80];
                for (int i = 0; i < 0x80; i++)
                {
                    bufData[i] = 0;
                }
                byte ret = FRRAPT.QueryRFCard(this.porthandle, 0x52, bufData);
                switch (ret)
                {
                case 0xfe:
                case 0xff:
                    this.errmsg = "通讯失败";
                    return(string.Empty);

                default:
                {
                    int num3;
                    if ((((bufData[2] == 0) && (bufData[3] == 0)) && (bufData[4] == 0)) && (0 == bufData[5]))
                    {
                        this.errmsg = "没有卡片";
                        return(string.Empty);
                    }
                    string str2 = string.Empty;
                    string str3 = string.Empty;
                    for (num3 = 0; num3 < 4; num3++)
                    {
                        str2 = str2 + bufData[num3 + 4].ToString("X2");
                    }
                    for (num3 = 0; num3 < 7; num3++)
                    {
                        str3 = str3 + bufData[num3 + 4].ToString("X2");
                    }
                    switch (bufData[1])
                    {
                    case 8:
                        str = str2;
                        break;

                    case 0x10:
                        str = string.Empty;
                        this.Beep(3, 200);
                        break;

                    case 1:
                        str = string.Empty;
                        this.Beep(3, 200);
                        break;

                    case 4:
                        str = string.Empty;
                        this.Beep(3, 200);
                        break;
                    }
                    break;
                }
                }
                return(str);
            }
            catch (Exception exception)
            {
                this.errmsg = exception.ToString();
                return(null);
            }
        }
Ejemplo n.º 8
0
        public string Excute()
        {
            string result;

            if (!this.Available())
            {
                result = string.Empty;
            }
            else
            {
                try
                {
                    string text  = string.Empty;
                    byte[] array = new byte[128];
                    for (int i = 0; i < 128; i++)
                    {
                        array[i] = 0;
                    }
                    switch (FRRAPT.QueryRFCard(this.porthandle, 82, array))
                    {
                    case 254:
                    case 255:
                        this.errmsg = "通讯失败";
                        result      = string.Empty;
                        break;

                    default:
                        if (array[2] == 0 && array[3] == 0 && array[4] == 0 && 0 == array[5])
                        {
                            this.errmsg = "没有卡片";
                            result      = string.Empty;
                        }
                        else
                        {
                            string text2 = string.Empty;
                            string str   = string.Empty;
                            for (int j = 0; j < 4; j++)
                            {
                                text2 += array[j + 4].ToString("X2");
                            }
                            for (int j = 0; j < 7; j++)
                            {
                                str += array[j + 4].ToString("X2");
                            }
                            byte b = array[1];
                            if (b <= 4)
                            {
                                if (b != 1)
                                {
                                    if (b == 4)
                                    {
                                        text = string.Empty;
                                        this.Beep(3, 200);
                                    }
                                }
                                else
                                {
                                    text = string.Empty;
                                    this.Beep(3, 200);
                                }
                            }
                            else if (b != 8)
                            {
                                if (b == 16)
                                {
                                    text = string.Empty;
                                    this.Beep(3, 200);
                                }
                            }
                            else
                            {
                                text = text2;
                            }
                            result = text;
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    this.errmsg = ex.ToString();
                    result      = null;
                }
            }
            return(result);
        }