public static Results Calcu(List <PValue>[] inputs, CalcuInfo calcuinfo) { //公用变量 bool _errorFlag = false; string _errorInfo = ""; bool _warningFlag = false; string _warningInfo = ""; bool _fatalFlag = false; string _fatalInfo = ""; List <PValue>[] results = new List <PValue> [1]; try { string[] paras = calcuinfo.fparas.Split(';'); List <PValue> intValues = new List <PValue>(); foreach (List <PValue> item in inputs) { intValues.Add(item[0]); } for (int i = 0; i < intValues.Count - 1; i++) { double V, M, k, b, A, R1, R2, J1, J2, L; string P = string.Empty; V = int.Parse(paras[0]); M = int.Parse(paras[1]); P = paras[2]; k = double.Parse(paras[3]); b = double.Parse(paras[4]); A = int.Parse(paras[5]); R1 = double.Parse(paras[6]); R2 = double.Parse(paras[7]); J1 = int.Parse(paras[8]); J2 = int.Parse(paras[9]); L = int.Parse(paras[10]); string type = calcuinfo.fsourtagids[i].ToString(); double newValue = (A == 0 ? intValues[i].Value : Math.Abs(intValues[i].Value)) * k + b; double x = 0; if (V == 0) { bool j1Result = false; bool j2Result = false; switch (J1.ToString()) { case "0": if (newValue > R1) { j1Result = true; } break; case "1": if (newValue >= R1) { j1Result = true; } break; case "2": if (newValue < R1) { j1Result = true; } break; case "3": if (newValue <= R1) { j1Result = true; } break; default: break; } switch (J2.ToString()) { case "0": if (newValue > R2) { j2Result = true; } break; case "1": if (newValue >= R2) { j2Result = true; } break; case "2": if (newValue < R2) { j2Result = true; } break; case "3": if (newValue <= R2) { j2Result = true; } break; default: break; } switch (L.ToString()) { case "0": if (j1Result && j2Result) { x = 1; } else { x = 0; } break; case "1": if (j1Result || j2Result) { x = 1; } else { x = 0; } break; case "2": if (!j1Result && !j2Result) { x = 1; } else { x = 0; } break; default: break; } } else { x = newValue; } string tableNo = string.Empty; List <DateTime> seDate = getDateRegion(P, intValues[i].Timestamp); DataTable dt = BLL.AlgorithmBLL.getMHisOpHistory("MHisOp" + type + P, seDate); if (dt != null && dt.Rows.Count > 0) { double newX = 0; if (M == 0) { newX = Convert.ToDouble(dt.Rows[0]["tagvalue"].ToString()) + x; } else if (M == 1) { TimeSpan d1 = intValues[i].Timestamp.Subtract(seDate[0]); int mins = d1.Minutes; newX = Math.Round((Convert.ToDouble(dt.Rows[0]["tagvalue"].ToString()) * mins + x) / (mins + 1), 2); } bool isok = BLL.AlgorithmBLL.UpdateMHisOp("MHisOp" + type + P, newX, seDate); if (!isok) { _errorInfo += "MHisOp" + type + P + " 时间区间:" + seDate[0].ToString("yyyy-MM-dd HH:mm") + "--" + seDate[1].ToString("yyyy-MM-dd HH:mm") + " 时间点:" + intValues[i].Timestamp.ToString("yyyy-MM-dd HH:mm") + "更新报错"; } } else { bool isok = BLL.AlgorithmBLL.InsertMHisOp("MHisOp" + type + P, x, seDate); if (!isok) { _errorInfo += "MHisOp" + type + P + " 时间区间:" + seDate[0].ToString("yyyy-MM-dd HH:mm") + "--" + seDate[1].ToString("yyyy-MM-dd HH:mm") + " 时间点:" + intValues[i].Timestamp.ToString("yyyy-MM-dd HH:mm") + "录入报错"; } } } if (string.IsNullOrWhiteSpace(_errorInfo)) { return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo)); } else { _fatalFlag = true; _fatalInfo = "MHisOp算法出错"; return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo)); } } catch (Exception ex) { //计算中出任何错误,则需要记录log //LogHelper.Write(LogType.Error, "计算模块错误!"); //记录计算模块的名称、当前标签、起始时间、结束时间 //string moduleInfo = string.Format("——计算模块的名称是:{0},当前计算源标签是:{1},计算起始时间是:{2},计算结束时间是:{3}。", calcuInfo.fmodulename, calcuInfo.sourcetagname, calcuinfo.fstarttime.ToString(), calcuinfo.fendtime.ToString()); //LogHelper.Write(LogType.Error, moduleInfo); //计算引擎报错具体信息 //string errInfo = string.Format("——具体报错信息:{0}。", ex.ToString()); //LogHelper.Write(LogType.Error, errInfo); //返回null供计算引擎处理 _fatalFlag = true; _fatalInfo = ex.ToString(); return(new Results(results, _errorFlag, _errorInfo, _warningFlag, _warningInfo, _fatalFlag, _fatalInfo)); } }
public override string ToString() { return('(' + J1.ToString() + ", " + J2.ToString() + ", " + J3.ToString() + ", " + J4.ToString() + ", " + J5.ToString() + ", " + J6.ToString() + ')'); }