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 { /// /// 进行算法处理的类 /// 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 = ""; /// /// /// /// 是那种算法;0几何;1微小;2轮轨力; /// 选择条数 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 ID = new List(); 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 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 daochabiao = (List)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('-')[0].ToCharArray()); List quxianbiao = (List)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 daochabiao = (List)DataAnalysisToPG.QueryDCTZ(whichfile.Xlm, whichfile.Yswjm.Split('_')[2].Split('.')[0].ToCharArray()); List quxianbiao = (List)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; } } /// /// 微小算法 /// /// public void WXSFFun(T_file_account whichfile) { tzxx = true; List jhfe_account = DataAnalysisToPG.QueryToPGByNameWXSF(whichfile.Id.ToString()) as List; string[] date = new string[jhfe_account.Count]; string[] car = new string[jhfe_account.Count]; double[] mile = new double[jhfe_account.Count]; List wave_data = new List(); List id_wave_all = new List(); List jx_loc_all = new List(); 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 jhfe_account, ref string[] date, ref string[] car, ref double[] mile, ref List wave_data, ref List id_wave_all, ref List 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 wave_data, ref List id_wave_all) { List 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); } /// /// 从数据库获取对应符合要求的道岔台账信息 /// private double[] getTZDC(List taizhang) { //StreamWriter FileWriter = new StreamWriter("E://get2pgTZ.txt", true); //写文件 string txtDetail = ""; //StreamWriter sr = new StreamWriter("E://DDD.txt"); List result = new List(); 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; } /// /// 从数据库获取对应符合要求的曲线台账信息 /// private double[] getTZQX(List taizhang,bool isjh) { List result = new List(); 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; } /// /// 从数据库获取对应符合要求的曲线台账信息 /// private double[] getTZJGJX() { List tabledata = new List(); List tablelist = DataAnalysisToPG.QueryJGJXGJJ(); List GS = tablelist.Where(i => i.Sudutype == 0).ToList(); List 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 result = new List(); 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 taizhang) { List result = new List(); 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; } /// /// 几何读台账txt /// private double[] readtxt(string txtPath) { List result = new List(); 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; } /// /// 轮轨力读台账txt获取尖轨尖里程 /// private double[] readtxt2(string txtPath) { List result = new List(); 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; } /// /// 读几何分析数据 /// /// /// 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 JHobjs = new List(); 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 Bolist = new List(); 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 } /// /// 读轮轨力分析数据 /// /// /// 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 JHobjs = new List(); 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 Bolist = new List(); 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 JHWXobjs = new List(); 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 Bolist = new List(); 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 } /// /// char[]转string /// private static string Char2String(char[,] chararr) { string arr = ""; for (int j = 0; j < chararr.GetLength(1); j++) { arr += chararr[0, j].ToString(); } return arr; } } }