示例#1
0
        /// <summary>
        /// 模型初始化
        /// </summary>
        /// <param name="inConfigFile">配置文件</param>
        public PlotModelManager(ComtradeConfigFile inConfigFile, ComtradeDataFile inDataFile)
        {
            try
            {
                configFile = inConfigFile;
                dataFile   = inDataFile;

                plotCollect     = new List <PlotCurve>();
                colorsWave      = new List <OxyColor>();
                plotViewCollect = new List <PlotView>();

                //测试颜色
                var colors = new OxyColor[9] {
                    OxyColors.Yellow, OxyColors.Green, OxyColors.Red, OxyColors.Black,
                    OxyColors.Yellow, OxyColors.Green, OxyColors.Red, OxyColors.Black, OxyColors.Red
                };
                colorsWave.AddRange(colors);
                initWaveProperty();


                //LoadShowData(inDataFile);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "PlotModelManager");
            }
        }
示例#2
0
        static void TestComtradeConfig()
        {
            while (true)
            {
                try
                {
                    Console.WriteLine("TestComtrade-TestStart");
                    string str;
                    using (var file = File.OpenRead(@"file\cfg.cfg"))
                    {
                        StreamReader stream = new StreamReader(file);

                        str = stream.ReadToEnd();
                    }
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine(str);
                    Console.WriteLine();
                    Console.WriteLine();
                    ComtradeConfigFile comtrade = new ComtradeConfigFile();
                    comtrade.FileToRowMessage(str);

                    string path = @"file\" + DateTime.Now.Minute.ToString() + "_" + DateTime.Now.Second.ToString() + ".cfg";
                    using (var file = File.OpenWrite(path))
                    {
                        StreamWriter stream = new StreamWriter(file);
                        string[]     strcollect;
                        comtrade.MakeConfigFile(out strcollect);
                        foreach (var m in strcollect)
                        {
                            stream.Write(m);
                        }
                        stream.Flush();
                    }

                    Console.WriteLine("TestComtrade-TestEnd");
                    var instr = Console.ReadLine();
                    if (instr == "q")
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    var instr = Console.ReadLine();
                    if (instr == "q")
                    {
                        return;
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// 读取数据文件
        /// </summary>
        /// <param name="path">路径</param>
        /// <param name="config">配置文件</param>
        public void ReadDataFile(string path, ComtradeConfigFile config)
        {
            try
            {
                if (config.RowDataFileType.DataType == DataFileType.ASCII)
                {
                    string dataFileStr;
                    using (var file = File.OpenRead(path))
                    {
                        StreamReader stream = new StreamReader(file);
                        dataFileStr = stream.ReadToEnd();
                    }

                    DataFile.ASCIIFileToRowMessage(dataFileStr);


                    int configCount = config.RowSampleRateInformation.EndSampleCount;
                    if (DataFile.AsciiData.Count != configCount)
                    {
                        throw new ArgumentException("数据文件行数与配置文件定义数不一致");
                    }
                }
                else if (config.RowDataFileType.DataType == DataFileType.BINARY)
                {
                    using (var file = File.OpenRead(path))
                    {
                        //计算所需要的存储长度
                        int len = ConfigFile.GetBinaryDataRowByteLen(ConfigFile.RowChannelNumType.AnalogChannelCount,
                                                                     ConfigFile.RowChannelNumType.DigitalChannelCount);

                        int configCount = config.RowSampleRateInformation.EndSampleCount;
                        for (int i = 0; i < configCount; i++)
                        {
                            byte[] array = new byte[len];



                            file.Read(array, 0, len);

                            DataFile.BinaryData.Add(array);
                        }
                    }
                }
                else
                {
                    throw new ArgumentException("无法识别文件类型");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#4
0
 /// <summary>
 /// Comtrade文件管理器初始化
 /// </summary>
 public ComtradeFileManager()
 {
     ConfigFile = new ComtradeConfigFile();
     DataFile   = new ComtradeDataFile();
 }