private void CheckData(string targetCitFile)
        {
            _CorrResult.Clear();
            //左半边数据点个数,包括中间点
            foreach (var kvp in _fixedData)
            {
                int leftTargetCount = TargetSamplingCount + 1;

                long filePostion = _citProcess.GetCurrentPositionByMilestone(targetCitFile, kvp.Value[0].OriginalMileage, true);
                if (filePostion != -1)
                {
                    long targetStartPostion = _citProcess.GetAppointEndPostion(targetCitFile, filePostion, -1 * leftTargetCount);
                    long targetStartCount   = _citProcess.GetSampleCountByRange(targetCitFile, targetStartPostion, filePostion);

                    long targetEndPostion = _citProcess.GetAppointEndPostion(targetCitFile, filePostion, TargetSamplingCount);
                    long targetEndCount   = _citProcess.GetSampleCountByRange(targetCitFile, filePostion, targetEndPostion);



                    List <CorrelationResult> correlationResult = new List <CorrelationResult>();
                    foreach (var item in _fixedData[kvp.Key])
                    {
                        int      index     = -1;
                        double   lastValue = 0;
                        double[] newArr    = _citProcess.GetOneChannelDataInRange(targetCitFile, item.ChannelID, targetStartPostion, (int)(targetEndCount + targetStartCount));
                        double[] carr      = new double[item.Points.Length];
                        for (int i = 0; i < newArr.Length - item.Points.Length; i++)
                        {
                            Array.Clear(carr, 0, carr.Length);
                            Array.Copy(newArr, i, carr, 0, carr.Length);
                            //double per = Correlation.Pearson(item.Points, carr);
                            double per = correlationCalc(item.Points, carr);
                            if (per > lastValue)
                            {
                                lastValue = per;
                                index     = i;
                            }
                        }
                        FixParam          key    = FixParams.FirstOrDefault(p => p.ChannelID == item.ChannelID);
                        CorrelationResult result = new CorrelationResult();
                        if (key != null && lastValue > key.ThreShold)
                        {
                            result.FilePointer = targetStartPostion + index + item.FixPostion;
                            result.IsFind      = true;
                            result.ChannelID   = key.ChannelID;
                            result.ChannelName = key.ChannelName;
                        }
                        else
                        {
                            result.IsFind = false;
                        }
                        correlationResult.Add(result);
                    }
                    _CorrResult.Add(kvp.Key, correlationResult);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据里程获取修正后的里程
        /// </summary>
        /// <param name="pointMileStone">未修正的里程</param>
        /// <returns>修正后的里程</returns>
        public float CalcPointMileStone(float pointMileStone)
        {
            long postionInFile = _citProcess.GetCurrentPositionByMilestone(_citFilePath, pointMileStone, false);

            if (postionInFile != -1)
            {
                return(CalcPointMileStone(postionInFile));
            }
            else
            {
                return(0);
            }
        }
        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);
        }