Beispiel #1
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"Setup time:         {this.dt0.ToString()}\n\t\t\t{BinFileObject.ConvertByteArrayToDateTime(BitConverter.GetBytes(dt0))}");
            sb.AppendLine($"Panel number:       {this.number.ToString()}");
            sb.AppendLine($"Panel version:      {this.version.ToString()}");
            sb.AppendLine($"Tick:               {this.tick.ToString()}");
            sb.AppendLine($"Word per measure:   {this.wperi.ToString()}");
            sb.AppendLine($"Block offset:       {this.offset.ToString()}");
            sb.AppendLine($"Start time:         {this.dts.ToString()}\n\t\t\t{BinFileObject.ConvertByteArrayToDateTime(BitConverter.GetBytes(dts))}");
            sb.AppendLine($"Ust flow:           {this.onemr.ToString()}");
            sb.AppendLine($"Reserved 1:         {this.reserved1.ToString()}");
            sb.AppendLine($"Kemr:               {this.kemr.ToString()}");
            //sb.AppendLine($"Reserved 2:         {LineOptionsToString(this.reserved2, 16)}");
            sb.AppendLine($"Ust line options:   {LineOptionsToString(this.ust)}");
            sb.AppendLine($"Osn line options:   {LineOptionsToString(this.osn)}");
            sb.AppendLine($"Dop line options:   {LineOptionsToString(this.dop)}");

            sb.AppendLine($"Adrmdp:             {this.adrmdp.ToString()}");
            sb.AppendLine($"Spmdp:              {this.spmdp.ToString()}");
            sb.AppendLine($"Reserved 4:         {this.reserved4.ToString()}");

            //sb.AppendLine($"Ust Description:    {Encoder(this.ustLineDescription)}");
            //sb.AppendLine($"Osn Description:    {Encoder(this.osnLineDescription)}");
            //sb.AppendLine($"Dop Description:    {Encoder(this.dopLineDescription)}");
            //sb.AppendLine($"Reserved 3:         {Encoder(this.reserved3)}");

            return(sb.ToString());
        }
Beispiel #2
0
 public static void Save(string fileName, BinFileObject bfo)
 {
     try
     {
         using (StreamWriter writer = File.CreateText(fileName))
         {
             foreach (var item in bfo.dataEntryList)
             {
                 writer.WriteLine($"{item.ToString()}");
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #3
0
        static int Main(string[] args)
        {
            string line;
            char   quitChar = 'q';

            Console.WriteLine("***** CTransformer .bin file converter *****");
            Console.WriteLine($"    ... Press '{quitChar}' for exit ...");

            while ((line = Console.ReadLine()) != quitChar.ToString())
            {
                string        path = @"c:\bin\2.bin";
                BinFileObject bfo  = new BinFileObject(path);
                Console.WriteLine($"File {path} opened.");
                BinFileObject.Save(@"c:\\bin\\2.txt", bfo);

                //if (args == null)
                //{
                //    args = CommandLineParser.Splitter(line);
                //    //TO DO: сплиттер должен убирать из строки повторяющиеся пробелы и табуляцию
                //}
                //if (args.Length > 0)
                //{
                //    try
                //    {
                //        FileStream fs = CommandLineParser.InputFileNameParse(args[0]); //TO DO: заебенить проверку на ввод хелпа!
                //        fs.Close();
                //        BinFileObject fileObject = new BinFileObject(@args[0]);
                //        //if (args.Length > 1)
                //        //    CommandLineParser.KeyParser(args[1]);

                //        Console.WriteLine("File opened!");

                //    }
                //    catch (Exception ex)
                //    {

                //        Console.WriteLine(ex.Message);
                //        //throw;
                //    }

                //}
                //else
                //{
                //    Console.WriteLine("Enter the parameters!");
                //}
                ////Console.WriteLine(args[0]);
                //args = null;
            }

            //if (args.Length == 0)
            //{
            //    System.Console.WriteLine("Please enter a file name to transform");
            //    return 1;
            //}
            //string fileName = args[0];
            ////string fileExtension = fileName.Substring(fileName.Length - 4);
            //string fileExtension = ".bin";
            //if (fileExtension != ".bin")
            //{
            //    Console.WriteLine("Incorrect file format!");
            //    return 1;
            //}
            //byte[] b = new byte[640];
            //try
            //{
            //    using (FileStream fStream = File.OpenRead(Directory.GetCurrentDirectory() + $"\\{fileName}"))
            //    {
            //        if (fStream.Length < 640)
            //        {
            //            Console.WriteLine("Too small file!");
            //            return 1;
            //        }
            //        fStream.Read(b, 0, b.Length);
            //        //ph = (PanelHeader)Serializer.RawDeserialize(b, 0, typeof(PanelHeader));
            //    }
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e.Message);
            //    Console.Read();
            //    return 1;
            //}

            Console.ReadLine();
            return(0);
        }