Beispiel #1
0
        public String ReadCardNo()
        {
            if (!isPortOpened)
            {
                return("");
            }

            //读取卡号
            int   ReaderID  = 0;
            int   BlockID   = 0;
            char  KeySel    = SDTReader.PASSWORD_A;//SDTReader.PASSWORD_B
            short CardType1 = 0;
            char  CardMem1  = (char)0;

            byte[] Key        = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
            byte[] Data       = new byte[16];
            byte[] SN         = new byte[4];
            int    CardNoLen1 = 0;

            String strRet = "";

            try
            {
                if (SDTReader.YW_AntennaStatus(ReaderID, true) >= 0)
                {
                    if (SDTReader.YW_RequestCard(ReaderID, SDTReader.REQUESTMODE_ALL, ref CardType1) > 0)
                    {
                        if (SDTReader.YW_AntiCollideAndSelect(ReaderID, (char)1, ref CardMem1, ref CardNoLen1, ref SN[0]) > 0)
                        {
                            if (SDTReader.YW_KeyAuthorization(ReaderID, KeySel, BlockID, ref Key[0]) > 0)
                            {
                                if (SDTReader.YW_ReadaBlock(ReaderID, BlockID, 16, ref Data[0]) > 0)
                                {
                                    strRet = "";
                                    //for (int i = 0; i < 16; i++)
                                    for (int i = 0; i < 4; i++)//8位卡号,4个字节
                                    {
                                        strRet = strRet + Data[i].ToString("X2");
                                    }

                                    //MessageBox.Show("读取正确");
                                    //读取成功后,滴滴一声
                                    SDTReader.YW_Buzzer(ReaderID, 1, 1, 1);
                                    //绿灯闪一闪
                                    SDTReader.YW_Led(ReaderID, 1, 1, 1, 3);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception exp)
            {
                isPortOpened = false;
                Console.WriteLine(exp.Message);
                errorMessage = exp.Message;
            }

            return(strRet);
        }
Beispiel #2
0
        //Beep 使用在空队列出现新检查时
        public void Beep_EmptyQueue_New_Arrival()
        {
            int ReaderID = 0;

            if (!isPortOpened)
            {
                return;
            }

            try
            {
                //Beep
                SDTReader.YW_Buzzer(ReaderID, 3, 2, 3);
            }
            catch (Exception exp)
            {
                isPortOpened = false;
                Console.WriteLine(exp.Message);
                errorMessage = exp.Message;
            }
        }
Beispiel #3
0
        //Beep
        public void Beep()
        {
            int ReaderID = 0;

            if (!isPortOpened)
            {
                return;
            }

            try
            {
                //Beep
                SDTReader.YW_Buzzer(ReaderID, 1, 1, 1);
            }
            catch (Exception exp)
            {
                isPortOpened = false;
                Console.WriteLine(exp.Message);
                errorMessage = exp.Message;
            }
        }