private void InitListGEO2CIT() { String configPath = Path.Combine(Application.StartupPath, "GEOConfig"); configPath = Path.Combine(configPath, "CRH2-150C - AC.csv"); try { if (listGEO2CIT == null || listGEO2CIT.Count == 0) { listGEO2CIT = new List <GEO2CITBind>(); StreamReader sr = new StreamReader(configPath, Encoding.Default); while (sr.Peek() != -1) { string[] sSplit = sr.ReadLine().Trim().Split(new char[] { '=' }); GEO2CITBind fa = new GEO2CITBind(); fa.sCIT = sSplit[0].Trim(); fa.sGEO = sSplit[1].Trim(); fa.sChinese = sSplit[2].Trim(); listGEO2CIT.Add(fa); } sr.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonCitFilter_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxCitPath.Text)) { MessageBox.Show("请先选择一个波形文件!"); return; } if (checkBoxIs0haoche.Checked) { if (comboBoxLineName.SelectedIndex < 0) { MessageBox.Show("请选择检测线路!"); return; } if (comboBoxTrainCode.SelectedIndex < 0) { MessageBox.Show("请选择检测车号!"); return; } } String destDirectory = Path.GetDirectoryName(textBoxCitPath.Text); String destCitName = Path.GetFileNameWithoutExtension(textBoxCitPath.Text).ToUpper() + "_new.cit"; destFilePath = Path.Combine(destDirectory, destCitName); File.Copy(textBoxCitPath.Text, destFilePath, true); if (checkBoxIs0haoche.Checked) { try { listGEO2CIT = new List <GEO2CITBind>(); StreamReader sr = new StreamReader(dicTrainCodeAndConfigPath[(String)(comboBoxTrainCode.SelectedItem)], Encoding.Default); while (sr.Peek() != -1) { string[] sSplit = sr.ReadLine().Trim().Split(new char[] { '=' }); GEO2CITBind fa = new GEO2CITBind(); fa.sCIT = sSplit[0].Trim(); fa.sGEO = sSplit[1].Trim(); fa.sChinese = sSplit[2].Trim(); listGEO2CIT.Add(fa); } sr.Close(); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } } try { //listGEO2CIT = new List<GEO2CITBind>(); //StreamReader sr = new StreamReader(dicTrainCodeAndConfigPath[(String)(comboBoxTrainCode.SelectedItem)], Encoding.Default); //while (sr.Peek() != -1) //{ // string[] sSplit = sr.ReadLine().Trim().Split(new char[] { '=' }); // GEO2CITBind fa = new GEO2CITBind(); // fa.sCIT = sSplit[0].Trim(); // fa.sGEO = sSplit[1].Trim(); // fa.sChinese = sSplit[2].Trim(); // listGEO2CIT.Add(fa); //} //sr.Close(); SetObjectEnable(false); backgroundWorker1.RunWorkerAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonConvertData_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxGeoPath.Text)) { MessageBox.Show("请先选择一个波形文件!"); return; } if (comboBoxLineName.SelectedIndex < 0 || comboBoxLineDir.SelectedIndex < 0 || comboBoxTrainCode.SelectedIndex < 0 || comboBoxRunDir.SelectedIndex < 0 || comboBoxKmInc.SelectedIndex < 0 || string.IsNullOrEmpty(textBoxStartPos.Text) || string.IsNullOrEmpty(textBoxEndPos.Text)) { MessageBox.Show("请完善基础信息!"); return; } for (int i = 0; i < listLineCodeAndName.Count; i++) { if (i == comboBoxLineName.SelectedIndex) { lineCode = listLineCodeAndName[i].lineCode; break; } } try { listGEO2CIT = new List <GEO2CITBind>(); String trainCode = (String)comboBoxTrainCode.SelectedItem; if (trainCode.Contains("999307")) { iType = 307;//iType=307时,geo转换有特殊情况 } else { iType = 1; } StreamReader sr = new StreamReader(dicTrainCodeAndConfigPath[trainCode], Encoding.Default); while (sr.Peek() != -1) { string[] sSplit = sr.ReadLine().Trim().Split(new char[] { '=' }); GEO2CITBind fa = new GEO2CITBind(); fa.sCIT = sSplit[0].Trim(); fa.sGEO = sSplit[1].Trim(); fa.sChinese = sSplit[2].Trim(); listGEO2CIT.Add(fa); } sr.Close(); dhi = new CITDataProcess.DataHeadInfo(); dhi.iDataType = 1; dhi.sDataVersion = "3.0.0"; dhi.sTrackCode = lineCode; dhi.sTrackName = comboBoxLineName.SelectedItem.ToString(); dhi.sTrain = comboBoxTrainCode.SelectedItem.ToString(); dhi.sDate = dateTimePickerData.Value.ToString("yyyy-MM-dd"); dhi.sTime = dateTimePickerTime.Value.ToString("HH:mm:ss"); dhi.iSmaleRate = 4; dhi.iRunDir = comboBoxRunDir.SelectedIndex; dhi.iKmInc = comboBoxKmInc.SelectedIndex; dhi.iDir = comboBoxLineDir.SelectedIndex + 1; //geoProcess.ConvertData(textBoxGeoPath.Text, textBoxGeoPath.Text + "_new" + ".cit", listGEO2CIT, 1, dhi); //MessageBox.Show("波形转换完成!\n新文件位置及名字:" + textBoxGeoPath.Text + "_new" + ".cit"); SetContralEnable(false); backgroundWorker1.RunWorkerAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }