Merge branch 'develop' into feature/add-alarm-mute-support
This commit is contained in:
commit
d5633f5f3c
|
@ -52,20 +52,15 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
|||
}
|
||||
public bool Initialize()
|
||||
{
|
||||
|
||||
DataFlowList = new List<DataFlow>();
|
||||
foreach (var item in NameList)
|
||||
{
|
||||
DataFlowList.Add(new DataFlow()
|
||||
{
|
||||
Name = item,
|
||||
//RunFeedBack = Convert.ToDouble(DATA.Poll($"{Module}.Flow.{item}_Run.FeedBack")),
|
||||
//VentFeedBack = Convert.ToDouble(DATA.Poll($"{Module}.Flow.{item}_Vent.FeedBack")),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
DATA.Subscribe($"{Module}.MfcManager.DataFlow", () => GetDataFlowJsonString());
|
||||
OP.Subscribe($"{Module}.FlowName.Query", (string cmd, object[] args) => Query(args));
|
||||
return true;
|
||||
|
@ -110,28 +105,23 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
|||
string flowName = objects[0].ToString();
|
||||
start =Convert.ToDateTime(objects[1]);
|
||||
end = Convert.ToDateTime(objects[2]);
|
||||
QueryRunVentVolume(flowName + "_Run");
|
||||
QueryRunVentVolume(flowName + "_Vent");
|
||||
QueryRunVentVolume("Flow."+flowName + "_Run");
|
||||
QueryRunVentVolume("Flow."+flowName + "_Vent");
|
||||
return true;
|
||||
}
|
||||
private void QueryRunVentVolume(string flowName)
|
||||
{
|
||||
List<double> valueList = MfcSqlHelp.Query(Module, "Flow", flowName, start, end);
|
||||
if (valueList.Count == 0)
|
||||
return;
|
||||
double values = MfcSqlHelp.Query(Module, flowName, start, end);
|
||||
|
||||
foreach (var item in DataFlowList)
|
||||
{
|
||||
if (flowName.Contains(item.Name))
|
||||
{
|
||||
double allValue = 0;
|
||||
for (int i = 0; i < valueList.Count; i++)
|
||||
{
|
||||
allValue += valueList[i];
|
||||
}
|
||||
if (flowName.Contains("Run"))
|
||||
item.RunVolume = allValue * 1.66667 * Math.Pow(10, -7);
|
||||
item.RunVolume = values * 1.66667 * Math.Pow(10, -7);
|
||||
else
|
||||
item.VentVolume = allValue * 1.66667 * Math.Pow(10, -7);
|
||||
item.VentVolume = values * 1.66667 * Math.Pow(10, -7);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,17 +18,22 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
|||
{
|
||||
public class MfcSqlHelp
|
||||
{
|
||||
public static List<double> Query(string module,string tabName, string name,DateTime start,DateTime end)
|
||||
/// <summary>
|
||||
/// 根据名称和时间段查询结果
|
||||
/// </summary>
|
||||
/// <param name="module">模块名称</param>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
public static double Query(string module, string name, DateTime start, DateTime end)
|
||||
{
|
||||
var daySlices = DateRangeHelper.SplitInToHours(new DateRangeHelper(start, end), 12);
|
||||
string tableName = module;
|
||||
string propertyCmd = "," + $"\"{module}.{tabName}.{name}.FeedBack\"";
|
||||
string property = $"{module}.{tabName}.{name}.FeedBack";
|
||||
|
||||
string propertyCmd = "," + $"\"{module}.{name}.FeedBack\"";
|
||||
string property = $"{module}.{name}.FeedBack";
|
||||
|
||||
return GetData(GetDataSetList(daySlices, tableName, propertyCmd, property), property);
|
||||
|
||||
|
||||
}
|
||||
private static List<DataSet> GetDataSetList(IEnumerable<DateRangeHelper> daySlices, string tableName, string propertyCmd, string property)
|
||||
{
|
||||
|
@ -46,6 +51,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
|||
sql.Append("select time AS InternalTimeStamp");
|
||||
// 添加待查询的列
|
||||
sql.Append(propertyCmd);
|
||||
sql.Append($", \"time\"");
|
||||
sql.Append($" from \"{tblName}\"");
|
||||
|
||||
if (day < ts.Days)
|
||||
|
@ -68,14 +74,13 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
|||
}
|
||||
return DataSetList;
|
||||
}
|
||||
private static List<double> GetData(List<DataSet> dataSetList, string property)
|
||||
private static double GetData(List<DataSet> dataSetList, string property)
|
||||
{
|
||||
double values = 0;
|
||||
string rowStr;
|
||||
List<double> values = new List<double>();
|
||||
foreach (DataSet ds in dataSetList)
|
||||
{
|
||||
try
|
||||
{
|
||||
double timeDifference = 0;
|
||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||
{
|
||||
rowStr = ds.Tables[0].Rows[i][property].ToString();
|
||||
|
@ -83,22 +88,21 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
|||
continue;
|
||||
double bd = double.Parse(ds.Tables[0].Rows[i][property].ToString());
|
||||
if (bd > 0)
|
||||
values.Add(bd);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
if (i != ds.Tables[0].Rows.Count - 1)//最后一个数据使用的时间差,是它前一个计算得到的
|
||||
{
|
||||
var startTime = new DateTime(long.Parse(ds.Tables[0].Rows[i]["time"].ToString()));
|
||||
var endTime = new DateTime(long.Parse(ds.Tables[0].Rows[i + 1]["time"].ToString()));
|
||||
timeDifference = (endTime - startTime).TotalSeconds;
|
||||
}
|
||||
values += bd * timeDifference;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
private static bool CheckTableExists(string tableName)
|
||||
{
|
||||
var sql =
|
||||
|
|
Loading…
Reference in New Issue