Esempio n. 1
0
        private static void MakeFile(string source, string dest, CtpCompressionMode mode, EncodingMethod encoding)
        {
            using (var fs = new FileStream(source, FileMode.Open))
                using (var fs2 = new FileStream(dest, FileMode.Create))
                    using (var ctp = new SttpFileReader(fs, false))
                        using (var ctp2 = new SttpFileWriter(fs2, false, mode, encoding))
                        {
                            while (true)
                            {
                                switch (ctp.Next())
                                {
                                case FileReaderItem.ProducerMetadata:
                                    var md = ctp.GetMetadata();
                                    ctp2.ProducerMetadata(md);
                                    break;

                                case FileReaderItem.DataPoint:
                                    var dp = new SttpDataPoint();
                                    while (ctp.ReadDataPoint(dp))
                                    {
                                        ctp2.AddDataPoint(dp);
                                    }
                                    break;

                                case FileReaderItem.EndOfStream:
                                    return;

                                default:
                                    throw new ArgumentOutOfRangeException();
                                }
                            }
                        }
        }
Esempio n. 2
0
        private void BenchmarkFile(string source, string dest, CtpCompressionMode mode, EncodingMethod encoding)
        {
            string newFileName = Path.ChangeExtension(source, ".txt");

            //using (var raw = new StreamWriter(newFileName, false))
            using (var fs = new FileStream(source, FileMode.Open))
                using (var fs2 = new FileStream(dest, FileMode.Create))
                    using (var ctp = new SttpFileReader(fs, false))
                        using (var ctp2 = new SttpFileWriter(fs2, false, mode, encoding))
                        {
                            while (true)
                            {
                                switch (ctp.Next())
                                {
                                case FileReaderItem.ProducerMetadata:
                                    var md = ctp.GetMetadata();
                                    ctp2.ProducerMetadata(md);
                                    break;

                                case FileReaderItem.DataPoint:
                                    var dp = new SttpDataPoint();
                                    while (ctp.ReadDataPoint(dp))
                                    {
                                        //if (dp.Value.AsSingle > 3000000)
                                        //{
                                        //    dp.Value = dp.Value;
                                        //}
                                        //if (dp.Metadata.DataPointID.AsString.EndsWith(":DFreq0"))
                                        //{
                                        //    dp.Value = new CtpNumeric((long)(dp.Value.AsSingle * 100), 2);
                                        //}
                                        //Names.Add(dp.Metadata.DataPointID.AsString);
                                        //raw.WriteLine(dp.ToString());
                                        PointCount++;
                                        //dp.Value = (double)dp.Value;
                                        //dp.Value = (long)dp.Value*1000;
                                        ctp2.AddDataPoint(dp);
                                    }
                                    break;

                                case FileReaderItem.EndOfStream:
                                    return;

                                default:
                                    throw new ArgumentOutOfRangeException();
                                }
                            }
                        }
        }