Exemple #1
0
        //get the connection details
        public bool FunctionRFIDConnection_Parking()
        {
            try
            {
                Parking_readerAPI = new RFIDReader(strParkingIPaddress, Convert.ToUInt32(strParkingPort), 0);
                Parking_readerAPI.Connect();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Exception : Network Problem or Connection Already Exists...");
                lblErrorMessage.Text = "Exception : Network Problem or Connection Already Exists...";
                //if (ex.Message == "Connect")
                //{
                //    lblErrorMessage.Text = "Exception : Connection Already Exists...";
                //    tnrNetworkConnection.Enabled = false;
                //}
                //else
                //{
                //    lblErrorMessage.Text = "Exception : Network Problem...";
                //}
                btnParkingAreaReaderDisconnect.Enabled = false;
                btnParkingAreaReaderConnect.Enabled    = true;

                return(false);
            }
            try
            {
                if (Parking_readerAPI.IsConnected)
                {
                    Parking_readerAPI.Actions.TagAccess.OperationSequence.DeleteAll();

                    TagAccess.Sequence.Operation op = new TagAccess.Sequence.Operation();
                    op.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;

                    op.ReadAccessParams.ByteCount = 0;

                    Parking_readerAPI.Actions.TagAccess.OperationSequence.Add(op);
                    Parking_readerAPI.Actions.TagAccess.OperationSequence.PerformSequence();
                }

                //Parking_readerAPI.Config.GPO[1].PortState = GPOs.GPO_PORT_STATE.TRUE;
                //Parking_readerAPI.Config.GPO[2].PortState = GPOs.GPO_PORT_STATE.TRUE;
                //Parking_readerAPI.Config.GPO[3].PortState = GPOs.GPO_PORT_STATE.TRUE;

                //Thread.Sleep(500);

                //Parking_readerAPI.Config.GPO[1].PortState = GPOs.GPO_PORT_STATE.FALSE;
                //Parking_readerAPI.Config.GPO[2].PortState = GPOs.GPO_PORT_STATE.FALSE;
                //Parking_readerAPI.Config.GPO[3].PortState = GPOs.GPO_PORT_STATE.FALSE;

                tmrParkingArea.Enabled = true;
                nwflag = 0;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : " + ex.Message.ToString());
                return(false);
            }
        }
        public SimpleRFID()
        {
            try {
                m_ReaderAPI = new RFIDReader("localhost", 5084, 0);
                m_ReaderAPI.Connect();

                m_TagTable = new Hashtable(1023);

                m_ReaderAPI.Events.NotifyInventoryStartEvent    = true;
                m_ReaderAPI.Events.NotifyInventoryStopEvent     = true;
                m_ReaderAPI.Events.NotifyAccessStartEvent       = true;
                m_ReaderAPI.Events.NotifyAccessStopEvent        = true;
                m_ReaderAPI.Events.NotifyAntennaEvent           = true;
                m_ReaderAPI.Events.NotifyBufferFullEvent        = true;
                m_ReaderAPI.Events.NotifyBufferFullWarningEvent = true;
                m_ReaderAPI.Events.NotifyReaderExceptionEvent   = true;
                m_ReaderAPI.Events.NotifyReaderDisconnectEvent  = true;
                m_ReaderAPI.Events.NotifyHandheldTriggerEvent   = true;
                m_ReaderAPI.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
                m_ReaderAPI.Events.ReadNotify   += new Events.ReadNotifyHandler(Events_ReadNotify);
            }
            catch (Exception exc) {
                MessageBox.Show("Error conexión localhost", "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
                Application.Exit();
            }
        }
Exemple #3
0
        // ********************************************************************
        // RFID Connection Methods
        // ********************************************************************

        private void OpenRFIDConnection()
        {
            // Do this in MainActivity to test connection so we can notify user if they need to wake slep up

            if (readers == null)
            {
                readers = new Readers(this, ENUM_TRANSPORT.ServiceSerial);
            }
            ThreadPool.QueueUserWorkItem(o =>
            {
                try
                {
                    if (readers != null && readers.AvailableRFIDReaderList != null)
                    {
                        availableRFIDReaderList = readers.AvailableRFIDReaderList;
                        if (availableRFIDReaderList.Count > 0)
                        {
                            if (Reader == null)
                            {
                                // get first reader from list
                                readerDevice = availableRFIDReaderList[0];
                                Reader       = readerDevice.RFIDReader;
                                // Establish connection to the RFID Reader
                                Reader.Connect();
                                if (Reader.IsConnected)
                                {
                                    //Console.Out.WriteLine("Readers connected");
                                    serialRFD2000        = Reader.ReaderCapabilities.SerialNumber;
                                    rfidScannerConnected = true;
                                }
                            }
                            else
                            {
                                rfidScannerConnected = true;
                            }
                        }
                        else
                        {
                            rfidScannerConnected = false;
                        }
                    }
                    else
                    {
                        rfidScannerConnected = false;
                    }
                }
                catch (InvalidUsageException e)
                {
                    e.PrintStackTrace();
                }
                catch
                (OperationFailureException e)
                {
                    e.PrintStackTrace();
                    //Log.Debug(TAG, "OperationFailureException " + e.VendorMessage);
                }
            });
        }
        public void Start()
        {
            try
            {
                string info = "tatus:start";
                LogService.Info(TAG, info);

                if (rfidReader == null || rfidReader.IsConnected == false)
                {
                    rfidReader.Connect();
                    IsConnect = rfidReader.IsConnected;

                    // 1、阅读器事件配置
                    rfidReader.Events.NotifyInventoryStartEvent    = true;
                    rfidReader.Events.NotifyAccessStartEvent       = true;
                    rfidReader.Events.NotifyAccessStopEvent        = true;
                    rfidReader.Events.NotifyInventoryStopEvent     = true;
                    rfidReader.Events.NotifyAntennaEvent           = true;
                    rfidReader.Events.NotifyBufferFullWarningEvent = true;
                    rfidReader.Events.NotifyBufferFullEvent        = true;
                    rfidReader.Events.NotifyGPIEvent = true;
                    rfidReader.Events.NotifyReaderDisconnectEvent = true;
                    rfidReader.Events.NotifyReaderExceptionEvent  = true;
                    // 不通知tag读到事件,改由扫描按钮松开时,获取读到的标签信息
                    rfidReader.Events.AttachTagDataWithReadEvent = false;
                    // 注册扫描枪状态变化事件
                    rfidReader.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);

                    // 2、rssi值过滤配置,此处取最大最小值,因此没有过滤作用
                    PostFilter posFilter = new PostFilter();
                    posFilter.UseRSSIRangeFilter                 = true;
                    posFilter.RssiRangeFilter.MatchRange         = MATCH_RANGE.WITHIN_RANGE;
                    posFilter.RssiRangeFilter.PeakRSSILowerLimit = -128;
                    posFilter.RssiRangeFilter.PeakRSSIUpperLimit = 127;

                    // 3、扫描按钮信息配置
                    TriggerInfo triggerInfo = new TriggerInfo();
                    // 此参数配置为0,扫描枪在接收到扫描按钮松开事件后,停止扫描
                    triggerInfo.TagReportTrigger  = 0;
                    triggerInfo.StartTrigger.Type = START_TRIGGER_TYPE.START_TRIGGER_TYPE_HANDHELD;
                    triggerInfo.StartTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_PRESSED;
                    // 当扫描按钮松开后,经过一段时间出发扫描枪停止扫描事件(不过这里超时时间设为0,没有起到延迟触发事件的效果)
                    triggerInfo.StopTrigger.Type                   = STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_HANDHELD_WITH_TIMEOUT;
                    triggerInfo.StopTrigger.Handheld.Timeout       = 0;
                    triggerInfo.StopTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_RELEASED;

                    // 4、执行1、2、3的配置
                    rfidReader.Actions.Inventory.Perform(posFilter, triggerInfo, null);
                }
            }
            catch (Exception ex)
            {
                Message = "无法正常打开阅读器";
                LogService.Error(TAG, ex.Message);
            }
        }
        //get the connection details
        public bool FunctionRFIDConnection_Parking()
        {
            try
            {
                Parking_readerAPI = new RFIDReader(strReaderIPaddress, Convert.ToUInt32(strReaderPort), 0);
                Parking_readerAPI.Connect();
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Exception : Network Problem or Connection Already Exists...");
                lblErrorMessageText.Text = "Exception : Connection Already Exists...";
                classLog.writeLog("Error @: Connection Already Exists with the reader. Please check.");
                btnDisconnect.Enabled = false;
                btnConnect.Enabled    = true;

                return(false);
            }
            try
            {
                if (Parking_readerAPI.IsConnected)
                {
                    Parking_readerAPI.Actions.TagAccess.OperationSequence.DeleteAll();

                    TagAccess.Sequence.Operation op = new TagAccess.Sequence.Operation();
                    op.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;

                    op.ReadAccessParams.ByteCount = 0;

                    Parking_readerAPI.Actions.TagAccess.OperationSequence.Add(op);
                    Parking_readerAPI.Actions.TagAccess.OperationSequence.PerformSequence();
                }

                //Parking_readerAPI.Config.GPO[1].PortState = GPOs.GPO_PORT_STATE.TRUE;
                //Parking_readerAPI.Config.GPO[2].PortState = GPOs.GPO_PORT_STATE.TRUE;
                //Parking_readerAPI.Config.GPO[3].PortState = GPOs.GPO_PORT_STATE.TRUE;

                //Thread.Sleep(500);

                //Parking_readerAPI.Config.GPO[1].PortState = GPOs.GPO_PORT_STATE.FALSE;
                //Parking_readerAPI.Config.GPO[2].PortState = GPOs.GPO_PORT_STATE.FALSE;
                //Parking_readerAPI.Config.GPO[3].PortState = GPOs.GPO_PORT_STATE.FALSE;
                Parking_readerAPI.Config.GPO[classGlobalVariables.AntenaSet1Loc_RedLight_GPIO_PortNo].PortState = GPOs.GPO_PORT_STATE.TRUE;
                Parking_readerAPI.Config.GPO[classGlobalVariables.AntenaSet2Loc_RedLight_GPIO_PortNo].PortState = GPOs.GPO_PORT_STATE.TRUE;

                timerReader.Enabled = true;
                nwflag = 0;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : " + ex.Message.ToString());
                return(false);
            }
        }
Exemple #6
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     if (btnConnect.Text == "Connect")
     {
         string result = myComms.Connect(cboxReader.Text);
         listBox1.Items.Add(result);
         btnWrite.Enabled = true;
         btnConnect.Text  = "Disconnect";
     }
     else
     {
         btnConnect.Text  = "Connect";
         btnWrite.Enabled = false;
         listBox1.Items.Add(myComms.Disconnect());
     }
 }
Exemple #7
0
 private void InitReader()
 {
     if (readers == null)
     {
         readers = new Readers(this, ENUM_TRANSPORT.ServiceSerial);
     }
     ThreadPool.QueueUserWorkItem(o =>
     {
         try
         {
             if (readers != null && readers.AvailableRFIDReaderList != null)
             {
                 availableRFIDReaderList = readers.AvailableRFIDReaderList;
                 if (availableRFIDReaderList.Count > 0)
                 {
                     if (Reader == null)
                     {
                         // get first reader from list
                         readerDevice = availableRFIDReaderList[0];
                         Reader       = readerDevice.RFIDReader;
                         // Establish connection to the RFID Reader
                         Reader.Connect();
                         if (Reader.IsConnected)
                         {
                             ConfigureReader();
                             //Console.Out.WriteLine("Readers connected");
                             rfidScannerFound = true;
                         }
                     }
                 }
             }
         }
         catch (InvalidUsageException e)
         {
             e.PrintStackTrace();
         }
         catch
         (OperationFailureException e)
         {
             e.PrintStackTrace();
             //Log.Debug(TAG, "OperationFailureException " + e.VendorMessage);
         }
     });
 }
Exemple #8
0
        private void Connect()
        {
            if (Reader != null && !Reader.IsConnected)
            {
                RunOnUiThread(() =>
                {
                    Toast.MakeText(this, "Connecting", ToastLength.Short).Show();
                });

                Reader.Connect();

                RunOnUiThread(() =>
                {
                    if (Reader.IsConnected)
                    {
                        tvStatus.Text = "Connected";
                    }
                });

                ConfigureReader();
            }
        }
Exemple #9
0
        //get the connection details
        public bool FunctionRFIDConnection_PortEntry()
        {
            try
            {
                PortEntry_readerAPI = new RFIDReader(strPortEntryIPaddress, Convert.ToUInt32(strPortEntryPort), 0);
                PortEntry_readerAPI.Connect();
            }
            catch (Exception ex)
            {
                lblErrorMessage.Text = "Exception : Network Problem or Connection Already Exists...";
                btnPortEntryAreaReaderDisconnect.Enabled = false;
                btnPortEntryAreaReaderConnect.Enabled    = true;
                return(false);
            }
            try
            {
                if (PortEntry_readerAPI.IsConnected)
                {
                    PortEntry_readerAPI.Actions.TagAccess.OperationSequence.DeleteAll();

                    TagAccess.Sequence.Operation op = new TagAccess.Sequence.Operation();
                    op.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;

                    op.ReadAccessParams.ByteCount = 0;

                    PortEntry_readerAPI.Actions.TagAccess.OperationSequence.Add(op);
                    PortEntry_readerAPI.Actions.TagAccess.OperationSequence.PerformSequence();
                }

                tmrPortEntryArea.Enabled = true;
                nwflag = 0;
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : " + ex.Message.ToString());
                return(false);
            }
        }
Exemple #10
0
        public Form1()
        {
            InitializeComponent();
            m_ReaderAPI = new RFIDReader("localhost", 5084, 0);
            m_ReaderAPI.Connect();
            m_IsConnected = true;

            m_ReaderAPI.Events.NotifyInventoryStartEvent    = true;
            m_ReaderAPI.Events.NotifyInventoryStopEvent     = true;
            m_ReaderAPI.Events.NotifyAccessStartEvent       = true;
            m_ReaderAPI.Events.NotifyAccessStopEvent        = true;
            m_ReaderAPI.Events.NotifyAntennaEvent           = true;
            m_ReaderAPI.Events.NotifyBufferFullEvent        = true;
            m_ReaderAPI.Events.NotifyBufferFullWarningEvent = true;
            m_ReaderAPI.Events.NotifyReaderExceptionEvent   = true;
            m_ReaderAPI.Events.NotifyReaderDisconnectEvent  = true;
            m_ReaderAPI.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
            m_ReaderAPI.Events.ReadNotify   += new Events.ReadNotifyHandler(Events_ReadNotify);
            myDelegate = new AddListItem(addTag);

            labelLog.Text = "Probando " + EpcTools.getUpc("E20068060000000000000000");
        }
Exemple #11
0
        private void Initialize()
        {
            try
            {
                if (_reader != null)
                {
                    _reader.Events.ReadNotify -= new Events.ReadNotifyHandler(Events_ReadNotify);
                }

                //create RFIDReader using the default values and connect
                _reader = new RFIDReader(hostname, port, timeoutMs);
                _reader.Connect();

                //We are going to read just individual tags, attach tag data with read event
                _reader.Events.AttachTagDataWithReadEvent = true;

                //register read tag event notification
                _reader.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);

                //Set up start and stop triggers to be handheld trigger
                _triggerInfo = new TriggerInfo();

                _triggerInfo.StartTrigger.Type = START_TRIGGER_TYPE.START_TRIGGER_TYPE_HANDHELD;
                _triggerInfo.StartTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_PRESSED;

                _triggerInfo.StopTrigger.Type = STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_HANDHELD_WITH_TIMEOUT;
                _triggerInfo.StopTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_RELEASED;
                _triggerInfo.StopTrigger.Handheld.Timeout       = 0; // 0 = no timeout setting

                /* Setup inventory operation on the reader on the connected antenna, using the handheld trigger.
                 * Inventory starts when the handheld trigger is pressed and stops when released */
                _reader.Actions.Inventory.Perform(null, _triggerInfo, null);
            }
            catch (OperationFailureException ex)
            {
                throw new ApplicationException(String.Format("RFIDReader Initialization Error:{0}", ex.StatusDescription));
            }
        }
Exemple #12
0
        private void connectBackgroundWorker_DoWork(object sender, DoWorkEventArgs workEventArgs)
        {
            connectBackgroundWorker.ReportProgress(0, workEventArgs.Argument);

            if ((string)workEventArgs.Argument == "Connect")
            {
                m_ReaderAPI = new RFIDReader(m_ConnectionForm.IpText, uint.Parse(m_ConnectionForm.PortText), 0);

                try
                {
                    m_ReaderAPI.Connect();
                    m_IsConnected        = true;
                    workEventArgs.Result = "Connect Succeed";
                }
                catch (OperationFailureException operationException)
                {
                    workEventArgs.Result = operationException.StatusDescription;
                }
                catch (Exception ex)
                {
                    workEventArgs.Result = ex.Message;
                }
            }
            else if ((string)workEventArgs.Argument == "Disconnect")
            {
                try
                {
                    m_ReaderAPI.Disconnect();
                    m_IsConnected        = false;
                    workEventArgs.Result = "Disconnect Succeed";
                    m_ReaderAPI          = null;
                }
                catch (OperationFailureException ofe)
                {
                    workEventArgs.Result = ofe.Result;
                }
            }
        }
        public bool connect(string ip, uint port)
        {
            m_reader = new RFIDReader(ip, port, 0);

            try
            {
                m_reader.Connect();
                configureReader();
                m_reader.Actions.Inventory.Perform(null, null, null);
            }
            catch (OperationFailureException operationException)
            {
                Debug.WriteLine(operationException.StatusDescription);
                return(false);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("RFID Connect failed: " + ex.Message);
                return(false);
            }

            return(true);
        }
        //get the connection details
        public bool FunctionRFIDConnection_Parking()
        {
            try
            {
                Parking_readerAPI = new RFIDReader(strParkingIPaddress, Convert.ToUInt32(strParkingPort), 0);
                Parking_readerAPI.Connect();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : Connection Already Exists...");
                return(false);
            }
            try
            {
                if (Parking_readerAPI.IsConnected)
                {
                    Parking_readerAPI.Actions.TagAccess.OperationSequence.DeleteAll();

                    TagAccess.Sequence.Operation op = new TagAccess.Sequence.Operation();
                    op.AccessOperationCode = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;

                    op.ReadAccessParams.ByteCount = 0;

                    Parking_readerAPI.Actions.TagAccess.OperationSequence.Add(op);
                    Parking_readerAPI.Actions.TagAccess.OperationSequence.PerformSequence();
                }

                tmrParkingArea.Enabled = true;

                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception : " + ex.Message.ToString());
                return(false);
            }
        }
Exemple #15
0
        private void Connect()
        {
            try
            {
                _ReaderAPI.Connect();
                _Device.configureAntenna();

                /*
                 * Setup Events
                 */
                _ReaderAPI.Events.AttachTagDataWithReadEvent = false;
                _ReaderAPI.Events.ReadNotify   += new Events.ReadNotifyHandler(Events_ReadNotify);
                _ReaderAPI.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
                _ReaderAPI.Events.NotifyBufferFullWarningEvent = true;
                _ReaderAPI.Events.NotifyReaderDisconnectEvent  = true;

                _IsConnected = _ReaderAPI.IsConnected;
            }
            catch (OperationFailureException ofe)
            {
                //userNotification.Text = ofe.Result.ToString();
                //userNotification.Visible = true;
            }
        }
        private void Initialize()
        {
            try
            {
                if (_reader != null)
                {
                    _reader.Events.ReadNotify -= new Events.ReadNotifyHandler(Events_ReadNotify);
                }

                //create RFIDReader using the default values and connect
                _reader = new RFIDReader(hostname, port, timeoutMs);
                _reader.Connect();

                //We are going to read just individual tags, attach tag data with read event
                _reader.Events.AttachTagDataWithReadEvent = true;

                //register read tag event notification
                _reader.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);

                //Set up start and stop triggers to be handheld trigger
                _triggerInfo = new TriggerInfo();

                _triggerInfo.StartTrigger.Type = START_TRIGGER_TYPE.START_TRIGGER_TYPE_HANDHELD;
                _triggerInfo.StartTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_PRESSED;

                _triggerInfo.StopTrigger.Type = STOP_TRIGGER_TYPE.STOP_TRIGGER_TYPE_HANDHELD_WITH_TIMEOUT;
                _triggerInfo.StopTrigger.Handheld.HandheldEvent = HANDHELD_TRIGGER_EVENT_TYPE.HANDHELD_TRIGGER_RELEASED;
                _triggerInfo.StopTrigger.Handheld.Timeout = 0; // 0 = no timeout setting

                /* Setup inventory operation on the reader on the connected antenna, using the handheld trigger.
                 * Inventory starts when the handheld trigger is pressed and stops when released */
                _reader.Actions.Inventory.Perform(null, _triggerInfo, null);

            }
            catch (OperationFailureException ex)
            {
                throw new ApplicationException(String.Format("RFIDReader Initialization Error:{0}", ex.StatusDescription));
            }
        }
        internal void Connect(string status)
        {
            Cursor.Show();
            Cursor.Current = Cursors.WaitCursor;
            if (status == "Connect")
            {
                m_ReaderAPI = new RFIDReader("127.0.0.1", 5084, 0);

                try
                {
                    m_ReaderAPI.Connect();

                    /*
                     * Label setup
                     */
                    status = "Disconnect";
                    btnstarttstop.Text = "Start";
                    m_isReading = false;

                    try
                    {
                        // DiscardTagsOnInventoryStop enables faster processing of the stop operation
                        // by avoiding processing of tags that are still being received from the reader.
                        TagStorageSettings tagStorageSettings = m_ReaderAPI.Config.GetTagStorageSettings();
                        tagStorageSettings.DiscardTagsOnInventoryStop = true;
                        m_ReaderAPI.Config.SetTagStorageSettings(tagStorageSettings);
                        /*
                         *  Events Registration
                         */
                        this.m_ReaderAPI.Events.AttachTagDataWithReadEvent = false;
                        this.m_ReaderAPI.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
                        this.m_ReaderAPI.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
                        this.m_ReaderAPI.Events.NotifyBufferFullWarningEvent = true;
                        this.m_ReaderAPI.Events.NotifyBufferFullEvent = true;
                        this.m_ReaderAPI.Events.NotifyReaderDisconnectEvent = true;
                        this.m_ReaderAPI.Events.NotifyAccessStartEvent = true;
                        this.m_ReaderAPI.Events.NotifyAccessStopEvent = true;
                        this.m_ReaderAPI.Events.NotifyInventoryStartEvent = true;
                        this.m_ReaderAPI.Events.NotifyInventoryStopEvent = true;
                        this.m_ReaderAPI.Events.NotifyReaderExceptionEvent = true;
                        this.m_ReaderAPI.Events.NotifyHandheldTriggerEvent = true;

                    }
                    catch (OperationFailureException ofe)
                    {
                        notifyUser(ofe.VendorMessage, "Connect Configuration");
                    }
                }
                catch (OperationFailureException ofe)
                {
                    notifyUser(ofe.StatusDescription, "Connect");
                }
            }
            else if (status == "Disconnect")
            {
                if (!m_ReaderInitiatedDisconnectionReceived)
                {
                    try
                    {
                        m_ReaderAPI.Events.ReadNotify -= Events_ReadNotify;
                        m_ReaderAPI.Events.StatusNotify -= Events_StatusNotify;
                        StopReading();
                        m_ReaderAPI.Disconnect();
                    }
                    catch (OperationFailureException ofe)
                    {
                        notifyUser(ofe.VendorMessage, "Connect");
                    }
                }

                status = "Connect";
                this.btnstarttstop.Enabled = false;
            }
            m_IsConnected = m_ReaderAPI.IsConnected;
            Cursor.Current = Cursors.Default;
        }
        /// <summary>
        /// 打开读取器连接
        /// </summary>
        /// <returns></returns>
        public ReturnMessage OpenReaderConnection()
        {
            ReturnMessage returnMsg = new ReturnMessage();

            if (m_RFIDReader == null)
            {
                returnMsg.CallStatus  = false;
                returnMsg.CallMessage = "读取器开启失败 : 读取器对象为空.";
                //日志记录
                DeclaimerReaderLog.Error("[读取器开启失败 : 读取器对象为空.] ==== [" + DateTime.Now.ToString() + "]");
            }

            try
            {
                if (!m_RFIDReader.IsConnected)
                {
                    //连接操作
                    m_RFIDReader.Connect();
                    //允许开始读取
                    IsAllowStartRead = true;
                    //设置功率
                    returnMsg = SetReaderPower(this.ReaderPowerList);
                    //日志记录
                    DeclaimerReaderLog.Info("[" + returnMsg.CallMessage + "] ==== [" + DateTime.Now.ToString() + "]");
                    SetReaderAntennas(this.ReaderAntennasList);
                }

                m_IsReading = false;

                if (m_RFIDReader != null)
                {
                    m_RFIDReader.Actions.TagAccess.OperationSequence.DeleteAll();
                    TagAccess.Sequence.Operation op = new TagAccess.Sequence.Operation();
                    op.AccessOperationCode             = ACCESS_OPERATION_CODE.ACCESS_OPERATION_READ;
                    op.ReadAccessParams.MemoryBank     = (MEMORY_BANK)3; // 3 user区
                    op.ReadAccessParams.ByteCount      = 0;
                    op.ReadAccessParams.ByteOffset     = 0;
                    op.ReadAccessParams.AccessPassword = 0;
                    m_RFIDReader.Actions.TagAccess.OperationSequence.Add(op);
                }

                try
                {
                    TagStorageSettings tagStorageSettings = m_RFIDReader.Config.GetTagStorageSettings();
                    tagStorageSettings.DiscardTagsOnInventoryStop = true;
                    m_RFIDReader.Config.SetTagStorageSettings(tagStorageSettings);

                    /*
                     *  Events Registration
                     */
                    m_RFIDReader.Events.AttachTagDataWithReadEvent = false;
                    //读取回调
                    m_RFIDReader.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
                    //状态回调
                    //m_RFIDReader.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
                    m_RFIDReader.Events.NotifyBufferFullWarningEvent = true;
                    m_RFIDReader.Events.NotifyBufferFullEvent        = true;
                    m_RFIDReader.Events.NotifyReaderDisconnectEvent  = true;
                    m_RFIDReader.Events.NotifyAccessStartEvent       = true;
                    m_RFIDReader.Events.NotifyAccessStopEvent        = true;
                    m_RFIDReader.Events.NotifyInventoryStartEvent    = true;
                    m_RFIDReader.Events.NotifyInventoryStopEvent     = true;
                    m_RFIDReader.Events.NotifyReaderExceptionEvent   = true;
                    m_RFIDReader.Events.NotifyHandheldTriggerEvent   = false;
                }
                catch (OperationFailureException ofe)
                {
                    returnMsg.CallStatus  = false;
                    returnMsg.CallMessage = "Connect Configuration : " + ofe.VendorMessage;
                    //日志记录
                    DeclaimerReaderLog.Error("[" + returnMsg.CallMessage + "] ==== [" + DateTime.Now.ToString() + "]");
                }
            }
            catch (OperationFailureException ofe)
            {
                returnMsg.CallStatus  = false;
                returnMsg.CallMessage = "Connect Error : " + ofe.StatusDescription;
                //日志记录
                DeclaimerReaderLog.Error("[" + returnMsg.CallMessage + "] ==== [" + DateTime.Now.ToString() + "]");
            }
            return(returnMsg);
        }
        internal void Connect(string status)
        {
            if (status == "Connect")
            {
                m_ReaderAPI = new RFIDReader("127.0.0.1", 5084, 0);

                try
                {
                    m_ReaderAPI.Connect();

                    /*
                     * Label setup
                     */
                    //this.Text = m_ConnectionForm.IpText;
                    status = "Disconnect";

                    try
                    {
                        // DiscardTagsOnInventoryStop enables faster processing of the stop operation
                        // by avoiding processing of tags that are still being received from the reader.
                        TagStorageSettings tagStorageSettings = m_ReaderAPI.Config.GetTagStorageSettings();
                        tagStorageSettings.DiscardTagsOnInventoryStop = true;
                        m_ReaderAPI.Config.SetTagStorageSettings(tagStorageSettings);
                        /*
                         *  Events Registration
                         */
                        m_ReaderAPI.Events.AttachTagDataWithReadEvent = false;
                        m_ReaderAPI.Events.NotifyBufferFullWarningEvent = true;
                        m_ReaderAPI.Events.NotifyBufferFullEvent = true;
                        m_ReaderAPI.Events.NotifyReaderDisconnectEvent = true;
                        m_ReaderAPI.Events.NotifyAccessStartEvent = true;
                        m_ReaderAPI.Events.NotifyAccessStopEvent = true;
                        m_ReaderAPI.Events.NotifyInventoryStartEvent = true;
                        m_ReaderAPI.Events.NotifyInventoryStopEvent = true;
                        m_ReaderAPI.Events.NotifyReaderExceptionEvent = true;
                        m_ReaderAPI.Events.NotifyHandheldTriggerEvent = true;
                    }
                    catch (Symbol.RFID3.OperationFailureException ofe)
                    {
                        notifyUser(ofe.VendorMessage, "Connect Configuration");
                    }
                }
                catch (Symbol.RFID3.OperationFailureException ofe)
                {
                    notifyUser(ofe.StatusDescription, "Connect");
                }
            }
            else if (status == "Disconnect")
            {
                if (!m_ReaderInitiatedDisconnectionReceived)
                {
                    try
                    {
                        m_ReaderAPI.Disconnect();
                    }
                    catch (Symbol.RFID3.OperationFailureException ofe)
                    {
                        notifyUser(ofe.VendorMessage, "Connect");
                    }
                }

                this.Text = "NeoPhotonics";
                this.status = "Connect";
            }

            m_IsConnected = m_ReaderAPI.IsConnected;
        }
Exemple #20
0
        private void Connect()
        {
            uint port = 5084;
            _ReaderAPI = new RFIDReader("127.0.0.1", port, 0);

            try
            {
                _ReaderAPI.Connect();
                _Device.configureAntenna();
                /*
                 * Setup Events
                 */
                _ReaderAPI.Events.AttachTagDataWithReadEvent = false;
                _ReaderAPI.Events.ReadNotify += new Events.ReadNotifyHandler(Events_ReadNotify);
                _ReaderAPI.Events.StatusNotify += new Events.StatusNotifyHandler(Events_StatusNotify);
                _ReaderAPI.Events.NotifyBufferFullWarningEvent = true;
                _ReaderAPI.Events.NotifyReaderDisconnectEvent = true;

                _IsConnected = _ReaderAPI.IsConnected;

            }
            catch (OperationFailureException ofe)
            {
                userNotification.Text = ofe.Result.ToString();
                userNotification.Visible = true;
            }
        }
Exemple #21
0
        private void OpenRFIDConnection2()
        {
            Message msg = new Message();

            cHandler = new ConnectionHandler(this);
            msg      = cHandler.ObtainMessage();

            // Display progress bar

            ProgressDialog progBar = new ProgressDialog(this);

            progBar.SetCancelable(false);
            progBar.SetTitle("Connecting to RFID reader");
            progBar.SetIcon(Resource.Drawable.iconChill64);
            progBar.SetMessage("One moment please...");
            progBar.SetProgressStyle(ProgressDialogStyle.Spinner);
            progBar.Show();

            if (readers == null)
            {
                readers = new Readers(this, ENUM_TRANSPORT.ServiceSerial);
            }

            var thread = new System.Threading.Thread(new ThreadStart(delegate
            {
                try
                {
                    if (readers != null && readers.AvailableRFIDReaderList != null)
                    {
                        availableRFIDReaderList = readers.AvailableRFIDReaderList;
                        if (availableRFIDReaderList.Count > 0)
                        {
                            if (Reader == null)
                            {
                                // get first reader from list
                                readerDevice = availableRFIDReaderList[0];
                                Reader       = readerDevice.RFIDReader;
                                // Establish connection to the RFID Reader
                                Reader.Connect();
                                if (Reader.IsConnected)
                                {
                                    ConfigureReader();
                                    //Console.Out.WriteLine("Readers connected");
                                    //serialRFD2000 = Reader.ReaderCapabilities.SerialNumber;
                                    rfidScannerConnected = true;
                                    msg.Arg1             = 0;
                                }
                            }
                            else
                            {
                                rfidScannerConnected = true;
                                msg.Arg1             = 0;
                            }
                        }
                        else
                        {
                            rfidScannerConnected = false;
                            msg.Arg1             = 1;
                        }
                    }
                    else
                    {
                        rfidScannerConnected = false;
                        msg.Arg1             = 1;
                    }
                }
                catch (InvalidUsageException e)
                {
                    e.PrintStackTrace();
                    msg.Arg1 = 1;
                }
                catch
                (OperationFailureException e)
                {
                    e.PrintStackTrace();
                    msg.Arg1 = 1;
                    //Log.Debug(TAG, "OperationFailureException " + e.VendorMessage);
                }
                RunOnUiThread(() =>
                {
                    progBar.Dismiss();
                });
                cHandler.SendMessage(msg);
            }));

            thread.Start();
        }