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);
                    }
                }
            }
        }
Exemplo n.º 2
0
 public MilestoneFix(string citFilePath, IOperator indexOperator)
 {
     _indexOperator  = indexOperator;
     _citProcess     = new CITFileProcess();
     _citFilePath    = citFilePath;
     _citFileInfo    = _citProcess.GetFileInformation(citFilePath);
     _longChainTable = new LongChainTable(_citFileInfo.sTrackCode, _citFileInfo.iKmInc, _citFileInfo.iDir);
     _userFixedTable = new UserFixedTable(indexOperator, _citFileInfo.iKmInc);
     _fixData        = new List <MileStoneFixData>();
 }
        static void Main(string[] args)
        {
            string citpath = @"H:\工作文件汇总\铁科院\程序\车载加速度\数据文件\CitData_170413050607_GJGX\CitData_170413050607_GJGX.cit";

            CITFileProcess cithelper      = new CITFileProcess();
            var            fileInfomation = cithelper.GetFileInformation(citpath);

            var channelList = cithelper.GetChannelDefinitionList(citpath);

            var channelData = cithelper.GetAllMileStone(citpath);

            var type        = cithelper.GetDataType(citpath);
            var DataVersion = cithelper.GetDataVersion(citpath);

            var date = cithelper.GetDate(citpath);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 偏差修正
        /// </summary>
        /// <param name="citFilePath">cit文件路径</param>
        /// <param name="iicFilePath">iic文件路径</param>
        /// <param name="listIC">里程修正结果集合</param>
        /// <param name="cyjg">采样点</param>
        /// <param name="gjtds">通道数量</param>
        /// <param name="sKmInc">增减里程</param>
        /// <param name="listETC">偏差类型</param>
        public void ExceptionFix(string citFilePath, string iicFilePath, List <IndexSta> listIC, List <ExceptionType> listETC)
        {
            List <Defects> listDC = new List <Defects>();

            try
            {
                using (OleDbConnection sqlconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + iicFilePath + ";Persist Security Info=True"))
                {
                    string       sqlCreate = "select RecordNumber,maxpost,maxminor from fix_defects where maxval2 is null or maxval2<>-200";
                    OleDbCommand sqlcom    = new OleDbCommand(sqlCreate, sqlconn);
                    sqlconn.Open();
                    OleDbDataReader oleDBdr = sqlcom.ExecuteReader();
                    while (oleDBdr.Read())
                    {
                        Defects dc = new Defects();
                        dc.iRecordNumber = int.Parse(oleDBdr.GetValue(0).ToString());
                        dc.iMaxpost      = int.Parse(oleDBdr.GetValue(1).ToString());
                        dc.dMaxminor     = double.Parse(oleDBdr.GetValue(2).ToString());
                        listDC.Add(dc);
                    }

                    oleDBdr.Close();
                    sqlconn.Close();
                }
                Application.DoEvents();
            }
            catch
            {
            }

            FileInformation fi = citHelper.GetFileInformation(citFilePath);

            //
            List <Milestone>       listMilestone = citHelper.GetAllMileStone(citFilePath);
            List <cPointFindMeter> listcpfm      = new List <cPointFindMeter>();

            for (int i = 0; i < listMilestone.Count; i++)
            {
                cPointFindMeter cpfm = new cPointFindMeter();
                cpfm.lLoc   = listMilestone[i].mFilePosition;
                cpfm.lMeter = Convert.ToInt64(listMilestone[i].mKm * 100000 + listMilestone[i].mMeter * 100);

                listcpfm.Add(cpfm);
            }


            for (int i = 0; i < listDC.Count; i++)
            {
                for (int j = 0; j < listcpfm.Count; j++)
                {
                    if (listcpfm[j].lMeter == listDC[i].GetMeter())
                    {
                        int iValue = PointToMeter(listIC, listcpfm[j].lLoc, fi.iChannelNumber, fi.iKmInc);
                        if (iValue > 0)
                        {
                            listDC[i].bFix      = true;
                            listDC[i].iMaxpost  = iValue / 1000;
                            listDC[i].dMaxminor = iValue % 1000;
                        }
                        break;
                    }
                }
            }


            //将修正后的偏差数据存储到iic中

            try
            {
                using (OleDbConnection sqlconn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + iicFilePath + ";Persist Security Info=True"))
                {
                    string       sqlCreate = "";
                    OleDbCommand sqlcom    = new OleDbCommand(sqlCreate, sqlconn);
                    sqlconn.Open();
                    for (int i = 0; i < listDC.Count; i++)
                    {
                        if (listDC[i].bFix)
                        {
                            sqlcom.CommandText = "update fix_defects set maxpost=" + listDC[i].iMaxpost.ToString() +
                                                 ",maxminor=" + listDC[i].dMaxminor.ToString() + ",maxval2=-200 where RecordNumber=" + listDC[i].iRecordNumber.ToString();
                            sqlcom.ExecuteNonQuery();
                        }
                    }
                    sqlconn.Close();
                }
                Application.DoEvents();
            }
            catch
            {
            }
        }
        /// <summary>
        /// 读取CIT文件
        /// </summary>
        /// <param name="citFilePath"></param>
        private void ReadCIT(String citFilePath)
        {
            if (numericUpDown1.Value <= 0)
            {
                MessageBox.Show("容许跳变值为 0");
                return;
            }

            try
            {
                autoIndexClsList.Clear();
                dataGridView1.Rows.Clear();

                FileInformation          fileInfomation = citHelper.GetFileInformation(citFilePath);
                List <ChannelDefinition> channelList    = citHelper.GetChannelDefinitionList(citFilePath);

                FileStream   fs = new FileStream(citFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                BinaryReader br = new BinaryReader(fs, Encoding.Default);
                br.BaseStream.Position = 0;

                br.ReadBytes(120);


                br.ReadBytes(65 * fileInfomation.iChannelNumber);
                br.ReadBytes(BitConverter.ToInt32(br.ReadBytes(4), 0));
                int    iChannelNumberSize = fileInfomation.iChannelNumber * 2;
                byte[] b = new byte[iChannelNumberSize];

                long milePos       = 0;
                int  km_pre        = 0;
                int  meter_pre     = 0;
                int  km_currrent   = 0;
                int  meter_current = 0;
                int  meter_between = 0;
                int  km_index      = 0;
                int  meter_index   = 2;

                long iArray = (br.BaseStream.Length - br.BaseStream.Position) / iChannelNumberSize;

                for (int i = 0; i < iArray; i++)
                {
                    milePos = br.BaseStream.Position;

                    b = br.ReadBytes(iChannelNumberSize);

                    if (Encryption.IsEncryption(fileInfomation.sDataVersion))
                    {
                        b = Encryption.Translate(b);
                    }

                    if (i == 0)
                    {
                        km_pre    = (int)(BitConverter.ToInt16(b, km_index));
                        meter_pre = (int)(BitConverter.ToInt16(b, meter_index));
                    }
                    else
                    {
                        km_currrent   = (int)(BitConverter.ToInt16(b, km_index));
                        meter_current = (int)(BitConverter.ToInt16(b, meter_index));
                        //第二个通道为采样点,换算为米就要除以4
                        meter_between = (km_currrent - km_pre) * 1000 + (meter_current - meter_pre) / 4;

                        if (Math.Abs(meter_between) > numericUpDown1.Value)
                        {
                            AutoIndex autoIndexCls = new AutoIndex();
                            autoIndexCls.milePos       = milePos;
                            autoIndexCls.km_current    = km_currrent;
                            autoIndexCls.meter_current = meter_current;
                            autoIndexCls.km_pre        = km_pre;
                            autoIndexCls.meter_pre     = meter_pre;
                            autoIndexCls.meter_between = meter_between;

                            autoIndexClsList.Add(autoIndexCls);
                        }

                        km_pre    = km_currrent;
                        meter_pre = meter_current;
                    }
                }

                br.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                MyLogger.logger.Error("读取CIT文件跳变点失败:" + ex.Message + ",堆栈:" + ex.StackTrace);

                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 读取CIT文件
        /// </summary>
        /// <param name="citFilePath">cit文件路径----->来自里程快速校正中的选择cit文件的按钮</param
        /// <param name="numericUpDown1">跳变允许值----->来自里程快速校正中的  跳变容许值</param>
        private List <AutoIndex> _readCit(String citFilePath, int numericUpDown1)
        {
            List <AutoIndex> autoIndexClsList = new List <AutoIndex>();

            //autoIndexClsList.Max(p => p.meter_between);
            //autoIndexClsList.Min(p => p.meter_between);
            //double  count = citHelper.GetTotalSampleCount(citFilePath)/4/1000;
            //double tiaobian1=autoIndexClsList.Sum(p => p.meter_between)/count;
            //double tiaobian1i = autoIndexClsList.Sum(p => Math.Abs(p.meter_between))/autoIndexClsList.Count;
            if (numericUpDown1 <= 0)
            {
                ///MessageBox.Show("容许跳变值为 0");
                return(autoIndexClsList);
            }

            try
            {
                FileInformation          fileInfomation = citHelper.GetFileInformation(citFilePath);
                List <ChannelDefinition> channelList    = citHelper.GetChannelDefinitionList(citFilePath);

                FileStream   fs = new FileStream(citFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                BinaryReader br = new BinaryReader(fs, Encoding.Default);
                br.BaseStream.Position = 0;

                br.ReadBytes(120);


                br.ReadBytes(65 * fileInfomation.iChannelNumber);
                br.ReadBytes(BitConverter.ToInt32(br.ReadBytes(4), 0));
                int    iChannelNumberSize = fileInfomation.iChannelNumber * 2;
                byte[] b = new byte[iChannelNumberSize];

                long milePos       = 0;
                int  km_pre        = 0;
                int  meter_pre     = 0;
                int  km_currrent   = 0;
                int  meter_current = 0;
                int  meter_between = 0;
                int  km_index      = 0;
                int  meter_index   = 2;

                long iArray = (br.BaseStream.Length - br.BaseStream.Position) / iChannelNumberSize;

                for (int i = 0; i < iArray; i++)
                {
                    milePos = br.BaseStream.Position;

                    b = br.ReadBytes(iChannelNumberSize);

                    if (Encryption.IsEncryption(fileInfomation.sDataVersion))
                    {
                        b = Encryption.Translate(b);
                    }

                    if (i == 0)
                    {
                        km_pre    = (int)(BitConverter.ToInt16(b, km_index));
                        meter_pre = (int)(BitConverter.ToInt16(b, meter_index));
                    }
                    else
                    {
                        km_currrent   = (int)(BitConverter.ToInt16(b, km_index));
                        meter_current = (int)(BitConverter.ToInt16(b, meter_index));
                        //第二个通道为采样点,换算为米就要除以4
                        meter_between = (km_currrent - km_pre) * 1000 + (meter_current - meter_pre) / 4;

                        if (Math.Abs(meter_between) > numericUpDown1)
                        {
                            AutoIndex autoIndexCls = new AutoIndex();
                            autoIndexCls.milePos       = milePos;
                            autoIndexCls.km_current    = km_currrent;
                            autoIndexCls.meter_current = meter_current;
                            autoIndexCls.km_pre        = km_pre;
                            autoIndexCls.meter_pre     = meter_pre;
                            autoIndexCls.meter_between = meter_between;

                            autoIndexClsList.Add(autoIndexCls);
                        }

                        km_pre    = km_currrent;
                        meter_pre = meter_current;
                    }
                }

                br.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("读取CIT文件跳变点失败:" + ex.Message + ",堆栈:" + ex.StackTrace);
            }
            return(autoIndexClsList);
        }
Exemplo n.º 7
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;
            }
        }
Exemplo n.º 8
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
                {
                }
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 向idf文件中写入
        /// </summary>
        /// <param name="citFilePath">cit文件路径----->来自里程快速校正中的选择cit文件的按钮</param
        /// <param name="numericUpDown1">跳变允许值----->来自里程快速校正中的  跳变容许值</param>
        /// <param name="innerdbpath">内部数据库-----></param>
        private string _writeIdf(String citFilePath, int numericUpDown1, string innerdbpath)
        {
            //String idfFileName = Path.GetFileNameWithoutExtension(citFilePath) + ".idf";

            //String idfFilePath = Path.Combine(Path.GetDirectoryName(citFilePath), idfFileName);

            //if (!File.Exists(idfFilePath))
            //{
            //    //MessageBox.Show("找不到波形索引文件!");
            //    Console.WriteLine("找不到波形索引文件!");
            //    return;
            //}

            //公共方法
            ResultInfo resultInfo = new ResultInfo();

            //读取cit文件
            List <AutoIndex> autoIndexClsList = _readCit(citFilePath, numericUpDown1);

            String idfFileName = Path.GetFileNameWithoutExtension(citFilePath) + "_MileageFix" + ".idf";

            String idfFilePath = Path.Combine(Path.GetDirectoryName(citFilePath), idfFileName);

            //设置附带数据库路径和链接字符串,流程修正使用
            InnerFileOperator.InnerFilePath   = innerdbpath;
            InnerFileOperator.InnerConnString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = {0}; Persist Security Info = True; Mode = Share Exclusive; Jet OLEDB:Database Password = iicdc; ";
            //InnerFileOperator.InnerConnString = "provider=Microsoft.Ace.OLEDB.12.0;extended properties=excel 12.0; Data Source = {0}; Persist Security Info = True; Mode = Share Exclusive; Extended Properties=Excel 12.0:Database Password = iicdc; ";

            try
            {
                _op = new IndexOperator();
                _op.IndexFilePath = idfFilePath;
                CITFileProcess  cit        = new CITFileProcess();
                FileInformation fileforma  = cit.GetFileInformation(citFilePath);
                UserFixedTable  fixedTable = new UserFixedTable(_op, fileforma.iKmInc);
                fixedTable.Clear();
                for (int i = 0; i < autoIndexClsList.Count; i++)
                {
                    float           mile        = autoIndexClsList[i].km_current + autoIndexClsList[i].meter_current;
                    UserMarkedPoint markedPoint = new UserMarkedPoint();
                    markedPoint.ID             = (i + 1).ToString();
                    markedPoint.FilePointer    = autoIndexClsList[i].milePos;
                    markedPoint.UserSetMileage = mile;
                    fixedTable.MarkedPoints.Add(markedPoint);
                }
                fixedTable.Save();

                try
                {
                    MilestoneFix fix = new MilestoneFix(citFilePath, _op);
                    fix.RunFixingAlgorithm();
                    fix.SaveMilestoneFixTable();

                    resultInfo.flag = 1;
                    resultInfo.msg  = "";
                    resultInfo.data = idfFilePath;
                }
                catch (Exception ex)
                {
                    resultInfo.flag = 0;
                    resultInfo.msg  = ex.Message;
                }
            }
            catch (Exception ex)
            {
                resultInfo.flag = 0;
                resultInfo.msg  = ex.Message;
            }

            return(JsonConvert.SerializeObject(resultInfo));
        }