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.
1206 lines
48 KiB
C#
1206 lines
48 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Xml;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Action.Feeding.BasicInfo;
|
|
using Mesnac.Codd.Session;
|
|
|
|
namespace Mesnac.Action.Feeding.FeedingPlc
|
|
{
|
|
public class SaveMixingData
|
|
{
|
|
#region 基本函数
|
|
/// <summary>
|
|
/// 获取本地连接
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private DbHelper getLocalHelper()
|
|
{
|
|
return new DatabaseAction().NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.local);
|
|
}
|
|
/// <summary>
|
|
/// 获取网络连接
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private DbHelper getServerHelper()
|
|
{
|
|
return new DatabaseAction().NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Server);
|
|
}
|
|
private bool IsNet()
|
|
{
|
|
bool Result = false;
|
|
Result = new BaseAction().NetType == BaseAction.NetTypes.Net;
|
|
return Result;
|
|
}
|
|
#endregion
|
|
|
|
#region 数据信息
|
|
private RecipeData.RecipeInfo recipeInfo = new RecipeData.RecipeInfo();
|
|
private RecipeData.PptPlanInfo planInfo = new RecipeData.PptPlanInfo();
|
|
private List<RecipeData.RecipeWeightInfo> allWeightInfo = new List<RecipeData.RecipeWeightInfo>();
|
|
private List<RecipeData.RecipeMixingInfo> allMixingInfo = new List<RecipeData.RecipeMixingInfo>();
|
|
private void IniRecipeData()
|
|
{
|
|
RecipeData recipeData = new RecipeData();
|
|
this.recipeInfo = recipeData.GetCurrentRecipeInfo();
|
|
this.planInfo = recipeData.GetCurrentPptPlanInfo();
|
|
this.allWeightInfo = recipeData.GetCurrentRecipeWeightInfo();
|
|
this.allMixingInfo = recipeData.GetCurrentRecipeMixingInfo();
|
|
}
|
|
#endregion
|
|
|
|
#region Plc信息
|
|
/// <summary>
|
|
/// 重置存盘信息
|
|
/// </summary>
|
|
private void FinishedOneReset()
|
|
{
|
|
//清空密炼曲线信号
|
|
CurveInfo.Instance.MixingCurve = new StringBuilder();
|
|
|
|
CurveInfo.Instance.MixTimeStr = new StringBuilder();
|
|
CurveInfo.Instance.MixTempStr = new StringBuilder();
|
|
CurveInfo.Instance.MixPowerStr = new StringBuilder();
|
|
CurveInfo.Instance.MixEnerStr = new StringBuilder();
|
|
CurveInfo.Instance.MixPressStr = new StringBuilder();
|
|
CurveInfo.Instance.MixSpeedStr = new StringBuilder();
|
|
//重置存盘信号
|
|
PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.FinishedOneReset, new object[] { 1 });
|
|
}
|
|
|
|
private PlanExecuteData planExecuteData = new PlanExecuteData();
|
|
private class PlanExecuteData
|
|
{
|
|
/// <summary>
|
|
/// 计划编号
|
|
/// </summary>
|
|
public string PlanID { get; set; }
|
|
/// <summary>
|
|
/// 当前计划车数
|
|
/// </summary>
|
|
public int RecipeSetNumber { get; set; }
|
|
/// <summary>
|
|
/// 计划完成数量
|
|
/// </summary>
|
|
public int MixingFinishedCount { get; set; }
|
|
/// <summary>
|
|
/// 密炼开始时间
|
|
/// </summary>
|
|
public DateTime MixingStartTime { get; set; }
|
|
}
|
|
private void IniPlanExecuteData()
|
|
{
|
|
planExecuteData.PlanID = planInfo.PlanID;
|
|
|
|
// 计划完成数量
|
|
planExecuteData.RecipeSetNumber = PlcData.Instance.RecipeSetNumber.LastValue.ToInt();
|
|
// 计划完成数量
|
|
planExecuteData.MixingFinishedCount = PlcData.Instance.MixingFinishedCount.LastValue.ToInt();
|
|
// 密炼开始时间
|
|
planExecuteData.MixingStartTime = PlcData.Instance.MixingStartTime.LastValue.ToDateTime();
|
|
}
|
|
|
|
#region 配方PLC数据读取
|
|
private void ReadPlcSaveData()
|
|
{
|
|
Equips.Factory.Instance.ReadAll();
|
|
IniRecipeData();
|
|
IniPlanExecuteData();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 条码信息
|
|
private ShelfBarcode shelfBarcode;
|
|
private class ShelfBarcode
|
|
{
|
|
private DbHelper dbHelper = null;
|
|
private string planID = string.Empty;
|
|
private int shelfLotCount = 0;
|
|
public ShelfBarcode(DbHelper _dbHelper, string _planID, int _shelfLotCount)
|
|
{
|
|
this.dbHelper = _dbHelper;
|
|
this.planID = _planID;
|
|
this.shelfLotCount = _shelfLotCount;
|
|
IniShelfBarcode();
|
|
}
|
|
|
|
private void InsertPptShiftConfigBarCode()
|
|
{
|
|
string sqstr = @"INSERT INTO dbo.PptShiftConfig(
|
|
Barcode,BarcodeStart,BarcodeEnd,TotalWeight,
|
|
ShelfNum,RealWeight,OperCode,MemNote,StockFlag,CheckFlag,UpdateFlag,UPERP) VALUES (
|
|
@Barcode,@BarcodeStart,@BarcodeEnd,@TotalWeight,
|
|
@ShelfNum,@RealWeight,@OperCode,@MemNote,@StockFlag,@CheckFlag,@UpdateFlag, @UPERP)";
|
|
|
|
dbHelper.CommandText = sqstr;
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@Barcode", this._shelfbarcode);
|
|
dbHelper.AddParameter("@BarcodeStart", this._totalCount);
|
|
dbHelper.AddParameter("@BarcodeEnd", this._totalCount);
|
|
dbHelper.AddParameter("@TotalWeight", 0);
|
|
dbHelper.AddParameter("@ShelfNum", 0);
|
|
dbHelper.AddParameter("@RealWeight", 0);
|
|
dbHelper.AddParameter("@OperCode", string.Empty);
|
|
dbHelper.AddParameter("@MemNote", string.Empty);
|
|
dbHelper.AddParameter("@StockFlag", 0);
|
|
dbHelper.AddParameter("@CheckFlag", "N");
|
|
dbHelper.AddParameter("@UpdateFlag", 0);
|
|
dbHelper.AddParameter("@UPERP", 0);
|
|
dbHelper.ExecuteNonQuery();
|
|
}
|
|
private void IniShelfBarcode()
|
|
{
|
|
string sqlstr = "SELECT TOP 1 Barcode,ShelfNum FROM dbo.PptShiftConfig WHERE PlanID=@PlanID ORDER BY Barcode DESC";
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@PlanID", planID);
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
if (dt == null || dt.Rows.Count == 0)
|
|
{
|
|
this._totalCount = 1;
|
|
return;
|
|
}
|
|
this._totalCount = dt.Rows.Count + 1;
|
|
#region 当前架子号是否可用
|
|
DataRow row = dt.Rows[0];
|
|
string barcode = row["Barcode"].ToString();
|
|
if (barcode.Length < 18)
|
|
{
|
|
return;
|
|
}
|
|
int hasDoneShelfNum = Convert.ToInt16(row["ShelfNum"].ToString());
|
|
if (this.shelfLotCount > hasDoneShelfNum)
|
|
{
|
|
this._shelfbarcode = barcode;
|
|
}
|
|
#endregion
|
|
}
|
|
private int _totalCount;
|
|
public int TotalCount
|
|
{
|
|
get
|
|
{
|
|
return _totalCount;
|
|
}
|
|
}
|
|
private string _shelfbarcode = string.Empty;
|
|
public string Barcode
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(_shelfbarcode))
|
|
{
|
|
return this._shelfbarcode;
|
|
}
|
|
string planid = this.planID + "000000000000";
|
|
planid = planid.Substring(0, 12);
|
|
string factid = new BaseAction().GetConfigValue("FactoryID", "1") + "1";
|
|
factid = factid.Substring(0, 1);
|
|
string plancode = planid + factid;
|
|
|
|
string barcode = plancode
|
|
+ this.TotalCount.ToString("D4").Substring(0, 4)
|
|
+ this.shelfLotCount.ToString("D1").Substring(0, 1);
|
|
this._shelfbarcode = barcode;
|
|
InsertPptShiftConfigBarCode();
|
|
return this._shelfbarcode;
|
|
}
|
|
}
|
|
public override string ToString()
|
|
{
|
|
return this.Barcode;
|
|
}
|
|
}
|
|
private class BarcodeInfo
|
|
{
|
|
#region 单例实现
|
|
private static BarcodeInfo instance;
|
|
public static BarcodeInfo Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new BarcodeInfo();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private BarcodeInfo()
|
|
{
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 车条码
|
|
/// </summary>
|
|
public string LotBarcode { get; set; }
|
|
}
|
|
private void IniCurrentLotBarcode()
|
|
{
|
|
string barcode = planExecuteData.PlanID;
|
|
barcode += planExecuteData.MixingFinishedCount.ToString("D4");
|
|
BarcodeInfo.Instance.LotBarcode = barcode;
|
|
}
|
|
private bool HasSaveBarCode()
|
|
{
|
|
string barcode = BarcodeInfo.Instance.LotBarcode;
|
|
string sqlstr = "SELECT 1 FROM dbo.PptLotData WHERE Barcode=@Barcode";
|
|
DbHelper dbHelper = getLocalHelper();
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@Barcode", barcode);
|
|
DataTable dt = dbHelper.ToDataTable();
|
|
return dt.Rows.Count > 0;
|
|
}
|
|
private bool UpdateCurrentShelfBarcode(DbHelper dbHelper)
|
|
{
|
|
string sqlstr = @"
|
|
UPDATE PptShiftConfig SET ShelfNum=ShelfNum+1,BarcodeEnd=@BarcodeEnd,ProdDate=GETDATE(),
|
|
RealWeight=RealWeight+@RealWeight,MemNote=MemNote+@MemNote,
|
|
PlanDate=@PlanDate,EquipCode=@EquipCode,ShiftID=@ShiftID,ClassID=@ClassID,
|
|
MaterialCode=@MaterialCode,MaterialName=@MaterialName,PlanID=@PlanID
|
|
WHERE Barcode=@Barcode";
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@BarcodeEnd", shelfBarcode.TotalCount);
|
|
dbHelper.AddParameter("@RealWeight", totalRealWeight);
|
|
dbHelper.AddParameter("@MemNote", "," + shelfBarcode.TotalCount.ToString());
|
|
|
|
dbHelper.AddParameter("@PlanDate", planInfo.PlanDate);
|
|
dbHelper.AddParameter("@EquipCode", planInfo.RecipeEquipCode);
|
|
dbHelper.AddParameter("@ShiftID", planInfo.ShiftID);
|
|
dbHelper.AddParameter("@ClassID", planInfo.ClassID);
|
|
dbHelper.AddParameter("@MaterialCode", planInfo.RecipeMaterialCode);
|
|
dbHelper.AddParameter("@MaterialName", planInfo.RecipeMaterialName);
|
|
dbHelper.AddParameter("@PlanID", planInfo.PlanID);
|
|
|
|
|
|
|
|
dbHelper.AddParameter("@Barcode", shelfBarcode.Barcode);
|
|
dbHelper.ExecuteNonQuery();
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 读取配置文件
|
|
private string getPlcSchemaPath()
|
|
{
|
|
string path = System.Windows.Forms.Application.StartupPath;
|
|
return Path.Combine(path, "Data\\MCProject\\PlcSchema.xml");
|
|
}
|
|
private string ToValue(XmlNode node, string key, string defaultValue)
|
|
{
|
|
foreach (XmlAttribute a in node.Attributes)
|
|
{
|
|
if (a.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
return a.Value;
|
|
}
|
|
}
|
|
return defaultValue;
|
|
}
|
|
private int ToValue(XmlNode node, string key, int defaultValue)
|
|
{
|
|
int Result = 0;
|
|
string value = ToValue(node, key, string.Empty);
|
|
if (!string.IsNullOrWhiteSpace(value)
|
|
&& int.TryParse(value, out Result))
|
|
{
|
|
return Result;
|
|
}
|
|
return defaultValue;
|
|
}
|
|
private class PlcRecipeReaderItem
|
|
{
|
|
public PlcRecipeReaderItem()
|
|
{
|
|
this.DataFieldName = string.Empty;
|
|
this.PlcFiledName = string.Empty;
|
|
this.DataType = string.Empty;
|
|
this.PlcShifting = 0;
|
|
this.DefaultValue = 0;
|
|
this.ValueLen = 1;
|
|
this.Multiply = 1;
|
|
this.SetValue = null;
|
|
}
|
|
/// <summary>
|
|
/// 数据库字段名
|
|
/// </summary>
|
|
public string DataFieldName { get; set; }
|
|
/// <summary>
|
|
/// Plc别名
|
|
/// </summary>
|
|
public string PlcFiledName { get; set; }
|
|
/// <summary>
|
|
/// 偏移值
|
|
/// </summary>
|
|
public int PlcShifting { get; set; }
|
|
/// <summary>
|
|
/// 默认值
|
|
/// </summary>
|
|
public int DefaultValue { get; set; }
|
|
/// <summary>
|
|
/// 长度
|
|
/// </summary>
|
|
public int ValueLen { get; set; }
|
|
/// <summary>
|
|
/// 数据处理方式
|
|
/// </summary>
|
|
public string DataType { get; set; }
|
|
/// <summary>
|
|
/// 乘数
|
|
/// </summary>
|
|
public int Multiply { get; set; }
|
|
/// <summary>
|
|
/// 原始值
|
|
/// </summary>
|
|
public int[] SetValue { get; set; }
|
|
/// <summary>
|
|
/// 数据转化值
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public object GetValue()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(DataType))
|
|
{
|
|
return GetValue_Null();
|
|
}
|
|
return GetValue_Null();
|
|
}
|
|
|
|
private double MultiplyData(double buff)
|
|
{
|
|
double result = buff;
|
|
if (this.Multiply != 0)
|
|
{
|
|
result = result / (double)this.Multiply;
|
|
}
|
|
return result;
|
|
}
|
|
private double GetValue_Null()
|
|
{
|
|
if (this.SetValue.Length == 0)
|
|
{
|
|
return DefaultValue;
|
|
}
|
|
return MultiplyData(this.SetValue[0]);
|
|
}
|
|
|
|
}
|
|
private class PlcRecipeReader
|
|
{
|
|
public PlcRecipeReader()
|
|
{
|
|
this.PlcFiledName = string.Empty;
|
|
this.ThisCount = 1;
|
|
this.ThisType = 0;
|
|
this.ItemList = new List<PlcRecipeReaderItem>();
|
|
}
|
|
/// <summary>
|
|
/// Plc别名
|
|
/// </summary>
|
|
public string PlcFiledName { get; set; }
|
|
/// <summary>
|
|
/// 数量
|
|
/// </summary>
|
|
public int ThisCount { get; set; }
|
|
/// <summary>
|
|
/// 类型
|
|
/// </summary>
|
|
public int ThisType { get; set; }
|
|
/// <summary>
|
|
/// 数据项
|
|
/// </summary>
|
|
public List<PlcRecipeReaderItem> ItemList { get; set; }
|
|
}
|
|
private List<PlcRecipeReader> getPlcRecipeReader(string tableName)
|
|
{
|
|
List<PlcRecipeReader> result = new List<PlcRecipeReader>();
|
|
XmlDocument xmlDocument = new XmlDocument();
|
|
xmlDocument.Load(getPlcSchemaPath());
|
|
foreach (XmlNode configNode in xmlDocument)
|
|
{
|
|
if (!configNode.Name.Equals("configuration", StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
continue;
|
|
}
|
|
foreach (XmlNode writeNode in configNode.ChildNodes)
|
|
{
|
|
if (!writeNode.Name.Equals("PlcSaveRead", StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
continue;
|
|
}
|
|
foreach (XmlNode serviceNode in writeNode.ChildNodes)
|
|
{
|
|
if (!serviceNode.Name.Equals(tableName, StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
continue;
|
|
}
|
|
PlcRecipeReader writer = new PlcRecipeReader();
|
|
writer.PlcFiledName = ToValue(serviceNode, "equip", string.Empty);
|
|
writer.ThisCount = ToValue(serviceNode, "count", 1);
|
|
writer.ThisType = ToValue(serviceNode, "type", 0);
|
|
foreach (XmlNode node in serviceNode.ChildNodes)
|
|
{
|
|
PlcRecipeReaderItem plc = new PlcRecipeReaderItem();
|
|
plc.DataFieldName = ToValue(node, "field", string.Empty);
|
|
plc.PlcFiledName = ToValue(node, "equip", string.Empty);
|
|
plc.PlcShifting = ToValue(node, "shifting", 0);
|
|
plc.DefaultValue = ToValue(node, "default", 0);
|
|
plc.ValueLen = ToValue(node, "len", 1);
|
|
plc.DataType = ToValue(node, "datatype", string.Empty);
|
|
plc.Multiply = ToValue(node, "multiply", 1);
|
|
writer.ItemList.Add(plc);
|
|
}
|
|
result.Add(writer);
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
#endregion
|
|
|
|
#region 数据库信息
|
|
|
|
#region 更新条数
|
|
private bool SetLocalPlanFinishedLotCount(DbHelper dbHelper)
|
|
{
|
|
//完成当前计划车数
|
|
int finishLotCount = planExecuteData.MixingFinishedCount;
|
|
string sqlstr = string.Empty;
|
|
sqlstr = "UPDATE dbo.PptGroupLot SET FinishNum=@FinishNum ,EndDatetime=GETDATE() WHERE FinishTag=0";
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@FinishNum", finishLotCount);
|
|
dbHelper.ExecuteNonQuery();
|
|
sqlstr = "UPDATE dbo.PptPlan SET RealNum=RealNum+1,RealEndtime=GETDATE() WHERE PlanID=@PlanID";
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@PlanID", planExecuteData.PlanID);
|
|
dbHelper.ExecuteNonQuery();
|
|
return true;
|
|
}
|
|
private bool SetServerPlanFinishedLotCount(DbHelper dbHelper)
|
|
{
|
|
int finishLotCount = planExecuteData.MixingFinishedCount;
|
|
string sqlstr = string.Empty;
|
|
sqlstr = "UPDATE dbo.PptPlan SET RealNum=@realNum,RealEndtime=GETDATE() WHERE PlanID=@PlanId";
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("@realNum", finishLotCount);
|
|
dbHelper.AddParameter("@PlanId", planExecuteData.PlanID);
|
|
dbHelper.ExecuteNonQuery();
|
|
return true;
|
|
}
|
|
#endregion
|
|
#region SavePptLotData
|
|
private bool SavePptLotData(DbHelper dbHelper)
|
|
{
|
|
#region 基本信息
|
|
dbHelper.CommandType = CommandType.Text;
|
|
StringBuilder sqlstr_field = new StringBuilder();
|
|
StringBuilder sqlstr_value = new StringBuilder();
|
|
string fieldName = string.Empty;
|
|
string valueName = string.Empty;
|
|
sqlstr_field.AppendLine("INSERT INTO dbo.PptLotData(");
|
|
sqlstr_value.AppendLine(" ) VALUES (");
|
|
#region 数据整理
|
|
#region Barcode
|
|
fieldName = "Barcode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, BarcodeInfo.Instance.LotBarcode);
|
|
#endregion
|
|
#region PlanDate
|
|
fieldName = "PlanDate";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.PlanDate);
|
|
#endregion
|
|
#region MaterCode
|
|
fieldName = "MaterCode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, this.recipeInfo.RecipeMaterialCode);
|
|
#endregion
|
|
#region MaterName
|
|
fieldName = "MaterName";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, this.recipeInfo.RecipeMaterialName);
|
|
#endregion
|
|
#region EquipCode
|
|
fieldName = "EquipCode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.RecipeEquipCode);
|
|
#endregion
|
|
#region SerialID
|
|
fieldName = "SerialID";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planExecuteData.MixingFinishedCount);
|
|
#endregion
|
|
#region ShiftID
|
|
fieldName = "ShiftID";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.ShiftID);
|
|
#endregion
|
|
#region ClassID
|
|
fieldName = "ClassID";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.ClassID);
|
|
#endregion
|
|
#region EdtCode
|
|
fieldName = "EdtCode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, this.recipeInfo.RecipeVersionID);
|
|
#endregion
|
|
#region PlanID
|
|
fieldName = "PlanID";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.PlanID);
|
|
#endregion
|
|
#region StartDatetime
|
|
fieldName = "StartDatetime";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planExecuteData.MixingStartTime);
|
|
#endregion
|
|
#region ShelfBarcode
|
|
fieldName = "ShelfBarcode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, shelfBarcode.Barcode);
|
|
#endregion
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 配置信息
|
|
PlcRecipeReader reader = getPlcRecipeReader("PptLot").FirstOrDefault();
|
|
foreach (PlcRecipeReaderItem item in reader.ItemList)
|
|
{
|
|
fieldName = item.DataFieldName;
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, PlcData.Instance.PlcLastValueRead(item.PlcFiledName));
|
|
}
|
|
#endregion
|
|
|
|
#region 执行存储
|
|
#region SDSTime
|
|
fieldName = "SDSTime";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName);
|
|
sqlstr_value.Append(valueName).AppendLine(");");
|
|
dbHelper.AddParameter(valueName, "0");
|
|
#endregion
|
|
dbHelper.CommandText = sqlstr_field.ToString() + sqlstr_value.ToString();
|
|
dbHelper.ExecuteNonQuery();
|
|
#endregion
|
|
|
|
return true;
|
|
}
|
|
#endregion
|
|
#region SavePptWeighData
|
|
private double totalRealWeight = 0;
|
|
private bool SavePptWeighData(DbHelper dbHelper)
|
|
{
|
|
BaseAction action = new BaseAction();
|
|
#region 基本信息
|
|
List<PlcRecipeReader> readerLst = getPlcRecipeReader("PptWeighData");
|
|
#endregion
|
|
foreach (PlcRecipeReader reader in readerLst)
|
|
{
|
|
int[] buff;
|
|
if (!PlcData.Instance.PlcLastValueRead(reader.PlcFiledName, out buff))
|
|
{
|
|
continue;
|
|
}
|
|
#region 称量配方
|
|
List<RecipeData.RecipeWeightInfo> recipeweight = new List<RecipeData.RecipeWeightInfo>();
|
|
for (int i = 0; i < allWeightInfo.Count; i++)
|
|
{
|
|
if (allWeightInfo[i].WeightType == reader.ThisType)
|
|
{
|
|
recipeweight.Add(allWeightInfo[i]);
|
|
}
|
|
}
|
|
if (recipeweight.Count == 0)
|
|
{
|
|
continue;
|
|
}
|
|
#endregion
|
|
int shifting = 0;
|
|
for (int i = 0; i < recipeweight.Count; i++)
|
|
{
|
|
RecipeData.RecipeWeightInfo weight = recipeweight[i];
|
|
#region 基本信息
|
|
dbHelper.CommandType = CommandType.Text;
|
|
StringBuilder sqlstr_field = new StringBuilder();
|
|
StringBuilder sqlstr_value = new StringBuilder();
|
|
string fieldName = string.Empty;
|
|
string valueName = string.Empty;
|
|
sqlstr_field.AppendLine("INSERT INTO PptWeighData(");
|
|
sqlstr_value.AppendLine(" ) VALUES (");
|
|
#region 数据整理
|
|
#region WeightID
|
|
fieldName = "WeightID";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, weight.WeightID);
|
|
#endregion
|
|
#region MaterCode
|
|
fieldName = "MaterCode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, weight.MaterialCode);
|
|
#endregion
|
|
#region MaterName
|
|
fieldName = "MaterName";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, weight.MaterialName);
|
|
#endregion
|
|
#region EquipCode
|
|
fieldName = "EquipCode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, action.CurrEquipCode);
|
|
#endregion
|
|
#region SetWeight
|
|
fieldName = "SetWeight";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, weight.SetWeight);
|
|
#endregion
|
|
#region ErrorAllow
|
|
fieldName = "ErrorAllow";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, weight.ErrorAllow);
|
|
#endregion
|
|
#region WeighTime
|
|
fieldName = "WeighTime";
|
|
valueName = "getdate()";
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
#endregion
|
|
#region WeighType
|
|
fieldName = "WeighType";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, weight.WeightType);
|
|
#endregion
|
|
#region PlanID
|
|
fieldName = "PlanID";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.PlanID);
|
|
#endregion
|
|
#region PlanDate
|
|
fieldName = "PlanDate";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, planInfo.PlanDate);
|
|
#endregion
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 配置信息
|
|
foreach (PlcRecipeReaderItem item in reader.ItemList)
|
|
{
|
|
fieldName = item.DataFieldName;
|
|
if (!fieldName.Equals("RealWeight", StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
continue;
|
|
}
|
|
int[] data = new int[item.ValueLen];
|
|
for (int idx = 0; idx < data.Length; idx++)
|
|
{
|
|
data[idx] = buff[idx + shifting];
|
|
}
|
|
shifting += item.ValueLen;
|
|
item.SetValue = data;
|
|
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
if (fieldName.Equals("RealWeight", StringComparison.CurrentCultureIgnoreCase))
|
|
{
|
|
totalRealWeight += (double)item.GetValue();
|
|
}
|
|
dbHelper.AddParameter(valueName, item.GetValue());
|
|
}
|
|
#endregion
|
|
|
|
#region 执行存储
|
|
#region Barcode
|
|
fieldName = "Barcode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine("");
|
|
sqlstr_value.Append(valueName).AppendLine(")");
|
|
dbHelper.AddParameter(valueName, BarcodeInfo.Instance.LotBarcode);
|
|
#endregion
|
|
dbHelper.CommandText = sqlstr_field.ToString() + sqlstr_value.ToString();
|
|
dbHelper.ExecuteNonQuery();
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
dbHelper.CommandText = "UPDATE PptWeighData SET ErrorOut=SetWeight-RealWeight WHERE Barcode='" + BarcodeInfo.Instance.LotBarcode + "'";
|
|
dbHelper.ExecuteNonQuery();
|
|
return true;
|
|
}
|
|
#endregion
|
|
#region SavePptMixingData
|
|
private bool SavePptMixingData(DbHelper dbHelper)
|
|
{
|
|
#region 基本信息
|
|
PlcRecipeReader reader = getPlcRecipeReader("PptMixData").FirstOrDefault();
|
|
#endregion
|
|
int[] buff;
|
|
if (!PlcData.Instance.PlcLastValueRead(reader.PlcFiledName, out buff))
|
|
{
|
|
return true;
|
|
}
|
|
int shifting = 0;
|
|
for (int i = 0; i < allMixingInfo.Count; i++)
|
|
{
|
|
RecipeData.RecipeMixingInfo mixing = allMixingInfo[i];
|
|
#region 基本信息
|
|
dbHelper.CommandType = CommandType.Text;
|
|
StringBuilder sqlstr_field = new StringBuilder();
|
|
StringBuilder sqlstr_value = new StringBuilder();
|
|
string fieldName = string.Empty;
|
|
string valueName = string.Empty;
|
|
sqlstr_field.AppendLine("INSERT INTO dbo.PptMixingData(");
|
|
sqlstr_value.AppendLine(" ) VALUES (");
|
|
#region 数据整理
|
|
#region SaveTime
|
|
fieldName = "SaveTime";
|
|
valueName = "getdate()";
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
#endregion
|
|
#region TermCode
|
|
fieldName = "MixID";
|
|
valueName = "@MixID";
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, mixing.MixingStep);
|
|
#endregion
|
|
//#region TermCode
|
|
//fieldName = "TermCode";
|
|
//valueName = "@TermCode";
|
|
//sqlstr_field.Append(fieldName).AppendLine(",");
|
|
//sqlstr_value.Append(valueName).AppendLine(",");
|
|
//dbHelper.AddParameter(valueName, mixing.TermCode);
|
|
//#endregion
|
|
//#region ActCode
|
|
//fieldName = "ActCode";
|
|
//valueName = "@ActCode";
|
|
//sqlstr_field.Append(fieldName).AppendLine(",");
|
|
//sqlstr_value.Append(valueName).AppendLine(",");
|
|
//dbHelper.AddParameter(valueName, mixing.ActionCode);
|
|
//#endregion
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 配置信息
|
|
foreach (PlcRecipeReaderItem item in reader.ItemList)
|
|
{
|
|
int[] data = new int[item.ValueLen];
|
|
for (int idx = 0; idx < data.Length; idx++)
|
|
{
|
|
data[idx] = buff[idx + shifting];
|
|
}
|
|
shifting += item.ValueLen;
|
|
item.SetValue = data;
|
|
|
|
fieldName = item.DataFieldName;
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine(",");
|
|
sqlstr_value.Append(valueName).AppendLine(",");
|
|
dbHelper.AddParameter(valueName, item.GetValue());
|
|
}
|
|
#endregion
|
|
|
|
#region 执行存储
|
|
#region Barcode
|
|
fieldName = "Barcode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine("");
|
|
sqlstr_value.Append(valueName).AppendLine(")");
|
|
dbHelper.AddParameter(valueName, BarcodeInfo.Instance.LotBarcode);
|
|
#endregion
|
|
dbHelper.CommandText = sqlstr_field.ToString() + sqlstr_value.ToString();
|
|
dbHelper.ExecuteNonQuery();
|
|
#endregion
|
|
}
|
|
return true;
|
|
}
|
|
#endregion
|
|
#region SavePptShiftConfig
|
|
private bool SavePptShiftConfig(DbHelper dbHelper)
|
|
{
|
|
return true;
|
|
BaseAction action = new BaseAction();
|
|
#region 基本信息
|
|
dbHelper.CommandType = CommandType.Text;
|
|
StringBuilder sqlstr_field = new StringBuilder();
|
|
StringBuilder sqlstr_value = new StringBuilder();
|
|
string fieldName = string.Empty;
|
|
string valueName = string.Empty;
|
|
sqlstr_field.AppendLine("INSERT INTO dbo.PptWeigh(");
|
|
sqlstr_value.AppendLine(" ) VALUES (");
|
|
#region 数据整理
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 执行存储
|
|
#region Barcode
|
|
fieldName = "Barcode";
|
|
valueName = "@" + fieldName;
|
|
sqlstr_field.Append(fieldName).AppendLine("");
|
|
sqlstr_value.Append(valueName).AppendLine(")");
|
|
dbHelper.AddParameter(valueName, "");
|
|
#endregion
|
|
dbHelper.CommandText = sqlstr_field.ToString() + sqlstr_value.ToString();
|
|
action.LogInfo(dbHelper.CommandText);
|
|
dbHelper.ExecuteNonQuery();
|
|
#endregion
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
#region SaveMixingCurve
|
|
private bool SaveMixingCurve(DbHelper dbHelper)
|
|
{
|
|
bool Result = false;
|
|
return true;
|
|
string sqlstr = "Insert into (BarCode) values ()";
|
|
dbHelper.CommandType = CommandType.Text;
|
|
dbHelper.CommandText = sqlstr;
|
|
dbHelper.ClearParameter();
|
|
dbHelper.AddParameter("", "");
|
|
dbHelper.ExecuteNonQuery();
|
|
return Result;
|
|
}
|
|
#endregion
|
|
|
|
#region 保存信息
|
|
private bool SaveInfo()
|
|
{
|
|
bool save = false;
|
|
DbHelper localHelper = getLocalHelper();
|
|
DbHelper serverHelper = getServerHelper();
|
|
try
|
|
{
|
|
localHelper.BeginTransaction();
|
|
serverHelper.BeginTransaction();
|
|
bool result = true;
|
|
totalRealWeight = 0;
|
|
if (result && IsNet()) { shelfBarcode = new ShelfBarcode(serverHelper, planInfo.PlanID, recipeInfo.ShelfLotCount); }
|
|
|
|
if (result) { result = SetLocalPlanFinishedLotCount(localHelper); }
|
|
if (result && IsNet()) { result = SetServerPlanFinishedLotCount(serverHelper); }
|
|
|
|
if (result) { result = SavePptLotData(localHelper); }
|
|
if (result && IsNet()) { result = SavePptLotData(serverHelper); }
|
|
|
|
if (result) { result = SavePptMixingData(localHelper); }
|
|
if (result && IsNet()) { result = SavePptMixingData(serverHelper); }
|
|
|
|
if (result) { result = SavePptWeighData(localHelper); }
|
|
if (result && IsNet()) { result = SavePptWeighData(serverHelper); }
|
|
|
|
if (result && IsNet()) { result = SavePptShiftConfig(serverHelper); }
|
|
if (result && IsNet()) { result = SaveMixingCurve(serverHelper); }
|
|
if (result && IsNet()) { result = UpdateCurrentShelfBarcode(serverHelper); };
|
|
if (result)
|
|
{
|
|
localHelper.CommitTransaction();
|
|
serverHelper.CommitTransaction();
|
|
save = true;
|
|
}
|
|
else
|
|
{
|
|
localHelper.RollbackTransaction();
|
|
serverHelper.RollbackTransaction();
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
localHelper.RollbackTransaction();
|
|
serverHelper.RollbackTransaction();
|
|
}
|
|
finally
|
|
{
|
|
localHelper.CloseConnection();
|
|
serverHelper.CloseConnection();
|
|
}
|
|
return save;
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 存盘数据
|
|
private class MixingInfo
|
|
{
|
|
#region 单例实现
|
|
|
|
private static MixingInfo instance;
|
|
public static MixingInfo Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new MixingInfo();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private MixingInfo()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 上次存盘密炼开始时间
|
|
/// </summary>
|
|
public DateTime LastFinishedBatchMixingStaretTime { get; set; }
|
|
}
|
|
private void SaveFinishBatchData()
|
|
{
|
|
ReadPlcSaveData();
|
|
BaseAction action = new BaseAction();
|
|
DbHelper dbHelper = getLocalHelper();
|
|
|
|
//当前计划车数
|
|
int planLotCount = planExecuteData.RecipeSetNumber;
|
|
//完成当前计划车数
|
|
int finishLotCount = planExecuteData.MixingFinishedCount;
|
|
if (finishLotCount == 0)
|
|
{
|
|
action.LogDebug("清除错误的存盘信号:" + finishLotCount.ToString());
|
|
FinishedOneReset();
|
|
return;
|
|
}
|
|
if (finishLotCount <= planLotCount && finishLotCount > 0)
|
|
{
|
|
action.LogDebug("存盘信号:" + finishLotCount.ToString());
|
|
//读取本次存盘信号时间和保存的全局上次时间对比,相同则退出
|
|
if (MixingInfo.Instance.LastFinishedBatchMixingStaretTime == planExecuteData.MixingStartTime)
|
|
{
|
|
action.LogDebug("清除重复的存盘信号:" + finishLotCount.ToString());
|
|
FinishedOneReset();
|
|
return;
|
|
}
|
|
IniCurrentLotBarcode();
|
|
if (HasSaveBarCode())
|
|
{
|
|
action.LogDebug("条码存在:" + BarcodeInfo.Instance.LotBarcode);
|
|
FinishedOneReset();
|
|
return;
|
|
}
|
|
action.LogDebug("开始存盘:" + BarcodeInfo.Instance.LotBarcode);
|
|
if (SaveInfo())
|
|
{
|
|
MixingInfo.Instance.LastFinishedBatchMixingStaretTime = planExecuteData.MixingStartTime;
|
|
FinishedOneReset();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 密炼曲线
|
|
private class CurveInfo
|
|
{
|
|
#region 单例实现
|
|
|
|
private static CurveInfo instance;
|
|
|
|
public static CurveInfo Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new CurveInfo();
|
|
}
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private CurveInfo()
|
|
{
|
|
this.MixingCurve = new StringBuilder();
|
|
this.MixTimeStr = new StringBuilder();
|
|
this.MixTempStr = new StringBuilder();
|
|
this.MixPowerStr = new StringBuilder();
|
|
this.MixEnerStr = new StringBuilder();
|
|
this.MixPressStr = new StringBuilder();
|
|
this.MixSpeedStr = new StringBuilder();
|
|
}
|
|
#endregion
|
|
/// <summary>
|
|
/// 密炼曲线
|
|
/// </summary>
|
|
public StringBuilder MixingCurve { get; set; }
|
|
/// <summary>
|
|
/// 密炼时间
|
|
/// </summary>
|
|
public StringBuilder MixTimeStr { get; set; }
|
|
/// <summary>
|
|
/// 密炼温度
|
|
/// </summary>
|
|
public StringBuilder MixTempStr { get; set; }
|
|
/// <summary>
|
|
/// 密炼功率
|
|
/// </summary>
|
|
public StringBuilder MixPowerStr { get; set; }
|
|
/// <summary>
|
|
/// 密炼能量
|
|
/// </summary>
|
|
public StringBuilder MixEnerStr { get; set; }
|
|
/// <summary>
|
|
/// 密炼压力
|
|
/// </summary>
|
|
public StringBuilder MixPressStr { get; set; }
|
|
/// <summary>
|
|
/// 密炼转速
|
|
/// </summary>
|
|
public StringBuilder MixSpeedStr { get; set; }
|
|
}
|
|
public void MixingData()
|
|
{
|
|
PlanLog currentPlan = Global.Deserialize<PlanLog>(PlanCommon.PlanLogFile);
|
|
if (currentPlan == null)
|
|
{
|
|
return;
|
|
}
|
|
#region 数据字符串
|
|
double mixingTime = PlcData.Instance.CurrentMixingTime.LastValue.ToDouble();
|
|
double mixingTemp = PlcData.Instance.CurrentMixingTemp.LastValue.ToDouble();
|
|
double mixingPower = PlcData.Instance.CurrentMixingPower.LastValue.ToDouble();
|
|
double mixingEnergy = PlcData.Instance.CurrentMixingEnergy.LastValue.ToDouble();
|
|
double mixingPressureRam = PlcData.Instance.CurrentMixingPressureRam.LastValue.ToDouble();
|
|
double mixingSpeedRotor = PlcData.Instance.CurrentMixingSpeedRotor.LastValue.ToDouble();
|
|
double mixingHoopPerstion = PlcData.Instance.CurrentMixingHoopPerstion.LastValue.ToDouble();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append(String.Format("{0:N2}", mixingTime)).Append(":");
|
|
sb.Append(String.Format("{0:N2}", mixingTemp)).Append(":");
|
|
sb.Append(String.Format("{0:N2}", mixingPower)).Append(":");
|
|
sb.Append(String.Format("{0:N2}", mixingEnergy)).Append(":");
|
|
sb.Append(String.Format("{0:N2}", mixingPressureRam)).Append(":");
|
|
sb.Append(String.Format("{0:N2}", mixingSpeedRotor)).Append(":");
|
|
sb.Append(String.Format("{0:N2}", mixingHoopPerstion)).Append("/");
|
|
CurveInfo.Instance.MixingCurve.Append(sb);
|
|
CurveInfo.Instance.MixTimeStr.Append(String.Format("{0:N2}", mixingTime)).Append(":");
|
|
CurveInfo.Instance.MixTempStr.Append(String.Format("{0:N2}", mixingTemp)).Append(":");
|
|
CurveInfo.Instance.MixPowerStr.Append(String.Format("{0:N2}", mixingPower)).Append(":");
|
|
CurveInfo.Instance.MixEnerStr.Append(String.Format("{0:N2}", mixingEnergy)).Append(":");
|
|
CurveInfo.Instance.MixPressStr.Append(String.Format("{0:N2}", mixingPressureRam)).Append(":");
|
|
CurveInfo.Instance.MixSpeedStr.Append(String.Format("{0:N2}", mixingSpeedRotor)).Append(":");
|
|
if (mixingTime < 2 && CurveInfo.Instance.MixingCurve.Length > 1000)
|
|
{
|
|
CurveInfo.Instance.MixingCurve = new StringBuilder();
|
|
|
|
CurveInfo.Instance.MixTimeStr = new StringBuilder();
|
|
CurveInfo.Instance.MixTempStr = new StringBuilder();
|
|
CurveInfo.Instance.MixPowerStr = new StringBuilder();
|
|
CurveInfo.Instance.MixEnerStr = new StringBuilder();
|
|
CurveInfo.Instance.MixPressStr = new StringBuilder();
|
|
CurveInfo.Instance.MixSpeedStr = new StringBuilder();
|
|
}
|
|
#endregion
|
|
DbHelper dbHelper = getLocalHelper();
|
|
RecipeData recipeData = new RecipeData();
|
|
string planID = recipeData.GetCurrentPlanID();
|
|
string socketSendstr = sb.ToString() + Global.ProtocalHeader.ReceivePlanIdIpNumber + ":" + planID + "/";
|
|
Mesnac.Communication.TcpService.Instance.NetSendMsg(socketSendstr);
|
|
|
|
//计划总数
|
|
int plansCount = recipeData.GetPlansCount();
|
|
//完成计划数
|
|
int finishPlansCount = recipeData.GetCurrentPlanIndex();
|
|
|
|
if (finishPlansCount <= plansCount)
|
|
{
|
|
if (PlcData.Instance.FinishedBatch.LastValue.ToInt() == 1)
|
|
{
|
|
SaveFinishBatchData();
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
public class MixingCurve : FeedingAction, IAction
|
|
{
|
|
SaveMixingData data = new SaveMixingData();
|
|
private void timersTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
timersTimer.Enabled = false;
|
|
try
|
|
{
|
|
data.MixingData();
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
timersTimer.Enabled = true;
|
|
}
|
|
|
|
System.Timers.Timer timersTimer = new System.Timers.Timer();
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
timersTimer.Elapsed += new System.Timers.ElapsedEventHandler(timersTimer_Elapsed);
|
|
timersTimer.Interval = 1000;
|
|
timersTimer.Enabled = true;
|
|
}
|
|
}
|
|
}
|