Example #1
0
        public Impinj(string IPAddress, uint PortNumber = 5084, uint TimeOut = 10000)
        {
            try
            {
                sIPAddress = IPAddress;
                uiPortNo = PortNumber;
                uiCommandTimeOut = TimeOut;

                objMotorolaReader = new RFIDReader(sIPAddress, uiPortNo, uiCommandTimeOut);

                rdrStatus = KTR.IRFID.ReaderStatus.DISCOVERED;
                rdrType = KTR.IRFID.ReaderType.MOTOROLA;

                rdrInfo = new ReaderDetails();
                rdrInfo.IPAddress = sIPAddress;
                rdrInfo.PortNumber = uiPortNo;
                rdrInfo.VersionInformation = objMotorolaReader.VersionInfo.Version;
                rdrInfo.Vendor = rdrType;
                rdrInfo.ModelName = objMotorolaReader.ReaderCapabilities.ModelName;

            }
            catch (Exception ex)
            {
                throw new Exception("Unable to create object. " + ex.Message);
            }
        }
Example #2
0
        public Impinj(ReaderDetails readerInfo)
        {
            try
            {
                rdrInfo = readerInfo;
                objMotorolaReader = new RFIDReader(rdrInfo.IPAddress, rdrInfo.PortNumber, 10000);

            }
            catch (Exception ex)
            {
                throw new Exception("Unable to create object. " + ex.Message);
            }
        }
Example #3
0
        public MotorolaFX(ReaderDetails readerInfo)
        {
            try
            {
                rdrInfo = readerInfo;
                objMotorolaReader = new RFIDReader();
                objMotorolaReader.HostName =rdrInfo.IPAddress;
                objMotorolaReader.Port = rdrInfo.PortNumber;
                objMotorolaReader.TimeoutMilliseconds = 0;

            }
            catch (Exception ex)
            {
                throw new Exception("Unable to create object. " + ex.Message);
            }
        }
Example #4
0
        public IRFIDReader CreateNewReader(ReaderDetails rdr)
        {
            try
            {
                IRFIDReader rdrObject;
                string KeyWord = rdr.IPAddress + "::" + rdr.PortNumber;
                if (dicReaderObjs.ContainsKey(KeyWord))
                    return dicReaderObjs[KeyWord];

                if (rdr.Vendor == ReaderType.MOTOROLA)
                    rdrObject = new MotorolaFX(rdr);
                else
                    rdrObject = new Impinj(rdr);
                dicReaderObjs.Add(KeyWord, rdrObject);
                return rdrObject;
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
        public static List<ReaderDetails> AutoDiscoverMotorola()
        {
            List<ReaderDetails> lstReaderDetails = new List<ReaderDetails>();
            try
            {
                //If we give hostname = "localhost", it returns only 1 address in the list,
                //so we have get the host name from the dns.
                string hostName = Dns.GetHostName();//"localhost";
                IPHostEntry ipHostEntry = Dns.GetHostEntry(hostName);
                try
                {
                    string msg1 = "<wsd:Types xmlns:_0=\"http://standards.iso.org/iso/24791-3/2009/rdmp\">_0:ISO24791-3</wsd:Types>";
                    string msg2 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\" xmlns:wsd=\"http://schemas.xmlsoap.org/ws/2005/04/discovery\" xmlns:wsdp=\"http://schemas.xmlsoap.org/ws/2006/02/devprof\"><soap:Header><wsa:To>urn:schemas-xmlsoap-org:ws:2005:04:discovery</wsa:To><wsa:Action>http://schemas.xmlsoap.org/ws/2005/04/discovery/Probe</wsa:Action><wsa:MessageID>";
                    string msg3 = Guid.NewGuid().ToString();
                    string msg4 = "</wsa:MessageID></soap:Header><soap:Body><wsd:Probe>" + msg1 + "</wsd:Probe></soap:Body></soap:Envelope>";
                    string msg = msg2 + msg3 + msg4;
                    string str5 = string.Empty;
                    string response;
                    byte[] packet = System.Text.Encoding.UTF8.GetBytes(msg);

                    try
                    {
                        response = UDP.SendMsg(msg, "239.255.255.250", 3702, 1000, 20, 65534);
                        if (response != null)
                        {
                            if (response == string.Empty)
                                return lstReaderDetails;
                        }
                        else
                            return lstReaderDetails;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Not able to discover reader. Error :" + ex.Message);
                    }

                    response.Replace('\n', ' ');
                    response.Replace('\r', ' ');
                    string resProcessed1 = response.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", string.Empty).Replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", string.Empty);
                    string resProcessed2 = Guid.NewGuid().ToString();
                    string resProcessed3 = "<_" + resProcessed2 + ">";
                    string resProcessed4 = "</_" + resProcessed2 + ">";
                    string xml = resProcessed3 + resProcessed1 + resProcessed4;
                    XmlDocument xmlDocument = new XmlDocument();
                    XmlNodeList elementsByTagName1;
                    XmlNodeList elementsByTagName2;
                    XmlNodeList elementsByTagName3;
                    XmlNodeList elementsByTagName4;
                    try
                    {
                        xmlDocument.LoadXml(xml);
                        elementsByTagName1 = xmlDocument.GetElementsByTagName("Action", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
                        elementsByTagName2 = xmlDocument.GetElementsByTagName("RelatesTo", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
                        xmlDocument.GetElementsByTagName("Address", "http://schemas.xmlsoap.org/ws/2004/08/addressing");
                        elementsByTagName3 = xmlDocument.GetElementsByTagName("Types", "http://schemas.xmlsoap.org/ws/2005/04/discovery");
                        elementsByTagName4 = xmlDocument.GetElementsByTagName("XAddrs", "http://schemas.xmlsoap.org/ws/2005/04/discovery");
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Not able to discover reader. Error :" + ex.Message);
                    }

                    for (int index = 0; index < elementsByTagName1.Count; ++index)
                    {
                        if (elementsByTagName1[index].FirstChild.Value.EndsWith("ProbeMatches", StringComparison.OrdinalIgnoreCase) && elementsByTagName2[index].FirstChild.Value.Equals(msg3) && elementsByTagName3[index].FirstChild.Value.StartsWith("rdmpdev:ISO24791-3", StringComparison.OrdinalIgnoreCase))
                        {
                            Uri uri = new Uri(elementsByTagName4[index].FirstChild.Value);
                            bool result;
                            ReaderDetails rfidObj;
                            try
                            {
                                rfidObj = new ReaderDetails();
                                rfidObj.HostName = uri.DnsSafeHost.ToString();
                                rfidObj.IPAddress = uri.DnsSafeHost.ToString();
                                rfidObj.MAC = uri.AbsolutePath.Substring(uri.AbsolutePath.LastIndexOf("-")+1 ,
                                  12);
                            }
                            catch (Exception ex)
                            {
                                continue;
                            }
                            bool flag = true;
                            foreach (ReaderDetails rfidReader in lstReaderDetails)
                            {
                                if (rfidReader.HostName.Equals(rfidObj.HostName))
                                {
                                    flag = false;
                                    break;
                                }
                            }
                            if (flag)
                                lstReaderDetails.Add(rfidObj);
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Not able to discover reader. Error :" + ex.Message);
                }

            }
            catch (Exception ex)
            {
                throw new Exception("Not able to discover reader. Error :" + ex.Message);
            }

            return lstReaderDetails;
        }