|
|
|
|
using DataBlockHelper.DBHelpers;
|
|
|
|
|
using DataBlockHelper.Entity.DB2104Entity;
|
|
|
|
|
using DataBlockHelper.Entity.DB2106Entity;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.AutoControl.DB;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjMixManager;
|
|
|
|
|
using Mesnac.Controls.Base;
|
|
|
|
|
using Mesnac.Controls.Default;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using Button = System.Windows.Forms.Button;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.LjPlanning;
|
|
|
|
|
using System.Diagnostics.SymbolStore;
|
|
|
|
|
using Mesnac.Basic;
|
|
|
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.AutoControl
|
|
|
|
|
{
|
|
|
|
|
internal class GelerWeterControl : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
private List<Control> McControls;
|
|
|
|
|
RuntimeParameter _runtime;
|
|
|
|
|
GelerWeterControlsEntity ControlsEntity = new GelerWeterControlsEntity();
|
|
|
|
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须要调用
|
|
|
|
|
|
|
|
|
|
this._runtime = runtime;
|
|
|
|
|
|
|
|
|
|
McControls = GetAllControls();
|
|
|
|
|
|
|
|
|
|
ControlImport();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
BottomSelect(runtime);
|
|
|
|
|
}
|
|
|
|
|
catch(Exception e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请检查输入内容格式是否正确!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BottomSelect(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region 自动参数下传
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.Download == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认下传数据?", "下传确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int b1 = Convert.ToInt32(ControlsEntity.ChooseMaterial1.MCValue.ToString());
|
|
|
|
|
int b2 = Convert.ToInt32(ControlsEntity.ChooseMaterial2.MCValue.ToString());
|
|
|
|
|
|
|
|
|
|
short bin1 = (short)StockMaterrialDbHelp.GetCodeById(b1);
|
|
|
|
|
short bin2 = (short)StockMaterrialDbHelp.GetCodeById(b2);
|
|
|
|
|
|
|
|
|
|
float MatTol1 = Convert.ToSingle(ControlsEntity.MaterialTolerance1.MCValue.ToString());
|
|
|
|
|
float MatTol2 = Convert.ToSingle(ControlsEntity.MaterialTolerance2.MCValue.ToString());
|
|
|
|
|
|
|
|
|
|
float MatWei1 = Convert.ToSingle(ControlsEntity.MaterialWeight1.MCValue.ToString());
|
|
|
|
|
float MatWei2 = Convert.ToSingle(ControlsEntity.MaterialWeight2.MCValue.ToString());
|
|
|
|
|
|
|
|
|
|
float GelSpeed = Convert.ToSingle(ControlsEntity.GelSpeedSet.MCValue.ToString());
|
|
|
|
|
|
|
|
|
|
float GelPosA = Convert.ToSingle(ControlsEntity.GelPosTimeA.MCValue.ToString());
|
|
|
|
|
float GelNagB = Convert.ToSingle(ControlsEntity.GelNagTimeB.MCValue.ToString());
|
|
|
|
|
short GelPosC = Convert.ToInt16(ControlsEntity.GelPosTimeC.MCValue.ToString());
|
|
|
|
|
|
|
|
|
|
short GelWater = Convert.ToInt16(ControlsEntity.GelWaterTime.MCValue.ToString());
|
|
|
|
|
short GelWait = Convert.ToInt16(ControlsEntity.GelWaitTime.MCValue.ToString());
|
|
|
|
|
short GelCloseHeat = Convert.ToInt16(ControlsEntity.GelCloseHeatTime.MCValue.ToString());
|
|
|
|
|
float GelDelayTime = Convert.ToSingle(ControlsEntity.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(ControlsEntity.WetDryWeight.MCValue.ToString());
|
|
|
|
|
short WetMix = Convert.ToInt16(ControlsEntity.WetMixTime.MCValue.ToString());
|
|
|
|
|
short WetOutDelay = Convert.ToInt16(ControlsEntity.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 = SingleSelect(),
|
|
|
|
|
MaterrialId = b1,
|
|
|
|
|
Type = 2,
|
|
|
|
|
Code = StockMaterrialDbHelp.GetCodeById(b1)
|
|
|
|
|
};
|
|
|
|
|
DeviceMaterrial deviceMaterial2 = new DeviceMaterrial()
|
|
|
|
|
{
|
|
|
|
|
DeviceId = SingleSelect(),
|
|
|
|
|
MaterrialId = b2,
|
|
|
|
|
Type = 2,
|
|
|
|
|
Code = StockMaterrialDbHelp.GetCodeById(b2)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
materials.Add(deviceMaterial1);
|
|
|
|
|
materials.Add(deviceMaterial2);
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "糊化湿混数据下传",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
MaterialBin1 = bin1,
|
|
|
|
|
MaterialBin2 = bin2,
|
|
|
|
|
MaterialWeight1 = MatWei1,
|
|
|
|
|
MaterialWeight2 = MatWei2,
|
|
|
|
|
MaterialTolerance1 = MatTol1,
|
|
|
|
|
MaterialTolerance2 = MatTol2,
|
|
|
|
|
GelSpeedSet = GelSpeed,
|
|
|
|
|
GelPosTimeA = GelPosA,
|
|
|
|
|
GelNagTimeB = GelNagB,
|
|
|
|
|
GelPosTimeC = GelPosC,
|
|
|
|
|
GelWaterTime = GelWater,
|
|
|
|
|
GelWaitTime = GelWait,
|
|
|
|
|
GelCloseHeatTime = GelCloseHeat,
|
|
|
|
|
GelOutDelayTime = GelDelayTime,
|
|
|
|
|
WetDryWeight = WetDryWei,
|
|
|
|
|
WetMixTime = WetMix,
|
|
|
|
|
WetOutDelayTime = WetOutDelay
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("数据下传成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 手动控制
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.GelManualPowder == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认手动下粉料?", "下粉确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isReady;
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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 = true;
|
|
|
|
|
MessageBox.Show("当前未选择产线!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isReady)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("信号未准备好!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "手动下粉料",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("信号下达成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.GelManualColdWater == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认下冷水?", "下水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bool isReady;
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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 = true;
|
|
|
|
|
MessageBox.Show("当前未选择产线!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isReady)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("信号未准备好!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "手动下冷水",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("信号下达成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.GelManualHotWater == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认下热水?", "下水确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isReady;
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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 = true;
|
|
|
|
|
MessageBox.Show("当前未选择产线!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isReady)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("信号未准备好!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "手动下热水",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("信号下达成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.WetManualGel == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认下糊化料?", "下糊化料确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool isReady;
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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("当前未选择产线!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isReady)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("信号未准备好!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "手动下糊化料",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("信号下达成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.WetManualControl == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认下传数据?", "下传确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float t = Convert.ToSingle(ControlsEntity.ManualTolerance.MCValue.ToString());
|
|
|
|
|
float w = Convert.ToSingle(ControlsEntity.ManualWeight.MCValue.ToString());
|
|
|
|
|
if (t < 0.1)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("公差不能小于0.1!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetValue value = new SetValue()
|
|
|
|
|
{
|
|
|
|
|
Value = w,
|
|
|
|
|
Toterance = t
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "手动下黑粉",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
ManualTolerance = t,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
ManualWeight = w,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("数据下传成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 自动启停
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.LineStart == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("确认启动生产?", "启动确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "产线启动",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("产线已启动!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.LineStop == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
switch (SingleSelect())
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "产线停止",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("已经停止生产");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 维修模式
|
|
|
|
|
|
|
|
|
|
if(ControlsEntity.RepairMode == runtime.Sender)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ControlsEntity.RepairState.MCValue.ToString() == "关")
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("是否开启维修模式?", "维修模式确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Db3000Helper.WriteModel(SingleSelect(), true);
|
|
|
|
|
ControlsEntity.RepairState.MCValue = "开";
|
|
|
|
|
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "维修模式开启",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("维修模式已开启");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ControlsEntity.RepairState.MCValue.ToString() == "开")
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("是否关闭维修模式?", "维修模式确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Db3000Helper.WriteModel(SingleSelect(), false);
|
|
|
|
|
ControlsEntity.RepairState.MCValue = "关";
|
|
|
|
|
|
|
|
|
|
Auto_Log log = new Auto_Log()
|
|
|
|
|
{
|
|
|
|
|
ActionKind = "维修模式关闭",
|
|
|
|
|
LogTime = DateTime.Now,
|
|
|
|
|
LineNo = SingleSelect(),
|
|
|
|
|
UserID = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FreeSqlUnit.Instance.Insert(log).ExecuteIdentity();
|
|
|
|
|
|
|
|
|
|
MessageBox.Show("维修模式已关闭");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 帮助类
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 单选选择
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回单选的产线号 如果未选择返回0</returns>
|
|
|
|
|
private int SingleSelect()
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToBoolean(ControlsEntity.Line1.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line2.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line3.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 3;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line4.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line5.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line6.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 6;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line7.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 7;
|
|
|
|
|
}
|
|
|
|
|
else if (Convert.ToBoolean(ControlsEntity.Line8.MCValue) == true)
|
|
|
|
|
{
|
|
|
|
|
return 8;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 控件导入
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ControlImport()
|
|
|
|
|
{
|
|
|
|
|
ControlsEntity.Line1 = GetMCRadioButtonControl("Line1");
|
|
|
|
|
ControlsEntity.Line2 = GetMCRadioButtonControl("Line2");
|
|
|
|
|
ControlsEntity.Line3 = GetMCRadioButtonControl("Line3");
|
|
|
|
|
ControlsEntity.Line4 = GetMCRadioButtonControl("Line4");
|
|
|
|
|
ControlsEntity.Line5 = GetMCRadioButtonControl("Line5");
|
|
|
|
|
ControlsEntity.Line6 = GetMCRadioButtonControl("Line6");
|
|
|
|
|
ControlsEntity.Line7 = GetMCRadioButtonControl("Line7");
|
|
|
|
|
ControlsEntity.Line8 = GetMCRadioButtonControl("Line8");
|
|
|
|
|
|
|
|
|
|
ControlsEntity.ChooseMaterial1 = GetComboBoxControl("ChooseMaterial1");
|
|
|
|
|
ControlsEntity.ChooseMaterial2 = GetComboBoxControl("ChooseMaterial2");
|
|
|
|
|
|
|
|
|
|
ControlsEntity.MaterialWeight1 = GetBaseControl("MaterialWeight1");
|
|
|
|
|
ControlsEntity.MaterialWeight2 = GetBaseControl("MaterialWeight2");
|
|
|
|
|
ControlsEntity.MaterialTolerance1 = GetBaseControl("MaterialTolerance1");
|
|
|
|
|
ControlsEntity.MaterialTolerance2 = GetBaseControl("MaterialTolerance2");
|
|
|
|
|
ControlsEntity.GelSpeedSet = GetBaseControl("GelSpeedSet");
|
|
|
|
|
ControlsEntity.GelPosTimeA = GetBaseControl("GelPosTimeA");
|
|
|
|
|
ControlsEntity.GelNagTimeB = GetBaseControl("GelNagTimeB");
|
|
|
|
|
ControlsEntity.GelPosTimeC = GetBaseControl("GelPosTimeC");
|
|
|
|
|
ControlsEntity.GelWaterTime = GetBaseControl("GelWaterTime");
|
|
|
|
|
ControlsEntity.GelWaitTime = GetBaseControl("GelWaitTime");
|
|
|
|
|
ControlsEntity.GelCloseHeatTime = GetBaseControl("GelCloseHeatTime");
|
|
|
|
|
ControlsEntity.GelOutDelayTime = GetBaseControl("GelOutDelayTime");
|
|
|
|
|
|
|
|
|
|
ControlsEntity.RepairState = GetBaseControl("RepairState") as MCLabel;
|
|
|
|
|
|
|
|
|
|
ControlsEntity.WetDryWeight = GetBaseControl("WetDryWeight");
|
|
|
|
|
ControlsEntity.WetMixTime = GetBaseControl("WetMixTime");
|
|
|
|
|
ControlsEntity.WetOutDelayTime = GetBaseControl("WetOutDelayTime");
|
|
|
|
|
ControlsEntity.ManualTolerance = GetBaseControl("ManualTolerance");
|
|
|
|
|
ControlsEntity.ManualWeight = GetBaseControl("ManualWeight");
|
|
|
|
|
|
|
|
|
|
ControlsEntity.WetManualControl = GetButtonControl("WetManualControl");
|
|
|
|
|
ControlsEntity.Download = GetButtonControl("Download");
|
|
|
|
|
ControlsEntity.LineStart = GetButtonControl("LineStart");
|
|
|
|
|
ControlsEntity.LineStop = GetButtonControl("LineStop");
|
|
|
|
|
ControlsEntity.GelManualPowder = GetButtonControl("GelManualPowder");
|
|
|
|
|
ControlsEntity.GelManualColdWater = GetButtonControl("GelManualColdWater");
|
|
|
|
|
ControlsEntity.GelManualHotWater = GetButtonControl("GelManualHotWater");
|
|
|
|
|
ControlsEntity.WetManualGel = GetButtonControl("WetManualGel");
|
|
|
|
|
ControlsEntity.RepairMode = GetButtonControl("RepairMode");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IBaseControl GetBaseControl(string name)
|
|
|
|
|
{
|
|
|
|
|
return McControls.First(x => x.Name == name) as IBaseControl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Button GetButtonControl(string name)
|
|
|
|
|
{
|
|
|
|
|
return McControls.First(x => x.Name == name) as Button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MCCombobox GetComboBoxControl(string name)
|
|
|
|
|
{
|
|
|
|
|
return McControls.First(x => x.Name == name) as MCCombobox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MCRadioButton GetMCRadioButtonControl(string name)
|
|
|
|
|
{
|
|
|
|
|
return McControls.First(x => x.Name == name) as MCRadioButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|