Exemple #1
0
        /// <summary>
        /// 打开comtrade文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOpenComtradeFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string filter = "config files (*.cfg)|*.cfg|data files (*.dat)|*.dat|All files (*.*)|*.*";
                int    index  = 1;
                string path   = FileOperateDialog.OpenFileDialog(defaultDirectory, filter, index, true);

                string dir = System.IO.Path.GetDirectoryName(path);
                defaultDirectory = dir;
                string filename = System.IO.Path.GetFileNameWithoutExtension(path);
                string cfgPath  = System.IO.Path.Combine(dir, filename + ".cfg");
                string dataPath = System.IO.Path.Combine(dir, filename + ".dat");


                if (!System.IO.File.Exists(cfgPath))
                {
                    throw new Exception("不存在选择的配置文件");
                }
                if (!System.IO.File.Exists(dataPath))
                {
                    throw new Exception("不存在选择的数据文件");
                }

                comtradeGridManager = new ComtradeGridManager(
                    gridRowStationRev,
                    gridRowChannelNumType,
                    gridRowAnalogChannelInformation,
                    gridRowDigitalChannelInformation,
                    gridRowChannelFrequency,
                    gridRowSampleNum,
                    gridRowSampleRateInformation,
                    gridRowFirstDateStamp,
                    gridRowTriggerDateStamp,
                    gridRowDataFileType,
                    gridRowTimeStampMultiply);


                comtradeGridManager.ReadComtradeFile(cfgPath, dataPath);


                UpdataTxtConfigShow();
                initPlot();
                plotModeManager.LoadShowData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "btnOpenComtradeFile");
            }
        }
Exemple #2
0
        /// <summary>
        /// 存储文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveComtradeFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string filter = "config files (*.cfg)|*.cfg|data files (*.dat)|*.dat|All files (*.*)|*.*";
                int    index  = 1;
                string path   = FileOperateDialog.SaveFileDialog(defaultDirectory, filter, index, true);
                string dir    = System.IO.Path.GetDirectoryName(path);
                defaultDirectory = dir;
                string filename = System.IO.Path.GetFileNameWithoutExtension(path);
                string cfgPath  = System.IO.Path.Combine(dir, filename + ".cfg");
                string dataPath = System.IO.Path.Combine(dir, filename + ".dat");

                //TestData();
                comtradeGridManager.ContradeManger.WriteFile(cfgPath, dataPath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "btnSaveComtradeFile_Click");
            }
        }