예제 #1
0
파일: MainForm.cs 프로젝트: aaana/rfid
        public Boolean connect()
        {
            string address = _readerSettingsForm.GetReaderAddress();

            if (address == String.Empty)
            {
                return(false);
            }

            Console.WriteLine("Connectting to Reader...");

            // Modify label status in the Status Strip
            tsslblStatus.Text  = ReaderStatus.Connecting.ToString();
            tsslblStatus.Image = Properties.Resources.status_connecting;
            ConnectResponse connectResponse = null;

            try
            {
                IImpinjControlService impinjControlService = ServiceManager.getOneImpinjControlService();
                connectResponse = impinjControlService.connect(address);
                ServiceManager.closeService(impinjControlService);
                this.tsbtnStart.Enabled       = true;
                this.toolStripButton1.Enabled = true;
            }
            catch
            {
            }
            // Check for a connection error
            if (connectResponse == null)
            {
                // Could not connect to the reader; Print out the error
                Console.WriteLine("Failed to Connect to Reader!");
                tsslblStatus.Text  = "失败!";
                tsslblStatus.Image = Properties.Resources.status_stop;

                MessageBox.Show(tsslblStatus.Text, "Connection Error");
                //    RFIDReaderParameter.IsConnected = false;
                return(false);
            }
            else
            {
                // Connect to the reader successfully
                Console.WriteLine("Succeeded to Connect to Reader!");
                RFIDReaderParameter.antennaConfiguration = connectResponse.antennaConfiguration;
                RFIDReaderParameter.readerCapabilities   = connectResponse.readerCapabilities;
                RFIDReaderParameter.rOReportSpec         = connectResponse.rOReportSpec;
                // Display settings in ReaderSettingsForm
                //  _readerSettingsForm.ReceiveConfigFromRFIDReaderPara();

                // Modify label status in the Status Strip


                // Modify Setting panel status

                //     RFIDReaderParameter.IsConnected = true;
                return(true);
            }
        }
예제 #2
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            string oldEpc = this.CurrentEpcTextBox.Text;
            string newEpc = this.newEpcTextBox.Text;
            IImpinjControlService service = ServiceManager.getOneImpinjControlService();

            service.updateEpc(oldEpc, newEpc);
            ServiceManager.closeService(service);
        }
예제 #3
0
        public void StartInventory()
        {
            SARParameter.IsSimulation = false;
            PhaseLocating.getInstance().started        = true;
            IImpinjControlService impinjControlService = ServiceManager.getOneImpinjControlService();

            impinjControlService.startInventory(RFIDReaderParameter.antennaConfiguration, RFIDReaderParameter.rOReportSpec);
            ServiceManager.closeService(impinjControlService);
            //    this.UpdateComponentStatus((int)ENUM_ROSpecEventType.Start_Of_ROSpec, SARParameter.IsSimulation);
            StartDequeueThread();
        }
예제 #4
0
        /// <summary>
        /// Dequeue tagInfo from tags queue
        /// </summary>
        public void DequeueTagInfo()
        {
            while (true)
            {
                List <TagInfo> tagInfoList = null;
                TagInfo        tagInfo     = null;
                if (SARParameter.IsSimulation)
                {
                    if (_tagsQueue.TryDequeue(out tagInfo))
                    {
                        tagInfoList = new List <TagInfo>();
                        tagInfoList.Add(tagInfo);
                    }
                }
                else
                {
                    try
                    {
                        IImpinjControlService impinjControlService = ServiceManager.getOneImpinjControlService();
                        TagInfo[]             tagInfoArray         = impinjControlService.tryDeque();
                        ServiceManager.closeService(impinjControlService);
                        tagInfoList = new List <TagInfo>(tagInfoArray);
                    }
                    catch
                    {
                    }
                }
                if (tagInfoList != null && tagInfoList.Count > 0)
                {
                    foreach (TagInfo tagInfoInList in tagInfoList)
                    {
                        PhaseLocating.getInstance().addPhaseRecord(tagInfoInList);
                        this.BeginInvoke(method: new Action(() =>
                        {
                            this.UpdateDisplayForms(tagInfoInList, SARParameter.IsSimulation);
                        }));

                        if (_sortingBooksForm.Visible)
                        {
                            if (SARParameter.IsSimulation)
                            {
                                //处于模拟中,使用SAR(tagInfo)
                                _sortingBooksForm.SAR(tagInfoInList);
                            }
                        }
                    }
                    TagInfo lastTagInfo = tagInfoList.Last();
                    UpdateStatusStrip(lastTagInfo, false);
                    this._systemInfoForm.updateTime((long)lastTagInfo.FirstSeenTime);
                }
                Thread.Sleep(10);
            }
        }
예제 #5
0
파일: MainForm.cs 프로젝트: aaana/rfid
        public void StopInventory()
        {
            PhaseLocating.getInstance().started = false;
            StopDequeueThread();

            if (tsbtnStop.Enabled)
            {
                IImpinjControlService impinjControlService = ServiceManager.getOneImpinjControlService();
                impinjControlService.stopInventory();
                ServiceManager.closeService(impinjControlService);
                // this.UpdateComponentStatus((int)ENUM_ROSpecEventType.End_Of_ROSpec, SARParameter.IsSimulation);
            }
        }
예제 #6
0
파일: MainForm.cs 프로젝트: aaana/rfid
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            Properties.Settings.Default.IP       = RFIDReaderParameter.IP;
            Properties.Settings.Default.MAC      = RFIDReaderParameter.MAC;
            Properties.Settings.Default.Hostname = RFIDReaderParameter.Hostname;

            Properties.Settings.Default.Save();
            _linearGuideForm.stopDmc();
            //Dispose objects
            if (tsbtnStop.Enabled)
            {
                try
                {
                    _dequeueThread.Abort();
                }
                catch (Exception)
                {
                    throw;
                }
            }
            try
            {
                IImpinjControlService impinjControlService = ServiceManager.getOneImpinjControlService();
                impinjControlService.disconnect();
                ServiceManager.closeService(impinjControlService);
            }
            catch
            {
            }
            // Save DockPanel.config
            try
            {
                this.dockPanelMain.SaveAsXml(Path.Combine(_filepath, "DockPanel.config"));
            }
            catch (Exception)
            {
                MessageBox.Show("Fail to save DockPanel.config!", "File Save Error");
                return;
            }
        }
예제 #7
0
 public static void closeService(IImpinjControlService service)
 {
     ((ImpinjControlServiceClient)service).Close();
 }