123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using DevExpress.XtraGrid.Views.Grid;
- using DevExpress.XtraGrid;
- using Uninpho.DBOperation.Model;
- using Uninpho.DBOperation.Operation;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- using MathWorks.MATLAB.NET.Arrays;
- using System.Threading;
- //数据库表重置;
- //TRUNCATE TABLE public.t_jihefenxi_boxing;//删除表内所有数据
- //ALTER TABLE public.t_jihefenxi_boxing DROP COLUMN id;//删除id序号
- //alter table public.t_jihefenxi_boxing add id serial PRIMARY KEY;//重置新加id序号
- namespace Uninpho.Tools.components.DataAnalysis
- {
- /// <summary>
- /// 进行算法处理的类
- /// </summary>
- public class DataAnalysisFun
- {
- static GridControl GC1; static GridControl GC2; static GridView GVJH; static GridView GVLGL;
- static bool tzxx = true;
- static int isuseDIYdisp = 0;
- static string fname_disp = "";
- /// <summary>
- ///
- /// </summary>
- /// <param name="whatfun">是那种算法;0几何;1微小;2轮轨力;</param>
- /// <param name="selectrow">选择条数</param>
- public static void resAsyncFun(int whatfun, int[] selectrow, ref GridControl GC1_, ref GridControl GC2_, ref GridView GVJH_, ref GridView GVLGL_)
- {
- if (!Directory.Exists(Application.StartupPath + "\\result\\jh"))
- {
- Directory.CreateDirectory(Application.StartupPath + "\\result\\jh");
- }
- if (!Directory.Exists(Application.StartupPath + "\\result\\lgl"))
- {
- Directory.CreateDirectory(Application.StartupPath + "\\result\\lgl");
- }
- isuseDIYdisp = 0;
- fname_disp = "";
- GC1 = GC1_; GC2 = GC2_; GVJH = GVJH_; GVLGL = GVLGL_;
- int iszhengc = 0;//错误码: 0:正常;1:文件找不到;2:检测车信息未录入;3:算法已执行;4:未选择文件
- List<int> ID = new List<int>();
- if (selectrow.Length >= 1)
- {
- for (int i = 0; i < selectrow.Length; i++)
- {
- if (whatfun == 0 || whatfun == 1)
- {
- if (GVJH.GetRowCellValue(selectrow[i], "Wjzt").ToString() == "正常")
- {
- ID.Add(Convert.ToInt32(GVJH.GetRowCellValue(selectrow[i], "Id").ToString()));
- }
- else
- {
- iszhengc = 1;
- break;
- }
- if (whatfun == 0)
- {
- if (GVJH.GetRowCellValue(selectrow[i], "Jccxx").ToString() == " " || GVJH.GetRowCellValue(selectrow[i], "Jccxx").ToString() == "")
- {
- iszhengc = 2;
- break;
- }
- if (GVJH.GetRowCellValue(selectrow[i], "Rwzt").ToString() == "几何算法执行完毕")
- {
- iszhengc = 3;
- break;
- }
- }
- if (whatfun == 1)
- {
- //微小算法一些前置条件:比如所选条数是否都没有执行过微小算法
- if (GVJH.GetRowCellValue(selectrow[i], "Rwzt").ToString() == "微小算法执行完毕")
- {
- iszhengc = 3;
- break;
- }
- }
- }
- else
- {
- if (GVLGL.GetRowCellValue(selectrow[i], "Wjzt").ToString() == "正常")
- {
- ID.Add(Convert.ToInt32(GVLGL.GetRowCellValue(selectrow[i], "Id").ToString()));
- }
- else
- {
- iszhengc = 1;
- break;
- }
- if (whatfun == 2 || whatfun == 0)
- {
- if (GVLGL.GetRowCellValue(selectrow[i], "Jccxx").ToString() == " " || GVLGL.GetRowCellValue(selectrow[i], "Jccxx").ToString() == "")
- {
- iszhengc = 2;
- break;
- }
- if (GVLGL.GetRowCellValue(selectrow[i], "Rwzt").ToString() == "轮轨力算法执行完毕")
- {
- iszhengc = 3;
- break;
- }
- }
- }
- }
- }
- else
- {
- iszhengc = 4;
- }
- if (iszhengc == 0)
- {
- if (whatfun == 0 || whatfun == 2)
- {
- SuanFaFrom frm = new SuanFaFrom();
- frm.StartPosition = FormStartPosition.CenterParent;
- frm.changeLabel(whatfun == 0 ? true : false);
- if (frm.ShowDialog() == DialogResult.OK)
- {
- DataAnalysisFun daf = new DataAnalysisFun();
- daf.AAAsync(daf, whatfun, selectrow, ID);
- }
- }
- else
- {
- DataAnalysisFun daf = new DataAnalysisFun();
- daf.AAAsync(daf, whatfun, selectrow, ID);
- }
- }
- else if (iszhengc == 1)
- {
- XtraMessageBox.Show("存在文件状态异常文件,请检查后在执行算法!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else if (iszhengc == 2)
- {
- XtraMessageBox.Show("没有选定检测车信息,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else if (iszhengc == 3)
- {
- if (XtraMessageBox.Show("此算法已执行,是否重新执行?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
- {
- if (whatfun == 0 || whatfun == 2)
- {
- SuanFaFrom frm = new SuanFaFrom();
- frm.StartPosition = FormStartPosition.CenterParent;
- frm.changeLabel(whatfun == 0 ? true : false);
- if (frm.ShowDialog() == DialogResult.OK)
- {
- DataAnalysisFun daf = new DataAnalysisFun();
- daf.AAAsync(daf, whatfun, selectrow, ID);
- }
- }
- else
- {
- DataAnalysisFun daf = new DataAnalysisFun();
- daf.AAAsync(daf, whatfun, selectrow, ID);
- }
- }
- }
- else if (iszhengc == 4)
- {
- XtraMessageBox.Show("请先选择要执行的文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private async Task AAAsync(DataAnalysisFun daf, int whatfun, int[] selectrow, List<int> ID)
- {
- string[] yswjm_ = new string[2];
- for (int i = 0; i < selectrow.Length; i++)
- {
- if (whatfun == 0)
- {
- //先删除已有的
- DataAnalysisToPG.DelUpdataData(GVJH.GetRowCellValue(selectrow[i], "Id").ToString(), "dd");
- //在做其他操作
- GVJH.SetRowCellValue(selectrow[i], "Rwzt", "正在执行几何算法...");
- yswjm_[0] = GVJH.GetRowCellValue(selectrow[i], "Yswjm").ToString();
- yswjm_[1] = "几何算法执行完毕";
- }
- else if (whatfun == 1)
- {
- GVJH.SetRowCellValue(selectrow[i], "Rwzt", "正在执行微小算法...");
- yswjm_[0] = GVJH.GetRowCellValue(selectrow[i], "Yswjm").ToString();
- yswjm_[1] = "微小算法执行完毕";
-
- }
- else if (whatfun == 2)
- {
- //先删除已有的
- DataAnalysisToPG.DelUpdataData(GVLGL.GetRowCellValue(selectrow[i], "Id").ToString(), "dd");
- //在做其他操作
- GVLGL.SetRowCellValue(selectrow[i], "Rwzt", "正在执行轮轨力算法...");
- yswjm_[0] = GVLGL.GetRowCellValue(selectrow[i], "Yswjm").ToString();
- yswjm_[1] = "轮轨力算法执行完毕";
- }
- else
- {
- }
- var boolyunx = true;
- //if (whatfun == 0)
- //{
- // OpenFileDialog op1 = new OpenFileDialog();
- // if (XtraMessageBox.Show("是否添加里程修正文件?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
- // {
- // if (op1.ShowDialog() == DialogResult.OK)
- // {
- // isuseDIYdisp = 1;
- // fname_disp = op1.FileName;
- // XtraMessageBox.Show("里程修正文件添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // }
- // else
- // {
- // if (XtraMessageBox.Show("已取消添加里程修正文件!是否正常执行算法?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
- // {
- // boolyunx = false;
- // tzxx = false;
- // }
- // }
- // }
- //}
- //if (boolyunx)
- //{
- await Task.Run(() => daf.dataAnalysis(whatfun, ID[i]));
- //}
- if (whatfun == 0)
- {
- GVJH.SetRowCellValue(selectrow[i], "Rwzt", "几何算法执行完毕");
- if (!tzxx)
- {
- GVJH.SetRowCellValue(selectrow[i], "Rwzt", "算法未执行");
- }
- }
- else if (whatfun == 1)
- {
- GVJH.SetRowCellValue(selectrow[i], "Rwzt", "微小算法执行完毕");
- if (!tzxx)
- {
- GVJH.SetRowCellValue(selectrow[i], "Rwzt", "算法未执行");
- }
- }
- else if (whatfun == 2)
- {
- GVLGL.SetRowCellValue(selectrow[i], "Rwzt", "轮轨力算法执行完毕");
- if (!tzxx)
- {
- GVLGL.SetRowCellValue(selectrow[i], "Rwzt", "算法未执行");
- }
- }
- else
- {
- GVLGL.SetRowCellValue(selectrow[i], "Rwzt", "????????");
- if (!tzxx)
- {
- GVLGL.SetRowCellValue(selectrow[i], "Rwzt", "算法未执行");
- }
- }
- //更新数据库状态
- DataAnalysisToPG.updataRWZT(yswjm_);
- }
- if (selectrow.Length != 0 && tzxx)
- {
- //更新显示状态
- XtraMessageBox.Show("算法执行完毕!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void dataAnalysis(int whatfun, int idindex)
- {
- //DataAnalysisToPG.DelGetBX();
- T_file_account whichfile = (T_file_account)DataAnalysisToPG.QueryToPGById(idindex);
- switch (whatfun)
- {
- case 0:
- //JHTQ
- //JH_TQ(whichfile);
- JH_new(whichfile);
- break;
- case 1:
- //WXSF
- WXSFFun(whichfile);
- break;
- case 2:
- //LGLTQ
- LGL_new(whichfile);
- break;
- default:
- break;
- }
- //DataAnalysisToPG.DelUpdataData()
- }
- public void JH_new(T_file_account whichfile)
- {
- tzxx = true;
- List<T_daocha_account> daochabiao = (List<T_daocha_account>)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray());
- List<T_quxian_account> quxianbiao = (List<T_quxian_account>)DataAnalysisToPG.QueryQXTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray());
- string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\";
- string fname0 = Path.GetFileName(whichfile.Srlj);
- T_xianlulicheng_sf sf = (T_xianlulicheng_sf)DataAnalysisToPG.QueryToString(fname0.Split('-')[0]);
- double mile_min = Convert.ToDouble(sf.Qslc);
- double mile_max = Convert.ToDouble(sf.Zzlc);
- int mile_id = DACommon.xzlcBool ? 0 : 1;
- string line_name = fname0.Split('-')[0];
- double[] tz_curv = getTZQX(quxianbiao,true);
- double[] tz_turnout = getTZDC(daochabiao);
- double[] distance_table = getTZJGJX();
- string carname = whichfile.Jccxx;
- try
- {
- var data = AnalysisAlgorithmcs.JHFX(fname_dir0, fname0, mile_id, line_name, mile_min, mile_max, tz_curv, tz_turnout, distance_table, carname);
- readJHFX(data, whichfile);
- }
- catch (Exception ex)
- {
- tzxx = false;
- XtraMessageBox.Show("文件:" + whichfile.Yswjm + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- throw;
- }
- }
- public void LGL_new(T_file_account whichfile)
- {
- tzxx = true;
- List<T_daocha_account> daochabiao = (List<T_daocha_account>)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('_')[2].Split('.')[0].ToCharArray());
- List<T_quxian_account> quxianbiao = (List<T_quxian_account>)DataAnalysisToPG.QueryQXTZ(whichfile.Xlm, whichfile.Yswjm.Split('_')[2].Split('.')[0].ToCharArray());
- string fname_dir0 = Path.GetDirectoryName(whichfile.Srlj) + "\\";
- string fname0 = Path.GetFileName(whichfile.Srlj);
- string line_name = fname0.Split('_')[2].Split('.')[0];
- T_xianlulicheng_sf sf = (T_xianlulicheng_sf)DataAnalysisToPG.QueryToString(line_name);
- double mile_min = Convert.ToDouble(sf.Qslc);
- double mile_max = Convert.ToDouble(sf.Zzlc);
-
- double[] tz_curv = getTZQX(quxianbiao,false);
- double[] tz_turnout = getTZDC(daochabiao);
- double[] distance_table = getTZJGJX();
- string carname = whichfile.Jccxx;
- try
- {
- var data = AnalysisAlgorithmcs.LGLFX(fname_dir0, fname0, line_name, mile_min, mile_max, tz_curv, tz_turnout, distance_table, carname);
- readLGLFX(data, whichfile);
- }
- catch (Exception ex)
- {
- tzxx = false;
- if (quxianbiao.Count == 0)
- {
- XtraMessageBox.Show("曲线表缺少数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else if (daochabiao.Count == 0)
- {
- XtraMessageBox.Show("道岔表缺少数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- else
- {
- XtraMessageBox.Show("文件:" + whichfile.Yswjm + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- throw;
- }
- }
- /// <summary>
- /// 微小算法
- /// </summary>
- /// <param name="whichfile"></param>
- public void WXSFFun(T_file_account whichfile)
- {
- tzxx = true;
- List<T_jihefenxi_account> jhfe_account = DataAnalysisToPG.QueryToPGByNameWXSF(whichfile.Id.ToString()) as List<T_jihefenxi_account>;
- string[] date = new string[jhfe_account.Count];
- string[] car = new string[jhfe_account.Count];
- double[] mile = new double[jhfe_account.Count];
- List<double> wave_data = new List<double>();
- List<double> id_wave_all = new List<double>();
- List<double> jx_loc_all = new List<double>();
- string[] line = new string[jhfe_account.Count];
- double[] velo = new double[jhfe_account.Count];
- string[] zc = new string[jhfe_account.Count];
- getdataWXSF(jhfe_account, ref date, ref car, ref mile, ref wave_data, ref id_wave_all, ref jx_loc_all, ref line, ref velo, ref zc);
- try
- {//存在问题,wave_data
- var data = AnalysisAlgorithmcs.WXSF(date, car, mile, wave_data.ToArray(), id_wave_all.ToArray(), jx_loc_all.ToArray(), line, velo, zc);
- //readWXSF(data, whichfile);
- }
- catch (Exception ex)
- {
- tzxx = false;
- XtraMessageBox.Show("文件:" + whichfile.Yswjm + "执行失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- throw;
- }
- }
- private void getdataWXSF(List<T_jihefenxi_account> jhfe_account, ref string[] date, ref string[] car, ref double[] mile, ref List<double> wave_data, ref List<double> id_wave_all, ref List<double> jx_loc_all, ref string[] line, ref double[] velo, ref string[] zc)
- {
- int bxindex = 0;
- for (int i = 0; i < jhfe_account.Count; i++)
- {
- date[i] = jhfe_account[i].Riqi;
- car[i] = jhfe_account[i].Jcc.Split('-')[1];
- mile[i] = Convert.ToDouble(jhfe_account[i].Jgjlc);
- jx_loc_all.Add(Convert.ToDouble(jhfe_account[i].Jgjcydxh));
- jx_loc_all.Add(Convert.ToDouble(jhfe_account[i].Xgjcydxh));
- line[i] = ((T_file_account)DataAnalysisToPG.QueryToPGById(Convert.ToInt32(jhfe_account[i].Filename_jh.Trim()))).Yswjm.Split('-')[0];
- velo[i] = Convert.ToDouble(jhfe_account[i].Sudu_jhfx);
- zc[i] = jhfe_account[i].Zcx;
- getWXSFBXdata(jhfe_account[i].Yswjm_jhfx,ref bxindex, ref wave_data, ref id_wave_all);
- }
- }
- private void getWXSFBXdata(string ids, ref int index , ref List<double> wave_data, ref List<double> id_wave_all)
- {
- List<T_jihefenxi_boxing> bolist = DMControl.GetJHFX_BXDataByIDS(ids);
- index = index + 1;
- id_wave_all.Add(index);
- for (int i = 0; i < bolist.Count; i++)
- {
- wave_data.Add((double)(bolist[i].Licheng));
- wave_data.Add((double)(bolist[i].Sudu_jhbx));
- wave_data.Add((double)(bolist[i].Cthj));
- wave_data.Add((double)(bolist[i].Ctcj));
- wave_data.Add((double)(bolist[i].Gjzhy));
- wave_data.Add((double)(bolist[i].Gjyhy));
- wave_data.Add((double)(bolist[i].Zgd));
- wave_data.Add((double)(bolist[i].Ygd));
- wave_data.Add((double)(bolist[i].Zgx));
- wave_data.Add((double)(bolist[i].Ygx));
- wave_data.Add((double)(bolist[i].Gj));
- wave_data.Add((double)(bolist[i].Sp));
- wave_data.Add((double)(bolist[i].Sjk));
- wave_data.Add((double)(bolist[i].Cbzgd));
- wave_data.Add((double)(bolist[i].Cbygd));
- wave_data.Add((double)(bolist[i].Cbzgx));
- wave_data.Add((double)(bolist[i].Cbygx));
- wave_data.Add((double)(bolist[i].Dcdw));
- }
- index += bolist.Count - 1;
- id_wave_all.Add(index);
- }
- /// <summary>
- /// 从数据库获取对应符合要求的道岔台账信息
- /// </summary>
- private double[] getTZDC(List<T_daocha_account> taizhang)
- {
- //StreamWriter FileWriter = new StreamWriter("E://get2pgTZ.txt", true); //写文件
- string txtDetail = "";
- //StreamWriter sr = new StreamWriter("E://DDD.txt");
- List<double> result = new List<double>();
- for (int i = 0; i < taizhang.Count; i++)
- {
- result.Add(Convert.ToDouble(taizhang[i].Jgjlc));
- result.Add(Convert.ToDouble(taizhang[i].Zch));
- result.Add(Convert.ToDouble(taizhang[i].Quanchang));
- txtDetail += taizhang[i].Jgjlc + "\t" + taizhang[i].Zch + "\t" + taizhang[i].Quanchang + "\n";
- }
- //FileWriter.Write(txtDetail);//将字符串写入
- //FileWriter.Close(); //关闭StreamWriter对象k
- //******构造二维数组******
- double[] ret = new double[result.Count];
- for (int i = 0; i < result.Count; i++)
- {
- ret[i] = result[i];
- }
- return ret;
- }
- /// <summary>
- /// 从数据库获取对应符合要求的曲线台账信息
- /// </summary>
- private double[] getTZQX(List<T_quxian_account> taizhang,bool isjh)
- {
- List<double> result = new List<double>();
- for (int i = 0; i < taizhang.Count; i++)
- {
- result.Add(Convert.ToDouble(taizhang[i].Qzlc));
- result.Add(Convert.ToDouble(taizhang[i].Jslc));
- if (taizhang[i].Qxfx.Trim() == "左")
- {
- result.Add(1);
- }
- else
- {
- result.Add(-1);
- }
- if (isjh)
- {
- result.Add(Convert.ToDouble(taizhang[i].Chaogao));
- }
- else
- {
- result.Add(Convert.ToDouble(taizhang[i].Qxbj));
- }
- result.Add(Convert.ToDouble(taizhang[i].Qhhxc));
- result.Add(Convert.ToDouble(taizhang[i].Zhhxc));
- }
- //******构造二维数组******
- double[] ret = new double[result.Count];
- for (int i = 0; i < result.Count; i++)
- {
- ret[i] = result[i];
- }
- return ret;
- }
- /// <summary>
- /// 从数据库获取对应符合要求的曲线台账信息
- /// </summary>
- private double[] getTZJGJX()
- {
- List<T_jgjdistance_table> tabledata = new List<T_jgjdistance_table>();
- List<T_jgjdistance_table> tablelist = DataAnalysisToPG.QueryJGJXGJJ();
- List<T_jgjdistance_table> GS = tablelist.Where(i => i.Sudutype == 0).ToList();
- List<T_jgjdistance_table> DS = tablelist.Where(i => i.Sudutype == 1).ToList();
- if (DACommon.gdsBool == 0)
- {
- tabledata = GS;
- }
- else if (DACommon.gdsBool == 1)
- {
- tabledata = DS;
- }
- else
- {
- tabledata = tablelist;
- }
- List<double> result = new List<double>();
- for (int i = 0; i < tabledata.Count; i++)
- {
- result.Add(Convert.ToDouble(tabledata[i].Zch));
- result.Add(Convert.ToDouble(tabledata[i].Dcqc));
- result.Add(Convert.ToDouble(tabledata[i].Gdjxgjj));
- }
- //******构造二维数组******
- double[] ret = new double[result.Count];
- for (int i = 0; i < result.Count; i++)
- {
- ret[i] = result[i];
- }
- return ret;
- }
- private double[] getTZXX1(List<T_daocha_account> taizhang)
- {
- List<double> result = new List<double>();
- for (int i = 0; i < taizhang.Count; i++)
- {
- result.Add(Convert.ToDouble(taizhang[i].Jgjlc));
- }
- //******构造二维数组******
- double[] ret = new double[result.Count];
- for (int i = 0; i < result.Count; i++)
- {
- ret[i] = result[i];
- }
- return ret;
- }
- /// <summary>
- /// 几何读台账txt
- /// </summary>
- private double[] readtxt(string txtPath)
- {
- List<double> result = new List<double>();
- StreamReader SR = new StreamReader(txtPath);
- while (!SR.EndOfStream)
- {
- string[] str = SR.ReadLine().Replace("\t", " ").Split(' ');
- for (int i = 0; i < str.Length; i++)
- {
- result.Add(Convert.ToDouble(str[i]));
- }
- }
- //******构造二维数组******
- double[] ret = new double[result.Count];
- for (int i = 0; i < result.Count; i++)
- {
- ret[i] = result[i];
- }
- return ret;
- }
- /// <summary>
- /// 轮轨力读台账txt获取尖轨尖里程
- /// </summary>
- private double[] readtxt2(string txtPath)
- {
- List<double> result = new List<double>();
- StreamReader SR = new StreamReader(txtPath);
- while (!SR.EndOfStream)
- {
- string[] str = SR.ReadLine().Replace("\t", " ").Split(' ');
- result.Add(Convert.ToDouble(str[0]));
- }
- //******构造二维数组******
- double[] ret = new double[result.Count];
- for (int i = 0; i < result.Count; i++)
- {
- ret[i] = result[i];
- }
- return ret;
- }
- /// <summary>
- /// 读几何分析数据
- /// </summary>
- /// <param name="agrsOut"></param>
- /// <param name="whichfile"></param>
- private static void readJHFX(MWArray[] agrsOut, T_file_account whichfile)
- {
- MWCellArray output1 = agrsOut[0] as MWCellArray;//第1个输出参数
- MWNumericArray output2 = agrsOut[1] as MWNumericArray;//第2个输出参数
- MWArray output3 = agrsOut[2] as MWArray;//第3个输出参数
- MWCellArray output4 = agrsOut[3] as MWCellArray;//第4个输出参数
- MWCellArray output5 = agrsOut[4] as MWCellArray;//第5个输出参数
- MWNumericArray output6 = agrsOut[5] as MWNumericArray;//第6个输出参数
- MWCellArray output7 = agrsOut[6] as MWCellArray;//第7个输出参数
- MWCellArray output10 = agrsOut[7] as MWCellArray;//第7个输出参数
- MWCellArray output11 = agrsOut[8] as MWCellArray;//第7个输出参数
- MWNumericArray output8 = agrsOut[9] as MWNumericArray;//第8个输出参数
- MWNumericArray output9 = agrsOut[10] as MWNumericArray;//第9个输出参数
- MWNumericArray output12 = agrsOut[11] as MWNumericArray;//第12个输出参数
- var table_header = output1.ToArray();
- var table_data = (double[,])output2.ToArray();
- var table_zc = (object[,])output3.ToArray();
- var table_date = (object[,])output4.ToArray();
- var table_zf = (object[,])output5.ToArray();
- var table_tqi = (double[,])output6.ToArray();
- var table_car = (object[,])output7.ToArray();
- var table_name = (object[,])output10.ToArray();
- var table_xb = (object[,])output11.ToArray();
- var wave_id = (double[,])output8.ToArray();
- var wave_sw = (double[,])output9.ToArray();
- var wave_loc = (double[,])output12.ToArray();
- List<T_jihefenxi_account> JHobjs = new List<T_jihefenxi_account>();
- DataAnalysisToPG.InsertGetIdMAX(new T_jihefenxi_boxing() { Yswjm = "?????" });
- int idindex = DataAnalysisToPG.QueryMaxID("jh") + 1;
- #region 录入T_jihefenxi_account
- for (int i = 0; i < table_data.GetLength(0); i++)
- {
- int bxidq = (int)wave_id[i, 0];
- int bxidz = (int)wave_id[i, 1];
- int bxindex = bxidz - bxidq;
- T_jihefenxi_account jhojb = new T_jihefenxi_account();
- jhojb.Xuhao = table_data[i, 0].ToString();
- jhojb.Jgjlc = Convert.ToDecimal(table_data[i, 1]);
- jhojb.Sudu_jhfx = Convert.ToDecimal(table_data[i, 2]);
- jhojb.Cthjfz = Convert.ToDecimal(table_data[i, 3]);
- jhojb.Cthjffz = Convert.ToDecimal(table_data[i, 4]);
- jhojb.Ctcjfz = Convert.ToDecimal(table_data[i, 5]);
- jhojb.Ctcjffz = Convert.ToDecimal(table_data[i, 6]);
- jhojb.Zgjfz = Convert.ToDecimal(table_data[i, 7]);
- jhojb.Zgjffz_jhfx = Convert.ToDecimal(table_data[i, 8]);
- jhojb.Ygjfz = Convert.ToDecimal(table_data[i, 9]);
- jhojb.Ygjffz = Convert.ToDecimal(table_data[i, 10]);
- jhojb.Zgdfz = Convert.ToDecimal(table_data[i, 11]);
- jhojb.Ygdfz = Convert.ToDecimal(table_data[i, 12]);
- jhojb.Zgxfz = Convert.ToDecimal(table_data[i, 13]);
- jhojb.Ygxfz = Convert.ToDecimal(table_data[i, 14]);
- jhojb.Spfz = Convert.ToDecimal(table_data[i, 15]);
- jhojb.Sjkfz = Convert.ToDecimal(table_data[i, 16]);
- jhojb.Cbzgdfz = Convert.ToDecimal(table_data[i, 17]);
- jhojb.Cbygdfz = Convert.ToDecimal(table_data[i, 18]);
- jhojb.Cbzgxfz = Convert.ToDecimal(table_data[i, 19]);
- jhojb.Cbygxfz = Convert.ToDecimal(table_data[i, 20]);
- jhojb.Zcx = Char2String((char[,])table_zc[i, 0]);
- jhojb.Riqi = Char2String((char[,])table_date[i, 0]);
- jhojb.Zfx = Char2String((char[,])table_zf[i, 0]);
- jhojb.Dcqtqi = Convert.ToDecimal(table_tqi[i, 0]);
- jhojb.Jcc = Char2String((char[,])table_car[i, 0]);
- jhojb.Filename_jh = whichfile.Id.ToString();
- jhojb.Boxingid_jhfx = wave_id[i, 0].ToString() + "," + wave_id[i, 1].ToString();
- jhojb.Jgjcydxh = Convert.ToDecimal(wave_loc[i, 0]);
- jhojb.Xgjcydxh = Convert.ToDecimal(wave_loc[i, 1]);
- jhojb.Xlm = whichfile.Xlm;
- //jhojb.Xlm = Char2String((char[,])table_name[i, 0]);
- jhojb.Yswjm_jhfx = idindex.ToString() + "," + (idindex + bxindex).ToString();
- jhojb.Xingbie = whichfile.Hangbie;
- //jhojb.Xingbie = Char2String((char[,])table_xb[i, 0]);
- jhojb.Gjhy = Math.Abs(jhojb.Zgjfz) > Math.Abs(jhojb.Ygjfz) ? jhojb.Zgjfz : jhojb.Ygjfz;
- jhojb.Gjhyffz = Math.Abs(jhojb.Zgjffz_jhfx) > Math.Abs(jhojb.Ygjffz) ? jhojb.Zgjffz_jhfx : jhojb.Ygjffz;
- jhojb.Gdfz = Math.Abs(jhojb.Zgdfz) > Math.Abs(jhojb.Ygdfz) ? jhojb.Zgdfz : jhojb.Ygdfz;
- jhojb.Gxfz = Math.Abs(jhojb.Zgxfz) > Math.Abs(jhojb.Ygxfz) ? jhojb.Zgxfz : jhojb.Ygxfz;
- jhojb.Cbgdfz = Math.Abs(jhojb.Cbzgdfz) > Math.Abs(jhojb.Cbygdfz) ? jhojb.Cbzgdfz : jhojb.Cbygdfz;
- jhojb.Cbgxfz = Math.Abs(jhojb.Cbzgxfz) > Math.Abs(jhojb.Cbygxfz) ? jhojb.Cbzgxfz : jhojb.Cbygxfz;
- JHobjs.Add(jhojb);
- idindex += bxindex + 1;
- }
- DataAnalysisToPG.InsertJHDataToPG(JHobjs);
- #endregion
- #region 录入波形
- List<T_jihefenxi_boxing> Bolist = new List<T_jihefenxi_boxing>();
- for (int i = 0; i < wave_sw.GetLength(0); i++)
- {
- T_jihefenxi_boxing bolist = new T_jihefenxi_boxing();
- bolist.Licheng = Convert.ToDecimal(wave_sw[i, 0]);
- bolist.Sudu_jhbx = Convert.ToDecimal(wave_sw[i, 1]);
- bolist.Cthj = Convert.ToDecimal(wave_sw[i, 2]);
- bolist.Ctcj = Convert.ToDecimal(wave_sw[i, 3]);
- bolist.Gjzhy = Convert.ToDecimal(wave_sw[i, 4]);
- bolist.Gjyhy = Convert.ToDecimal(wave_sw[i, 5]);
- bolist.Zgd = Convert.ToDecimal(wave_sw[i, 6]);
- bolist.Ygd = Convert.ToDecimal(wave_sw[i, 7]);
- bolist.Zgx = Convert.ToDecimal(wave_sw[i, 8]);
- bolist.Ygx = Convert.ToDecimal(wave_sw[i, 9]);
- bolist.Gj = Convert.ToDecimal(wave_sw[i, 10]);
- bolist.Sp = Convert.ToDecimal(wave_sw[i, 11]);
- bolist.Sjk = Convert.ToDecimal(wave_sw[i, 12]);
- bolist.Cbzgd = Convert.ToDecimal(wave_sw[i, 13]);
- bolist.Cbygd = Convert.ToDecimal(wave_sw[i, 14]);
- bolist.Cbzgx = Convert.ToDecimal(wave_sw[i, 15]);
- bolist.Cbygx = Convert.ToDecimal(wave_sw[i, 16]);
- bolist.Dcdw = Convert.ToDecimal(wave_sw[i, 17]);
- bolist.Bxid = i + 1;
- Bolist.Add(bolist);
- }
- DataAnalysisToPG.InsertJHBXDataToPG(Bolist);
- #endregion
- }
- /// <summary>
- /// 读轮轨力分析数据
- /// </summary>
- /// <param name="agrsOut"></param>
- /// <param name="whichfile"></param>
- private static void readLGLFX(MWArray[] agrsOut, T_file_account whichfile)
- {
- MWCellArray output1 = agrsOut[0] as MWCellArray;//第1个输出参数
- MWNumericArray output2 = agrsOut[1] as MWNumericArray;//第2个输出参数
- MWNumericArray output3 = agrsOut[6] as MWNumericArray;//第3个输出参数
- MWNumericArray output4 = agrsOut[7] as MWNumericArray;//第4个输出参数
- MWCellArray output5 = agrsOut[2] as MWCellArray;//第3个输出参数
- MWCellArray output6 = agrsOut[4] as MWCellArray;//第4个输出参数
- MWCellArray output7 = agrsOut[5] as MWCellArray;//第4个输出参数
- MWCellArray output8 = agrsOut[3] as MWCellArray;//第4个输出参数
- var table_header = (object[,])output1.ToArray();
- var table_data = (double[,])output2.ToArray();
- var table_name = (object[,])output5.ToArray();
- var table_xb = (object[,])output6.ToArray();
- var table_date = (object[,])output7.ToArray();
- var wave_sw = (double[,])output4.ToArray();
- var boxingid = (double[,])output3.ToArray();
- var table_car = (object[,])output8.ToArray();
- List<T_lunguili_account> JHobjs = new List<T_lunguili_account>();
- DataAnalysisToPG.InsertGetIdMAX(new T_lunguili_boxing() { Yswjm = "?????" });
- int idindex = DataAnalysisToPG.QueryMaxID("lgl") + 1;
- for (int i = 0; i < table_data.GetLength(0); i++)
- {
- int bxidq = (int)boxingid[i, 0];
- int bxidz = (int)boxingid[i, 1];
- int bxindex = bxidz - bxidq;
- T_lunguili_account jhojb = new T_lunguili_account();
- jhojb.Xuhao = table_data[i, 0].ToString();
- jhojb.Jgjlc = Convert.ToDecimal(table_data[i, 1]);
- jhojb.Sudu_lgl = Convert.ToDecimal(table_data[i, 2]);
- jhojb.Zzcfz = Convert.ToDecimal(table_data[i, 3]);
- jhojb.Zzhfz = Convert.ToDecimal(table_data[i, 4]);
- jhojb.Yzcfz = Convert.ToDecimal(table_data[i, 5]);
- jhojb.Yzhfz = Convert.ToDecimal(table_data[i, 6]);
- jhojb.Lzlfz = Convert.ToDecimal(table_data[i, 7]);
- jhojb.Lzjzl = Convert.ToDecimal(table_data[i, 8]);
- jhojb.Ztgxs = Convert.ToDecimal(table_data[i, 9]);
- jhojb.Ytgxs = Convert.ToDecimal(table_data[i, 10]);
- jhojb.Filename_lgl = whichfile.Id.ToString();
- jhojb.Boxingid_lgl = bxidq.ToString() + "," + bxidz.ToString();
- //jhojb.Xlm = Char2String((char[,])table_name[i, 0]);
- jhojb.Xlm = whichfile.Xlm;
- //jhojb.Xingbie = Char2String((char[,])table_xb[i, 0]);
- jhojb.Xingbie = whichfile.Hangbie;
- jhojb.Yswjm = idindex.ToString() + "," + (idindex + bxindex).ToString();
- jhojb.Jcrq = Char2String((char[,])table_date[i, 0]);
- jhojb.Lgcxl = Math.Abs(jhojb.Zzcfz) > Math.Abs(jhojb.Yzcfz) ? jhojb.Zzcfz : jhojb.Yzcfz;
- jhojb.Lghxl = Math.Abs(jhojb.Zzhfz) > Math.Abs(jhojb.Yzhfz) ? jhojb.Zzhfz : jhojb.Yzhfz;
- jhojb.Tgxs = jhojb.Ztgxs > jhojb.Ytgxs ? jhojb.Ztgxs : jhojb.Ytgxs;
- JHobjs.Add(jhojb);
- idindex += bxindex + 1;
- }
- DataAnalysisToPG.InsertLGLDataToPG(JHobjs);
- #region 录入波形
- List<T_lunguili_boxing> Bolist = new List<T_lunguili_boxing>();
- for (int i = 0; i < wave_sw.GetLength(0); i++)
- {
- T_lunguili_boxing bolist = new T_lunguili_boxing();
- bolist.Licheng = Convert.ToDecimal(wave_sw[i, 0]);
- bolist.Sudu_lglbx = Convert.ToDecimal(wave_sw[i, 1]);
- bolist.Zzc = Convert.ToDecimal(wave_sw[i, 2]);
- bolist.Zzh = Convert.ToDecimal(wave_sw[i, 3]);
- bolist.Yzc = Convert.ToDecimal(wave_sw[i, 4]);
- bolist.Yzh = Convert.ToDecimal(wave_sw[i, 5]);
- bolist.Bxid = i + 1;
- Bolist.Add(bolist);
- }
- DataAnalysisToPG.InsertLGLBXDataToPG(Bolist);
- #endregion
- }
- //读取微小算法分析数据
- private static void readWXSF(MWArray[] agrsOut, T_file_account whichfile)
- {
- MWCellArray output1 = agrsOut[0] as MWCellArray;//第1个输出参数
- MWCellArray output2 = agrsOut[1] as MWCellArray;//第2个输出参数
- MWCellArray output3 = agrsOut[2] as MWCellArray;//第3个输出参数
- MWNumericArray output4 = agrsOut[3] as MWNumericArray;//第4个输出参数
- MWNumericArray output5 = agrsOut[4] as MWNumericArray;//第5个输出参数
- MWCellArray output6 = agrsOut[5] as MWCellArray;//第6个输出参数
- MWCellArray output7 = agrsOut[6] as MWCellArray;//第7个输出参数
- MWNumericArray output8 = agrsOut[7] as MWNumericArray;//第8个输出参数
- MWNumericArray output9 = agrsOut[8] as MWNumericArray;//第9个输出参数
- MWNumericArray output10 = agrsOut[9] as MWNumericArray;//第10个输出参数
- MWCellArray output11 = agrsOut[10] as MWCellArray;//第11个输出参数
- var table_header = output1.ToArray();
- var tableline = (object[,])output2.ToArray();
- var table_xb = (object[,])output3.ToArray();
- var table_milej = (double[,])output4.ToArray();
- var table_milex = (double[,])output5.ToArray();
- var table_date = (object[,])output6.ToArray();
- var table_car = (object[,])output7.ToArray();
- var table_data = (double[,])output8.ToArray();
- var wave_id = (double[,])output9.ToArray();
- var wave_sw = (double[,])output10.ToArray();
- var table_check = (object[,])output11.ToArray();
- List<T_jihefenxi_account> JHWXobjs = new List<T_jihefenxi_account>();
- DataAnalysisToPG.InsertGetIdMAX(new T_jihefenxi_boxing() { Yswjm = "?????" });
- T_jihefenxi_account jhwxojb = new T_jihefenxi_account();
- jhwxojb.Wx_xgjlc = Convert.ToDecimal(table_milex);
- int idindex = DataAnalysisToPG.QueryMaxID("jh") + 1;
- #region 录入T_jihefenxi_account
- for (int i = 0; i < table_data.GetLength(0); i++)
- {
- int bxidq = (int)wave_id[i, 0];
- int bxidz = (int)wave_id[i, 1];
- int bxindex = bxidz - bxidq;
- jhwxojb.Wx_bhl_gd = Convert.ToDecimal(table_data[i, 0]);
- jhwxojb.Wx_bhl_gx = Convert.ToDecimal(table_data[i, 1]);
- jhwxojb.Wx_bhl_sp = Convert.ToDecimal(table_data[i, 2]);
- jhwxojb.Wx_bhl_sjk = Convert.ToDecimal(table_data[i, 3]);
- jhwxojb.Wx_bhl_gj = Convert.ToDecimal(table_data[i, 4]);
- JHWXobjs.Add(jhwxojb);
- idindex += bxindex + 1;
- }
- DataAnalysisToPG.InsertJHDataToPG(JHWXobjs);
- #endregion
- #region 录入波形
- List<T_jihefenxi_boxing> Bolist = new List<T_jihefenxi_boxing>();
- for (int i = 0; i < wave_sw.GetLength(0); i++)
- {
- T_jihefenxi_boxing bolist = new T_jihefenxi_boxing();
- bolist.Licheng = Convert.ToDecimal(wave_sw[i, 0]);
- bolist.Sudu_jhbx = Convert.ToDecimal(wave_sw[i, 1]);
- bolist.Cthj = Convert.ToDecimal(wave_sw[i, 2]);
- bolist.Ctcj = Convert.ToDecimal(wave_sw[i, 3]);
- bolist.Gjzhy = Convert.ToDecimal(wave_sw[i, 4]);
- bolist.Gjyhy = Convert.ToDecimal(wave_sw[i, 5]);
- bolist.Zgd = Convert.ToDecimal(wave_sw[i, 6]);
- bolist.Ygd = Convert.ToDecimal(wave_sw[i, 7]);
- bolist.Zgx = Convert.ToDecimal(wave_sw[i, 8]);
- bolist.Ygx = Convert.ToDecimal(wave_sw[i, 9]);
- bolist.Gj = Convert.ToDecimal(wave_sw[i, 10]);
- bolist.Sp = Convert.ToDecimal(wave_sw[i, 11]);
- bolist.Sjk = Convert.ToDecimal(wave_sw[i, 12]);
- bolist.Cbzgd = Convert.ToDecimal(wave_sw[i, 13]);
- bolist.Cbygd = Convert.ToDecimal(wave_sw[i, 14]);
- bolist.Cbzgx = Convert.ToDecimal(wave_sw[i, 15]);
- bolist.Cbygx = Convert.ToDecimal(wave_sw[i, 16]);
- bolist.Dcdw = Convert.ToDecimal(wave_sw[i, 17]);
- bolist.Bxid = i + 1;
- Bolist.Add(bolist);
- }
- DataAnalysisToPG.InsertJHBXDataToPG(Bolist);
- #endregion
- }
- /// <summary>
- /// char[]转string
- /// </summary>
- private static string Char2String(char[,] chararr)
- {
- string arr = "";
- for (int j = 0; j < chararr.GetLength(1); j++)
- {
- arr += chararr[0, j].ToString();
- }
- return arr;
- }
- }
- }
|