Пример #1
0
        /// <summary>
        /// 接口函数:计算峰峰值指标
        /// </summary>
        /// <param name="citFileName">cit文件全路径</param>
        /// <returns></returns>
        public List <String> PreProcessDeviation(String citFileName)
        {
            List <String> dataStrList = new List <String>();

            //cdp.QueryDataInfoHead(citFileName);

            //double[] d_tt = cdp.GetMilesDataDouble(citFileName);//里程
            CITDataProcess.DataHeadInfo dhi = cdp.GetDataInfoHeadNew(citFileName);
            int tds = dhi.iChannelNumber;

            long startPos = 0;
            long endPos   = 0;

            using (FileStream fs = new FileStream(citFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] b = new byte[tds * 2];
                    br.ReadBytes(120);      //120
                    br.ReadBytes(65 * tds); //65
                    br.ReadBytes(BitConverter.ToInt32(br.ReadBytes(4), 0));


                    startPos = br.BaseStream.Position;
                    endPos   = br.BaseStream.Length;

                    br.Close();
                }
                fs.Close();
            }

            double[] d_tt = wdp.GetDataMileageInfoDouble(citFileName, tds, dhi.iSmaleRate, CommonClass.listDIC[0].bEncrypt,
                                                         CommonClass.listDIC[0].listIC, CommonClass.listDIC[0].bIndex, startPos, endPos, CommonClass.listDIC[0].sKmInc);//里程

            double[] d_wvelo = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, "Speed", "速度"));
            double[] d_gauge = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, "Gage", "轨距"));


            double[] d_wx = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, "L_Prof_SC", "左高低_中波"));


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

            dataStrList.AddRange(tmpDataStrList);

            d_wx = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, "R_Prof_SC", "右高低_中波"));

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

            d_wx = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, "L_Align_SC", "左轨向_中波"));

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

            d_wx = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, "R_Align_SC", "右轨向_中波"));

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

            return(dataStrList);
        }
        /// <summary>
        /// 接口函数:计算功率谱
        /// </summary>
        /// <param name="citFileName">cit全路径文件名</param>
        /// <param name="channelNameEn">英文通道名</param>
        /// <param name="channelNameCh">中文通道名</param>
        /// <param name="kmStart">起始里程</param>
        /// <param name="kmEnd">结束里程</param>
        /// <param name="fourierLen">傅里叶变换窗长</param>
        /// <param name="timeLen">时间步长</param>
        /// <returns>频率和幅值谱</returns>
        private List <String> SubProcess(String citFileName, String channelNameEn, String channelNameCh, float kmStart, float kmEnd, float fourierLen, float timeLen)
        {
            double[] retVal = new double[2];

            CITDataProcess.DataHeadInfo dhi = cdp.GetDataInfoHeadNew(citFileName);
            int tds = dhi.iChannelNumber;

            long startPos = 0;
            long endPos   = 0;

            using (FileStream fs = new FileStream(citFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (BinaryReader br = new BinaryReader(fs))
                {
                    byte[] b = new byte[tds * 2];
                    br.ReadBytes(120);      //120
                    br.ReadBytes(65 * tds); //65
                    br.ReadBytes(BitConverter.ToInt32(br.ReadBytes(4), 0));


                    startPos = br.BaseStream.Position;
                    endPos   = br.BaseStream.Length;

                    br.Close();
                }
                fs.Close();
            }
            //先把整条线的数据取出,然后再从中取出一段数
            double[] d_tt = wdp.GetDataMileageInfoDouble(citFileName, tds, 4, CommonClass.listDIC[0].bEncrypt,
                                                         CommonClass.listDIC[0].listIC, CommonClass.listDIC[0].bIndex, startPos, endPos, CommonClass.listDIC[0].sKmInc);//里程

            double[] d_wx = cdp.GetSingleChannelData(citFileName, dataProcessing.GetChannelNumberByChannelName(citFileName, channelNameEn, channelNameCh));

            int indexStart = 0;
            int indexEnd   = d_tt.Length - 1;

            if (d_tt[0] < d_tt[d_tt.Length - 1])
            {
                //增里程
                for (int i = 0; i < d_tt.Length; i++)
                {
                    if (d_tt[i] >= kmStart)
                    {
                        indexStart = i;
                        break;
                    }
                }
                for (int i = 0; i < d_tt.Length; i++)
                {
                    if (d_tt[i] >= kmEnd)
                    {
                        indexEnd = i;
                        break;
                    }
                }
            }
            else
            {
                //减里程
                for (int i = 0; i < d_tt.Length; i++)
                {
                    if (d_tt[i] <= kmStart)
                    {
                        indexStart = i;
                        break;
                    }
                }
                for (int i = 0; i < d_tt.Length; i++)
                {
                    if (d_tt[i] <= kmEnd)
                    {
                        indexEnd = i;
                        break;
                    }
                }
            }
            int len = indexEnd - indexStart + 1;

            double[] tt_new = new double[len];
            double[] wx_new = new double[len];

            Array.Copy(d_tt, indexStart, tt_new, 0, len);
            Array.Copy(d_wx, indexStart, wx_new, 0, len);

            List <String> str_retVal = glpc.Sub_Fourier_analysis(channelNameCh, tt_new, wx_new, fourierLen, timeLen);


            return(str_retVal);
        }