コード例 #1
0
        /// <summary>
        /// 开始处理按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnProcess_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(citFilePath))
            {
                MessageBox.Show("请选择轨检cit文件");
                return;
            }
            if (String.IsNullOrEmpty(curveFilePath))
            {
                MessageBox.Show("曲率台账模板文件");
                return;
            }
            if (String.IsNullOrEmpty(abruptMileFilePath))
            {
                MessageBox.Show("请选择长短链模板文件");
                return;
            }

            CalculateCorrugationClass calculateCorrugation = new CalculateCorrugationClass();



            var header      = citHelper.GetDataInfoHead(citFilePath);
            var channelList = citHelper.GetDataChannelInfoHead(citFilePath);

            string correctMileFilePath = citFilePath.Substring(0, citFilePath.Length - 4) + "correctMileStone.cit";

            CreateCitHeader(correctMileFilePath, header, channelList);

            long startPos = citHelper.GetSamplePointStartOffset(header.iChannelNumber);
            long endPos   = 0;

            int sampleNum = Convert.ToInt32((citHelper.GetFileLength(citFilePath) - startPos) / (header.iChannelNumber * 2));

            double[,] wcCurveData;    //台账曲率
            double[,] abruptMileData; //长短链

            wcCurveData    = GetData(curveFilePath);
            abruptMileData = GetData(abruptMileFilePath);

            int    fs           = Convert.ToInt32(this.txt_fs.Text.Trim());
            double thresh_curve = Convert.ToDouble(this.txt_thresh_curve.Text.Trim());

            int count = 10;

            for (int k = 0; k < count; k++)
            {
                List <double[]> dataList = citHelper.GetAllChannelDataInRange(citFilePath, startPos, sampleNum / count, ref endPos);

                startPos = endPos;

                List <double[]> dataList_input = new List <double[]>();
                dataList_input.Add(dataList[0]);
                dataList_input.Add(dataList[1]);
                dataList_input.Add(dataList[7]);
                //double[] dataKm = citHelper.GetSingleChannelData(citFilePath, 1);
                //double[] dataM = citHelper.GetSingleChannelData(citFilePath, 2);
                //double[] dataChaoGao = citHelper.GetSingleChannelData(citFilePath, 7);

                //dataList.Add(dataKm);
                //dataList.Add(dataM);
                //dataList.Add(dataChaoGao);

                //string path = @"H:\工作文件汇总\铁科院\程序\离线加速度\data\ww_save.txt";
                //dataList = ReadTxt(path);

                MWNumericArray array = calculateCorrugation.GetProcessAbnormalDispResultProcess(dataList_input);

                List <double[]> listData = calculateCorrugation.GetProcessAbnormalDispResult(array);


                double[] mileData;
                double[] curveData;//超高

                mileData  = listData[0];
                curveData = listData[1];


                MWNumericArray array2 = calculateCorrugation.GetVerifyKilometerResultProcess(mileData, curveData, wcCurveData, abruptMileData, fs, thresh_curve);

                var correctMileData = calculateCorrugation.GetVerifyKilometerResult(array2);

                double[] kmData = new double[correctMileData.Length];
                double[] mData  = new double[correctMileData.Length];

                for (int i = 0; i < correctMileData.Length; i++)
                {
                    kmData[i] = correctMileData[i] / 1000;
                    mData[i]  = correctMileData[i] % 1000;
                }

                dataList[0] = kmData;
                dataList[1] = mData;

                CreateCitData(correctMileFilePath, dataList);
            }


            MessageBox.Show("处理完成");
        }
コード例 #2
0
        private string _fixCit(string citFilePath, string curveFilePath, string abruptMileFilePath, int fs, double thresh_curve, int pointCount)
        {
            CalculateCorrugationClass calculateCorrugation = new CalculateCorrugationClass();

            var header      = citHelper.GetDataInfoHead(citFilePath);
            var channelList = citHelper.GetDataChannelInfoHead(citFilePath);

            string correctMileFilePath = citFilePath.Substring(0, citFilePath.Length - 4) + "correctMileStone.cit";

            CreateCitHeader(correctMileFilePath, header, channelList);

            long startPos = citHelper.GetSamplePointStartOffset(header.iChannelNumber);
            long endPos   = 0;

            //点位数
            int sampleNum = Convert.ToInt32((citHelper.GetFileLength(citFilePath) - startPos) / (header.iChannelNumber * 2));

            //循环次数
            int count = Convert.ToInt32(sampleNum / pointCount);
            //是否有余点
            int residue = Convert.ToInt32(sampleNum % pointCount);

            bool iszero = false;

            //是否执行一次
            if (count == 0)
            {
                iszero = true;
            }
            //如果有余数循环次数加1
            if (residue > 0)
            {
                count++;
            }

            double[,] wcCurveData;    //台账曲率
            double[,] abruptMileData; //长短链

            wcCurveData    = GetData(curveFilePath);
            abruptMileData = GetData(abruptMileFilePath);

            //if (count == 0) count = 1;
            for (int k = 0; k < count; k++)
            {
                List <double[]> dataList = null;

                if (iszero)
                {
                    dataList = citHelper.GetAllChannelDataInRange(citFilePath, startPos, residue, ref endPos);
                }
                else
                {
                    if (residue == 0)
                    {
                        dataList = citHelper.GetAllChannelDataInRange(citFilePath, startPos, pointCount, ref endPos);
                    }
                    else
                    {
                        if (k == (count - 1))
                        {
                            dataList = citHelper.GetAllChannelDataInRange(citFilePath, startPos, residue, ref endPos);
                        }
                        else
                        {
                            dataList = citHelper.GetAllChannelDataInRange(citFilePath, startPos, pointCount, ref endPos);
                        }
                    }
                }

                List <double[]> dataList_input = new List <double[]>();
                dataList_input.Add(dataList[0]);
                dataList_input.Add(dataList[1]);
                dataList_input.Add(dataList[7]);

                MWNumericArray array = calculateCorrugation.GetProcessAbnormalDispResultProcess(dataList_input);

                List <double[]> listData = calculateCorrugation.GetProcessAbnormalDispResult(array);


                double[] mileData;
                double[] curveData;//超高

                mileData  = listData[0];
                curveData = listData[1];


                MWNumericArray array2 = calculateCorrugation.GetVerifyKilometerResultProcess(mileData, curveData, wcCurveData, abruptMileData, fs, thresh_curve);

                var correctMileData = calculateCorrugation.GetVerifyKilometerResult(array2);

                double[] kmData = new double[correctMileData.Length];
                double[] mData  = new double[correctMileData.Length];

                for (int i = 0; i < correctMileData.Length; i++)
                {
                    kmData[i] = correctMileData[i] / 1000;
                    mData[i]  = correctMileData[i] % 1000;
                }

                dataList[0] = kmData;
                dataList[1] = mData;

                CreateCitData(correctMileFilePath, dataList);

                startPos = endPos;
            }

            return(correctMileFilePath);
        }