Exemplo n.º 1
0
        public string Format(byte[] rawdata)
        {
            string retval = string.Empty;

            switch (_tagid)
            {
            case TagID.OBJECT_IDENTIFIER:
                retval = CalculaOID(rawdata, _start_contents, _lenght_octets);
                break;

            case TagID.IA5String:
            case TagID.T61String:
            case TagID.PrintableString:
            case TagID.UTCTime:
            case TagID.OCTET_STRING:
            case TagID.UTF8_STRING:
            case TagID.RFC822NAME:
                retval = (new ASCIIEncoding()).GetString(rawdata, _start_contents, _lenght_octets);
                break;

            default:
                retval = (string)_tagid.ToString();
                break;
            }

            //case TagID.BIT_STRING:
            //case TagID.INTEGER:
            //case TagID.UTCTime:
            //case TagID.NULL:
            //case TagID.SEQUENCE:
            //case TagID.SET:
            //    break;

            return(retval);
        }
Exemplo n.º 2
0
        internal FileInfo getPathByID(TagID id)
        {
            DirectoryInfo objDir = getObjectsDirectory();
            string        idStr  = id.ToString();

            string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2), idStr.Substring(2));

            return(new FileInfo(path));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Возвращает коллекцию параметров.
        /// </summary>
        public override Dictionary <string, string> GetParameters()
        {
            var parameters = base.GetParameters();

            parameters["tag_id"] = TagID.ToString();
            if (OwnerID != 0)
            {
                parameters["owner_id"] = OwnerID.ToString();
            }
            parameters["video_id"] = VideoID.ToString();

            return(parameters);
        }
Exemplo n.º 4
0
        public override string ToString()
        {
            List <TagKey> keys = TagMap.GetKeys(TagID);

            if (keys.Count == 0)
            {
                switch (Type)
                {
                case 1: return(String.Format("{0} = {1}", TagID.ToString(), Float));

                case 4: return(String.Format("{0} = {1}", TagID.ToString(), ScriptFormula));

                default: return(String.Format("{0} = {1}", TagID.ToString(), Int));
                }
            }

            if (keys.Count == 1)
            {
                var value = keys.First().GetType().GetMethod("GetValue").Invoke(keys.First(), new object[] { this });
                return(String.Format("{0} = {1}", keys.First().Name, value == null ? "null" : value.ToString()));
            }

            return(String.Format("Ambigious key: Depending of the context it one of {0}", String.Join(",", keys.Select(x => x.Name).ToArray())));
        }
Exemplo n.º 5
0
 // override object.GetHashCode
 public override int GetHashCode()
 {
     return((GetType().FullName + "|" + TagID.ToString()).GetHashCode());
 }
Exemplo n.º 6
0
        public bool LoadTagData(ref XtiveTag[] tagData, ref int RecordCount)
        {
            if (m_handle == IntPtr.Zero)
            {
                return(false);
            }

            RecordCount = 0;
            try
            {
                while (RecordCount < 100)
                {
                    if (!ReaderTag(m_handle, ref btTagType, ref TagID, ref bExcite, ref bLowPower, ref ExciteID, ref RID, ref fRSSI))   // get one tag once, FIFO
                    {
                        //     Debug.WriteLine("failed to ReaderTag");
                        break;
                    }
                    else
                    {
                        //     Debug.WriteLine(TagID.ToString());

                        /*tagData[RecordCount].RSSI = Convert.ToInt32(fRSSI);
                         * tagData[RecordCount].UID = TagID.ToString();
                         * //    tagData[RecordCount].RID = RID;
                         * tagData[RecordCount].bLowPower = bLowPower;
                         * tagData[RecordCount].bExcite = bExcite;
                         * tagData[RecordCount].An = "0";
                         * tagData[RecordCount].ReaderIP = ip;
                         * tagData[RecordCount].datetime = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");*/
                        XtiveTag tag = (new XtiveTag.Builder())
                                       .SetUid(TagID.ToString())
                                       .SetRssi(Convert.ToInt32(fRSSI))
                                       .SetBLowPower(bLowPower)
                                       .SetBExcite(bExcite)
                                       .SetReaderIP(ip)
                                       .SetAn("0")
                                       .SetDateTime(System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).Build();
                        tagData[RecordCount] = tag;
                        RecordCount++;
                    }
                }
                _ReaderErrorCode      = 0;
                _ReaderErrorSpecified = "";
            }
            catch (Exception e)
            {
                _ReaderErrorCode      = 42;
                _ReaderErrorSpecified = "读写器LoadTagData函数故障:" + m_handle.ToString() + "  " + e.Message.ToString();
                log.Error(_ReaderErrorSpecified);
                return(false);
            }
            finally
            {
            }
            if (RecordCount == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 7
0
 public override string ToString()
 {
     return(TagID.ToString());
 }
        internal FileInfo[] getPathsByPartialID(TagID.Partial partial)
        {
            DirectoryInfo objDir = getObjectsDirectory();
            string idStr = partial.ToString();

            string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2));
            var di = new DirectoryInfo(path);
            if (!di.Exists) return new FileInfo[0];

            return di.GetFiles(idStr.Substring(2) + "*");
        }
        internal FileInfo getPathByID(TagID id)
        {
            DirectoryInfo objDir = getObjectsDirectory();
            string idStr = id.ToString();

            string path = System.IO.Path.Combine(objDir.FullName, idStr.Substring(0, 2), idStr.Substring(2));
            return new FileInfo(path);
        }
 public Task<Errorable<TagID>> ResolvePartialID(TagID.Partial id)
 {
     FileInfo[] fis = system.getPathsByPartialID(id);
     if (fis.Length == 1) return Task.FromResult(TagID.TryParse(id.ToString().Substring(0, 2) + fis[0].Name));
     if (fis.Length == 0) return Task.FromResult((Errorable<TagID>)new TagIDPartialNoResolutionError(id));
     return Task.FromResult((Errorable<TagID>)new TagIDPartialAmbiguousResolutionError(id, fis.SelectAsArray(f => TagID.TryParse(id.ToString().Substring(0, 2) + f.Name).Value)));
 }