using NG_Tools; using NGTools.Tools; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web; namespace NGTools.ASHX { /// /// FLowCal 的摘要说明 /// public class FLowCal : IHttpHandler { public static double dbPerJd = 0; public void ProcessRequest(HttpContext context) { if (context.Request.QueryString["action"] == "KBCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(KBFlowcal(tempPar)); context. Response.End(); } if (context.Request.QueryString["action"] == "test") { context.Response.Write(test()); context.Response.End(); } if (context.Request.QueryString["action"] == "SDCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(SDFlowcal(tempPar)); context.Response.End(); } if (context.Request.QueryString["action"] == "PZCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(PZFlowcal(tempPar)); context.Response.End(); } if (context.Request.QueryString["action"] == "PARCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(PARCal(tempPar)); context.Response.End(); } if (context.Request.QueryString["action"] == "GSCVCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(GSCVCal(tempPar)); context.Response.End(); } if (context.Request.QueryString["action"] == "ZXCCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(ZXCCal(tempPar)); context.Response.End(); } if (context.Request.QueryString["action"] == "ZTCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(ZTCal(tempPar)); context.Response.End(); } if (context.Request.QueryString["action"] == "GSCVTCal") { string[] tempPar = context.Request["Par"].Split(','); context.Response.Write(GSCVTCal(tempPar)); context.Response.End(); } } private string test() { return "\"ok\":\""+ "1\""; } private string GSCVTCal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); gasPar.dCbtj = (int)tempPar[4]; //'计量参比条件 switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } int dPfUnit = (int)tempPar[28]; //压力单位 int dTfUnit = (int)tempPar[31]; //温度单位 int dPfType = (int)tempPar[29]; //压力类型 int dPatmUnit = (int)tempPar[10]; //当地大气压单位 double dPatm = MyConvert.Converter("yl", tempPar[9], dPatmUnit, 0, 4); ; //当地大气压 NG_Tools.NG_Cal NG_Cal = new NG_Tools.NG_Cal(); double dPstart = tempPar[27]; double dTstart = tempPar[30]; double dPend = tempPar[39]; double dTend = tempPar[40]; double dPjg = tempPar[37]; double dTjg = tempPar[38]; DataTable dtZ = new DataTable(); int Ccount = int.Parse(Math.Round((dPend - dPstart) / dPjg).ToString()) + 1; int Rcount = int.Parse(Math.Round((dTend - dTstart) / dTjg).ToString()) + 1; double[] arrP = new double[Ccount]; double[] arrT = new double[Rcount]; dtZ.Columns.Add("T_P_V", typeof(string)); for (int i = 0; i < Ccount; i++) { arrP[i] = dPstart + i * dPjg; dtZ.Columns.Add((dPstart + i * dPjg).ToString() + " MPa", typeof(string)); } for (int i = 0; i < Rcount; i++) { arrT[i] = dTstart + i * dTjg; } int totalNum = Ccount * Rcount; int jsnum = 0; dbPerJd = 0; double dV = tempPar[41]; for (int i = 0; i < Rcount; i++) { DataRow dr = dtZ.NewRow(); dr[0] = arrT[i] + " ℃"; for (int j = 0; j < Ccount; j++) { //将压力换算为绝压 gasPar.dPf = MyConvert.Converter("yl", arrP[j], dPfUnit, 0, 4); //输入压力 gasPar.dTf = MyConvert.Converter("wd", arrT[i], dTfUnit, 1, 4); //输入温度 if (dPfType == 0) { gasPar.dPf = gasPar.dPf + dPatm; } NG_Cal.Zcal(ref gasPar, 0.0); dr[j + 1] = (dV * gasPar.dPf * gasPar.dTb * gasPar.dZb / (gasPar.dTf * gasPar.dZf * gasPar.dPb)).ToString("0.####"); ; jsnum += 1; dbPerJd = jsnum * 100 / totalNum; } dtZ.Rows.Add(dr); } DataRow drNG = dtZ.NewRow(); drNG[0] = "组分数据:"; drNG[Ccount-1] = string.Join("_",ngCom); dtZ.Rows.Add(drNG); string json = JSONConvert.DataTableToDataGridJson(dtZ, true); return json; } private string ZTCal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); gasPar.dCbtj = (int)tempPar[4]; //'计量参比条件 switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } int dPfUnit = (int)tempPar[28]; //压力单位 int dTfUnit = (int)tempPar[31]; //温度单位 int dPfType = (int)tempPar[29]; //压力类型 int dPatmUnit = (int)tempPar[10]; //当地大气压单位 double dPatm = MyConvert.Converter("yl", tempPar[9], dPatmUnit, 0, 4); ; //当地大气压 NG_Tools.NG_Cal NG_Cal = new NG_Cal(); double dPstart = tempPar[27]; double dTstart = tempPar[30]; double dPend = tempPar[39]; double dTend = tempPar[40]; double dPjg = tempPar[37]; double dTjg = tempPar[38]; DataTable dtZ = new DataTable(); int Ccount = int.Parse(Math.Round((dPend - dPstart) / dPjg).ToString()) + 1; int Rcount = int.Parse(Math.Round((dTend - dTstart) / dTjg).ToString()) + 1; double[] arrP = new double[Ccount]; double[] arrT = new double[Rcount]; dtZ.Columns.Add("T_P_Z", typeof(string)); for (int i = 0; i < Ccount; i++) { arrP[i] = dPstart + i * dPjg; dtZ.Columns.Add((dPstart + i * dPjg).ToString() + " MPa", typeof(string)); } for (int i = 0; i < Rcount; i++) { arrT[i] = dTstart + i * dTjg; } int totalNum = Ccount * Rcount; int jsnum = 0; dbPerJd = 0; for (int i = 0; i < Rcount; i++) { DataRow dr = dtZ.NewRow(); dr[0] = arrT[i] + " ℃"; for (int j = 0; j < Ccount; j++) { //将压力换算为绝压 gasPar.dPf = MyConvert.Converter("yl", arrP[j], dPfUnit, 0, 4); //输入压力 gasPar.dTf = MyConvert.Converter("wd", arrT[i], dTfUnit, 1, 4); //输入温度 if (dPfType == 0) { gasPar.dPf = gasPar.dPf + dPatm; } NG_Cal.Zcal(ref gasPar, 0.0); dr[j + 1] = gasPar.dZf.ToString("0.######"); jsnum += 1; dbPerJd = jsnum * 100 / totalNum; } dtZ.Rows.Add(dr); } DataRow drNG = dtZ.NewRow(); drNG[0] = "组分数据:"; drNG[Ccount - 1] = string.Join("_", ngCom); dtZ.Rows.Add(drNG); string json = JSONConvert.DataTableToDataGridJson(dtZ, true); return json; } private string ZXCCal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); gasPar.dCbtj = (int)tempPar[4]; //'计量参比条件 int dPfUnit = (int)tempPar[28]; //压力单位 int dPfType = (int)tempPar[29]; //压力类型 int dTfUnit = (int)tempPar[31]; //温度单位 int dPatmUnit = (int)tempPar[10]; //当地大气压单位 double dPatm = MyConvert.Converter("yl", tempPar[9], dPatmUnit, 0, 4); ; //当地大气压 gasPar.dPf = MyConvert.Converter("yl", tempPar[27], dPfUnit, 0, 4); //输入压力 gasPar.dTf = MyConvert.Converter("wd", tempPar[30], dTfUnit, 1, 4); //输入温度 //将压力换算为绝压 if (dPfType == 0) { gasPar.dPf = gasPar.dPf + dPatm; } switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Tools.NG_Cal NG_Cal = new NG_Cal(); NG_Cal.Zcal(ref gasPar, 0.0); double dV = tempPar[37]; double dVNG = dV * gasPar.dPf * gasPar.dTb * gasPar.dZb / (gasPar.dTf * gasPar.dZf * gasPar.dPb); //最终压力温度计算 gasPar.dPf = MyConvert.Converter("yl", tempPar[38], dPfUnit, 0, 4); //输入压力 gasPar.dTf = MyConvert.Converter("wd", tempPar[39], dTfUnit, 1, 4); //输入温度 //将压力换算为绝压 if (dPfType == 0) { gasPar.dPf = gasPar.dPf + dPatm; } switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Cal.Zcal(ref gasPar, 0.0); double dVNGe = dV * gasPar.dPf * gasPar.dTb * gasPar.dZb / (gasPar.dTf * gasPar.dZf * gasPar.dPb); tempPar[63] = dVNGe - dVNG; tempPar[64] = (dVNGe - dVNG) * gasPar.dRhob; StringBuilder Json = new StringBuilder(); Json.Append("["); for (int i = 0; i < tempPar.Length; i++) { Json.Append(tempPar[i].ToString() + ","); } string json = (Json.Replace(",", "", Json.Length - 1, 1).Append("]")).ToString(); return json; } private string GSCVCal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); gasPar.dCbtj = (int)tempPar[4]; //'计量参比条件 int dPfUnit = (int)tempPar[28]; //压力单位 gasPar.dPf = MyConvert.Converter("yl", tempPar[27], dPfUnit, 0, 4); //输入压力 int dPfType = (int)tempPar[29]; //压力类型 int dTfUnit = (int)tempPar[31]; //温度单位 gasPar.dTf = MyConvert.Converter("wd", tempPar[30], dTfUnit, 1, 4); //输入温度 int dPatmUnit = (int)tempPar[10]; //当地大气压单位 double dPatm = MyConvert.Converter("yl", tempPar[9], dPatmUnit, 0, 4); ; //当地大气压 //将压力换算为绝压 if (dPfType == 0) { gasPar.dPf = gasPar.dPf + dPatm; } switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Tools.NG_Cal NG_Cal = new NG_Cal(); NG_Cal.Zcal(ref gasPar, 0.0); double dV = tempPar[37]; double dVNG = dV * gasPar.dPf * gasPar.dTb * gasPar.dZb / (gasPar.dTf * gasPar.dZf * gasPar.dPb); tempPar[63] = dVNG; tempPar[64] = dVNG * gasPar.dRhob; StringBuilder Json = new StringBuilder(); Json.Append("["); for (int i = 0; i < tempPar.Length; i++) { Json.Append(tempPar[i].ToString() + ","); } string json = (Json.Replace(",", "", Json.Length - 1, 1).Append("]")).ToString(); return json; } private string PARCal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); gasPar.dCbtj = (int)tempPar[4]; //'计量参比条件 int dPfUnit = (int)tempPar[28]; //压力单位 gasPar.dPf = MyConvert.Converter("yl", tempPar[27], dPfUnit, 0, 4); //输入压力 int dPfType = (int)tempPar[29]; //压力类型 int dTfUnit = (int)tempPar[31]; //温度单位 gasPar.dTf = MyConvert.Converter("wd", tempPar[30], dTfUnit, 1, 4); //输入温度 int dPatmUnit = (int)tempPar[10]; //当地大气压单位 double dPatm = MyConvert.Converter("yl", tempPar[9], dPatmUnit, 0, 4); ; //当地大气压 //将压力换算为绝压 if (dPfType == 0) { gasPar.dPf = gasPar.dPf + dPatm; } switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Tools.NG_Cal NG_Cal = new NG_Cal(); NG_Cal.Crit(ref gasPar, 0.0); tempPar[63] = gasPar.dMrx; tempPar[64] = gasPar.dZb; tempPar[65] = gasPar.dZf; tempPar[66] = gasPar.dFpv; tempPar[67] = gasPar.dDb; tempPar[68] = gasPar.dDf; tempPar[69] = gasPar.dRhob; tempPar[70] = gasPar.dRhof; tempPar[71] = gasPar.dRD_Ideal; tempPar[72] = gasPar.dRD_Real; tempPar[73] = gasPar.dHo; tempPar[74] = gasPar.dH; tempPar[75] = gasPar.dS; tempPar[76] = gasPar.dCpi; tempPar[77] = gasPar.dCp; tempPar[78] = gasPar.dCv; tempPar[79] = gasPar.dk; tempPar[80] = gasPar.dKappa; tempPar[81] = gasPar.dSOS; tempPar[82] = gasPar.dCstar; tempPar[83] = gasPar.dHhvMol; tempPar[84] = gasPar.dLhvMol; tempPar[85] = gasPar.dHhvv; tempPar[86] = gasPar.dLhvv; tempPar[87] = gasPar.dHhvm; tempPar[88] = gasPar.dLhvm; tempPar[89] = gasPar.dZb11062; tempPar[90] = gasPar.dRhob11062; tempPar[91] = gasPar.dRhof11062; tempPar[92] = gasPar.dRD_Ideal11062; tempPar[93] = gasPar.dRD_Real11062; tempPar[94] = gasPar.dWobbeIndex; tempPar[95] = gasPar.Pc; tempPar[96] = gasPar.TC; tempPar[97] = gasPar.Bzsx; tempPar[98] = gasPar.Bzxx; tempPar[99] = gasPar.TotalC; tempPar[100] = gasPar.C2; tempPar[101] = gasPar.C2j; tempPar[102] = gasPar.C3j; tempPar[103] = gasPar.C4j; tempPar[104] = gasPar.C5j; tempPar[105] = gasPar.C6j; tempPar[106] = gasPar.C3C4; StringBuilder Json = new StringBuilder(); Json.Append("["); for (int i = 0; i < tempPar.Length; i++) { Json.Append(tempPar[i].ToString() + ","); } string json = (Json.Replace(",", "", Json.Length - 1, 1).Append("]")).ToString(); return json; } private string PZFlowcal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.FlowParStruct flPar = new NG_Cal.FlowParStruct(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); flPar.dMeterType = (int)tempPar[0]; //流量计类别 flPar.dCoreType = (int)tempPar[1]; //节流装置类型 flPar.dFlowCalbz = (int)tempPar[2]; //流量计算标准 flPar.dZcalbz = (int)tempPar[3]; //压缩因子计算标准 flPar.dCbtj = (int)tempPar[4]; //'计量参比条件 flPar.dPb_M = tempPar[5]; //计量参比条件压力 flPar.dTb_M = tempPar[6]; //计量参比条件温度 flPar.dPb_E = tempPar[7]; //燃烧参比条件压力 flPar.dTb_E = tempPar[8]; //燃烧参比条件温度 flPar.dPatmUnit = (int)tempPar[10]; //当地大气压单位 flPar.dPatm = MyConvert.Converter("yl", tempPar[9], flPar.dPatmUnit, 0, 4); ; //当地大气压 flPar.dNG_Compents = gasPar.adMixture; //天然气组分 flPar.dPtmode = (int)tempPar[12]; //取压方式 flPar.dPipeType = (int)tempPar[13]; //管道类型 flPar.dPipeD = tempPar[14] / 1000; //管道内径 flPar.dLenUnit = (int)tempPar[15]; //长度单位 flPar.dPipeDtemp = tempPar[16]; //管道内径参考温度 flPar.dPileDtempUint = (int)tempPar[17]; //温度单位 flPar.dPipeMaterial = (int)tempPar[18]; //管道材料 flPar.dOrificeD = tempPar[19] / 1000; //喷嘴喉径换算成米 flPar.dOrificeUnit = (int)tempPar[20]; //长度单位 flPar.dOrificeDtemp = tempPar[21]; //孔板内径参考温度 flPar.dOrificeDtempUnit = (int)tempPar[22]; //温度单位 flPar.dOrificeMaterial = (int)tempPar[23]; //孔板材料 flPar.dOrificeSharpness = (int)tempPar[24]; //锐利度系数计算方法 flPar.dOrificeRk = tempPar[25]; //孔板入口圆弧半径 flPar.dOrificeRkLenUint = (int)tempPar[26]; //长度单位 flPar.dPfUnit = (int)tempPar[28]; //压力单位 flPar.dPf = MyConvert.Converter("yl", tempPar[27], flPar.dPfUnit, 0, 4); //输入压力 flPar.dPfType = (int)tempPar[29]; //压力类型 flPar.dTfUnit = (int)tempPar[31]; //温度单位 flPar.dTf = MyConvert.Converter("wd", tempPar[30], flPar.dTfUnit, 1, 4); //输入温度 flPar.dDpUnit = (int)tempPar[33]; //压力单位 flPar.dDp = MyConvert.Converter("yl", tempPar[32], flPar.dDpUnit, 0, 4); //输入压力; //输入差压 flPar.dVFlowUnit = (int)tempPar[34]; //体积流量单位 flPar.dMFlowUnit = (int)tempPar[35]; //质量流量单位 flPar.dEFlowUnit = (int)tempPar[36]; //能量流量单位 flPar.dCd = tempPar[37]; //流出系数 //将压力换算为绝压 if (flPar.dPfType == 0) { flPar.dPf = flPar.dPf + flPar.dPatm; } gasPar.dCbtj = flPar.dCbtj; gasPar.dPf = flPar.dPf; gasPar.dTf = flPar.dTf; switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Tools.NG_Cal NG_Cal = new NG_Cal(); NG_Cal.Crit(ref gasPar, 0.0); NGFLOW.NozellFLowCal(ref gasPar, ref flPar); tempPar[56] = flPar.dVFlowb * 86400; tempPar[57] = flPar.dVFlowf * 3600; tempPar[58] = flPar.dMFlowb; tempPar[59] = flPar.dEFlowb; tempPar[64] = gasPar.dZb; tempPar[65] = gasPar.dZf; tempPar[80] = gasPar.dKappa; tempPar[82] = gasPar.dCstar; StringBuilder Json = new StringBuilder(); Json.Append("["); for (int i = 0; i < tempPar.Length; i++) { Json.Append(tempPar[i].ToString() + ","); } string json = (Json.Replace(",", "", Json.Length - 1, 1).Append("]")).ToString(); return json; } private string SDFlowcal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.FlowParStruct flPar = new NG_Cal.FlowParStruct(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); flPar.dMeterType = (int)tempPar[0]; //流量计类别 flPar.dCoreType = (int)tempPar[1]; //节流装置类型 flPar.dFlowCalbz = (int)tempPar[2]; //流量计算标准 flPar.dZcalbz = (int)tempPar[3]; //压缩因子计算标准 flPar.dCbtj = (int)tempPar[4]; //'计量参比条件 flPar.dPb_M = tempPar[5]; //计量参比条件压力 flPar.dTb_M = tempPar[6]; //计量参比条件温度 flPar.dPb_E = tempPar[7]; //燃烧参比条件压力 flPar.dTb_E = tempPar[8]; //燃烧参比条件温度 flPar.dPatmUnit = (int)tempPar[10]; //当地大气压单位 flPar.dPatm = MyConvert.Converter("yl", tempPar[9], flPar.dPatmUnit, 0, 4); ; //当地大气压 flPar.dNG_Compents = gasPar.adMixture; //天然气组分 flPar.dPtmode = (int)tempPar[12]; //取压方式 flPar.dPipeType = (int)tempPar[13]; //管道类型 flPar.dPipeD = tempPar[14]; //管道内径 flPar.dLenUnit = (int)tempPar[15]; //长度单位 flPar.dPipeDtemp = tempPar[16]; //管道内径参考温度 flPar.dPileDtempUint = (int)tempPar[17]; //温度单位 flPar.dPipeMaterial = (int)tempPar[18]; //管道材料 flPar.dOrificeD = tempPar[19]; //孔板孔径 flPar.dOrificeUnit = (int)tempPar[20]; //长度单位 flPar.dOrificeDtemp = tempPar[21]; //孔板内径参考温度 flPar.dOrificeDtempUnit = (int)tempPar[22]; //温度单位 flPar.dOrificeMaterial = (int)tempPar[23]; //孔板材料 flPar.dOrificeSharpness = (int)tempPar[24]; //锐利度系数计算方法 flPar.dOrificeRk = tempPar[25]; //孔板入口圆弧半径 flPar.dOrificeRkLenUint = (int)tempPar[26]; //长度单位 flPar.dPfUnit = (int)tempPar[28]; //压力单位 flPar.dPf = MyConvert.Converter("yl", tempPar[27], flPar.dPfUnit, 0, 4); //输入压力 flPar.dPfType = (int)tempPar[29]; //压力类型 flPar.dTfUnit = (int)tempPar[31]; //温度单位 flPar.dTf = MyConvert.Converter("wd", tempPar[30], flPar.dTfUnit, 1, 4); //输入温度 flPar.dMeterFactor = (int)tempPar[37]; //仪表系数 flPar.dPulseNum = tempPar[32]; //脉冲数 flPar.dVFlowUnit = (int)tempPar[34]; //体积流量单位 flPar.dMFlowUnit = (int)tempPar[35]; //质量流量单位 flPar.dEFlowUnit = (int)tempPar[36]; //能量流量单位 //将压力换算为绝压 if (flPar.dPfType == 0) { flPar.dPf = flPar.dPf + flPar.dPatm; } gasPar.dCbtj = flPar.dCbtj; gasPar.dPf = flPar.dPf; gasPar.dTf = flPar.dTf; switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Tools.NG_Cal NG_Cal = new NG_Cal(); NG_Cal.Crit(ref gasPar, 0.0); NGFLOW.SdFlowCal(ref gasPar, ref flPar); tempPar[56] = flPar.dVFlowb * 86400; tempPar[57] = flPar.dVFlowf * 3600; tempPar[58] = flPar.dMFlowb; tempPar[59] = flPar.dEFlowb; tempPar[64] = gasPar.dZb; tempPar[65] = gasPar.dZf; StringBuilder Json = new StringBuilder(); Json.Append("["); for (int i = 0; i < tempPar.Length; i++) { Json.Append(tempPar[i].ToString() + ","); } string json = (Json.Replace(",", "", Json.Length - 1, 1).Append("]")).ToString(); return json; } private string KBFlowcal(string[] par) { double[] ngCom = new double[21]; double[] tempPar = new double[110]; for (int i = 0; i < par.Length; i++) { if (i != 11) { tempPar[i] = double.Parse(par[i]); } else { for (int j = 0; j < 21; j++) { ngCom[j] = double.Parse(par[11].Split('_')[j]) / 100; } } } FlowCal NGFLOW = new FlowCal(); NG_Cal.FlowParStruct flPar = new NG_Cal.FlowParStruct(); NG_Cal.GasPropsSTRUCT gasPar = new NG_Cal.GasPropsSTRUCT(); gasPar.adMixture = ngCom; UnitConvert MyConvert = new UnitConvert(); flPar.dMeterType = (int)tempPar[0]; //流量计类别 flPar.dCoreType = (int)tempPar[1]; //节流装置类型 flPar.dFlowCalbz = (int)tempPar[2]; //流量计算标准 flPar.dZcalbz = (int)tempPar[3]; //压缩因子计算标准 flPar.dCbtj = (int)tempPar[4]; //'计量参比条件 flPar.dPb_M = tempPar[5]; //计量参比条件压力 flPar.dTb_M = tempPar[6]; //计量参比条件温度 flPar.dPb_E = tempPar[7]; //燃烧参比条件压力 flPar.dTb_E = tempPar[8]; //燃烧参比条件温度 flPar.dPatmUnit = (int)tempPar[10]; //当地大气压单位 flPar.dPatm = MyConvert.Converter("yl", tempPar[9], flPar.dPatmUnit, 0, 4); ; //当地大气压 flPar.dNG_Compents = gasPar.adMixture; //天然气组分 flPar.dPtmode = (int)tempPar[12]; //取压方式 flPar.dPipeType = (int)tempPar[13]; //管道类型 flPar.dPipeD = tempPar[14]; //管道内径 flPar.dLenUnit = (int)tempPar[15]; //长度单位 flPar.dPipeDtemp = tempPar[16]; //管道内径参考温度 flPar.dPileDtempUint = (int)tempPar[17]; //温度单位 flPar.dPipeMaterial = (int)tempPar[18]; //管道材料 flPar.dOrificeD = tempPar[19]; //孔板孔径 flPar.dOrificeUnit = (int)tempPar[20]; //长度单位 flPar.dOrificeDtemp = tempPar[21]; //孔板内径参考温度 flPar.dOrificeDtempUnit = (int)tempPar[22]; //温度单位 flPar.dOrificeMaterial = (int)tempPar[23]; //孔板材料 flPar.dOrificeSharpness = (int)tempPar[24]; //锐利度系数计算方法 flPar.dOrificeRk = tempPar[25]; //孔板入口圆弧半径 flPar.dOrificeRkLenUint = (int)tempPar[26]; //长度单位 flPar.dPfUnit = (int)tempPar[28]; //压力单位 flPar.dPf = MyConvert.Converter("yl", tempPar[27], flPar.dPfUnit, 0, 4); //输入压力 flPar.dPfType = (int)tempPar[29]; //压力类型 flPar.dTfUnit = (int)tempPar[31]; //温度单位 flPar.dTf = MyConvert.Converter("wd", tempPar[30], flPar.dTfUnit, 1, 4); //输入温度 flPar.dDpUnit = (int)tempPar[33]; //压力单位 flPar.dDp = MyConvert.Converter("yl", tempPar[32], flPar.dDpUnit, 0, 4); //输入压力; //输入差压 flPar.dVFlowUnit = (int)tempPar[34]; //体积流量单位 flPar.dMFlowUnit = (int)tempPar[35]; //质量流量单位 flPar.dEFlowUnit = (int)tempPar[36]; //能量流量单位 //将压力换算为绝压 if (flPar.dPfType == 0) { flPar.dPf = flPar.dPf + flPar.dPatm; } gasPar.dCbtj = flPar.dCbtj; gasPar.dPf = flPar.dPf; gasPar.dTf = flPar.dTf; switch (gasPar.dCbtj) { case 2: gasPar.dPb = 101325; gasPar.dTb = 273.15; break; case 1: gasPar.dPb = 101325; gasPar.dTb = 288.15; break; case 0: gasPar.dPb = 101325; gasPar.dTb = 293.15; break; } NG_Tools.NG_Cal NG_Cal = new NG_Cal(); NG_Cal.Crit(ref gasPar, 0.0); NGFLOW.OFlowCal(ref gasPar, ref flPar); tempPar[45] = flPar.dCd; tempPar[46] = flPar.dE; tempPar[47] = flPar.dFG; tempPar[48] = flPar.dFT; tempPar[49] = flPar.dDViscosity; tempPar[50] = flPar.dDExpCoefficient; tempPar[51] = flPar.dRnPipe; tempPar[52] = flPar.dBk; tempPar[53] = flPar.dRoughNessPipe; tempPar[54] = flPar.dCdCorrect; tempPar[55] = 0; tempPar[56] = flPar.dVFlowb * 86400; tempPar[57] = flPar.dVFlowf * 3600; tempPar[58] = flPar.dMFlowb; tempPar[59] = flPar.dEFlowb; tempPar[60] = flPar.dVelocityFlow; tempPar[61] = flPar.dPressLost; tempPar[62] = flPar.dBeta; tempPar[63] = gasPar.dMrx; tempPar[64] = gasPar.dZb; tempPar[65] = gasPar.dZf; tempPar[66] = gasPar.dFpv; tempPar[67] = gasPar.dDb; tempPar[68] = gasPar.dDf; tempPar[69] = gasPar.dRhob; tempPar[70] = gasPar.dRhof; tempPar[71] = gasPar.dRD_Ideal; tempPar[72] = gasPar.dRD_Real; tempPar[73] = gasPar.dHo; tempPar[74] = gasPar.dH; tempPar[75] = gasPar.dS; tempPar[76] = gasPar.dCpi; tempPar[77] = gasPar.dCp; tempPar[78] = gasPar.dCv; tempPar[79] = gasPar.dk; tempPar[80] = gasPar.dKappa; tempPar[81] = gasPar.dSOS; tempPar[82] = gasPar.dCstar; tempPar[83] = gasPar.dHhvMol; tempPar[84] = gasPar.dLhvMol; tempPar[85] = gasPar.dHhvv; tempPar[86] = gasPar.dLhvv; tempPar[87] = gasPar.dHhvm; tempPar[88] = gasPar.dLhvm; tempPar[89] = gasPar.dZb11062; tempPar[90] = gasPar.dRhob11062; tempPar[91] = gasPar.dRhof11062; tempPar[92] = gasPar.dRD_Ideal11062; tempPar[93] = gasPar.dRD_Real11062; tempPar[94] = gasPar.dWobbeIndex; tempPar[95] = gasPar.Pc; tempPar[96] = gasPar.TC; tempPar[97] = gasPar.Bzsx; tempPar[98] = gasPar.Bzxx; tempPar[99] = gasPar.TotalC; tempPar[100] = gasPar.C2; tempPar[101] = gasPar.C2j; tempPar[102] = gasPar.C3j; tempPar[103] = gasPar.C4j; tempPar[104] = gasPar.C5j; tempPar[105] = gasPar.C6j; tempPar[106] = gasPar.C3C4; StringBuilder Json = new StringBuilder(); Json.Append("["); for (int i = 0; i < tempPar.Length; i++) { Json.Append(tempPar[i].ToString() + ","); } string json = (Json.Replace(",", "", Json.Length - 1, 1).Append("]")).ToString(); return json; } public bool IsReusable { get { return false; } } } }