Exemplo n.º 1
0
 // Initializes an RFIDReader and passes the delegate functions to it.
 // Also sets up a thread to run a realtime chart, if desired.
 public RFIDReaderThread(int numTags, Action <ConcurrentDictionary <string, Bernoulli> > onTouchDistributionChanged,
                         Action <ConcurrentDictionary <string, Normal> > onVelocityDistributionChanged, bool shouldGraph)
 {
     this.shouldGraph = shouldGraph;
     Console.WriteLine("reader thread " + shouldGraph);
     if (shouldGraph)
     {
         this.chart = new TimeSeriesChart();
     }
     RFIDReader.initializeSettings(numTags, chart);
     if (onTouchDistributionChanged != null)
     {
         RFIDReader.setDelegates(onTouchDistributionChanged, onVelocityDistributionChanged);
     }
 }
Exemplo n.º 2
0
        private void ConnectBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if ((string)e.Argument == "Connect")
            {
                m_ReaderAPI = new RFIDReader(IPtxt.Text, uint.Parse("5064"), 0);

                try
                {
                    m_ReaderAPI.Connect();
                    m_IsConnected = true;
                    e.Result      = "Connect Succeed";
                }
                catch (OperationFailureException operationException)
                {
                    e.Result = operationException.StatusDescription;
                }
                catch (Exception ex)
                {
                    e.Result = ex.Message;
                }
            }
            else if ((string)e.Argument == "Disconnect")
            {
                try
                {
                    m_ReaderAPI.Disconnect();
                    m_IsConnected = false;
                    e.Result      = "Disconnect Succeed";
                    m_ReaderAPI   = null;
                }
                catch (OperationFailureException ofe)
                {
                    e.Result = ofe.Result;
                }
            }
        }