/// <summary>
        /// 根据里程信息获取采样值,换算为采样点个数,同时获取坐标位置
        /// </summary>
        /// <param name="mileage">里程,单位为米</param>
        /// <param name="locationPostion"></param>
        /// <returns>采样点个数</returns>
        public long GetLocationSampleCount(float mileage, ref long locationPostion)
        {
            if (IsLoadIndex)
            {
                //if (CitFile.iKmInc == 0)
                //{

                //    Milestone stone= MileageFix.CalcMilestoneByFixedMilestone(mileage);
                //    //Milestone stone = _allStone.FindLast(p => p.GetMeter() <= mileage);
                //    if (stone != null)
                //    {
                //        locationPostion = stone.mFilePosition;
                //    }
                //    else
                //    {
                //        locationPostion = -1;
                //    }
                //}
                //else
                //{
                //    //Milestone stone = _allStone.FindLast(p => p.GetMeter() >= mileage);
                //    long postion = CitFileProcess.GetCurrentPositionByMilestone(_citFilePath, mileage, true);
                //    if (postion != -1)
                //    {
                //        locationPostion = postion;
                //    }
                //    else
                //    {
                //        locationPostion = -1;
                //    }
                //}
                Milestone stone = MileageFix.CalcMilestoneByFixedMilestone(mileage);
                if (stone != null)
                {
                    locationPostion = stone.mFilePosition;
                }
                else
                {
                    locationPostion = -1;
                }
            }
            else
            {
                locationPostion = CitFileProcess.GetCurrentPositionByMilestone(_citFilePath, mileage, true);
            }
            if (locationPostion != -1)
            {
                return(GetLocationSampleCount(locationPostion));
            }
            return(-1);
        }
        /// <summary>
        /// 获取所有的里程信息
        /// </summary>
        /// <returns></returns>
        public List <Milestone> GetAllMileage()
        {
            List <Milestone> _allStone = new List <Milestone>();

            _allStone = CitFileProcess.GetAllMileStone(_citFilePath);
            if (IsLoadIndex)
            {
                if (MileageFix.FixData.Count > 0)
                {
                    _allStone = MileageFix.GetMileageReviseData(_allStone);
                }
                else
                {
                    IsLoadIndex = false;
                }
            }
            return(_allStone);
        }
        public List <Milestone> GetRangeMileage(int totalSmapleCount)
        {
            List <Milestone> rangeMileage = new List <Milestone>(WaveformDataCount);
            long             endPostion   = -1;

            long[] postions = CitFileProcess.GetPositons(_citFilePath);
            long   postion  = CitFileProcess.GetAppointEndPostion(CitFilePath, postions[0], totalSmapleCount);

            rangeMileage = CitFileProcess.GetMileStoneByRange(CitFilePath, postion, WaveformDataCount, ref endPostion);
            if (IsLoadIndex)
            {
                if (MileageFix.FixData.Count > 0)
                {
                    rangeMileage = MileageFix.GetMileageReviseData(rangeMileage);
                }
                else
                {
                    IsLoadIndex = false;
                }
            }
            return(rangeMileage);
        }
        /// <summary>
        /// 根据索引导出CIT文件
        /// </summary>
        /// <param name="filePath">cit文件路径</param>
        /// <param name="startMileage">开始里程(公里)</param>
        /// <param name="endMileage">结束里程(公里)</param>
        /// <returns>成功:返回导出路径,失败:空字符串</returns>
        public string ExportCITFileAndIndexData(string filePath, double startMileage, double endMileage)
        {
            string destFile = filePath + "\\" +
                              Path.GetFileNameWithoutExtension(CitFilePath) + "_" +
                              startMileage.ToString() + "-" + endMileage.ToString() + ".cit";

            if (_citFile.iKmInc == 1 && startMileage < endMileage)
            {
                double change = startMileage;
                startMileage = endMileage;
                endMileage   = change;
            }
            if (_citFile != null && MileageFix.FixData.Count > 0)
            {
                if (_citFile.iKmInc == 0)
                {
                    if (startMileage >= MileageFix.FixData[MileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000 ||
                        endMileage <= MileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000)
                    {
                        return("");
                    }
                    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 (_citFile.iKmInc == 1)
                {
                    if (endMileage >= MileageFix.FixData[MileageFix.FixData.Count - 1].MarkedEndPoint.UserSetMileage / 1000 ||
                        startMileage <= MileageFix.FixData[0].MarkedStartPoint.UserSetMileage / 1000)
                    {
                        return("");
                    }
                    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 = MileageFix.CalcMilestoneByFixedMilestone((float)startMileage * 1000);
                endStone   = MileageFix.CalcMilestoneByFixedMilestone((float)endMileage * 1000);
                if (startStone.mFilePosition != -1 && endStone.mFileEndPostion != -1)
                {
                    if (!Directory.Exists(filePath))
                    {
                        Directory.CreateDirectory(filePath);
                    }

                    List <double[]>          channelData           = CitFileProcess.GetAllChannelDataInRange(_citFilePath, startStone.mFilePosition, endStone.mFileEndPostion);
                    List <ChannelDefinition> channelDefinitionList = CitFileProcess.GetChannelDefinitionList(_citFilePath);
                    if (CitFileProcess.WriteCitFile(destFile, CitFile, channelDefinitionList, "", channelData))
                    {
                        CitFileProcess.SetKmFrom(destFile, (float)startStone.GetMeter() / 1000);
                        CitFileProcess.SetKmTo(destFile, (float)endStone.GetMeter() / 1000);
                        string    indexFile   = destFile.Replace(".cit", ".idf");
                        IOperator newOperator = new IndexOperator();
                        newOperator.IndexFilePath = indexFile;
                        //IndexOperator.CreateDB(indexFile);
                        long fileHead = FileDataOffset.GetSamplePointStartOffset(channelData.Count, 4);
                        AddNewIndexData(destFile, newOperator, fileHead, startStone.mFilePosition, endStone.mFileEndPostion, channelData.Count);
                        AddInvaildData(newOperator, fileHead, startStone.mFilePosition, endStone.mFileEndPostion, channelData.Count);
                        return(destFile);
                    }
                    return("");
                }
                return("");
            }
            else
            {
                return(ExportOnlyCITFile(destFile, startMileage, endMileage));
            }
        }
        /// <summary>
        /// 根据起始位置加载波形数据
        /// </summary>
        /// <param name="startPostion">起始点</param>
        public void GetWaveformData(long startPostion)
        {
            if (File.Exists(_citFilePath))
            {
                long   endPos       = 0;
                long   startPos     = 0;
                long   realStartPos = 0;
                long[] postions     = CitFileProcess.GetPositons(_citFilePath);
                startPos = startPostion;
                if (LayerConfig.IsReverse)
                {
                    startPos -= ReviseValue * _citFile.iChannelNumber * 2;
                }
                else
                {
                    startPos += ReviseValue * _citFile.iChannelNumber * 2;
                }
                realStartPos = startPos;
                int pointCount = 0;
                if (startPos < postions[0])
                {
                    while (startPos < postions[0] && pointCount < WaveformDataCount)
                    {
                        startPos += _citFile.iChannelNumber * 2;
                        pointCount++;
                    }
                    pointCount = WaveformDataCount - pointCount;
                }
                else if (startPos > postions[1])
                {
                    while (startPos > postions[1] && pointCount < WaveformDataCount)
                    {
                        startPos -= _citFile.iChannelNumber * 2;
                        pointCount++;
                    }
                    pointCount = WaveformDataCount - pointCount;
                }
                else
                {
                    pointCount = WaveformDataCount;
                }
                if (LayerConfig.IsReverse)
                {
                    pointCount = pointCount * -1;
                }


                CurrentPostion = startPos;
                endPos         = CitFileProcess.GetAppointEndPostion(_citFilePath, startPos, pointCount);
                List <double[]> data = null;

                if (LayerConfig.IsReverse)
                {
                    data = CitFileProcess.GetAllChannelDataInRange(_citFilePath, endPos, startPos);
                    MileList.milestoneList = CitFileProcess.GetMileStoneByRange(_citFilePath, endPos, startPos);
                }
                else
                {
                    data = CitFileProcess.GetAllChannelDataInRange(_citFilePath, startPos, endPos);
                    MileList.milestoneList = CitFileProcess.GetMileStoneByRange(_citFilePath, startPos, endPos);
                }

                if (IsLoadIndex)
                {
                    MileList.milestoneList = MileageFix.GetMileageReviseData(MileList.milestoneList);
                }
                data.RemoveAt(0);
                data.RemoveAt(0);
                if (ChannelList.Count > 0)
                {
                    for (int i = 0; i < data.Count; i++)

                    {
                        if (ChannelList.Count > i)
                        {
                            ChannelList[i].Data = new double[WaveformDataCount];
                            if (data[i].Length < WaveformDataCount)
                            {
                                double[] temp = new double[data[i].Length];
                                Array.Copy(data[i], temp, data[i].Length);
                                data[i] = new double[WaveformDataCount];
                                if (realStartPos < postions[0])
                                {
                                    Array.Copy(temp, 0, data[i], WaveformDataCount - temp.Length, temp.Length);
                                }
                                else
                                {
                                    Array.Copy(temp, data[i], temp.Length);
                                }
                            }
                            if (LayerConfig.IsReverse)
                            {
                                Array.Reverse(data[i]);
                            }
                            Array.Copy(data[i], ChannelList[i].Data, WaveformDataCount);
                        }
                        else
                        {
                            break;
                        }
                    }

                    if (MileList.milestoneList.Count < WaveformDataCount)
                    {
                        int count = WaveformDataCount - MileList.milestoneList.Count;
                        for (int i = 0; i < count; i++)
                        {
                            if (realStartPos < postions[0])
                            {
                                MileList.milestoneList.Insert(0, new Milestone()
                                {
                                    mKm = 0, mMeter = 0
                                });
                            }
                            else
                            {
                                MileList.milestoneList.Add(new Milestone()
                                {
                                    mKm = 0, mMeter = 0
                                });
                            }
                        }
                    }
                    if (LayerConfig.IsReverse)
                    {
                        MileList.milestoneList.Reverse();
                    }
                }
            }
            else
            {
                throw new InvalidDataException("CIT文件路径无效或为空!");
            }
        }