Esempio n. 1
0
        /// <summary>
        /// 计算起始里程
        /// </summary>
        private void CalcCitStartMileStone()
        {
            if (_fixData != null && _fixData.Count > 0)
            {
                long markedStartPostion = _fixData[0].MarkedStartPoint.FilePointer;
                long sampleCount        = _citProcess.GetAppointSampleCount(_citFilePath, markedStartPostion);
                if (sampleCount > 0)
                {
                    MileStoneFixData data = new MileStoneFixData();
                    data.MarkedEndPoint   = _fixData[0].MarkedStartPoint;
                    data.SamplePointCount = sampleCount;
                    data.SampleRate       = _meanSampleRate;
                    UserMarkedPoint markedStartPoint = new UserMarkedPoint();
                    long[]          points           = _citProcess.GetPositons(_citFilePath);
                    markedStartPoint.FilePointer = points[0];
                    //if (_citFileInfo.iKmInc == 1)
                    //{
                    //    markedStartPoint.UserSetMileage = data.MarkedEndPoint.UserSetMileage + (data.SamplePointCount - 1) * data.SampleRate;
                    //}
                    //else
                    //{
                    //    markedStartPoint.UserSetMileage = data.MarkedEndPoint.UserSetMileage - (data.SamplePointCount - 1) * data.SampleRate;
                    //}
                    markedStartPoint.UserSetMileage = data.MarkedEndPoint.UserSetMileage - (data.SamplePointCount - 1) * data.SampleRate;
                    markedStartPoint.FilePointer    = points[0];

                    data.MarkedStartPoint = markedStartPoint;
                    data.RealDistance     = data.MarkedEndPoint.UserSetMileage - data.MarkedStartPoint.UserSetMileage;
                    _fixData.Insert(0, data);
                }
            }
        }
        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);
        }
Esempio n. 3
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. 4
0
        public void DisplayInListview(string citPath)
        {
            FileInformation fileInfo     = null;
            double          startMileage = 0;
            double          endMileage   = 0;
            double          totalMileage = 0;

            try
            {
                fileInfo = _citProcess.GetFileInformation(citPath);
                long[]    startAndEnd = _citProcess.GetPositons(citPath);
                Milestone start       = _citProcess.GetStartMilestone(citPath);
                Milestone end         = _citProcess.GetEndMilestone(citPath);
                startMileage = start.GetMeter() / 1000;
                endMileage   = end.GetMeter() / 1000;
                long sampleCount = _citProcess.GetSampleCountByRange(citPath, startAndEnd[0], startAndEnd[1]);
                totalMileage = (sampleCount * 0.25) / 1000;
            }
            catch (Exception ex)
            {
                MyLogger.logger.Error("读取文件头部信息出错:" + ex.Message + ",堆栈:" + ex.StackTrace + ",CIT文件名称:" + citPath);
                MessageBox.Show("读取文件头部信息出错,请检查文件是否有效!");
            }
            if (fileInfo != null)
            {
                //线路名
                ListViewItem item = new ListViewItem(fileInfo.sTrackName);
                //线路编码
                item.SubItems.Add(fileInfo.sTrackCode);
                //行别
                string dir = string.Empty;
                switch (fileInfo.iDir)
                {
                case 1:
                {
                    dir = "上行"; break;
                }

                case 2:
                {
                    dir = "下行"; break;
                }

                case 3:
                {
                    dir = "单线"; break;
                }

                default:
                {
                    dir = "上行"; break;
                }
                }
                item.SubItems.Add(dir);
                if (dir.Contains("下"))
                {
                    item.BackColor = Color.LightCyan;
                }
                else
                {
                    item.BackColor = Color.LightBlue;
                }
                //方向
                item.SubItems.Add(fileInfo.iRunDir == 0 ? "正" : "反");
                //增减里程
                item.SubItems.Add(fileInfo.iKmInc == 0 ? "增" : "减");
                item.SubItems.Add(startMileage.ToString()); //起始里程
                item.SubItems.Add(endMileage.ToString());   //终止里程
                item.SubItems.Add(totalMileage.ToString()); //总里程
                //检测日期
                item.SubItems.Add(fileInfo.sDate);
                //检测时间
                item.SubItems.Add(fileInfo.sTime);
                //检测车号
                item.SubItems.Add(fileInfo.sTrain);
                //原始文件名
                item.SubItems.Add(Path.GetFileName(citPath));
                //大小
                item.SubItems.Add((new FileInfo(citPath)).Length.ToString());
                //原始路径
                item.SubItems.Add(Path.GetDirectoryName(citPath));
                //ListViewItem.ListViewSubItem subItem = new ListViewItem.ListViewSubItem();
                //subItem.ForeColor = Color.Red;
                //subItem.Text = "点击移除";
                item.SubItems.Add("点击移除");
                item.Tag     = fileInfo;
                item.Checked = true;

                listViewFiles.Items.Add(item);
                listViewFiles.Columns[listViewFiles.Columns.Count - 1].Width = -2;
            }
        }
Esempio n. 5
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);
        }