change - 自动控制代码重构

wangsr
wangsr 1 year ago
parent 051c41da3d
commit 564616b7bf

@ -0,0 +1,81 @@
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Basic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
public static class AutoLogHelper
{
/// <summary>
/// 无数据log
/// </summary>
/// <param name="logText">log说明</param>
/// <param name="RadioE">产线选择</param>
public static void SingleLog(string logText, MCRadioButtonEntity RadioE)
{
Auto_Log log = new Auto_Log()
{
ActionKind = logText,
LogTime = DateTime.Now,
LineNo = ControlsHelper.SingleSelect(RadioE),
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
};
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
}
public static void ManualWeightLog(float w, float t, MCRadioButtonEntity RadioE)
{
Auto_Log log = new Auto_Log()
{
ActionKind = "手动下黑粉",
LogTime = DateTime.Now,
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
ManualTolerance = t,
LineNo = ControlsHelper.SingleSelect(RadioE),
ManualWeight = w,
};
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
}
public static void GWlog(List<RecipePlcView> recipes, List<Step> steps, List<MixStep> mixSteps, MCRadioButtonEntity RadioE)
{
Auto_Log log = new Auto_Log()
{
ActionKind = "糊化湿混数据下传",
LogTime = DateTime.Now,
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
LineNo = ControlsHelper.SingleSelect(RadioE),
MaterialBin1 = recipes[0].Bin,
MaterialBin2 = recipes[1].Bin,
MaterialWeight1 = recipes[0].Set,
MaterialWeight2 = recipes[1].Set,
MaterialTolerance1 = recipes[0].Tolerance,
MaterialTolerance2 = recipes[1].Tolerance,
GelSpeedSet = steps[0].MixSpeed,
GelPosTimeA = steps[2].MixTemp,
GelNagTimeB = steps[2].MixSpeed,
GelPosTimeC = steps[2].MixTime,
GelWaterTime = steps[4].MixTime,
GelWaitTime = steps[6].MixTime,
GelCloseHeatTime = steps[7].MixTime,
GelOutDelayTime = steps[7].MixTemp,
WetDryWeight = mixSteps[1].SetValue,
WetMixTime = mixSteps[2].MixTime,
WetOutDelayTime = mixSteps[4].MixTime
};
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
}
}
}

@ -39,5 +39,77 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
}
}
/// <summary>
/// 单选选择
/// </summary>
/// <returns>返回单选的产线号 如果未选择返回0</returns>
public static int SingleSelect(MCRadioButtonEntity RadioE)
{
int no = 0;
if (Convert.ToBoolean(RadioE.Line1.MCValue))
{
no = 1;
}
else if (Convert.ToBoolean(RadioE.Line2.MCValue))
{
no = 2;
}
else if (Convert.ToBoolean(RadioE.Line3.MCValue))
{
no = 3;
}
else if (Convert.ToBoolean(RadioE.Line4.MCValue))
{
no = 4;
}
else if (Convert.ToBoolean(RadioE.Line5.MCValue))
{
no = 5;
}
else if (Convert.ToBoolean(RadioE.Line6.MCValue))
{
no = 6;
}
else if (Convert.ToBoolean(RadioE.Line7.MCValue))
{
no = 7;
}
else if (Convert.ToBoolean(RadioE.Line8.MCValue))
{
no = 8;
}
return no;
}
/// <summary>
/// 单混机单选选择
/// </summary>
/// <returns></returns>
public static int DrySelect(MCRadioButtonEntity RadioE)
{
if (Convert.ToBoolean(RadioE.Dry1.MCValue) == true)
{
return 1;
}
else if (Convert.ToBoolean(RadioE.Dry2.MCValue) == true)
{
return 2;
}
else if (Convert.ToBoolean(RadioE.Dry3.MCValue) == true)
{
return 3;
}
else if (Convert.ToBoolean(RadioE.Dry4.MCValue) == true)
{
return 4;
}
else
{
return 0;
}
}
}
}

@ -68,7 +68,6 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl.Entity
public Button GelManualHotWater { get; set; }
public Button WetManualGel { get; set; }
public Button RepairMode { get; set; }
public Button WaterConfrim { get; set; }
public Button DryDownload { get; set; }
public Button WaterDownload { get; set; }

@ -4,6 +4,7 @@ using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
@ -40,9 +41,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
ControlsHelper.ControlImport(TextE, ButtonE, ComboE, LabelE, RadioE, McControls);
RadioE.Line1.MCValue = true;
RadioE.Dry1.MCValue = true;
RadioE.Line1.BackColor = System.Drawing.Color.LightSkyBlue;
ControlInit();
RadioE.Line1.CheckedChanged += Mcradion_CheckedChanged;
RadioE.Line2.CheckedChanged += Mcradion_CheckedChanged;
@ -53,7 +52,13 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
RadioE.Line7.CheckedChanged += Mcradion_CheckedChanged;
RadioE.Line8.CheckedChanged += Mcradion_CheckedChanged;
ControlInitFromPLC();
RadioE.Dry1.CheckedChanged += DMcradion_CheckedChanged;
RadioE.Dry2.CheckedChanged += DMcradion_CheckedChanged;
RadioE.Dry3.CheckedChanged += DMcradion_CheckedChanged;
RadioE.Dry4.CheckedChanged += DMcradion_CheckedChanged;
RadioE.Line1.MCValue = true;
RadioE.Dry1.MCValue = true;
timer = new Timer();
timer.Interval = 1000;
@ -61,7 +66,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
timer.Tick += new EventHandler(StateRefresh);//添加事件
}
#region 前端状态
#region 前端Timer状态刷新
private void StateRefresh(object sender, EventArgs e)
{
@ -95,7 +100,7 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
var rd = Db3000Helper.ReadModel();
if (rd[SingleSelect() - 1])
if (rd[ControlsHelper.SingleSelect(RadioE) - 1])
{
LabelE.RepairState.MCValue = "开";
}
@ -129,6 +134,10 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
}
}
#endregion
#region PLC读数刷新控件
private void Mcradion_CheckedChanged(object sender, EventArgs e)
{
MCRadioButton mCRadio = sender as MCRadioButton;
@ -141,23 +150,43 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
RadioE.Line7.BackColor = backColor;
RadioE.Line8.BackColor = backColor;
mCRadio.BackColor = Color.LightSkyBlue;
int select = ControlsHelper.SingleSelect(RadioE);
GWInit(select);
switch (select)
{
case 1:
case 2:
RadioE.Dry1.MCValue = true; break;
case 3:
case 4:
RadioE.Dry2.MCValue = true; break;
case 5:
case 6:
RadioE.Dry3.MCValue = true; break;
case 7:
case 8:
RadioE.Dry4.MCValue = true; break;
default: break;
}
}
#endregion
/// <summary>
/// 控件从Plc初始化
/// </summary>
private void ControlInitFromPLC()
private void DMcradion_CheckedChanged(object sender, EventArgs e)
{
MCRadioButton mCRadio = sender as MCRadioButton;
RadioE.Dry1.BackColor = backColor;
RadioE.Dry2.BackColor = backColor;
RadioE.Dry3.BackColor = backColor;
RadioE.Dry4.BackColor = backColor;
mCRadio.BackColor = Color.LightSkyBlue;
DInit(ControlsHelper.DrySelect(RadioE));
}
ComboE.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
ComboE.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
private void GWInit(int select)
{
var selected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().
Where(x => x.DeviceId == SingleSelect() && x.Type == 2).ToList();
var selected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().Where(x => x.DeviceId == select && x.Type == 2).ToList();
if(selected.Count != 0)
if (selected.Count != 0)
{
ComboE.ChooseMaterial1.SelectedValue = selected[0].MaterrialId;
ComboE.ChooseMaterial2.SelectedValue = selected[1].MaterrialId;
@ -170,49 +199,59 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
var getGelatG1 = LjPlanningPlcHelp.GetGelatG1;
var getWeterM1 = LjPlanningPlcHelp.GetWeterM1;
var getGelatG2 = LjPlanningPlcHelp.GetGelatG2;
var getWeterM2 = LjPlanningPlcHelp.GetWeterM2;
var getGelatG3 = LjPlanningPlcHelp.GetGelatG3;
var getWeterM3 = LjPlanningPlcHelp.GetWeterM3;
var getGelatG4 = LjPlanningPlcHelp.GetGelatG4;
var getWeterM4 = LjPlanningPlcHelp.GetWeterM4;
var getGelatG5 = LjPlanningPlcHelp.GetGelatG5;
var getWeterM5 = LjPlanningPlcHelp.GetWeterM5;
var getGelatG6 = LjPlanningPlcHelp.GetGelatG6;
var getWeterM6 = LjPlanningPlcHelp.GetWeterM6;
var getGelatG7 = LjPlanningPlcHelp.GetGelatG7;
var getWeterM7 = LjPlanningPlcHelp.GetWeterM7;
var getGelatG8 = LjPlanningPlcHelp.GetGelatG8;
var getWeterM8 = LjPlanningPlcHelp.GetWeterM8;
switch (select)
{
case 1:
GWDataShow(getGelatG1, getWeterM1);
break;
case 2:
GWDataShow(getGelatG2, getWeterM2);
break;
case 3:
GWDataShow(getGelatG3, getWeterM3);
break;
case 4:
GWDataShow(getGelatG4, getWeterM4);
break;
case 5:
GWDataShow(getGelatG5, getWeterM5);
break;
case 6:
GWDataShow(getGelatG6, getWeterM6);
break;
case 7:
GWDataShow(getGelatG7, getWeterM7);
break;
case 8:
GWDataShow(getGelatG8, getWeterM8);
break;
default:
return;
TextE.MaterialWeight1.MCValue = getGelatG1.RecipePlcViews[0].Set;
TextE.MaterialWeight2.MCValue = getGelatG1.RecipePlcViews[1].Set;
//TextE.MaterialTolerance1.MCValue = getGelatG1.RecipePlcViews[0].Tolerance;
//TextE.MaterialTolerance2.MCValue = getGelatG1.RecipePlcViews[1].Tolerance;
TextE.GelSpeedSet.MCValue = getGelatG1.RecipeSteps[0].MixSpeed;
TextE.GelPosTimeA.MCValue = getGelatG1.RecipeSteps[2].MixTemp;
TextE.GelNagTimeB.MCValue = getGelatG1.RecipeSteps[2].MixSpeed;
TextE.GelPosTimeC.MCValue = getGelatG1.RecipeSteps[2].MixTime;
TextE.GelWaterTime.MCValue = getGelatG1.RecipeSteps[4].MixTime;
TextE.GelWaitTime.MCValue = getGelatG1.RecipeSteps[6].MixTime;
TextE.GelCloseHeatTime.MCValue = getGelatG1.RecipeSteps[7].MixTime;
TextE.GelOutDelayTime.MCValue = getGelatG1.RecipeSteps[7].MixTemp;
TextE.WetDryWeight.MCValue = getWeterM1[1].SetValue;
TextE.WetMixTime.MCValue = getWeterM1[2].MixTime;
TextE.WetOutDelayTime.MCValue = getWeterM1[4].MixTime;
DB2104Helper dB2104Helper = new DB2104Helper();
TextE.ColdValueA.MCValue = dB2104Helper.GetAColWater.Set;
TextE.ColdValueB.MCValue = dB2104Helper.GetBColWater.Set;
TextE.HotValueA.MCValue = dB2104Helper.GetAHotWater.Set;
TextE.HotValueB.MCValue = dB2104Helper.GetBHotWater.Set;
TextE.ColdToleranceA.MCValue = dB2104Helper.GetAColWater.Tolerance;
TextE.ColdToleranceB.MCValue = dB2104Helper.GetBColWater.Tolerance;
TextE.HotToleranceA.MCValue = dB2104Helper.GetAHotWater.Tolerance;
TextE.HotToleranceB.MCValue = dB2104Helper.GetBHotWater.Tolerance;
}
ComboE.DryM1.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM2.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM3.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM4.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM5.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM6.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM7.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM8.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM9.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM10.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM11.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM12.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
}
private void DInit(int select)
{
var drtSelected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().
Where(x => x.DeviceId == DrySelect() && x.Type == 1).ToList();
Where(x => x.DeviceId == select && x.Type == 1).ToList();
if (drtSelected.Count != 0)
{
@ -246,107 +285,98 @@ namespace Mesnac.Action.ChemicalWeighing.AutoControl
}
var getDryerD1 = LjPlanningPlcHelp.GetDryerD1;
var getDryerD2 = LjPlanningPlcHelp.GetDryerD2;
var getDryerD3 = LjPlanningPlcHelp.GetDryerD3;
var getDryerD4 = LjPlanningPlcHelp.GetDryerD4;
TextE.DryW1.MCValue = getDryerD1.RecipePlcViews[0].Set;
TextE.DryW2.MCValue = getDryerD1.RecipePlcViews[1].Set;
TextE.DryW3.MCValue = getDryerD1.RecipePlcViews[2].Set;
TextE.DryW4.MCValue = getDryerD1.RecipePlcViews[3].Set;
TextE.DryW5.MCValue = getDryerD1.RecipePlcViews[4].Set;
TextE.DryW6.MCValue = getDryerD1.RecipePlcViews[5].Set;
TextE.DryW7.MCValue = getDryerD1.RecipePlcViews[6].Set;
TextE.DryW8.MCValue = getDryerD1.RecipePlcViews[7].Set;
TextE.DryW9.MCValue = getDryerD1.RecipePlcViews[8].Set;
TextE.DryW10.MCValue = getDryerD1.RecipePlcViews[9].Set;
TextE.DryW11.MCValue = getDryerD1.RecipePlcViews[10].Set;
TextE.DryW12.MCValue = getDryerD1.RecipePlcViews[11].Set;
TextE.DryT1.MCValue = getDryerD1.RecipePlcViews[0].Tolerance;
TextE.DryT2.MCValue = getDryerD1.RecipePlcViews[1].Tolerance;
TextE.DryT3.MCValue = getDryerD1.RecipePlcViews[2].Tolerance;
TextE.DryT4.MCValue = getDryerD1.RecipePlcViews[3].Tolerance;
TextE.DryT5.MCValue = getDryerD1.RecipePlcViews[4].Tolerance;
TextE.DryT6.MCValue = getDryerD1.RecipePlcViews[5].Tolerance;
TextE.DryT7.MCValue = getDryerD1.RecipePlcViews[6].Tolerance;
TextE.DryT8.MCValue = getDryerD1.RecipePlcViews[7].Tolerance;
TextE.DryT9.MCValue = getDryerD1.RecipePlcViews[8].Tolerance;
TextE.DryT10.MCValue = getDryerD1.RecipePlcViews[9].Tolerance;
TextE.DryT11.MCValue = getDryerD1.RecipePlcViews[10].Tolerance;
TextE.DryT12.MCValue = getDryerD1.RecipePlcViews[11].Tolerance;
}
switch (select)
{
case 1:
DryDataShow(getDryerD1);
break;
case 2:
DryDataShow(getDryerD2);
break;
case 3:
DryDataShow(getDryerD3);
break;
case 4:
DryDataShow(getDryerD4);
break;
default: return;
}
#region 帮助类
}
/// <summary>
/// 单选选择
/// 控件从Plc初始化
/// </summary>
/// <returns>返回单选的产线号 如果未选择返回0</returns>
private int SingleSelect()
private void ControlInit()
{
int no = 0;
if (Convert.ToBoolean(RadioE.Line1.MCValue))
{
no= 1;
}
else if (Convert.ToBoolean(RadioE.Line2.MCValue))
{
no= 2;
}
else if (Convert.ToBoolean(RadioE.Line3.MCValue))
{
no= 3;
}
else if (Convert.ToBoolean(RadioE.Line4.MCValue))
{
no= 4;
}
else if (Convert.ToBoolean(RadioE.Line5.MCValue))
{
no= 5;
}
else if (Convert.ToBoolean(RadioE.Line6.MCValue))
{
no= 6;
}
else if (Convert.ToBoolean(RadioE.Line7.MCValue))
{
no= 7;
}
else if (Convert.ToBoolean(RadioE.Line8.MCValue))
{
no= 8;
}
return no;
ComboE.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
ComboE.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
DB2104Helper waterData = new DB2104Helper();
TextE.ColdValueA.MCValue = waterData.GetAColWater.Set;
TextE.ColdValueB.MCValue = waterData.GetBColWater.Set;
TextE.HotValueA.MCValue = waterData.GetAHotWater.Set;
TextE.HotValueB.MCValue = waterData.GetBHotWater.Set;
TextE.ColdToleranceA.MCValue = waterData.GetAColWater.Tolerance;
TextE.ColdToleranceB.MCValue = waterData.GetBColWater.Tolerance;
TextE.HotToleranceA.MCValue = waterData.GetAHotWater.Tolerance;
TextE.HotToleranceB.MCValue = waterData.GetBHotWater.Tolerance;
ComboE.DryM1.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM2.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM3.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM4.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM5.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM6.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM7.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM8.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM9.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM10.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM11.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM12.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
}
private void DryDataShow(DryerView Dry)
{
TextE.DryW1.MCValue = Dry.RecipePlcViews[0].Set;
TextE.DryW2.MCValue = Dry.RecipePlcViews[1].Set;
TextE.DryW3.MCValue = Dry.RecipePlcViews[2].Set;
TextE.DryW4.MCValue = Dry.RecipePlcViews[3].Set;
TextE.DryW5.MCValue = Dry.RecipePlcViews[4].Set;
TextE.DryW6.MCValue = Dry.RecipePlcViews[5].Set;
TextE.DryW7.MCValue = Dry.RecipePlcViews[6].Set;
TextE.DryW8.MCValue = Dry.RecipePlcViews[7].Set;
TextE.DryW9.MCValue = Dry.RecipePlcViews[8].Set;
TextE.DryW10.MCValue = Dry.RecipePlcViews[9].Set;
TextE.DryW11.MCValue = Dry.RecipePlcViews[10].Set;
TextE.DryW12.MCValue = Dry.RecipePlcViews[11].Set;
}
/// <summary>
/// 单混机单选选择
/// </summary>
/// <returns></returns>
private int DrySelect()
private void GWDataShow(DryerView Gel, List<MixStep> Wet)
{
if (Convert.ToBoolean(RadioE.Dry1.MCValue) == true)
{
return 1;
}
else if (Convert.ToBoolean(RadioE.Dry2.MCValue) == true)
{
return 2;
}
else if (Convert.ToBoolean(RadioE.Dry3.MCValue) == true)
{
return 3;
}
else if (Convert.ToBoolean(RadioE.Dry4.MCValue) == true)
{
return 4;
}
else
{
return 0;
}
TextE.MaterialWeight1.MCValue = Gel.RecipePlcViews[0].Set;
TextE.MaterialWeight2.MCValue = Gel.RecipePlcViews[1].Set;
TextE.GelSpeedSet.MCValue = Gel.RecipeSteps[0].MixSpeed;
TextE.GelPosTimeA.MCValue = Gel.RecipeSteps[2].MixTemp;
TextE.GelNagTimeB.MCValue = Gel.RecipeSteps[2].MixSpeed;
TextE.GelPosTimeC.MCValue = Gel.RecipeSteps[2].MixTime;
TextE.GelWaterTime.MCValue = Gel.RecipeSteps[4].MixTime;
TextE.GelWaitTime.MCValue = Gel.RecipeSteps[6].MixTime;
TextE.GelCloseHeatTime.MCValue = Gel.RecipeSteps[7].MixTime;
TextE.GelOutDelayTime.MCValue = Gel.RecipeSteps[7].MixTemp;
TextE.WetDryWeight.MCValue = Wet[1].SetValue;
TextE.WetMixTime.MCValue = Wet[2].MixTime;
TextE.WetOutDelayTime.MCValue = Wet[4].MixTime;
}
#endregion
}

@ -0,0 +1,759 @@
using DataBlockHelper.DBHelpers;
using DataBlockHelper.Entity.DB2104Entity;
using DevExpress.XtraEditors.Filtering.Templates;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Mesnac.Controls.Default;
using Mesnac.Core.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static Mesnac.Action.ChemicalWeighing.AutoControl.AutoLogHelper;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
public static class PlcAutoWriteHelper
{
private static int TFlag = 0;
#region 湿混糊化下传
public static void GelWetDownload(MCTextBoxEntity TextE, MCComboBoxEntity ComboE, MCRadioButtonEntity RadioE)
{
int b1 = Convert.ToInt32(ComboE.ChooseMaterial1.MCValue.ToString());
int b2 = Convert.ToInt32(ComboE.ChooseMaterial2.MCValue.ToString());
short bin1 = (short)StockMaterrialDbHelp.GetCodeById(b1);
short bin2 = (short)StockMaterrialDbHelp.GetCodeById(b2);
float MatTol1 = Convert.ToSingle(TextE.MaterialTolerance1.MCValue.ToString());
float MatTol2 = Convert.ToSingle(TextE.MaterialTolerance2.MCValue.ToString());
float MatWei1 = Convert.ToSingle(TextE.MaterialWeight1.MCValue.ToString());
float MatWei2 = Convert.ToSingle(TextE.MaterialWeight2.MCValue.ToString());
float GelSpeed = Convert.ToSingle(TextE.GelSpeedSet.MCValue.ToString());
float GelPosA = Convert.ToSingle(TextE.GelPosTimeA.MCValue.ToString());
float GelNagB = Convert.ToSingle(TextE.GelNagTimeB.MCValue.ToString());
short GelPosC = Convert.ToInt16(TextE.GelPosTimeC.MCValue.ToString());
short GelWater = Convert.ToInt16(TextE.GelWaterTime.MCValue.ToString());
short GelWait = Convert.ToInt16(TextE.GelWaitTime.MCValue.ToString());
short GelCloseHeat = Convert.ToInt16(TextE.GelCloseHeatTime.MCValue.ToString());
float GelDelayTime = Convert.ToSingle(TextE.GelOutDelayTime.MCValue.ToString());
if (b2 == -1)
{
if (MatTol1 < 0.1)
{
MessageBox.Show("公差不能小于0.1");
return;
}
}
else
{
if (MatTol1 < 0.1 || MatTol2 < 0.1)
{
MessageBox.Show("公差不能小于0.1");
return;
}
}
List<RecipePlcView> recipes = new List<RecipePlcView>();
RecipePlcView recipe1 = new RecipePlcView()
{
Bin = bin1,
Set = MatWei1,
Tolerance = MatTol1,
};
RecipePlcView recipe2 = new RecipePlcView()
{
Bin = bin2,
Set = MatWei2,
Tolerance = MatTol2,
};
recipes.Add(recipe1);
recipes.Add(recipe2);
List<Step> steps = new List<Step>();
Step step1 = new Step()
{
MixCode = 1,
MixSpeed = GelSpeed
};
Step step2 = new Step()
{
MixCode = 2,
};
Step step3 = new Step()
{
MixCode = 3,
MixTime = GelPosC,
MixTemp = GelPosA,
MixSpeed = GelNagB
};
Step step4 = new Step()
{
MixCode = 4,
};
Step step5 = new Step()
{
MixCode = 5,
MixTime = GelWater
};
Step step6 = new Step()
{
MixCode = 6,
};
Step step7 = new Step()
{
MixCode = 5,
MixTime = GelWait
};
Step step8 = new Step()
{
MixCode = 7,
MixTime = GelCloseHeat,
MixTemp = GelDelayTime
};
steps.Add(step1);
steps.Add(step2);
steps.Add(step3);
steps.Add(step4);
steps.Add(step5);
steps.Add(step6);
steps.Add(step7);
steps.Add(step8);
float WetDryWei = Convert.ToSingle(TextE.WetDryWeight.MCValue.ToString());
short WetMix = Convert.ToInt16(TextE.WetMixTime.MCValue.ToString());
short WetOutDelay = Convert.ToInt16(TextE.WetOutDelayTime.MCValue.ToString());
List<MixStep> mixSteps = new List<MixStep>();
MixStep mixStep1 = new MixStep()
{
MixCode = 1,
};
MixStep mixStep2 = new MixStep()
{
MixCode = 2,
SetValue = WetDryWei
};
MixStep mixStep3 = new MixStep()
{
MixCode = 3,
MixTime = WetMix
};
MixStep mixStep4 = new MixStep()
{
MixCode = 4,
};
MixStep mixStep5 = new MixStep()
{
MixCode = 5,
MixTime = WetOutDelay
};
mixSteps.Add(mixStep1);
mixSteps.Add(mixStep2);
mixSteps.Add(mixStep3);
mixSteps.Add(mixStep4);
mixSteps.Add(mixStep5);
List<DeviceMaterrial> materials = new List<DeviceMaterrial>();
DeviceMaterrial deviceMaterial1 = new DeviceMaterrial()
{
DeviceId = ControlsHelper.SingleSelect(RadioE),
MaterrialId = b1,
Type = 2,
Code = StockMaterrialDbHelp.GetCodeById(b1)
};
DeviceMaterrial deviceMaterial2 = new DeviceMaterrial()
{
DeviceId = ControlsHelper.SingleSelect(RadioE),
MaterrialId = b2,
Type = 2,
Code = StockMaterrialDbHelp.GetCodeById(b2)
};
materials.Add(deviceMaterial1);
materials.Add(deviceMaterial2);
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
LjPlanningPlcHelp.DownG1Recipe(recipes, steps);
LjPlanningPlcHelp.DownM1Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 2:
LjPlanningPlcHelp.DownG2Recipe(recipes, steps);
LjPlanningPlcHelp.DownM2Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 3:
LjPlanningPlcHelp.DownG3Recipe(recipes, steps);
LjPlanningPlcHelp.DownM3Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 4:
LjPlanningPlcHelp.DownG4Recipe(recipes, steps);
LjPlanningPlcHelp.DownM4Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 5:
LjPlanningPlcHelp.DownG5Recipe(recipes, steps);
LjPlanningPlcHelp.DownM5Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 6:
LjPlanningPlcHelp.DownG6Recipe(recipes, steps);
LjPlanningPlcHelp.DownM6Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 7:
LjPlanningPlcHelp.DownG7Recipe(recipes, steps);
LjPlanningPlcHelp.DownM7Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
case 8:
LjPlanningPlcHelp.DownG8Recipe(recipes, steps);
LjPlanningPlcHelp.DownM8Recipe(mixSteps);
DeviceMaterrialService.Save(materials);
break;
default:
MessageBox.Show("请选择一条产线!");
return;
}
GWlog(recipes, steps, mixSteps, RadioE);
}
#endregion
#region 干混下传
public static void DryDownload(MCTextBoxEntity TextE, MCComboBoxEntity ComboE, MCRadioButtonEntity RadioE)
{
List<RecipePlcView> recipes = new List<RecipePlcView>();
List<Step> steps = new List<Step>();
List<DeviceMaterrial> materials = new List<DeviceMaterrial>();
DryerGetValue(ComboE.DryM1, TextE.DryW1, TextE.DryT1, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM2, TextE.DryW2, TextE.DryT2, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM3, TextE.DryW3, TextE.DryT3, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM4, TextE.DryW4, TextE.DryT4, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM5, TextE.DryW5, TextE.DryT5, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM6, TextE.DryW6, TextE.DryT6, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM7, TextE.DryW7, TextE.DryT7, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM8, TextE.DryW8, TextE.DryT8, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM9, TextE.DryW9, TextE.DryT9, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM10, TextE.DryW10, TextE.DryT10, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM11, TextE.DryW11, TextE.DryT11, recipes, materials, RadioE);
DryerGetValue(ComboE.DryM12, TextE.DryW12, TextE.DryT12, recipes, materials, RadioE);
if (TFlag == 1)
{
MessageBox.Show("公差不能小于0.1");
TFlag = 0;
return;
}
switch (ControlsHelper.DrySelect(RadioE))
{
case 1:
LjPlanningPlcHelp.DownD1Recipe(recipes, steps);
DeviceMaterrialService.Save(materials);
break;
case 2:
LjPlanningPlcHelp.DownD2Recipe(recipes, steps);
DeviceMaterrialService.Save(materials);
break;
case 3:
LjPlanningPlcHelp.DownD3Recipe(recipes, steps);
DeviceMaterrialService.Save(materials);
break;
case 4:
LjPlanningPlcHelp.DownD4Recipe(recipes, steps);
DeviceMaterrialService.Save(materials);
break;
}
}
#endregion
#region 水称下传
public static void WaterDownload(MCTextBoxEntity TextE)
{
WaterEntity HotA = new WaterEntity();
WaterEntity ColdA = new WaterEntity();
WaterEntity HotB = new WaterEntity();
WaterEntity ColdB = new WaterEntity();
float hotASet, hotBSet, coldASet, coldBSet, hotATol, hotBTol, coldATol, coldBTol;
if (float.TryParse(Convert.ToString(TextE.HotValueA.MCValue), out hotASet) &&
float.TryParse(Convert.ToString(TextE.HotToleranceA.MCValue), out hotATol) &&
float.TryParse(Convert.ToString(TextE.HotValueB.MCValue), out hotBSet) &&
float.TryParse(Convert.ToString(TextE.HotToleranceB.MCValue), out hotBTol) &&
float.TryParse(Convert.ToString(TextE.ColdValueA.MCValue), out coldASet) &&
float.TryParse(Convert.ToString(TextE.ColdToleranceA.MCValue), out coldATol) &&
float.TryParse(Convert.ToString(TextE.ColdValueB.MCValue), out coldBSet) &&
float.TryParse(Convert.ToString(TextE.ColdToleranceB.MCValue), out coldBTol))
{
HotA.Set = hotASet;
HotB.Set = hotBSet;
ColdA.Set = coldASet;
ColdB.Set = coldBSet;
HotA.Tolerance = hotATol;
HotB.Tolerance = hotBTol;
ColdA.Tolerance = coldATol;
ColdB.Tolerance = coldBTol;
Db2104WriteHelper.WriteAHostWater(HotA);
Db2104WriteHelper.WriteBHostWater(HotB);
Db2104WriteHelper.WriteAColWater(ColdA);
Db2104WriteHelper.WriteBColWater(ColdB);
MesnacServiceManager.Instance.LoggingService.Info("水称数据下发成功!");
MessageBox.Show("水称数据下发成功");
}
else
{
MesnacServiceManager.Instance.LoggingService.Info("输入数值的格式有误");
MessageBox.Show("输入数值的格式有误!");
return;
}
}
#endregion
#region 手动控制
#region 糊化锅手动下粉料
public static bool GelPowderDownload(MCRadioButtonEntity RadioE)
{
bool isReady;
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
isReady = DB2105WriteHelper.WriteG1Pd();
break;
case 2:
isReady = DB2105WriteHelper.WriteG2Pd();
break;
case 3:
isReady = DB2105WriteHelper.WriteG3Pd();
break;
case 4:
isReady = DB2105WriteHelper.WriteG4Pd();
break;
case 5:
isReady = DB2105WriteHelper.WriteG5Pd();
break;
case 6:
isReady = DB2105WriteHelper.WriteG6Pd();
break;
case 7:
isReady = DB2105WriteHelper.WriteG7Pd();
break;
case 8:
isReady = DB2105WriteHelper.WriteG8Pd();
break;
default:
isReady = false;
MessageBox.Show("当前未选择产线!");
break;
}
return isReady;
}
#endregion
#region 糊化锅手动加冷水
public static bool GelColdWaterDownload(MCRadioButtonEntity RadioE)
{
bool isReady;
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
isReady = DB2105WriteHelper.WriteG1Cw();
break;
case 2:
isReady = DB2105WriteHelper.WriteG2Cw();
break;
case 3:
isReady = DB2105WriteHelper.WriteG3Cw();
break;
case 4:
isReady = DB2105WriteHelper.WriteG4Cw();
break;
case 5:
isReady = DB2105WriteHelper.WriteG5Cw();
break;
case 6:
isReady = DB2105WriteHelper.WriteG6Cw();
break;
case 7:
isReady = DB2105WriteHelper.WriteG7Cw();
break;
case 8:
isReady = DB2105WriteHelper.WriteG8Cw();
break;
default:
isReady = false;
MessageBox.Show("当前未选择产线!");
break;
}
return isReady;
}
#endregion
#region 糊化锅手动加热水
public static bool GelHotWaterDownload(MCRadioButtonEntity RadioE)
{
bool isReady;
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
isReady = DB2105WriteHelper.WriteG1Hw();
break;
case 2:
isReady = DB2105WriteHelper.WriteG2Hw();
break;
case 3:
isReady = DB2105WriteHelper.WriteG3Hw();
break;
case 4:
isReady = DB2105WriteHelper.WriteG4Hw();
break;
case 5:
isReady = DB2105WriteHelper.WriteG5Hw();
break;
case 6:
isReady = DB2105WriteHelper.WriteG6Hw();
break;
case 7:
isReady = DB2105WriteHelper.WriteG7Hw();
break;
case 8:
isReady = DB2105WriteHelper.WriteG8Hw();
break;
default:
isReady = false;
MessageBox.Show("当前未选择产线!");
break;
}
return isReady;
}
#endregion
#region 湿混机手动下糊化料
public static bool WetGelatDownload(MCRadioButtonEntity RadioE)
{
bool isReady;
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
isReady = DB2105WriteHelper.WriteM1();
break;
case 2:
isReady = DB2105WriteHelper.WriteM2();
break;
case 3:
isReady = DB2105WriteHelper.WriteM3();
break;
case 4:
isReady = DB2105WriteHelper.WriteM4();
break;
case 5:
isReady = DB2105WriteHelper.WriteM5();
break;
case 6:
isReady = DB2105WriteHelper.WriteM6();
break;
case 7:
isReady = DB2105WriteHelper.WriteM7();
break;
case 8:
isReady = DB2105WriteHelper.WriteM8();
break;
default:
isReady = false;
MessageBox.Show("当前未选择产线!");
break;
}
return isReady;
}
#endregion
#region 湿混机手动下粉料
public static void WetGelatDownload(MCTextBoxEntity TextE, MCRadioButtonEntity RadioE)
{
float t = Convert.ToSingle(TextE.ManualTolerance.MCValue.ToString());
float w = Convert.ToSingle(TextE.ManualWeight.MCValue.ToString());
if (t < 0.1)
{
MessageBox.Show("公差不能小于0.1");
return;
}
SetValue value = new SetValue()
{
Value = w,
Toterance = t
};
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
DB2105WriteHelper.WriteManScrewH1();
DB2105WriteHelper.WriteSetValueH1(value);
break;
case 2:
DB2105WriteHelper.WriteManScrewH2();
DB2105WriteHelper.WriteSetValueH1(value);
break;
case 3:
DB2105WriteHelper.WriteManScrewH3();
DB2105WriteHelper.WriteSetValueH2(value);
break;
case 4:
DB2105WriteHelper.WriteManScrewH4();
DB2105WriteHelper.WriteSetValueH2(value);
break;
case 5:
DB2105WriteHelper.WriteManScrewH5();
DB2105WriteHelper.WriteSetValueH3(value);
break;
case 6:
DB2105WriteHelper.WriteManScrewH6();
DB2105WriteHelper.WriteSetValueH3(value);
break;
case 7:
DB2105WriteHelper.WriteManScrewH7();
DB2105WriteHelper.WriteSetValueH4(value);
break;
case 8:
DB2105WriteHelper.WriteManScrewH8();
DB2105WriteHelper.WriteSetValueH4(value);
break;
default:
MessageBox.Show("当前未选择产线!");
return;
}
ManualWeightLog(w, t, RadioE);
}
#endregion
#endregion
#region 产线启停
#region 产线启动
public static void LineStart(MCRadioButtonEntity RadioE)
{
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
DB2105WriteHelper.WriteStartJob1();
break;
case 2:
DB2105WriteHelper.WriteStartJob2();
break;
case 3:
DB2105WriteHelper.WriteStartJob3();
break;
case 4:
DB2105WriteHelper.WriteStartJob4();
break;
case 5:
DB2105WriteHelper.WriteStartJob5();
break;
case 6:
DB2105WriteHelper.WriteStartJob6();
break;
case 7:
DB2105WriteHelper.WriteStartJob7();
break;
case 8:
DB2105WriteHelper.WriteStartJob8();
break;
default:
MessageBox.Show("请选择一条产线!");
return;
}
SingleLog("产线启动", RadioE);
}
#endregion
#region 产线停止
public static void LineStop(MCRadioButtonEntity RadioE)
{
switch (ControlsHelper.SingleSelect(RadioE))
{
case 1:
DB2105WriteHelper.WriteStopJob1();
break;
case 2:
DB2105WriteHelper.WriteStopJob2();
break;
case 3:
DB2105WriteHelper.WriteStopJob3();
break;
case 4:
DB2105WriteHelper.WriteStopJob4();
break;
case 5:
DB2105WriteHelper.WriteStopJob5();
break;
case 6:
DB2105WriteHelper.WriteStopJob6();
break;
case 7:
DB2105WriteHelper.WriteStopJob7();
break;
case 8:
DB2105WriteHelper.WriteStopJob8();
break;
default:
MessageBox.Show("请选择一条产线!");
return;
}
SingleLog("产线停止", RadioE);
}
#endregion
#endregion
#region 维修模式
public static void RepairOnOff(MCLabelEntity LabelE, MCRadioButtonEntity RadioE)
{
if (LabelE.RepairState.MCValue.ToString() == "关")
{
if (MessageBox.Show("是否开启维修模式?", "维修模式确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
Db3000Helper.WriteModel(ControlsHelper.SingleSelect(RadioE), true);
LabelE.RepairState.MCValue = "开";
SingleLog("维修模式开启", RadioE);
MessageBox.Show("维修模式已开启");
}
else
{
if (LabelE.RepairState.MCValue.ToString() == "开")
{
if (MessageBox.Show("是否关闭维修模式?", "维修模式确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
return;
}
Db3000Helper.WriteModel(ControlsHelper.SingleSelect(RadioE), false);
LabelE.RepairState.MCValue = "关";
SingleLog("维修模式关闭", RadioE);
MessageBox.Show("维修模式已关闭");
}
}
}
#endregion
#region 湿混机物料封装
/// <summary>
/// 干混机数据打包封装
/// </summary>
/// <param name="DryM">物料类型</param>
/// <param name="DryW">重量</param>
/// <param name="DryT">公差</param>
/// <param name="recipes">物料集合</param>
/// <param name="steps">步骤集合</param>
/// <param name="materials">数据库物料记录</param>
private static void DryerGetValue(MCCombobox DryM, MCTextBox DryW, MCTextBox DryT,
List<RecipePlcView> recipes, List<DeviceMaterrial> materials, MCRadioButtonEntity RadioE)
{
int b = Convert.ToInt32(DryM.MCValue.ToString());
short bin = (short)StockMaterrialDbHelp.GetCodeById(b);
float w = Convert.ToSingle(DryW.MCValue.ToString());
float t = Convert.ToSingle(DryT.MCValue.ToString());
if (b != -1 && t < 0.1)
{
TFlag = 1;
}
RecipePlcView recipe1 = new RecipePlcView()
{
Bin = bin,
Set = w,
Tolerance = t,
};
recipes.Add(recipe1);
DeviceMaterrial deviceMaterial1 = new DeviceMaterrial()
{
DeviceId = ControlsHelper.DrySelect(RadioE),
MaterrialId = b,
Type = 1,
Code = StockMaterrialDbHelp.GetCodeById(b)
};
materials.Add(deviceMaterial1);
}
#endregion
}
}

@ -1,318 +0,0 @@
using DataBlockHelper.Entity.DB2106Entity;
using HslCommunication.Instrument.DLT;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Action.ChemicalWeighing.FreeDb;
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.AutoControl
{
public class RefreshAction : ChemicalWeighingAction, IAction
{
private List<Control> McControls;
MCTextBoxEntity TextE = new MCTextBoxEntity();
ButtonEntity ButtonE = new ButtonEntity();
MCLabelEntity LabelE = new MCLabelEntity();
MCComboBoxEntity ComboE = new MCComboBoxEntity();
MCRadioButtonEntity RadioE = new MCRadioButtonEntity();
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用
McControls = GetAllControls();
ControlsHelper.ControlImport(TextE, ButtonE, ComboE, LabelE, RadioE, McControls);
ControlInitFromPLC();
}
#region 控件初始化
/// <summary>
/// 控件从Plc初始化
/// </summary>
private void ControlInitFromPLC()
{
//switch (SingleSelect())
//{
// case 1:
// LjPlanningPlcHelp.GetGelatG1.
//}
ComboE.ChooseMaterial1.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
ComboE.ChooseMaterial2.DataSource = StockMaterrialDbHelp.GetSiloMaterrial();
var selected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().Where(x => x.DeviceId == SingleSelect() && x.Type == 2).ToList();
if (selected.Count != 0)
{
ComboE.ChooseMaterial1.SelectedValue = selected[0].MaterrialId;
ComboE.ChooseMaterial2.SelectedValue = selected[1].MaterrialId;
}
else
{
ComboE.ChooseMaterial1.SelectedIndex = 0;
ComboE.ChooseMaterial2.SelectedIndex = 0;
}
var getGelatG1 = LjPlanningPlcHelp.GetGelatG1;
var getWeterM1 = LjPlanningPlcHelp.GetWeterM1;
var getGelatG2 = LjPlanningPlcHelp.GetGelatG2;
var getWeterM2 = LjPlanningPlcHelp.GetWeterM2;
var getGelatG3 = LjPlanningPlcHelp.GetGelatG3;
var getWeterM3 = LjPlanningPlcHelp.GetWeterM3;
var getGelatG4 = LjPlanningPlcHelp.GetGelatG4;
var getWeterM4 = LjPlanningPlcHelp.GetWeterM4;
var getGelatG5 = LjPlanningPlcHelp.GetGelatG5;
var getWeterM5 = LjPlanningPlcHelp.GetWeterM5;
var getGelatG6 = LjPlanningPlcHelp.GetGelatG6;
var getWeterM6 = LjPlanningPlcHelp.GetWeterM6;
var getGelatG7 = LjPlanningPlcHelp.GetGelatG7;
var getWeterM7 = LjPlanningPlcHelp.GetWeterM7;
var getGelatG8 = LjPlanningPlcHelp.GetGelatG8;
var getWeterM8 = LjPlanningPlcHelp.GetWeterM8;
switch (SingleSelect())
{
case 1:
GWDataShow(getGelatG1, getWeterM1);
break;
case 2:
GWDataShow(getGelatG2, getWeterM2);
break;
case 3:
GWDataShow(getGelatG3, getWeterM3);
break;
case 4:
GWDataShow(getGelatG4, getWeterM4);
break;
case 5:
GWDataShow(getGelatG5, getWeterM5);
break;
case 6:
GWDataShow(getGelatG6, getWeterM6);
break;
case 7:
GWDataShow(getGelatG7, getWeterM7);
break;
case 8:
GWDataShow(getGelatG8, getWeterM8);
break;
default:
return;
}
ComboE.DryM1.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM2.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM3.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM4.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM5.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM6.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM7.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM8.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM9.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM10.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM11.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
ComboE.DryM12.DataSource = StockMaterrialDbHelp.GetDryerMaterrial();
var drtSelected = FreeSqlUnit.Instance.Select<DeviceMaterrial>().
Where(x => x.DeviceId == DrySelect() && x.Type == 1).ToList();
if (drtSelected.Count != 0)
{
ComboE.DryM1.SelectedValue = drtSelected[0].MaterrialId;
ComboE.DryM2.SelectedValue = drtSelected[1].MaterrialId;
ComboE.DryM3.SelectedValue = drtSelected[2].MaterrialId;
ComboE.DryM4.SelectedValue = drtSelected[3].MaterrialId;
ComboE.DryM5.SelectedValue = drtSelected[4].MaterrialId;
ComboE.DryM6.SelectedValue = drtSelected[5].MaterrialId;
ComboE.DryM7.SelectedValue = drtSelected[6].MaterrialId;
ComboE.DryM8.SelectedValue = drtSelected[7].MaterrialId;
ComboE.DryM9.SelectedValue = drtSelected[8].MaterrialId;
ComboE.DryM10.SelectedValue = drtSelected[9].MaterrialId;
ComboE.DryM11.SelectedValue = drtSelected[10].MaterrialId;
ComboE.DryM12.SelectedValue = drtSelected[11].MaterrialId;
}
else
{
ComboE.DryM1.SelectedIndex = 0;
ComboE.DryM2.SelectedIndex = 0;
ComboE.DryM3.SelectedIndex = 0;
ComboE.DryM4.SelectedIndex = 0;
ComboE.DryM5.SelectedIndex = 0;
ComboE.DryM6.SelectedIndex = 0;
ComboE.DryM7.SelectedIndex = 0;
ComboE.DryM8.SelectedIndex = 0;
ComboE.DryM9.SelectedIndex = 0;
ComboE.DryM10.SelectedIndex = 0;
ComboE.DryM11.SelectedIndex = 0;
ComboE.DryM12.SelectedIndex = 0;
}
var getDryerD1 = LjPlanningPlcHelp.GetDryerD1;
var getDryerD2 = LjPlanningPlcHelp.GetDryerD2;
var getDryerD3 = LjPlanningPlcHelp.GetDryerD3;
var getDryerD4 = LjPlanningPlcHelp.GetDryerD4;
switch (DrySelect())
{
case 1:
DryDataShow(getDryerD1);
break;
case 2:
DryDataShow(getDryerD2);
break;
case 3:
DryDataShow(getDryerD3);
break;
case 4:
DryDataShow(getDryerD4);
break;
default: return;
}
}
private void DryDataShow(DryerView Dry)
{
TextE.DryW1.MCValue = Dry.RecipePlcViews[0].Set;
TextE.DryW2.MCValue = Dry.RecipePlcViews[1].Set;
TextE.DryW3.MCValue = Dry.RecipePlcViews[2].Set;
TextE.DryW4.MCValue = Dry.RecipePlcViews[3].Set;
TextE.DryW5.MCValue = Dry.RecipePlcViews[4].Set;
TextE.DryW6.MCValue = Dry.RecipePlcViews[5].Set;
TextE.DryW7.MCValue = Dry.RecipePlcViews[6].Set;
TextE.DryW8.MCValue = Dry.RecipePlcViews[7].Set;
TextE.DryW9.MCValue = Dry.RecipePlcViews[8].Set;
TextE.DryW10.MCValue = Dry.RecipePlcViews[9].Set;
TextE.DryW11.MCValue = Dry.RecipePlcViews[10].Set;
TextE.DryW12.MCValue = Dry.RecipePlcViews[11].Set;
TextE.DryT1.MCValue = Dry.RecipePlcViews[0].Tolerance;
TextE.DryT2.MCValue = Dry.RecipePlcViews[1].Tolerance;
TextE.DryT3.MCValue = Dry.RecipePlcViews[2].Tolerance;
TextE.DryT4.MCValue = Dry.RecipePlcViews[3].Tolerance;
TextE.DryT5.MCValue = Dry.RecipePlcViews[4].Tolerance;
TextE.DryT6.MCValue = Dry.RecipePlcViews[5].Tolerance;
TextE.DryT7.MCValue = Dry.RecipePlcViews[6].Tolerance;
TextE.DryT8.MCValue = Dry.RecipePlcViews[7].Tolerance;
TextE.DryT9.MCValue = Dry.RecipePlcViews[8].Tolerance;
TextE.DryT10.MCValue = Dry.RecipePlcViews[9].Tolerance;
TextE.DryT11.MCValue = Dry.RecipePlcViews[10].Tolerance;
TextE.DryT12.MCValue = Dry.RecipePlcViews[11].Tolerance;
}
private void GWDataShow(DryerView Gel, List<MixStep> Wet)
{
TextE.MaterialWeight1.MCValue = Gel.RecipePlcViews[0].Set;
TextE.MaterialWeight2.MCValue = Gel.RecipePlcViews[1].Set;
//TextE.MaterialTolerance1.MCValue = Gel.RecipePlcViews[0].Tolerance;
//TextE.MaterialTolerance2.MCValue = Gel.RecipePlcViews[1].Tolerance;
TextE.GelSpeedSet.MCValue = Gel.RecipeSteps[0].MixSpeed;
TextE.GelPosTimeA.MCValue = Gel.RecipeSteps[2].MixTemp;
TextE.GelNagTimeB.MCValue = Gel.RecipeSteps[2].MixSpeed;
TextE.GelPosTimeC.MCValue = Gel.RecipeSteps[2].MixTime;
TextE.GelWaterTime.MCValue = Gel.RecipeSteps[4].MixTime;
TextE.GelWaitTime.MCValue = Gel.RecipeSteps[6].MixTime;
TextE.GelCloseHeatTime.MCValue = Gel.RecipeSteps[7].MixTime;
TextE.GelOutDelayTime.MCValue = Gel.RecipeSteps[7].MixTemp;
TextE.WetDryWeight.MCValue = Wet[1].SetValue;
TextE.WetMixTime.MCValue = Wet[2].MixTime;
TextE.WetOutDelayTime.MCValue = Wet[4].MixTime;
}
#endregion
#region 辅助类
/// <summary>
/// 单选选择
/// </summary>
/// <returns>返回单选的产线号 如果未选择返回0</returns>
private int SingleSelect()
{
if (Convert.ToBoolean(RadioE.Line1.MCValue) == true)
{
return 1;
}
else if (Convert.ToBoolean(RadioE.Line2.MCValue) == true)
{
return 2;
}
else if (Convert.ToBoolean(RadioE.Line3.MCValue) == true)
{
return 3;
}
else if (Convert.ToBoolean(RadioE.Line4.MCValue) == true)
{
return 4;
}
else if (Convert.ToBoolean(RadioE.Line5.MCValue) == true)
{
return 5;
}
else if (Convert.ToBoolean(RadioE.Line6.MCValue) == true)
{
return 6;
}
else if (Convert.ToBoolean(RadioE.Line7.MCValue) == true)
{
return 7;
}
else if (Convert.ToBoolean(RadioE.Line8.MCValue) == true)
{
return 8;
}
else
{
return 0;
}
}
/// <summary>
/// 单混机单选选择
/// </summary>
/// <returns></returns>
private int DrySelect()
{
if (Convert.ToBoolean(RadioE.Dry1.MCValue) == true)
{
return 1;
}
else if (Convert.ToBoolean(RadioE.Dry2.MCValue) == true)
{
return 2;
}
else if (Convert.ToBoolean(RadioE.Dry3.MCValue) == true)
{
return 3;
}
else if (Convert.ToBoolean(RadioE.Dry4.MCValue) == true)
{
return 4;
}
else
{
return 0;
}
}
#endregion
}
}

@ -219,6 +219,7 @@
<Compile Include="Alarm\PmtAlarm\InsertAction.cs" />
<Compile Include="Alarm\PmtAlarm\ModifyAction.cs" />
<Compile Include="Alarm\PmtAlarm\SelectAction.cs" />
<Compile Include="AutoControl\AutoLogHelper.cs" />
<Compile Include="AutoControl\ControlsHelper.cs" />
<Compile Include="AutoControl\DB\Auto_Log.cs" />
<Compile Include="AutoControl\DB\DeviceMaterrial.cs" />
@ -227,7 +228,7 @@
<Compile Include="AutoControl\Entity\GelerWeterControlsEntity.cs" />
<Compile Include="AutoControl\AutoControl.cs" />
<Compile Include="AutoControl\InitAction.cs" />
<Compile Include="AutoControl\RefreshAction.cs" />
<Compile Include="AutoControl\PlcAutoWriteHelper.cs" />
<Compile Include="BaseDataHelper.cs" />
<Compile Include="BasePlcHelper.cs" />
<Compile Include="Basic\BasicHelper.cs" />

@ -10,10 +10,6 @@
<Caption>自动界面初始化</Caption>
<Remark>自动界面初始化</Remark>
</Action>
<Action action="469F4DDEC2994D568465BEAB6F629E29">
<Caption>刷新事件</Caption>
<Remark>刷新事件</Remark>
</Action>
</Path>
</Design>
@ -25,16 +21,12 @@
<Design action="8A56C0B7BCE44AE6835221CAA3E1130E">
<Runtime action="1B0FD7B35DBC4677B4A791B8224C68DA"/>
</Design>
<Design action="469F4DDEC2994D568465BEAB6F629E29">
<Runtime action="469EE6B30E114E31B00113D69F86C036"/>
</Design>
</DesignToRuntime>
<Runtime>
<Import assembly = "Data/Action/ChemicalWeighing/Mesnac.Action.ChemicalWeighing.dll">
<Action action="FBB09CEE7C71473B8717C735C1B7E320" class="Mesnac.Action.ChemicalWeighing.AutoControl.AutoControl"/>
<Action action="1B0FD7B35DBC4677B4A791B8224C68DA" class="Mesnac.Action.ChemicalWeighing.AutoControl.InitAction"/>
<Action action="469EE6B30E114E31B00113D69F86C036" class="Mesnac.Action.ChemicalWeighing.AutoControl.RefreshAction"/>
</Import>
</Runtime>
</ActionService>

@ -1,6 +1,6 @@
<Object type="Mesnac.Gui.Common.FrmRunTemplate, Mesnac.Gui.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="AutoControlC" children="Controls">
<Object type="Mesnac.Controls.Default.MCButton, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="WaterDownLoad" children="Controls">
<Object type="Mesnac.Controls.Default.MCButton, Mesnac.Controls.Default, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" name="WaterDownload" children="Controls">
<Property name="ClickActionList">
<Binary>AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAAKAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIERCRTgxOTNENDE2MDRBRDVCOTRBRTNDMkQzNDc1MUQyBgYAAAAY6Ieq5Yqo5o6n5Yi25oyJ6ZKu5LqL5Lu2BgcAAAAY6Ieq5Yqo5o6n5Yi25oyJ6ZKu5LqL5Lu2Cw==</Binary>
</Property>
@ -21,7 +21,7 @@
<Property name="Text">水称下传</Property>
<Property name="Font">宋体, 12pt</Property>
<Property name="Location">516, 544</Property>
<Property name="Name">WaterDownLoad</Property>
<Property name="Name">WaterDownload</Property>
<Property name="Size">174, 50</Property>
<Property name="TabIndex">66</Property>
</Object>

Loading…
Cancel
Save