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.

882 lines
32 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Action.Intake.Qingquan.BasicInfo;
using Mesnac.Basic;
using Mesnac.Codd.Session;
using Mesnac.Action.Base;
using System.Data;
namespace Mesnac.Action.Intake.Qingquan.SaveData.Helper
{
/// <summary>
/// 实时读取数据区
/// </summary>
public class InstantData
{
private int _watchDog;//通讯检测
public int WatchDog
{
get { return _watchDog; }
set { _watchDog = value; }
}
private int _selVesselRem;//选择罐组
public int SelVesselRem
{
get { return _selVesselRem; }
set { _selVesselRem = value; }
}
private int _selMixerRem;//选择机台
public int SelMixerRem
{
get { return _selMixerRem; }
set { _selMixerRem = value; }
}
private int _selDaybinRem;//选择日罐
public int SelDaybinRem
{
get { return _selDaybinRem; }
set { _selDaybinRem = value; }
}
private int _selVesselLoc;//现场选择罐组
public int SelVesselLoc
{
get { return _selVesselLoc; }
set { _selVesselLoc = value; }
}
private int _selMixerLoc;//现场选择机台
public int SelMixerLoc
{
get { return _selMixerLoc; }
set { _selMixerLoc = value; }
}
private int _selDaybinLoc;//现场选择日罐
public int SelDaybinLoc
{
get { return _selDaybinLoc; }
set { _selDaybinLoc = value; }
}
private int _debugMode;//下位机维护模式
public int DebugMode
{
get { return _debugMode; }
set { _debugMode = value; }
}
private int _finishedFlag;//称量数据存盘标志
public int FinishedFlag
{
get { return _finishedFlag; }
set { _finishedFlag = value; }
}
}
/// <summary>
/// 罐组数据区解析类
/// </summary>
public class VesselsHandler
{
private static List<VesselsHandler> _instances
= new List<VesselsHandler>() { new VesselsHandler(), new VesselsHandler(), new VesselsHandler(), new VesselsHandler() };
public static List<VesselsHandler> Instances
{
get
{
return _instances;
}
}
private int _automatic; //自动
public int Automatic
{
get { return _automatic; }
set { _automatic = value; }
}
private int _manual; //手动
public int Manual
{
get { return _manual; }
set { _manual = value; }
}
private int _conveying; //输送
public int Conveying
{
get { return _conveying; }
set { _conveying = value; }
}
private int _purging; //清扫
public int Purging
{
get { return _purging; }
set { _purging = value; }
}
private int _fault; //故障
public int Fault
{
get { return _fault; }
set { _fault = value; }
}
private int _acknoledge; //等待确认
public int Acknoledge
{
get { return _acknoledge; }
set { _acknoledge = value; }
}
private int _startFlag; //罐开始标志
public int StartFlag
{
get { return _startFlag; }
set { _startFlag = value; }
}
private int _saveFlag; //存盘准备好
public int SaveFlag
{
get { return _saveFlag; }
set { _saveFlag = value; }
}
private int _topAir;//压送罐压力
public int TopAir
{
get { return _topAir; }
set { _topAir = value; }
}
private int _conveyAir;//压送罐出口压力
public int ConveyAir
{
get { return _conveyAir; }
set { _conveyAir = value; }
}
private int _bypass1;//管路压力1
public int Bypass1
{
get { return _bypass1; }
set { _bypass1 = value; }
}
private int _bypass2;//管路压力
public int Bypass2
{
get { return _bypass2; }
set { _bypass2 = value; }
}
private int _bypass3;//管路压力
public int Bypass3
{
get { return _bypass3; }
set { _bypass3 = value; }
}
private int _bypass4;//管路压力
public int Bypass4
{
get { return _bypass4; }
set { _bypass4 = value; }
}
private int _bypass5;//管路压力
public int Bypass5
{
get { return _bypass5; }
set { _bypass5 = value; }
}
private int _bypass6;//管路压力
public int Bypass6
{
get { return _bypass6; }
set { _bypass6 = value; }
}
private int _bypass7;//管路压力
public int Bypass7
{
get { return _bypass7; }
set { _bypass7 = value; }
}
private int _bypass8;//管路压力
public int Bypass8
{
get { return _bypass8; }
set { _bypass8 = value; }
}
private int _bypass9;//管路压力
public int Bypass9
{
get { return _bypass9; }
set { _bypass9 = value; }
}
private int _bypass10;//管路压力
public int Bypass10
{
get { return _bypass10; }
set { _bypass10 = value; }
}
private int _sysInfo; //系统步序信息
public int SysInfo
{
get { return _sysInfo; }
set { _sysInfo = value; }
}
public void ResetStartedFlagToPlC(int i)
{
int readword = 0;
if (i == 1)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G1_StartFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G1_StartFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G1_StartFlag失败写入PLC失败");
}
}
if (i == 2)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G2_StartFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G2_StartFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G2_StartFlag失败写入PLC失败");
}
}
if (i == 3)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G3_StartFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G3_StartFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G3_StartFlag失败写入PLC失败");
}
}
if (i == 4)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G4_StartFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G4_StartFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G4_StartFlag失败写入PLC失败");
}
}
}
public void ResetSaveFlagToPlC(int i)
{
int readword = 0;
if (i == 1)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G1_SaveFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G1_SaveFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G1_SaveFlag失败写入PLC失败");
}
}
if (i == 2)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G2_SaveFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G2_SaveFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G2_SaveFlag失败写入PLC失败");
}
}
if (i == 3)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G3_SaveFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G3_SaveFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G3_SaveFlag失败写入PLC失败");
}
}
if (i == 4)
{
if (PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.G4_SaveFlag, new object[] { readword }))
{
ICSharpCode.Core.LoggingService.Debug("重置G4_SaveFlag成功!");
}
else
{
ICSharpCode.Core.LoggingService.Error("重置G4_SaveFlag失败写入PLC失败");
}
}
}
#region 解析方法
/// <summary>
/// 解析方法
/// </summary>
public void ParseDataFromPlc(int i)
{
if (i == 1)
{
this.Automatic = PlcData.Instance.G1_Automatic.LastValue.ToInt();
this.Manual = PlcData.Instance.G1_Manual.LastValue.ToInt();
this.Conveying = PlcData.Instance.G1_Conveying.LastValue.ToInt();
this.Purging = PlcData.Instance.G1_Purging.LastValue.ToInt();
this.Fault = PlcData.Instance.G1_Fault.LastValue.ToInt();
this.Acknoledge = PlcData.Instance.G1_Acknoledge.LastValue.ToInt();
this.StartFlag = PlcData.Instance.G1_StartFlag.LastValue.ToInt();
this.SaveFlag = PlcData.Instance.G1_SaveFlag.LastValue.ToInt();
this.TopAir = PlcData.Instance.G1_TopAir.LastValue.ToInt();
this.ConveyAir = PlcData.Instance.G1_ConveyAir.LastValue.ToInt();
this.Bypass1 = PlcData.Instance.G1_Bypass1.LastValue.ToInt();
this.Bypass2 = PlcData.Instance.G1_Bypass2.LastValue.ToInt();
this.Bypass3 = PlcData.Instance.G1_Bypass3.LastValue.ToInt();
this.Bypass4 = PlcData.Instance.G1_Bypass4.LastValue.ToInt();
this.Bypass5 = PlcData.Instance.G1_Bypass5.LastValue.ToInt();
this.Bypass6 = PlcData.Instance.G1_Bypass6.LastValue.ToInt();
this.Bypass7 = PlcData.Instance.G1_Bypass7.LastValue.ToInt();
this.Bypass8 = PlcData.Instance.G1_Bypass8.LastValue.ToInt();
this.Bypass9 = PlcData.Instance.G1_Bypass9.LastValue.ToInt();
// this.SysInfo = PlcData.Instance.G1_SysInfo.LastValue.ToInt();
}
if (i == 2)
{
this.Automatic = PlcData.Instance.G2_Automatic.LastValue.ToInt();
this.Manual = PlcData.Instance.G2_Manual.LastValue.ToInt();
this.Conveying = PlcData.Instance.G2_Conveying.LastValue.ToInt();
this.Purging = PlcData.Instance.G2_Purging.LastValue.ToInt();
this.Fault = PlcData.Instance.G2_Fault.LastValue.ToInt();
this.Acknoledge = PlcData.Instance.G2_Acknoledge.LastValue.ToInt();
this.StartFlag = PlcData.Instance.G2_StartFlag.LastValue.ToInt();
this.SaveFlag = PlcData.Instance.G2_SaveFlag.LastValue.ToInt();
this.TopAir = PlcData.Instance.G2_TopAir.LastValue.ToInt();
this.ConveyAir = PlcData.Instance.G2_ConveyAir.LastValue.ToInt();
this.Bypass1 = PlcData.Instance.G2_Bypass1.LastValue.ToInt();
this.Bypass2 = PlcData.Instance.G2_Bypass2.LastValue.ToInt();
this.Bypass3 = PlcData.Instance.G2_Bypass3.LastValue.ToInt();
this.Bypass4 = PlcData.Instance.G2_Bypass4.LastValue.ToInt();
this.Bypass5 = PlcData.Instance.G2_Bypass5.LastValue.ToInt();
this.Bypass6 = PlcData.Instance.G2_Bypass6.LastValue.ToInt();
this.Bypass7 = PlcData.Instance.G2_Bypass7.LastValue.ToInt();
this.Bypass8 = PlcData.Instance.G2_Bypass8.LastValue.ToInt();
this.Bypass9 = PlcData.Instance.G2_Bypass9.LastValue.ToInt();
// this.SysInfo = PlcData.Instance.G2_SysInfo.LastValue.ToInt();
}
if (i == 3)
{
this.Automatic = PlcData.Instance.G3_Automatic.LastValue.ToInt();
this.Manual = PlcData.Instance.G3_Manual.LastValue.ToInt();
this.Conveying = PlcData.Instance.G3_Conveying.LastValue.ToInt();
this.Purging = PlcData.Instance.G3_Purging.LastValue.ToInt();
this.Fault = PlcData.Instance.G3_Fault.LastValue.ToInt();
this.Acknoledge = PlcData.Instance.G3_Acknoledge.LastValue.ToInt();
this.StartFlag = PlcData.Instance.G3_StartFlag.LastValue.ToInt();
this.SaveFlag = PlcData.Instance.G3_SaveFlag.LastValue.ToInt();
this.TopAir = PlcData.Instance.G3_TopAir.LastValue.ToInt();
this.ConveyAir = PlcData.Instance.G3_ConveyAir.LastValue.ToInt();
this.Bypass1 = PlcData.Instance.G3_Bypass1.LastValue.ToInt();
this.Bypass2 = PlcData.Instance.G3_Bypass2.LastValue.ToInt();
this.Bypass3 = PlcData.Instance.G3_Bypass3.LastValue.ToInt();
this.Bypass4 = PlcData.Instance.G3_Bypass4.LastValue.ToInt();
this.Bypass5 = PlcData.Instance.G3_Bypass5.LastValue.ToInt();
this.Bypass6 = PlcData.Instance.G3_Bypass6.LastValue.ToInt();
this.Bypass7 = PlcData.Instance.G3_Bypass7.LastValue.ToInt();
this.Bypass8 = PlcData.Instance.G3_Bypass8.LastValue.ToInt();
this.Bypass9 = PlcData.Instance.G3_Bypass9.LastValue.ToInt();
// this.SysInfo = PlcData.Instance.G3_SysInfo.LastValue.ToInt();
}
if (i == 4)
{
this.Automatic = PlcData.Instance.G4_Automatic.LastValue.ToInt();
this.Manual = PlcData.Instance.G4_Manual.LastValue.ToInt();
this.Conveying = PlcData.Instance.G4_Conveying.LastValue.ToInt();
this.Purging = PlcData.Instance.G4_Purging.LastValue.ToInt();
this.Fault = PlcData.Instance.G4_Fault.LastValue.ToInt();
this.Acknoledge = PlcData.Instance.G4_Acknoledge.LastValue.ToInt();
this.StartFlag = PlcData.Instance.G4_StartFlag.LastValue.ToInt();
this.SaveFlag = PlcData.Instance.G4_SaveFlag.LastValue.ToInt();
this.TopAir = PlcData.Instance.G4_TopAir.LastValue.ToInt();
this.ConveyAir = PlcData.Instance.G4_ConveyAir.LastValue.ToInt();
this.Bypass1 = PlcData.Instance.G4_Bypass1.LastValue.ToInt();
this.Bypass2 = PlcData.Instance.G4_Bypass2.LastValue.ToInt();
this.Bypass3 = PlcData.Instance.G4_Bypass3.LastValue.ToInt();
this.Bypass4 = PlcData.Instance.G4_Bypass4.LastValue.ToInt();
this.Bypass5 = PlcData.Instance.G4_Bypass5.LastValue.ToInt();
this.Bypass6 = PlcData.Instance.G4_Bypass6.LastValue.ToInt();
this.Bypass7 = PlcData.Instance.G4_Bypass7.LastValue.ToInt();
this.Bypass8 = PlcData.Instance.G4_Bypass8.LastValue.ToInt();
this.Bypass9 = PlcData.Instance.G4_Bypass9.LastValue.ToInt();
// this.SysInfo = PlcData.Instance.G4_SysInfo.LastValue.ToInt();
}
}
#endregion
}
/// <summary>
/// 存盘数据区解析类
/// </summary>
public class SaveDataHandler
{
private static List<SaveDataHandler> _instances
= new List<SaveDataHandler>() { new SaveDataHandler(), new SaveDataHandler(), new SaveDataHandler(), new SaveDataHandler() };
public static List<SaveDataHandler> Instances
{
get
{
return _instances;
}
}
#region 字段定义
private DateTime _startTime;//开始日期时间
private string _currentTime;//开始时间
private int _totalTime;//总时间
private int _chargeTime;//加料时间
private int _airationTime;//憋压时间
private int _dischargeTime;//压送时间
private int _purgeTime;//清扫时间
private int _destNo;//目标罐号
private int _destBinType;//目标罐类型
private int _sourceBinNo;//源罐号
private int _sourceBinType;//源罐类型
private int _destMixer;//目标机台
private int _spare;//预留1
#endregion
#region 属性定义
public DateTime StartTime
{
get { return _startTime; }
set { _startTime = value; }
}
public string CurrentTime
{
get { return _currentTime; }
set { _currentTime = value; }
}
public int TotalTime
{
get { return _totalTime; }
set { _totalTime = value; }
}
public int ChargeTime
{
get { return _chargeTime; }
set { _chargeTime = value; }
}
public int AirationTime
{
get { return _airationTime; }
set { _airationTime = value; }
}
public int DischargeTime
{
get { return _dischargeTime; }
set { _dischargeTime = value; }
}
public int PurgeTime
{
get { return _purgeTime; }
set { _purgeTime = value; }
}
public int DestNo
{
get { return _destNo; }
set { _destNo = value; }
}
public int DestBinType
{
get { return _destBinType; }
set { _destBinType = value; }
}
public int SourceBinNo
{
get { return _sourceBinNo; }
set { _sourceBinNo = value; }
}
public int SourceBinType
{
get { return _sourceBinType; }
set { _sourceBinType = value; }
}
public int DestMixer
{
get { return _destMixer; }
set { _destMixer = value; }
}
public int Spare
{
get { return _spare; }
set { _spare = value; }
}
#endregion
#region 解析方法
/// <summary>
/// 解析方法
/// </summary>
public void ParseDataFromPlc(int i)
{
if (i == 1)
{
this.TotalTime = PlcData.Instance.G1_TotalTime.LastValue.ToInt();
this.ChargeTime = PlcData.Instance.G1_ChargeTime.LastValue.ToInt();
this.AirationTime = PlcData.Instance.G1_AirationTime.LastValue.ToInt();
this.DischargeTime = PlcData.Instance.G1_DischargeTime.LastValue.ToInt();
this.PurgeTime = PlcData.Instance.G1_PurgeTime.LastValue.ToInt();
this.DestNo = PlcData.Instance.G1_DestNo.LastValue.ToInt();
this.DestBinType = PlcData.Instance.G1_DestBinType.LastValue.ToInt();
this.SourceBinNo = PlcData.Instance.G1_SourceBinNo.LastValue.ToInt();
this.SourceBinType = PlcData.Instance.G1_SourceBinType.LastValue.ToInt();
this.DestMixer = PlcData.Instance.G1_DestMixer.LastValue.ToInt();
this.Spare = PlcData.Instance.G1_Spare1.LastValue.ToInt();
}
if (i == 2)
{
this.TotalTime = PlcData.Instance.G2_TotalTime.LastValue.ToInt();
this.ChargeTime = PlcData.Instance.G2_ChargeTime.LastValue.ToInt();
this.AirationTime = PlcData.Instance.G2_AirationTime.LastValue.ToInt();
this.DischargeTime = PlcData.Instance.G2_DischargeTime.LastValue.ToInt();
this.PurgeTime = PlcData.Instance.G2_PurgeTime.LastValue.ToInt();
this.DestNo = PlcData.Instance.G2_DestNo.LastValue.ToInt();
this.DestBinType = PlcData.Instance.G2_DestBinType.LastValue.ToInt();
this.SourceBinNo = PlcData.Instance.G2_SourceBinNo.LastValue.ToInt();
this.SourceBinType = PlcData.Instance.G2_SourceBinType.LastValue.ToInt();
this.DestMixer = PlcData.Instance.G2_DestMixer.LastValue.ToInt();
this.Spare = PlcData.Instance.G2_Spare1.LastValue.ToInt();
}
if (i == 3)
{
this.TotalTime = PlcData.Instance.G3_TotalTime.LastValue.ToInt();
this.ChargeTime = PlcData.Instance.G3_ChargeTime.LastValue.ToInt();
this.AirationTime = PlcData.Instance.G3_AirationTime.LastValue.ToInt();
this.DischargeTime = PlcData.Instance.G3_DischargeTime.LastValue.ToInt();
this.PurgeTime = PlcData.Instance.G3_PurgeTime.LastValue.ToInt();
this.DestNo = PlcData.Instance.G3_DestNo.LastValue.ToInt();
this.DestBinType = PlcData.Instance.G3_DestBinType.LastValue.ToInt();
this.SourceBinNo = PlcData.Instance.G3_SourceBinNo.LastValue.ToInt();
this.SourceBinType = PlcData.Instance.G3_SourceBinType.LastValue.ToInt();
this.DestMixer = PlcData.Instance.G3_DestMixer.LastValue.ToInt();
this.Spare = PlcData.Instance.G3_Spare1.LastValue.ToInt();
}
if (i == 4)
{
this.TotalTime = PlcData.Instance.G4_TotalTime.LastValue.ToInt();
this.ChargeTime = PlcData.Instance.G4_ChargeTime.LastValue.ToInt();
this.AirationTime = PlcData.Instance.G4_AirationTime.LastValue.ToInt();
this.DischargeTime = PlcData.Instance.G4_DischargeTime.LastValue.ToInt();
this.PurgeTime = PlcData.Instance.G4_PurgeTime.LastValue.ToInt();
this.DestNo = PlcData.Instance.G4_DestNo.LastValue.ToInt();
this.DestBinType = PlcData.Instance.G4_DestBinType.LastValue.ToInt();
this.SourceBinNo = PlcData.Instance.G4_SourceBinNo.LastValue.ToInt();
this.SourceBinType = PlcData.Instance.G4_SourceBinType.LastValue.ToInt();
this.DestMixer = PlcData.Instance.G4_DestMixer.LastValue.ToInt();
this.Spare = PlcData.Instance.G4_Spare1.LastValue.ToInt();
}
}
#endregion
/// <summary>
/// 保存曲线信息到本地数据库
/// </summary>
/// <returns>保存成功返回true保存失败返回false</returns>
public bool SaveDataToDB(int GroupID, String ID)
{
DbHelper curveHelper = new IntakeAction().NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
if (curveHelper == null)
{
return false;
}
string MaterCode = "";
string MaterName = "";
string sqlstr = "";
try
{
sqlstr = @"INSERT INTO ppt_FeedingData
(Serial_ID, Trans_Date, Mater_Code,Mater_Name,Source_Type,Source_Bin,
Equip_ID,Dest_Type, Dest_Bin,Start_Time, Charge_Time, Airation_Time, Discharge_Time,Purge_Time,Total_Time, Supplier_id )
VALUES
(@Serial_ID, @Trans_Date, @Mater_Code,@Mater_Name,@Source_Type,@Source_Bin,
@Equip_ID,@Dest_Type, @Dest_Bin,@Start_Time, @Charge_Time, @Airation_Time, @Discharge_Time,@Purge_Time,@Total_Time, @Supplier_id ) ";
curveHelper.CommandType = CommandType.Text;
curveHelper.CommandText = sqlstr;
curveHelper.ClearParameter();
curveHelper.AddParameter("@Serial_ID", GroupID.ToString() + ID);
curveHelper.AddParameter("@Trans_Date", string.Format("{0:yyyy-MM-dd}", DateTime.Now));
curveHelper.AddParameter("@Mater_Code", MaterCode);
curveHelper.AddParameter("@Mater_Name", MaterName);
curveHelper.AddParameter("@Source_Type", this.SourceBinType.ToString());
curveHelper.AddParameter("@Source_Bin", this.SourceBinNo.ToString());
curveHelper.AddParameter("@Equip_ID", this.DestMixer.ToString());
curveHelper.AddParameter("@Dest_Type", this.DestBinType.ToString());
curveHelper.AddParameter("@Dest_Bin", this.DestMixer.ToString());
curveHelper.AddParameter("@Start_Time", this.StartTime.ToString());
curveHelper.AddParameter("@Charge_Time", this.ChargeTime.ToString());
curveHelper.AddParameter("@Airation_Time", this.AirationTime.ToString());
curveHelper.AddParameter("@Discharge_Time", this.DischargeTime.ToString());
curveHelper.AddParameter("@Purge_Time", this.PurgeTime.ToString());
curveHelper.AddParameter("@Total_Time", this.TotalTime.ToString());
curveHelper.AddParameter("@Supplier_id", "");
curveHelper.ExecuteNonQuery();
return true;
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService.Error("曲线数据存盘失败:" + ex.Message);
return false;
}
}
}
/// <summary>
/// 曲线数据区解析类
/// </summary>
public class SaveCurveDataHandler
{
private static List<SaveCurveDataHandler> _instances
= new List<SaveCurveDataHandler>() { new SaveCurveDataHandler(), new SaveCurveDataHandler(), new SaveCurveDataHandler(), new SaveCurveDataHandler() };
public static List<SaveCurveDataHandler> Instances
{
get
{
return _instances;
}
}
private bool _started;//开始记录曲线标志
public bool Started
{
get { return _started; }
set { _started = value; }
}
private string _topAir;//压送罐压力
public string TopAir
{
get { return _topAir; }
set { _topAir = value; }
}
private string _conveyAir;//压送罐出口压力
public string ConveyAir
{
get { return _conveyAir; }
set { _conveyAir = value; }
}
private string _bypass1;//管路压力1
public string Bypass1
{
get { return _bypass1; }
set { _bypass1 = value; }
}
private string _bypass2;//管路压力
public string Bypass2
{
get { return _bypass2; }
set { _bypass2 = value; }
}
private string _bypass3;//管路压力
public string Bypass3
{
get { return _bypass3; }
set { _bypass3 = value; }
}
private string _bypass4;//管路压力
public string Bypass4
{
get { return _bypass4; }
set { _bypass4 = value; }
}
private string _bypass5;//管路压力
public string Bypass5
{
get { return _bypass5; }
set { _bypass5 = value; }
}
private string _bypass6;//管路压力
public string Bypass6
{
get { return _bypass6; }
set { _bypass6 = value; }
}
private string _bypass7;//管路压力
public string Bypass7
{
get { return _bypass7; }
set { _bypass7 = value; }
}
private string _bypass8;//管路压力
public string Bypass8
{
get { return _bypass8; }
set { _bypass8 = value; }
}
private string _bypass9;//管路压力
public string Bypass9
{
get { return _bypass9; }
set { _bypass9 = value; }
}
private string _bypass10;//管路压力
public string Bypass10
{
get { return _bypass10; }
set { _bypass10 = value; }
}
public void ClearCurve()
{
this._topAir = "";
this._conveyAir = "";
this._bypass1 = "";
this._bypass2 = "";
this._bypass3 = "";
this._bypass4 = "";
this._bypass5 = "";
this._bypass6 = "";
this._bypass7 = "";
this._bypass8 = "";
this._bypass9 = "";
this._bypass10 = "";
}
/// <summary>
/// 保存曲线信息到本地数据库
/// </summary>
/// <returns>保存成功返回true保存失败返回false</returns>
///
public bool SaveCurveToDB(int GroupID, String ID)
{
DbHelper curveHelper = new IntakeAction().NewDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
if (curveHelper == null)
{
return false;
}
string sqlstr = "";
try
{
sqlstr = @"INSERT INTO ppt_CurveData
( Serial_ID, Trans_Date, TopAir, ConveyAir, Bypass1, Bypass2, Bypass3, Bypass4,
Bypass5, Bypass6, Bypass7, Bypass8, Bypass9, Bypass10
) VALUES (
@Serial_ID,@Trans_Date,@TopAir,@ConveyAir,@Bypass1,@Bypass2,@Bypass3,@Bypass4,
@Bypass5,@Bypass6,@Bypass7,@Bypass8,@Bypass9,@Bypass10)";
curveHelper.CommandType = CommandType.Text;
curveHelper.CommandText = sqlstr;
curveHelper.ClearParameter();
curveHelper.AddParameter("@Serial_ID", GroupID.ToString() + ID);
curveHelper.AddParameter("@Trans_Date", string.Format("{0:yyyy-MM-dd}", DateTime.Now));
curveHelper.AddParameter("@TopAir", this.TopAir.ToString());
curveHelper.AddParameter("@ConveyAir", this.ConveyAir.ToString());
curveHelper.AddParameter("@Bypass1", this.Bypass1.ToString());
curveHelper.AddParameter("@Bypass2", this.Bypass2.ToString());
curveHelper.AddParameter("@Bypass3", this.Bypass3.ToString());
curveHelper.AddParameter("@Bypass4", this.Bypass4.ToString());
curveHelper.AddParameter("@Bypass5", this.Bypass5.ToString());
curveHelper.AddParameter("@Bypass6", this.Bypass6.ToString());
curveHelper.AddParameter("@Bypass7", this.Bypass7.ToString());
curveHelper.AddParameter("@Bypass8", this.Bypass8.ToString());
curveHelper.AddParameter("@Bypass9", this.Bypass9.ToString());
curveHelper.AddParameter("@Bypass10", this.Bypass10.ToString());
curveHelper.ExecuteNonQuery();
this.Started = false;
return true;
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService.Error("曲线数据存盘失败:" + ex.Message);
return false;
}
}
}
}