/// <summary>
 /// 加载配置
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OpenButton1_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog1.InitialDirectory = Application.StartupPath;
         OpenFileDialog1.FileName         = "";
         DialogResult dr = OpenFileDialog1.ShowDialog();
         if (dr == DialogResult.OK)
         {
             var channelList = cithelper.GetChannelDefinitionList(waveformMaker.WaveformDataList[0].CitFilePath);
             GetChannelsData(OpenFileDialog1.FileName, channelList);
             channelConfigPathCurrent = OpenFileDialog1.FileName;
             ApplyCurrentConfig();
         }
     }
     catch (Exception ex)
     {
         MyLogger.LogError("加载配置文件时出错", ex);
         MessageBox.Show(ex.Message);
     }
 }
        public void InitFixData(string fixedCitFile, string fixedIdfFile = null, bool diffFileName = false)
        {
            List <ChannelDefinition> channelDefinition = _citProcess.GetChannelDefinitionList(fixedCitFile);

            for (int i = 0; i < FixParams.Count; i++)
            {
                FixParams[i].ChannelID = channelDefinition.Where(p => p.sNameEn == FixParams[i].ChannelName).ToList()[0].sID;
            }
            FileInformation citFile = _citProcess.GetFileInformation(fixedCitFile);

            _fixedData.Clear();

            string idfFIle = fixedCitFile.Replace(".cit", ".idf");

            if (diffFileName)
            {
                idfFIle = fixedIdfFile;
            }

            IndexOperator indexOperator = new IndexOperator();

            if (File.Exists(idfFIle))
            {
                indexOperator.IndexFilePath = idfFIle;
                UserFixedTable fixTable = new UserFixedTable(indexOperator, citFile.iKmInc);
                if (fixTable.MarkedPoints.Count > 0)
                {
                    foreach (var point in fixTable.MarkedPoints)
                    {
                        //左半边数据点个数,包括中间点
                        List <FixPoint> fixPoint         = new List <FixPoint>();
                        int             leftFixedCount   = FixedSamplingCount + 1;
                        long            leftStartPostion = _citProcess.GetAppointFileEndPostion(fixedCitFile, point.FilePointer, -1 * leftFixedCount);
                        long            realLeftCount    = _citProcess.GetSampleCountByRange(fixedCitFile, leftStartPostion, point.FilePointer);
                        long            rightEndPostion  = _citProcess.GetAppointFileEndPostion(fixedCitFile, point.FilePointer, FixedSamplingCount);
                        long            realRightCount   = _citProcess.GetSampleCountByRange(fixedCitFile, point.FilePointer, rightEndPostion);
                        Milestone       mile             = _citProcess.GetAppointMilestone(fixedCitFile, point.FilePointer);
                        foreach (var item in FixParams)
                        {
                            FixPoint fixP = new FixPoint();
                            fixP.FixPostion = leftFixedCount;
                            double[] data = _citProcess.GetOneChannelDataInRange(fixedCitFile, item.ChannelID, leftStartPostion, ((int)(realLeftCount + realRightCount)));
                            fixP.Points          = data;
                            fixP.ChannelID       = item.ChannelID;
                            fixP.OriginalMileage = mile.GetMeter();
                            fixPoint.Add(fixP);
                        }
                        _fixedData.Add(point, fixPoint);
                    }
                }
            }
        }
        static void Main(string[] args)
        {
            string citpath = @"H:\工作文件汇总\铁科院\程序\车载加速度\数据文件\CitData_170413050607_GJGX\CitData_170413050607_GJGX.cit";

            CITFileProcess cithelper      = new CITFileProcess();
            var            fileInfomation = cithelper.GetFileInformation(citpath);

            var channelList = cithelper.GetChannelDefinitionList(citpath);

            var channelData = cithelper.GetAllMileStone(citpath);

            var type        = cithelper.GetDataType(citpath);
            var DataVersion = cithelper.GetDataVersion(citpath);

            var date = cithelper.GetDate(citpath);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取通道序号
        /// </summary>
        /// <param name="citFilePath">cit文件路径</param>
        /// <param name="iStartKM">TQI开始里程</param>
        /// <param name="iEndKM">TQI结束里程</param>
        /// <returns></returns>
        private int[] GetChannelNumber(string citFilePath, ref int iStartKM, ref int iEndKM, ref float[] fscale, ref FileInformation fi)
        {
            string[] sTQIItem = new string[] { "L_Prof_SC", "R_Prof_SC", "L_Align_SC",
                                               "R_Align_SC", "Gage", "Crosslevel", "Short_Twist", "LACC", "VACC", "Speed" };
            int[] sTQIItemIndex = new int[sTQIItem.Length];

            fi = citHelper.GetFileInformation(citFilePath);
            List <ChannelDefinition> channelList = citHelper.GetChannelDefinitionList(citFilePath);

            fscale = new float[channelList.Count];

            for (int i = 0; i < sTQIItem.Length; i++)
            {
                for (int j = 0; j < channelList.Count; j++)
                {
                    if (sTQIItem[i].Equals(channelList[j].sNameEn))
                    {
                        sTQIItemIndex[i] = j;
                        break;
                    }

                    fscale[j] = channelList[j].fScale;
                }
            }

            fscale[1] = 4;//有时为了加密数据。通道基线可能会设置成别的值。这里统一校正成4
            //减里程
            if (fi.iKmInc == 1)
            {
                int iChange = 0;
                iChange  = iStartKM;
                iStartKM = iEndKM;
                iEndKM   = iChange;
            }

            return(sTQIItemIndex);
        }
        private void UnFixCalc(string citFilePath, int mileUnitValue, string exportFilePath, float startMile, float endMile)
        {
            /* 左高低_中波
             * 右高低_中波
             * 左轨向_中波
             * 右轨向_中波
             * 轨距
             * 水平
             * 三角坑
             * */
            string[] sTQIItem = new string[] { "L_Prof_SC", "R_Prof_SC", "L_Align_SC",
                                               "R_Align_SC", "Gage", "Crosslevel", "Short_Twist", "LACC", "VACC", "Speed" };
            int[] sTQIItemIndex = new int[sTQIItem.Length];

            channelList = citProcess.GetChannelDefinitionList(citFilePath);
            for (int i = 0; i < sTQIItem.Length; i++)
            {
                for (int j = 0; j < channelList.Count; j++)
                {
                    if (sTQIItem[i].Equals(channelList[j].sNameEn))
                    {
                        sTQIItemIndex[i] = j;
                        break;
                    }
                }
            }

            long startPos = 0;
            long endPos   = 0;

            long[] positions = citProcess.GetPositons(citFilePath);
            startPos = positions[0];
            endPos   = positions[1];

            if (startMile != 0)
            {
                startPos = citProcess.GetCurrentPositionByMilestone(citFilePath, startMile, true);
                if (startPos == -1)
                {
                    throw new Exception("未找到对应开始里程的位置");
                }
            }
            if (endMile != 0)
            {
                endPos = citProcess.GetCurrentPositionByMilestone(citFilePath, endMile, true);
                if (endPos == -1)
                {
                    throw new Exception("未找到对应结束里程的位置");
                }
            }
            long tempPos = 0;

            if (startPos > endPos)
            {
                tempPos  = startPos;
                startPos = endPos;
                endPos   = tempPos;
            }

            int  positionCount = mileUnitValue * 4;
            long range         = citProcess.GetSampleCountByRange(citFilePath, startPos, endPos);
            long divisor       = range / positionCount;
            long residue       = range % positionCount;

            long tempStartPos = startPos;
            long tempEndPos   = 0;

            for (int i = 0; i < divisor; i++)
            {
                tempEndPos = citProcess.GetAppointEndPostion(citFilePath, tempStartPos, positionCount);
                GetChannelData(citFilePath, tempStartPos, tempEndPos, sTQIItemIndex);

                tempStartPos = tempEndPos;
            }

            ExportExcel(exportFilePath, tqilist);
        }
        /// <summary>
        /// 读取CIT文件
        /// </summary>
        /// <param name="citFilePath"></param>
        private void ReadCIT(String citFilePath)
        {
            if (numericUpDown1.Value <= 0)
            {
                MessageBox.Show("容许跳变值为 0");
                return;
            }

            try
            {
                autoIndexClsList.Clear();
                dataGridView1.Rows.Clear();

                FileInformation          fileInfomation = citHelper.GetFileInformation(citFilePath);
                List <ChannelDefinition> channelList    = citHelper.GetChannelDefinitionList(citFilePath);

                FileStream   fs = new FileStream(citFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                BinaryReader br = new BinaryReader(fs, Encoding.Default);
                br.BaseStream.Position = 0;

                br.ReadBytes(120);


                br.ReadBytes(65 * fileInfomation.iChannelNumber);
                br.ReadBytes(BitConverter.ToInt32(br.ReadBytes(4), 0));
                int    iChannelNumberSize = fileInfomation.iChannelNumber * 2;
                byte[] b = new byte[iChannelNumberSize];

                long milePos       = 0;
                int  km_pre        = 0;
                int  meter_pre     = 0;
                int  km_currrent   = 0;
                int  meter_current = 0;
                int  meter_between = 0;
                int  km_index      = 0;
                int  meter_index   = 2;

                long iArray = (br.BaseStream.Length - br.BaseStream.Position) / iChannelNumberSize;

                for (int i = 0; i < iArray; i++)
                {
                    milePos = br.BaseStream.Position;

                    b = br.ReadBytes(iChannelNumberSize);

                    if (Encryption.IsEncryption(fileInfomation.sDataVersion))
                    {
                        b = Encryption.Translate(b);
                    }

                    if (i == 0)
                    {
                        km_pre    = (int)(BitConverter.ToInt16(b, km_index));
                        meter_pre = (int)(BitConverter.ToInt16(b, meter_index));
                    }
                    else
                    {
                        km_currrent   = (int)(BitConverter.ToInt16(b, km_index));
                        meter_current = (int)(BitConverter.ToInt16(b, meter_index));
                        //第二个通道为采样点,换算为米就要除以4
                        meter_between = (km_currrent - km_pre) * 1000 + (meter_current - meter_pre) / 4;

                        if (Math.Abs(meter_between) > numericUpDown1.Value)
                        {
                            AutoIndex autoIndexCls = new AutoIndex();
                            autoIndexCls.milePos       = milePos;
                            autoIndexCls.km_current    = km_currrent;
                            autoIndexCls.meter_current = meter_current;
                            autoIndexCls.km_pre        = km_pre;
                            autoIndexCls.meter_pre     = meter_pre;
                            autoIndexCls.meter_between = meter_between;

                            autoIndexClsList.Add(autoIndexCls);
                        }

                        km_pre    = km_currrent;
                        meter_pre = meter_current;
                    }
                }

                br.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                MyLogger.logger.Error("读取CIT文件跳变点失败:" + ex.Message + ",堆栈:" + ex.StackTrace);

                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 读取CIT文件
        /// </summary>
        /// <param name="citFilePath">cit文件路径----->来自里程快速校正中的选择cit文件的按钮</param
        /// <param name="numericUpDown1">跳变允许值----->来自里程快速校正中的  跳变容许值</param>
        private List <AutoIndex> _readCit(String citFilePath, int numericUpDown1)
        {
            List <AutoIndex> autoIndexClsList = new List <AutoIndex>();

            //autoIndexClsList.Max(p => p.meter_between);
            //autoIndexClsList.Min(p => p.meter_between);
            //double  count = citHelper.GetTotalSampleCount(citFilePath)/4/1000;
            //double tiaobian1=autoIndexClsList.Sum(p => p.meter_between)/count;
            //double tiaobian1i = autoIndexClsList.Sum(p => Math.Abs(p.meter_between))/autoIndexClsList.Count;
            if (numericUpDown1 <= 0)
            {
                ///MessageBox.Show("容许跳变值为 0");
                return(autoIndexClsList);
            }

            try
            {
                FileInformation          fileInfomation = citHelper.GetFileInformation(citFilePath);
                List <ChannelDefinition> channelList    = citHelper.GetChannelDefinitionList(citFilePath);

                FileStream   fs = new FileStream(citFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                BinaryReader br = new BinaryReader(fs, Encoding.Default);
                br.BaseStream.Position = 0;

                br.ReadBytes(120);


                br.ReadBytes(65 * fileInfomation.iChannelNumber);
                br.ReadBytes(BitConverter.ToInt32(br.ReadBytes(4), 0));
                int    iChannelNumberSize = fileInfomation.iChannelNumber * 2;
                byte[] b = new byte[iChannelNumberSize];

                long milePos       = 0;
                int  km_pre        = 0;
                int  meter_pre     = 0;
                int  km_currrent   = 0;
                int  meter_current = 0;
                int  meter_between = 0;
                int  km_index      = 0;
                int  meter_index   = 2;

                long iArray = (br.BaseStream.Length - br.BaseStream.Position) / iChannelNumberSize;

                for (int i = 0; i < iArray; i++)
                {
                    milePos = br.BaseStream.Position;

                    b = br.ReadBytes(iChannelNumberSize);

                    if (Encryption.IsEncryption(fileInfomation.sDataVersion))
                    {
                        b = Encryption.Translate(b);
                    }

                    if (i == 0)
                    {
                        km_pre    = (int)(BitConverter.ToInt16(b, km_index));
                        meter_pre = (int)(BitConverter.ToInt16(b, meter_index));
                    }
                    else
                    {
                        km_currrent   = (int)(BitConverter.ToInt16(b, km_index));
                        meter_current = (int)(BitConverter.ToInt16(b, meter_index));
                        //第二个通道为采样点,换算为米就要除以4
                        meter_between = (km_currrent - km_pre) * 1000 + (meter_current - meter_pre) / 4;

                        if (Math.Abs(meter_between) > numericUpDown1)
                        {
                            AutoIndex autoIndexCls = new AutoIndex();
                            autoIndexCls.milePos       = milePos;
                            autoIndexCls.km_current    = km_currrent;
                            autoIndexCls.meter_current = meter_current;
                            autoIndexCls.km_pre        = km_pre;
                            autoIndexCls.meter_pre     = meter_pre;
                            autoIndexCls.meter_between = meter_between;

                            autoIndexClsList.Add(autoIndexCls);
                        }

                        km_pre    = km_currrent;
                        meter_pre = meter_current;
                    }
                }

                br.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("读取CIT文件跳变点失败:" + ex.Message + ",堆栈:" + ex.StackTrace);
            }
            return(autoIndexClsList);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 接口函数:无效数据滤除---处理多个通道数据
        /// </summary>
        /// <param name="FileName"></param>
        /// <param name="sAddFileName"></param>
        /// <returns></returns>
        private bool GetDataInfoMulti(string FileName, int pointCount, string sAddFileName)
        {
            // CIT文件相关操作类
            CITFileProcess cfprocess = new CITFileProcess();

            // 通道定义相关操作类
            ChannelDefinitionList cdlist = new ChannelDefinitionList();

            //matlab算法
            PreproceingDeviationClass pdc = new PreproceingDeviationClass();

            //获取文件信息
            FileInformation fileinfo = new FileInformation();

            try
            {
                long[] position = cfprocess.GetPositons(FileName);
                long   startPos = position[0]; //开始位置、结束位置
                long   endPos   = position[1];

                cdlist.channelDefinitionList = cfprocess.GetChannelDefinitionList(FileName);

                //分段读取方法////////////////////

                long totleSample = cfprocess.GetTotalSampleCount(FileName);
                //循环次数
                int count = Convert.ToInt32(totleSample / pointCount);
                //是否有余点
                int residue = Convert.ToInt32(totleSample % pointCount);

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

                for (int z = 0; z < count; z++)
                {
                    if (iszero)
                    {
                        endPos = cfprocess.GetAppointEndPostion(FileName, startPos, residue);
                    }
                    else
                    {
                        if (residue == 0)
                        {
                            endPos = cfprocess.GetAppointEndPostion(FileName, startPos, pointCount);
                        }
                        else
                        {
                            if (z == (count - 1))
                            {
                                endPos = cfprocess.GetAppointEndPostion(FileName, startPos, residue);
                            }
                            else
                            {
                                endPos = cfprocess.GetAppointEndPostion(FileName, startPos, pointCount);
                            }
                        }
                    }

                    //分段读取方法////////////////////

                    //根据里程list获取里程数组
                    List <Milestone> dualmilelist = cfprocess.GetMileStoneByRange(FileName, startPos, endPos);
                    double[]         tt           = new double[dualmilelist.Count];
                    for (int i = 0; i < dualmilelist.Count; i++)
                    {
                        double obj = dualmilelist[i].GetMeter() / 1000;
                        tt[i] = obj;
                    }

                    double[] wvelo      = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("Speed", "速度"), startPos, endPos);
                    double[] L_Prof_SC  = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("L_Prof_SC", "左高低_中波"), startPos, endPos);
                    double[] R_Prof_SC  = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("R_Prof_SC", "右高低_中波"), startPos, endPos);
                    double[] L_Align_SC = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("L_Align_SC", "左轨向_中波"), startPos, endPos);
                    double[] R_Align_SC = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("R_Align_SC", "右轨向_中波"), startPos, endPos);
                    double[] Gage       = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("Gage", "轨距"), startPos, endPos);
                    double[] Crosslevel = cfprocess.GetOneChannelDataInRange(FileName, cdlist.GetChannelIdByName("Crosslevel", "水平"), startPos, endPos);

                    int      tmpChannelNumber = cdlist.GetChannelIdByName("Gage_L", "单边轨距左");
                    double[] Gage_L           = null;
                    if (tmpChannelNumber == -1)
                    {
                        Gage_L = new double[wvelo.Length];
                    }
                    else
                    {
                        Gage_L = cfprocess.GetOneChannelDataInRange(FileName, tmpChannelNumber, startPos, endPos);
                    }

                    tmpChannelNumber = cdlist.GetChannelIdByName("Gage_R", "单边轨距右");
                    double[] Gage_R = null;
                    if (tmpChannelNumber == -1)
                    {
                        Gage_R = new double[wvelo.Length];
                    }
                    else
                    {
                        Gage_R = cfprocess.GetOneChannelDataInRange(FileName, tmpChannelNumber, startPos, endPos);
                    }

                    DataProcessing dp = new DataProcessing();
                    //调用刘博士的算法---处理多个通道
                    dp.preProcess(tt, L_Prof_SC, R_Prof_SC, L_Align_SC, R_Align_SC, Gage, Crosslevel, wvelo, Gage_L, Gage_R, FileName, sAddFileName, "自动标识", true);

                    //分段读取方法////////////////////
                    startPos = endPos;
                }
                //分段读取方法////////////////////
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
            finally
            {
            }
            return(true);
        }
Exemplo n.º 9
0
        public void SaveChannelDataTxt(string citFilePath, string idfFilePath, string dbFilePath, string channleName, string exportTxtPath, double startMileage, double endMileage, int sampleCount, bool isChinese)
        {
            FileInformation citHeader = citProcess.GetFileInformation(citFilePath);

            List <ChannelDefinition> list = citProcess.GetChannelDefinitionList(citFilePath);

            int channelId   = 0;
            var channelItem = list.Where(s => s.sNameEn == channleName || s.sNameCh == channleName).FirstOrDefault();

            if (channelItem != null)
            {
                channelId = channelItem.sID;
            }

            if (citHeader.iKmInc == 1 && startMileage < endMileage)
            {
                double change = startMileage;
                startMileage = endMileage;
                endMileage   = change;
            }

            if (!String.IsNullOrEmpty(idfFilePath) && !String.IsNullOrEmpty(dbFilePath))
            {
                indexOperator = new IndexOperator();
                indexOperator.IndexFilePath = idfFilePath;

                InnerFileOperator.InnerFilePath   = dbFilePath;
                InnerFileOperator.InnerConnString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = {0}; Persist Security Info = True; Mode = Share Exclusive; Jet OLEDB:Database Password = iicdc; ";

                _mileageFix = new MilestoneFix(citFilePath, indexOperator);

                _mileageFix.ReadMilestoneFixTable();

                if (_mileageFix.FixData.Count > 0)
                {
                    if (citHeader.iKmInc == 0)
                    {
                        if (startMileage >= _mileageFix.FixData[_mileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000 ||
                            endMileage <= _mileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000)
                        {
                            //return "";

                            throw new Exception("此里程范围内没有修正数据:start:" + startMileage + "  end:" + endMileage);
                        }
                        if (startMileage < (_mileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000))
                        {
                            startMileage = (_mileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000);
                        }
                        if (endMileage > _mileageFix.FixData[_mileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000)
                        {
                            endMileage = _mileageFix.FixData[_mileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000;
                        }
                    }
                    else if (citHeader.iKmInc == 1)
                    {
                        if (endMileage >= _mileageFix.FixData[_mileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000 ||
                            startMileage <= _mileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000)
                        {
                            //return "";
                            throw new Exception("此里程范围内没有修正数据:start:" + startMileage + "  end:" + endMileage);
                        }
                        if (startMileage > _mileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000)
                        {
                            startMileage = _mileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000;
                        }
                        if (endMileage < _mileageFix.FixData[_mileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000)
                        {
                            endMileage = _mileageFix.FixData[_mileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000;
                        }
                    }



                    Milestone startStone = new Milestone();
                    Milestone endStone   = new Milestone();

                    startStone = CalcMilestoneByFixedMilestone((float)startMileage * 1000, _mileageFix.FixData, citFilePath);
                    endStone   = CalcMilestoneByFixedMilestone((float)endMileage * 1000, _mileageFix.FixData, citFilePath);
                    //_mileageFix.CalcMilestoneByFixedMilestone(123);
                    //endStone = _mileageFix.CalcMilestoneByFixedMilestone((float)endMileage * 1000);

                    if (startStone.mFilePosition != -1)
                    {
                        List <double[]> dataList = new List <double[]>();

                        double[] datas = citProcess.GetOneChannelDataInRange(citFilePath, channelId, startStone.mFilePosition, endStone.mFilePosition);

                        List <Milestone> mileStoneList = citProcess.GetMileStoneByRange(citFilePath, startStone.mFilePosition, endStone.mFilePosition);

                        List <Milestone> mileStoneListNew = GetMileageReviseData(mileStoneList, _mileageFix.FixData, citFilePath);

                        var dataKm    = mileStoneListNew.Select(s => Convert.ToDouble(s.mKm)).ToArray();
                        var dataMeter = mileStoneListNew.Select(s => Convert.ToDouble(s.mMeter)).ToArray();

                        dataList.Add(dataKm);
                        dataList.Add(dataMeter);
                        dataList.Add(datas);

                        ExportData(exportTxtPath, dataList);
                    }
                }
                else
                {
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 接口函数:计算峰峰值指标
        /// </summary>
        /// <param name="citFileName">cit文件全路径</param>
        /// <param name="citFileName">idf文件全路径</param>
        /// <returns></returns>
        private List <String> PreProcessDeviation2(String citFileName, int pointCount, string idfFileName = null)
        {
            List <String> dataStrList = new List <String>();

            cdlist.channelDefinitionList = cfprocess.GetChannelDefinitionList(citFileName);

            fileinfo = cfprocess.GetFileInformation(citFileName);
            //int tds = fileinfo.iChannelNumber;

            long[] position = cfprocess.GetPositons(citFileName);
            long   startPos = position[0]; //开始位置、结束位置
            long   endPos   = position[1];

            List <Milestone> allmilelist;
            List <Milestone> milelist = cfprocess.GetAllMileStone(citFileName);

            //验证是否修正
            if (!String.IsNullOrEmpty(idfFileName))
            {
                IndexOperator _op = new IndexOperator();
                _op.IndexFilePath = idfFileName;
                MilestoneFix mile = new MilestoneFix(citFileName, _op);
                mile.ReadMilestoneFixTable();
                allmilelist = mile.GetMileageReviseData(milelist);
            }
            else
            {
                allmilelist = milelist;
            }

            //开始里程  和结束里程
            double[] d_tt = new double[allmilelist.Count];
            for (int i = 0; i < allmilelist.Count; i++)
            {
                double obj = allmilelist[i].GetMeter() / 1000;
                d_tt[i] = obj;
            }

            double[] d_wvelo = cfprocess.GetOneChannelDataInRange(citFileName, cdlist.GetChannelIdByName("Speed", "速度"), startPos, endPos);
            double[] d_gauge = cfprocess.GetOneChannelDataInRange(citFileName, cdlist.GetChannelIdByName("Gage", "轨距"), startPos, endPos);

            double[] d_wx = cfprocess.GetOneChannelDataInRange(citFileName, cdlist.GetChannelIdByName("L_Prof_SC", "左高低_中波"), startPos, endPos);

            //StreamWriter sw2 = new StreamWriter("d:/peakvalue_all.csv", true, Encoding.Default);
            //StringBuilder sbtmp = new StringBuilder();
            //sbtmp.Append("d_tt,");
            //sbtmp.Append("d_wvelo,");
            //sbtmp.Append("d_gauge,");
            //sbtmp.Append("d_wx");
            //sw2.WriteLine(sbtmp.ToString());
            //for (int i = 0; i < d_tt.Length; i++)
            //{
            //    sw2.Write(d_tt[i]);
            //    sw2.Write(",");
            //    sw2.Write(d_wvelo[i]);
            //    sw2.Write(",");
            //    sw2.Write(d_gauge[i]);
            //    sw2.Write(",");
            //    sw2.Write(d_wx[i]);
            //    sw2.Write("\n");
            //}
            //sw2.Close();

            List <String> tmpDataStrList = pdc.WideGaugePreProcess("左高低_中波", d_tt, d_wx, d_wvelo, d_gauge, 8.0);

            dataStrList.AddRange(tmpDataStrList);

            d_wx = cfprocess.GetOneChannelDataInRange(citFileName, cdlist.GetChannelIdByName("R_Prof_SC", "右高低_中波"), startPos, endPos);

            tmpDataStrList = pdc.WideGaugePreProcess("右高低_中波", d_tt, d_wx, d_wvelo, d_gauge, 8.0);
            dataStrList.AddRange(tmpDataStrList);

            d_wx = cfprocess.GetOneChannelDataInRange(citFileName, cdlist.GetChannelIdByName("L_Align_SC", "左轨向_中波"), startPos, endPos);

            tmpDataStrList = pdc.WideGaugePreProcess("左轨向_中波", d_tt, d_wx, d_wvelo, d_gauge, 8.0);
            dataStrList.AddRange(tmpDataStrList);

            d_wx = cfprocess.GetOneChannelDataInRange(citFileName, cdlist.GetChannelIdByName("R_Align_SC", "右轨向_中波"), startPos, endPos);

            tmpDataStrList = pdc.WideGaugePreProcess("右轨向_中波", d_tt, d_wx, d_wvelo, d_gauge, 8.0);
            dataStrList.AddRange(tmpDataStrList);

            return(dataStrList);
        }