Exemplo n.º 1
0
        private ABFsection ReadSection(int firstByte)
        {
            ABFsection section = new ABFsection();

            section.block = FileReadUInt32(firstByte);
            section.size  = FileReadUInt32();
            section.count = FileReadUInt32();
            return(section);
        }
Exemplo n.º 2
0
 private void ReadSectionMap()
 {
     if (abfVersionMajor == 1)
     {
         // ABF1 files don't have a section map
     }
     else if (abfVersionMajor == 2)
     {
         sectionProtocol    = ReadSection(76);
         sectionADC         = ReadSection(92);
         sectionDAC         = ReadSection(108);
         sectionEpoch       = ReadSection(124);
         sectionADCperDAC   = ReadSection(140);
         sectionEpochperDAC = ReadSection(156);
         sectionStrings     = ReadSection(220);
         sectionData        = ReadSection(236);
         sectionTag         = ReadSection(252);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Summarize this ABF's properties as a text block
        /// </summary>
        public string Info()
        {
            string info = $"### ABF Information for {abfID} ###\n";

            // populate a dictionary with all fields in this class
            Dictionary <string, string> dict = new Dictionary <string, string>();

            FieldInfo[] fields = this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
            foreach (FieldInfo x in fields)
            {
                System.Object val = x.GetValue(this);

                // skip certain variables
                string[] skippedVars = new string[] { "br", "indexedStrings", "tagTimes" };
                if (skippedVars.Contains(x.Name))
                {
                    continue;
                }

                // skip sections
                if (x.Name.StartsWith("section"))
                {
                    continue;
                }

                // prepare the object's value as a string
                string valStr = null;
                if (val == null)
                {
                    valStr = "";
                }
                else if (val.GetType().IsArray)
                {
                    List <string> vals = new List <string>();
                    foreach (var item in (Array)val)
                    {
                        vals.Add(item.ToString());
                    }
                    valStr = "[" + string.Join(", ", vals) + "]";
                }
                else if (val is ABFsection)
                {
                    ABFsection section = (ABFsection)val;
                    valStr = $"ABFsection (firstByte={section.firstByte}, size={section.size}, count={section.count})";
                }
                else
                {
                    valStr = val.ToString();
                }

                // if our string contains text, show it
                if (valStr != null)
                {
                    dict.Add(x.Name, valStr);
                }
            }

            // print items in alphabetical order
            List <string> keyList = new List <string>(dict.Keys);

            keyList.Sort();
            foreach (string key in keyList)
            {
                info += $"{key} = {dict[key]}\n";
            }
            return(info + "\n");
        }