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);
                    }
                }
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
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
                {
                }
            }
        }
Esempio n. 4
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);
        }