private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            weldList.Clear();
            //测试数据
            //weldList.Add(new WeldModel { Mile = "1", Speed = "2", RmsValue = "3", PeakValue = "4", SampleNo = "5" });

            //citFilePath = @"H:\工作文件汇总\铁科院\程序\离线加速度\cit文件\CitData_160612060534_CHSS_11corrugationRms.cit";
            double[] mileData  = citHelper.GetMilesData(citFilePath);
            double[] speedData = citHelper.GetSingleChannelData(citFilePath, 3);
            int      channelId = 4;

            if (this.radioButton1.Checked)
            {
                channelId = 4;
            }
            else if (this.radioButton2.Checked)
            {
                channelId = 5;
            }
            else if (this.radioButton3.Checked)
            {
                channelId = 6;
            }
            double[] rmsData = citHelper.GetSingleChannelData(citFilePath, channelId);
            double   avg     = rmsData.ToList().Average();

            double[] avgRmsData = new double[rmsData.Length];
            for (int i = 0; i < avgRmsData.Length; i++)
            {
                avgRmsData[i] = rmsData[i] / avg;
            }
            int    fs        = Convert.ToInt32(this.txt_fs.Text.Trim());
            double dist_weld = Convert.ToDouble(this.txt_dist_weld.Text.Trim());

            WeldProcess(mileData, speedData, rmsData, avgRmsData, fs, dist_weld);
        }
Example #2
0
        /// <summary>
        /// 导出功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Export_Click(object sender, EventArgs e)
        {
            try
            {
                this.btn_Export.Enabled = false;

                GetCitSourceCheckFileList();

                GetChannelNames();
                if (channelNameList.Count == 0)
                {
                    MessageBox.Show("请选择至少一个通道");
                    return;
                }

                string startMile = this.txtStartMile.Text.Trim();
                string endMile   = this.txtEndMile.Text.Trim();

                for (int j = 0; j < citSourceCheckFileList.Count; j++)
                {
                    dataList.Clear();

                    for (int i = 0; i < channelNameList.Count; i++)
                    {
                        if (!String.IsNullOrEmpty(startMile) && !String.IsNullOrEmpty(endMile) && Convert.ToDouble(endMile) > Convert.ToDouble(startMile))
                        {
                            double[] d = citHelper.GetSingleChannelData(citSourceCheckFileList[j], channelNameList[i].sNameEn, Convert.ToDouble(startMile), Convert.ToDouble(endMile));
                            dataList.Add(d);
                        }
                        else
                        {
                            double[] d = citHelper.GetSingleChannelData(citSourceCheckFileList[j], citHelper.GetChannelId(channelNameList[i].sNameEn, citSourceCheckFileList[j]));
                            dataList.Add(d);
                        }
                    }

                    //使用中文名称
                    if (ckb_Chinese.Checked)
                    {
                        if (ckb_sameNameWithCit.Checked)
                        {
                            ExportDataTxt(true, citSourceCheckFileList[j].Replace(".cit", ".txt"));
                        }
                        else
                        {
                            ExportDataTxt(true, citSourceCheckFileNameList[j], citSourceCheckFileList[j]);
                        }
                    }
                    else
                    {
                        if (ckb_sameNameWithCit.Checked)
                        {
                            ExportDataTxt(true, citSourceCheckFileList[j].Replace(".cit", ".txt"));
                        }
                        else
                        {
                            ExportDataTxt(false, citSourceCheckFileNameList[j], citSourceCheckFileList[j]);
                        }
                    }
                }



                MessageBox.Show("数据导出完成");

                this.btn_Export.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        //public void SaveChannelDataTxt(string citFilePath, string channleName,string exportTxtPath, double startMileage, double endMileage)
        //{
        //    int channelId = citHelper.GetChannelId(channleName, citFilePath);

        //    if (startMileage != 0 && endMileage != 0)
        //    {
        //        var datas = citHelper.GetSingleChannelData(citFilePath, channleName, startMileage, endMileage);


        //        ExportData(exportTxtPath, datas);
        //    }
        //    else
        //    {
        //        var datas = citHelper.GetSingleChannelData(citFilePath, channelId);

        //        ExportData(exportTxtPath, datas);
        //    }
        //}


        public void SaveChannelDataTxt(string citFilePath, int channelId, string exportTxtPath)
        {
            var datas = citHelper.GetSingleChannelData(citFilePath, channelId);

            ExportData(exportTxtPath, datas);
        }
Example #4
0
        public List <PowerSpectrum> GetResult(string filePath, string channelName, double kmStart, double kmEnd, double Nlen, double dt)
        {
            long startPos = 0;
            long endPos   = 0;
            long pos1     = citHelper.GetCurrentPosition(filePath, Convert.ToSingle(kmStart) * 1000);
            long pos2     = citHelper.GetCurrentPosition(filePath, Convert.ToSingle(kmEnd) * 1000);

            if (pos1 > pos2)
            {
                startPos = pos2;
                endPos   = pos1;
            }
            else
            {
                startPos = pos1;
                endPos   = pos2;
            }

            double[] d_tt = citHelper.GetMilesData(filePath, startPos, endPos);

            int channelId = citHelper.GetChannelId(channelName, filePath);

            double[] d_wx = citHelper.GetSingleChannelData(filePath, channelId, startPos, endPos);

            #region 注释

            //int indexStart = 0;
            //int indexEnd = d_tt.Length - 1;

            //if (d_tt[0] < d_tt[d_tt.Length - 1])
            //{
            //    //增里程
            //    for (int i = 0; i < d_tt.Length; i++)
            //    {
            //        if (d_tt[i] >= kmStart)
            //        {
            //            indexStart = i;
            //            break;
            //        }
            //    }
            //    for (int i = 0; i < d_tt.Length; i++)
            //    {
            //        if (d_tt[i] >= kmEnd)
            //        {
            //            indexEnd = i;
            //            break;
            //        }
            //    }

            //}
            //else
            //{
            //    //减里程
            //    for (int i = 0; i < d_tt.Length; i++)
            //    {
            //        if (d_tt[i] <= kmStart)
            //        {
            //            indexStart = i;
            //            break;
            //        }
            //    }
            //    for (int i = 0; i < d_tt.Length; i++)
            //    {
            //        if (d_tt[i] <= kmEnd)
            //        {
            //            indexEnd = i;
            //            break;
            //        }
            //    }
            //}
            //int len = indexEnd - indexStart + 1;
            //double[] tt_new = new double[len];
            //double[] wx_new = new double[len];

            //Array.Copy(d_tt, indexStart, tt_new, 0, len);
            //Array.Copy(d_wx, indexStart, wx_new, 0, len);

            #endregion

            var list = Sub_Fourier_analysis(channelName, d_tt, d_wx, Nlen, dt);

            return(list);
        }