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()
|
public bool Initialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
DataFlowList = new List<DataFlow>();
|
DataFlowList = new List<DataFlow>();
|
||||||
foreach (var item in NameList)
|
foreach (var item in NameList)
|
||||||
{
|
{
|
||||||
DataFlowList.Add(new DataFlow()
|
DataFlowList.Add(new DataFlow()
|
||||||
{
|
{
|
||||||
Name = item,
|
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());
|
DATA.Subscribe($"{Module}.MfcManager.DataFlow", () => GetDataFlowJsonString());
|
||||||
OP.Subscribe($"{Module}.FlowName.Query", (string cmd, object[] args) => Query(args));
|
OP.Subscribe($"{Module}.FlowName.Query", (string cmd, object[] args) => Query(args));
|
||||||
return true;
|
return true;
|
||||||
|
@ -110,28 +105,23 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
||||||
string flowName = objects[0].ToString();
|
string flowName = objects[0].ToString();
|
||||||
start =Convert.ToDateTime(objects[1]);
|
start =Convert.ToDateTime(objects[1]);
|
||||||
end = Convert.ToDateTime(objects[2]);
|
end = Convert.ToDateTime(objects[2]);
|
||||||
QueryRunVentVolume(flowName + "_Run");
|
QueryRunVentVolume("Flow."+flowName + "_Run");
|
||||||
QueryRunVentVolume(flowName + "_Vent");
|
QueryRunVentVolume("Flow."+flowName + "_Vent");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private void QueryRunVentVolume(string flowName)
|
private void QueryRunVentVolume(string flowName)
|
||||||
{
|
{
|
||||||
List<double> valueList = MfcSqlHelp.Query(Module, "Flow", flowName, start, end);
|
double values = MfcSqlHelp.Query(Module, flowName, start, end);
|
||||||
if (valueList.Count == 0)
|
|
||||||
return;
|
|
||||||
foreach (var item in DataFlowList)
|
foreach (var item in DataFlowList)
|
||||||
{
|
{
|
||||||
if (flowName.Contains(item.Name))
|
if (flowName.Contains(item.Name))
|
||||||
{
|
{
|
||||||
double allValue = 0;
|
|
||||||
for (int i = 0; i < valueList.Count; i++)
|
|
||||||
{
|
|
||||||
allValue += valueList[i];
|
|
||||||
}
|
|
||||||
if (flowName.Contains("Run"))
|
if (flowName.Contains("Run"))
|
||||||
item.RunVolume = allValue * 1.66667 * Math.Pow(10, -7);
|
item.RunVolume = values * 1.66667 * Math.Pow(10, -7);
|
||||||
else
|
else
|
||||||
item.VentVolume = allValue * 1.66667 * Math.Pow(10, -7);
|
item.VentVolume = values * 1.66667 * Math.Pow(10, -7);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,19 +18,24 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
||||||
{
|
{
|
||||||
public class MfcSqlHelp
|
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);
|
var daySlices = DateRangeHelper.SplitInToHours(new DateRangeHelper(start, end), 12);
|
||||||
string tableName = module;
|
string tableName = module;
|
||||||
string propertyCmd = "," + $"\"{module}.{tabName}.{name}.FeedBack\"";
|
string propertyCmd = "," + $"\"{module}.{name}.FeedBack\"";
|
||||||
string property = $"{module}.{tabName}.{name}.FeedBack";
|
string property = $"{module}.{name}.FeedBack";
|
||||||
|
|
||||||
|
|
||||||
return GetData(GetDataSetList(daySlices, tableName, propertyCmd, property), property);
|
|
||||||
|
|
||||||
|
|
||||||
|
return GetData(GetDataSetList(daySlices, tableName, propertyCmd, property), property);
|
||||||
}
|
}
|
||||||
private static List<DataSet> GetDataSetList(IEnumerable<DateRangeHelper> daySlices, string tableName, string propertyCmd,string property)
|
private static List<DataSet> GetDataSetList(IEnumerable<DateRangeHelper> daySlices, string tableName, string propertyCmd, string property)
|
||||||
{
|
{
|
||||||
List<DataSet> DataSetList = new List<DataSet>();
|
List<DataSet> DataSetList = new List<DataSet>();
|
||||||
foreach (var range in daySlices)
|
foreach (var range in daySlices)
|
||||||
|
@ -46,6 +51,7 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
||||||
sql.Append("select time AS InternalTimeStamp");
|
sql.Append("select time AS InternalTimeStamp");
|
||||||
// 添加待查询的列
|
// 添加待查询的列
|
||||||
sql.Append(propertyCmd);
|
sql.Append(propertyCmd);
|
||||||
|
sql.Append($", \"time\"");
|
||||||
sql.Append($" from \"{tblName}\"");
|
sql.Append($" from \"{tblName}\"");
|
||||||
|
|
||||||
if (day < ts.Days)
|
if (day < ts.Days)
|
||||||
|
@ -68,37 +74,35 @@ namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
||||||
}
|
}
|
||||||
return DataSetList;
|
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;
|
string rowStr;
|
||||||
List<double> values = new List<double>();
|
|
||||||
foreach (DataSet ds in dataSetList)
|
foreach (DataSet ds in dataSetList)
|
||||||
{
|
{
|
||||||
try
|
double timeDifference = 0;
|
||||||
|
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
|
rowStr = ds.Tables[0].Rows[i][property].ToString();
|
||||||
|
if (rowStr is not null && rowStr.Length == 0)
|
||||||
|
continue;
|
||||||
|
double bd = double.Parse(ds.Tables[0].Rows[i][property].ToString());
|
||||||
|
if (bd > 0)
|
||||||
{
|
{
|
||||||
rowStr = ds.Tables[0].Rows[i][property].ToString();
|
|
||||||
if (rowStr is not null && rowStr.Length == 0)
|
if (i != ds.Tables[0].Rows.Count - 1)//最后一个数据使用的时间差,是它前一个计算得到的
|
||||||
continue;
|
{
|
||||||
double bd = double.Parse(ds.Tables[0].Rows[i][property].ToString());
|
var startTime = new DateTime(long.Parse(ds.Tables[0].Rows[i]["time"].ToString()));
|
||||||
if (bd > 0)
|
var endTime = new DateTime(long.Parse(ds.Tables[0].Rows[i + 1]["time"].ToString()));
|
||||||
values.Add(bd);
|
timeDifference = (endTime - startTime).TotalSeconds;
|
||||||
|
}
|
||||||
|
values += bd * timeDifference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool CheckTableExists(string tableName)
|
private static bool CheckTableExists(string tableName)
|
||||||
{
|
{
|
||||||
var sql =
|
var sql =
|
||||||
|
|
Loading…
Reference in New Issue