コード例 #1
0
        /**********************************************ENDE***********************************************************/

        /*******Thread method*****************/
        public void ReadThread()
        {
            int ReqSets;
            int status;

            //declaration of delegateobject
            DelegateDisplayRecSets   DisplayRecSetMethod    = new DelegateDisplayRecSets(DisplayRecSets);
            DelegateTextBoxDataClear TextBoxDataClearMethod = new DelegateTextBoxDataClear(TextBoxDataClear);
            DelegateReaderDisconnect ReaderDisconnectMethod = new DelegateReaderDisconnect(ReaderDisconnect);

            object[] obj = new object[10];

            IAsyncResult result;

            ReqSets = 255;


            while (true)
            {
                if (!(running && reader.Connected))
                {
                    continue;
                }
                // read data from reader
                // read max. possible no. of data sets: request 255 data sets
                try
                {
                    //if (ReaderInfo.ReaderType == FedmIscReaderConst.TYPE_ISCLR200)
                    if (reader.GetReaderType() == (byte)FedmIscReaderConst.TYPE_ISCLR200)
                    {
                        reader.SetData(FedmIscReaderID.FEDM_ISCLR_TMP_BRM_SETS, ReqSets);
                        status = reader.SendProtocol(0x21); // old BRM request
                    }
                    else
                    {
                        reader.SetData(FedmIscReaderID.FEDM_ISC_TMP_ADV_BRM_SETS, ReqSets);
                        status = reader.SendProtocol(0x22);
                    }

                    if ((status == 0x00) || (status == 0x83) || (status == 0x84) || (status == 0x85) || (status == 0x93) || (status == 0x94))
                    {
                        object[]           obj1     = new object[2];
                        FedmBrmTableItem[] brmItems = new FedmBrmTableItem[ReqSets];
                        try
                        {
                            brmItems = (FedmBrmTableItem[])reader.GetTable(FedmIscReaderConst.BRM_TABLE);
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }

                        if (brmItems != null)
                        {
                            string[] serialnumber = new string[brmItems.Length];
                            string[] dataBlock    = new string[brmItems.Length];
                            string[] timer        = new string[brmItems.Length];
                            string[] date         = new string[brmItems.Length];
                            byte[]   type         = new byte[brmItems.Length];
                            byte[]   antennaNr    = new byte[brmItems.Length];
                            byte[]   input        = new byte[brmItems.Length];
                            byte[]   state        = new byte[brmItems.Length];
                            Dictionary <byte, FedmIscRssiItem>[] dicRSSI = new Dictionary <byte, FedmIscRssiItem> [brmItems.Length];

                            byte[] dbsize = new byte[brmItems.Length];

                            string db;
                            int    i;

                            for (i = 0; i < brmItems.Length; i++)
                            {
                                // Serial Number
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_SNR))
                                {
                                    brmItems[i].GetData(FedmIscReaderConst.DATA_SNR, out serialnumber[i]);
                                }

                                // Data Blocks
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_RxDB))
                                {
                                    for (int cnt = 0; cnt < brmItems[i].GetBlockCount(); cnt++)
                                    {
                                        // Note: request of [0x21] Read Buffer contains a valid block address
                                        // while request of [0x22] Read Buffer has no block address
                                        // If you need no compatibility with ID ISC.LR200 you should remove
                                        // the term '+ brmItems[i].GetBlockAddress()' (returns always 0)
                                        brmItems[i].GetData(FedmIscReaderConst.DATA_RxDB, cnt + brmItems[i].GetBlockAddress(), out db);
                                        dataBlock[i] = dataBlock[i] + db + "\r\n" + "\t\t";
                                    }
                                }

                                // Transponder Type
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_TRTYPE))
                                {
                                    brmItems[i].GetData(FedmIscReaderConst.DATA_TRTYPE, out type[i]);
                                }

                                // Time
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_TIMER))
                                {
                                    timer[i] = brmItems[i].GetReaderTime().GetTime();
                                }

                                // Date
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_DATE))
                                {
                                    date[i] = brmItems[i].GetReaderTime().GetDate();
                                }

                                // Ant Nr.
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_ANT_NR))
                                {
                                    brmItems[i].GetData(FedmIscReaderConst.DATA_ANT_NR, out antennaNr[i]);
                                }

                                // RSSI value
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_ANT_RSSI))
                                {
                                    dicRSSI[i] = brmItems[i].GetRSSI();
                                }
                                else
                                {
                                    dicRSSI[i] = new Dictionary <byte, FedmIscRssiItem>();
                                }

                                // Input + State
                                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_INPUT))
                                {
                                    brmItems[i].GetData(FedmIscReaderConst.DATA_INPUT, out input[i]);
                                    brmItems[i].GetData(FedmIscReaderConst.DATA_STATE, out state[i]);
                                }
                            }

                            obj[0] = brmItems.Length;
                            obj[1] = type;
                            obj[2] = serialnumber;
                            obj[3] = dataBlock;
                            obj[4] = timer;
                            obj[5] = date;
                            obj[6] = antennaNr;
                            obj[7] = dicRSSI;
                            obj[8] = input;
                            obj[9] = state;


                            result = (IAsyncResult)Invoke(DisplayRecSetMethod, obj);
                            ClearBuffer();
                        }
                        else
                        {
                            //If not data in Table don't show this in ListView
                            result = (IAsyncResult)Invoke(TextBoxDataClearMethod);
                            EndInvoke(result);
                        }
                    }
                    else
                    {
                        //If Reader no support command 0x22
                        if ((status == 0x80) || (status == 0x81) || (status == 0x82))
                        {
                            result = (IAsyncResult)Invoke(ReaderDisconnectMethod);
                            EndInvoke(result);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
コード例 #2
0
        /*****************************Methods from interface FedmTaskListener*******************/
        public void OnNewNotification(int iError, string IP, uint PortNr)
        {
            int i;

            FedmBrmTableItem[] brmItems;
            brmItems = (FedmBrmTableItem[])reader.GetTable(FedmIscReaderConst.BRM_TABLE);

            //declaration from delegateobject
            DelegateDisplayRecSets DisplayRecSetMethod = new DelegateDisplayRecSets(DisplayRecSets);

            object[]     obj = new object[11];
            IAsyncResult result;

            if (brmItems == null)
            {
                return;
            }
            string[] serialnumber = new string[brmItems.Length];
            string[] dataBlock    = new string[brmItems.Length];
            string[] date         = new string[brmItems.Length];
            string[] time         = new string[brmItems.Length];
            byte[]   type         = new byte[brmItems.Length];
            byte[]   antennaNr    = new byte[brmItems.Length];
            byte[]   input        = new byte[brmItems.Length];
            byte[]   state        = new byte[brmItems.Length];
            byte[]   dbsize       = new byte[brmItems.Length];
            Dictionary <byte, FedmIscRssiItem>[] dicRSSI = new Dictionary <byte, FedmIscRssiItem> [brmItems.Length];

            long   dbn;
            byte   dbadr;
            string db;

            for (i = 0; i < brmItems.Length; i++)
            {   // serial number
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_SNR))
                {
                    brmItems[i].GetData(FedmIscReaderConst.DATA_SNR, out serialnumber[i]);
                }
                // data blocks
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_RxDB))
                {
                    brmItems[i].GetData(FedmIscReaderConst.DATA_DBN, out dbn);
                    brmItems[i].GetData(FedmIscReaderConst.DATA_DB_ADR, out dbadr);
                    int j;
                    for (j = dbadr; j < dbn; j++)
                    {
                        brmItems[i].GetData(FedmIscReaderConst.DATA_RxDB, j, out db);
                        dataBlock[i] = dataBlock[i] + db + "\r\n" + "\t\t";
                    }
                }
                // Transponder Type
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_TRTYPE))
                {
                    brmItems[i].GetData(FedmIscReaderConst.DATA_TRTYPE, out type[i]);
                }
                // Date
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_DATE))
                {
                    date[i] = brmItems[i].GetReaderTime().GetDate();
                }

                // Time
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_TIMER))
                {
                    time[i] = brmItems[i].GetReaderTime().GetTime();
                }

                // Antenna number
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_ANT_NR))
                {
                    brmItems[i].GetData(FedmIscReaderConst.DATA_ANT_NR, out antennaNr[i]);
                }
                // RSSI value
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_ANT_RSSI))
                {
                    dicRSSI[i] = brmItems[i].GetRSSI();
                }
                else
                {
                    dicRSSI[i] = new Dictionary <byte, FedmIscRssiItem>();
                }
                // Input
                if (brmItems[i].IsDataValid(FedmIscReaderConst.DATA_INPUT))
                {
                    brmItems[i].GetData(FedmIscReaderConst.DATA_INPUT, out input[i]);
                    brmItems[i].GetData(FedmIscReaderConst.DATA_STATE, out state[i]);
                }
            }
            obj[0]  = brmItems.Length;
            obj[1]  = type;
            obj[2]  = serialnumber;
            obj[3]  = dataBlock;
            obj[4]  = date;
            obj[5]  = time;
            obj[6]  = antennaNr;
            obj[7]  = dicRSSI;
            obj[8]  = input;
            obj[9]  = state;
            obj[10] = IP;

            result = (IAsyncResult)Invoke(DisplayRecSetMethod, obj);
        }