You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

212 lines
7.0 KiB
C#

1 month ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;
using System.Data;
using System.Xml;
using Mesnac.Equips;
using Mesnac.Maths;
namespace Mesnac.Math.OneStepMixing
{
public class RecipeOpening : IMath
{
private object NullResult = new DataTable();
public string Name
{
get { return "开炼步骤"; }
}
public string Caption
{
get
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("必须填写使用数据库连接的设备名称");
sb.AppendLine("例:");
sb.Append(" ").Append(Name).AppendLine("(A1)");
return sb.ToString();
}
}
public object Execute(string[] parameters, object[] buff)
{
string id = string.Empty;
if ((buff.Length > 0)
&& (buff[0] != null)
&& (!string.IsNullOrWhiteSpace(buff[0].ToString())))
{
id = buff[0].ToString();
}
if (string.IsNullOrWhiteSpace(id))
{
return this.NullResult;
}
if (parameters.Length < 1)
{
return this.NullResult;
}
string equipName = parameters[0];
BaseEquip equip = null;
if (!Mesnac.Equips.Factory.Instance.AllEquips.TryGetValue(equipName, out equip))
{
return this.NullResult;
}
DataTable Result = new DataTable();
string xml = string.Empty;
try
{
//Result = DeserializeObject<DataTable>(xml);
Result = TestData;
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService.Error("发生错误在Mesnac.Math.OneStepMixing.RecipeMixingXml" + ex.Message, ex);
}
Result.TableName = id;
return Result;
}
private DataTable DeserializeDataTable(string pXml)
{
StringReader strReader = new StringReader(pXml);
XmlReader xmlReader = XmlReader.Create(strReader);
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));
DataTable dt = serializer.Deserialize(xmlReader) as DataTable;
return dt;
}
/// <summary>
/// 把xml字符串反序列化为对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="xmlString"></param>
/// <returns></returns>
private T DeserializeObject<T>(string xmlString)
{
if (!String.IsNullOrEmpty(xmlString))
{
StringReader strReader = new StringReader(xmlString);
XmlSerializer serializer = new XmlSerializer(typeof(T));
T obj = (T)serializer.Deserialize(strReader);
strReader.Close();
strReader.Dispose();
return obj;
}
else
{
return default(T);
}
}
#region 测试数据
public static DataTable TestData
{
get
{
DataTable table = new DataTable();
DataColumn col1 = new DataColumn("序号");
DataColumn col2 = new DataColumn("动作");
DataColumn col3 = new DataColumn("时间");
DataColumn col4 = new DataColumn("冷却鼓速度");
DataColumn col5 = new DataColumn("开炼机速度");
DataColumn col6 = new DataColumn("辊距");
DataColumn col7 = new DataColumn("温度");
DataColumn col8 = new DataColumn("功率");
DataColumn col9 = new DataColumn("水温");
table.Columns.Add(col1);
table.Columns.Add(col2);
table.Columns.Add(col3);
table.Columns.Add(col4);
table.Columns.Add(col5);
table.Columns.Add(col6);
table.Columns.Add(col7);
table.Columns.Add(col8);
table.Columns.Add(col9);
DataRow row2 = table.NewRow();
row2["序号"] = 1;
row2["动作"] = "进料阶段";
row2["时间"] = 51;
row2["冷却鼓速度"] = 28.0;
row2["开炼机速度"] = 33.0;
row2["辊距"] = 5.0;
row2["温度"] = 125.0;
row2["功率"] = 101.2;
row2["水温"] = 53.9;
table.Rows.Add(row2);
DataRow row3 = table.NewRow();
row3["序号"] = 2;
row3["动作"] = "冷却阶段";
row3["时间"] = 76;
row3["冷却鼓速度"] = 35.0;
row3["开炼机速度"] = 40.0;
row3["辊距"] = 5.1;
row3["温度"] = 119.5;
row3["功率"] = 116.8;
row3["水温"] = 53.0;
table.Rows.Add(row3);
DataRow row4 = table.NewRow();
row4["序号"] = 3;
row4["动作"] = "成环阶段";
row4["时间"] = 96;
row4["冷却鼓速度"] = 40.0;
row4["开炼机速度"] = 45.0;
row4["辊距"] = 3.0;
row4["温度"] = 121.8;
row4["功率"] = 203.2;
row4["水温"] = 53.0;
table.Rows.Add(row4);
DataRow row5 = table.NewRow();
row5["序号"] = 4;
row5["动作"] = "拉断阶段";
row5["时间"] = 119;
row5["冷却鼓速度"] = 35.0;
row5["开炼机速度"] = 45.0;
row5["辊距"] = 3.0;
row5["温度"] = 126.9;
row5["功率"] = 174.3;
row5["水温"] = 53.0;
table.Rows.Add(row5);
DataRow row6 = table.NewRow();
row6["序号"] = 5;
row6["动作"] = "排胶阶段";
row6["时间"] = 118;
row6["冷却鼓速度"] = 45.0;
row6["开炼机速度"] = 0.5;
row6["辊距"] = 2.9;
row6["温度"] = 68.8;
row6["功率"] = 2.3;
row6["水温"] = 53.0;
table.Rows.Add(row6);
DataRow row7 = table.NewRow();
//row7["序号"] = 1;
//row7["动作"] = "";
row7["时间"] = 172;
row7["冷却鼓速度"] = 35.0;
row7["开炼机速度"] = 7.7;
row7["辊距"] = 4.8;
row7["温度"] = 59.2;
row7["功率"] = 2.3;
row7["水温"] = 53.0;
table.Rows.Add(row7);
return table;
}
}
#endregion
}
}