|
|
|
@ -1,4 +1,7 @@
|
|
|
|
|
using HighWayIot.Repository.domain;
|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
using HighWayIot.Plc;
|
|
|
|
|
using HighWayIot.Plc.PlcHelper;
|
|
|
|
|
using HighWayIot.Repository.domain;
|
|
|
|
|
using HighWayIot.Repository.service;
|
|
|
|
|
using HighWayIot.Winform.Business;
|
|
|
|
|
using HighWayIot.Winform.MainForm;
|
|
|
|
@ -15,6 +18,7 @@ using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Xml.Schema;
|
|
|
|
|
|
|
|
|
|
namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
{
|
|
|
|
@ -53,12 +57,7 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工位配方字段实例
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ZxRecipePositionParaEntity zxRecipePositionParaEntity = new ZxRecipePositionParaEntity();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配方字段实例剪切板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ZxRecipeParaEntity zxRecipeParaEntityCut;
|
|
|
|
|
private List<ZxRecipePositionParaEntity> zxRecipePositionParaEntity = new List<ZxRecipePositionParaEntity>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 称重DataGridView数据源
|
|
|
|
@ -80,6 +79,26 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string NowRecipeCode;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 配方字段剪切板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ZxRecipeParaEntity ParaCopyBoard = new ZxRecipeParaEntity();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工位全部配方字段剪切板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private List<ZxRecipePositionParaEntity> PositionParaCopyBoard = new List<ZxRecipePositionParaEntity>();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工位单个配方字段剪切板
|
|
|
|
|
/// </summary>
|
|
|
|
|
private ZxRecipePositionParaEntity SingalPositionParaCopyBoard;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// PLC实例
|
|
|
|
|
/// </summary>
|
|
|
|
|
private RecipeParaHelper recipeParaHelper = new RecipeParaHelper();
|
|
|
|
|
|
|
|
|
|
public RecipeConfigPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
@ -97,9 +116,17 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
RecipeDataGridView.DataSource = RecipeLists;
|
|
|
|
|
|
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[0].Cells["RecipeCode"].Value.ToString();
|
|
|
|
|
InitPositionEntities();
|
|
|
|
|
|
|
|
|
|
//读取SPEC编号
|
|
|
|
|
PlcSpecNoLabel.Text = PlcConnect.ReadUInt321("D206").ToString();
|
|
|
|
|
|
|
|
|
|
//读取SPEC名称
|
|
|
|
|
PlcSpecNameLabel.Text = PlcConnect.ReadString1("D290", 10).Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 配方信息
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加配方信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -232,6 +259,10 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
RecipeDataGridView.DataSource = RecipeLists;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 称量信息
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加称量信息
|
|
|
|
|
/// </summary>
|
|
|
|
@ -371,199 +402,6 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void SaveParaButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//if (MessageBox.Show($"确定要保存配方编号为 [{s}] 的配方的参数?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
//{
|
|
|
|
|
// return;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//获取前端的值
|
|
|
|
|
GetParaValue();
|
|
|
|
|
|
|
|
|
|
//搜索配方字段
|
|
|
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
int flag = GetSelectIndex();
|
|
|
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode && x.Position == flag);
|
|
|
|
|
//获得对应工位号
|
|
|
|
|
bool isSuccess = false;
|
|
|
|
|
//公共参数
|
|
|
|
|
//没有就插入
|
|
|
|
|
if (paraData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
if(zxRecipeParaService.InsertRecipeParaInfo(zxRecipeParaEntity))
|
|
|
|
|
{
|
|
|
|
|
isSuccess = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//有就更改
|
|
|
|
|
else if (paraData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
zxRecipeParaEntity.Id = paraData[0].Id;
|
|
|
|
|
if (zxRecipeParaService.UpdateRecipeParaInfo(zxRecipeParaEntity))
|
|
|
|
|
{
|
|
|
|
|
isSuccess = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同公共参数!请检查数据库。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//贴合参数
|
|
|
|
|
//没有就插入
|
|
|
|
|
if (positionParaData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
if (zxRecipePositionParaService.InsertRecipePositionParaInfo(zxRecipePositionParaEntity))
|
|
|
|
|
{
|
|
|
|
|
isSuccess = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//有就更改
|
|
|
|
|
else if (positionParaData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
zxRecipePositionParaEntity.Id = positionParaData[0].Id;
|
|
|
|
|
if (zxRecipePositionParaService.UpdateRecipePositionParaInfo(zxRecipePositionParaEntity))
|
|
|
|
|
{
|
|
|
|
|
isSuccess = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
isSuccess = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同贴合参数!请检查数据库。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isSuccess)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.LogRefreshAction.Invoke("保存成功" + DateTime.Now.ToString());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BaseForm.LogRefreshAction.Invoke("保存失败" + DateTime.Now.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void CopyParaButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//zxRecipeParaEntityCut = GetParaValue();
|
|
|
|
|
NowCopyLabel.Text = NowRecipeCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数粘贴
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void PasteParaButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (zxRecipeParaEntityCut == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("剪切板为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//SetParaValue(zxRecipeParaEntityCut);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数清空
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void ClearCutBoradButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
zxRecipeParaEntityCut = null;
|
|
|
|
|
NowCopyLabel.Text = "N/A";
|
|
|
|
|
|
|
|
|
|
if (MessageBox.Show("是否要清空前端数据", "", MessageBoxButtons.YesNo) == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
//SetParaValue(new ZxRecipeParaEntity());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 所选配方内容更改事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void RecipeDataGridView_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int a = RecipeDataGridView.CurrentRow.Index;
|
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
|
|
|
|
|
|
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
WeightToDataSource();
|
|
|
|
|
|
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
|
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
|
|
|
|
|
|
|
|
//设置参数
|
|
|
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
int flag = GetSelectIndex();
|
|
|
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode && x.Position == flag);
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (paraData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(new ZxRecipeParaEntity());
|
|
|
|
|
}
|
|
|
|
|
//有就显示
|
|
|
|
|
else if (paraData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
}
|
|
|
|
|
//有多条设为第一条
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同配方字段信息!将设置为第一条,请检查数据库。");
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (positionParaData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPrivateParaValue(new ZxRecipePositionParaEntity());
|
|
|
|
|
}
|
|
|
|
|
//有就显示
|
|
|
|
|
else if (positionParaData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
SetPrivateParaValue(positionParaData[0]);
|
|
|
|
|
}
|
|
|
|
|
//有多条设为第一条
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同配方字段信息!将设置为第一条,请检查数据库。");
|
|
|
|
|
SetPrivateParaValue(positionParaData[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 称重数据关联物料数据
|
|
|
|
|
/// </summary>
|
|
|
|
@ -605,6 +443,212 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 所选配方内容更改事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void RecipeDataGridView_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int a = RecipeDataGridView.CurrentRow.Index;
|
|
|
|
|
NowRecipeCode = RecipeDataGridView.Rows[a].Cells["RecipeCode"].Value.ToString();
|
|
|
|
|
SpecNoLabel.Text = RecipeDataGridView.Rows[a].Cells["RecipeSpecCode"].Value.ToString();
|
|
|
|
|
SpecNameLabel.Text = RecipeDataGridView.Rows[a].Cells["RecipeSpecName"].Value.ToString();
|
|
|
|
|
|
|
|
|
|
//初始化工位参数类
|
|
|
|
|
InitPositionEntities();
|
|
|
|
|
|
|
|
|
|
WeightLists = zxWeightService.GetWeightInfos(NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
WeightToDataSource();
|
|
|
|
|
|
|
|
|
|
WeightDataGridView.DataSource = null;
|
|
|
|
|
WeightDataGridView.DataSource = weightDataSourceEntities;
|
|
|
|
|
|
|
|
|
|
//设置参数
|
|
|
|
|
var paraData = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
int flag = GetSelectIndex();
|
|
|
|
|
var positionParaData = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.RecipeCode == NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (paraData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(new ZxRecipeParaEntity());
|
|
|
|
|
zxRecipeParaEntity = new ZxRecipeParaEntity();
|
|
|
|
|
}
|
|
|
|
|
//有就显示
|
|
|
|
|
else if (paraData.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
zxRecipeParaEntity = paraData[0];
|
|
|
|
|
}
|
|
|
|
|
//有多条设为第一条
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同公共配方字段信息!将设置为第一条。点击清除脏数据");
|
|
|
|
|
SetPublicParaValue(paraData[0]);
|
|
|
|
|
zxRecipeParaEntity = paraData[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//没有就全0
|
|
|
|
|
if (positionParaData.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
SetPrivateParaValue(new ZxRecipePositionParaEntity());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in positionParaData)
|
|
|
|
|
{
|
|
|
|
|
ChangePositionEntities(item);
|
|
|
|
|
}
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity.Where(x => x.Position == flag).FirstOrDefault());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数设置
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 参数保存
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void SaveParaButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show($"确定要保存配方编号为 [{NowRecipeCode}] 的配方的参数?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var index = GetSelectIndex();
|
|
|
|
|
//从前端更新值
|
|
|
|
|
GetPublicParaValue();
|
|
|
|
|
GetPrivateParaValue(index);
|
|
|
|
|
|
|
|
|
|
//查重
|
|
|
|
|
var paraEntity = zxRecipeParaService.GetRecipeParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
var positionParaEntity = zxRecipePositionParaService.GetRecipePositionParaInfoByRecipeCode(NowRecipeCode);
|
|
|
|
|
|
|
|
|
|
zxRecipeParaEntity.RecipeCode = NowRecipeCode;
|
|
|
|
|
//保存公共参数
|
|
|
|
|
var flag1 = true;
|
|
|
|
|
if (paraEntity.Count == 0) //没有就插入
|
|
|
|
|
{
|
|
|
|
|
flag1 = zxRecipeParaService.InsertRecipeParaInfo(zxRecipeParaEntity);
|
|
|
|
|
}
|
|
|
|
|
else if (paraEntity.Count == 1) //有就更新
|
|
|
|
|
{
|
|
|
|
|
zxRecipeParaEntity.Id = paraEntity[0].Id;
|
|
|
|
|
flag1 = zxRecipeParaService.UpdateRecipeParaInfo(zxRecipeParaEntity);
|
|
|
|
|
}
|
|
|
|
|
else //多条更新第一条
|
|
|
|
|
{
|
|
|
|
|
zxRecipeParaEntity.Id = paraEntity[0].Id;
|
|
|
|
|
flag1 = zxRecipeParaService.UpdateRecipeParaInfo(zxRecipeParaEntity);
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同公共配方字段信息!将设置为第一条。点击清除脏数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存贴合参数
|
|
|
|
|
var flag2 = true;
|
|
|
|
|
foreach (var item in zxRecipePositionParaEntity)
|
|
|
|
|
{
|
|
|
|
|
item.RecipeCode = NowRecipeCode;
|
|
|
|
|
var count = positionParaEntity.Count(x => x.Position == item.Position);
|
|
|
|
|
//如果没有
|
|
|
|
|
if (count == 0)
|
|
|
|
|
{
|
|
|
|
|
flag2 = zxRecipePositionParaService.InsertRecipePositionParaInfo(item);
|
|
|
|
|
}
|
|
|
|
|
else //有 多条存第一条
|
|
|
|
|
{
|
|
|
|
|
item.Id = positionParaEntity.FirstOrDefault(x => x.Position == item.Position).Id;
|
|
|
|
|
flag2 = zxRecipePositionParaService.UpdateRecipePositionParaInfo(item);
|
|
|
|
|
|
|
|
|
|
if (count != 1) //多条提示
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("存在多条未删除的相同公共配方字段信息!将设置为第一条。点击清除脏数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!flag2) break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (flag1 && flag2)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.LogRefreshAction.Invoke("更新成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BaseForm.LogRefreshAction.Invoke("更新失败");
|
|
|
|
|
}
|
|
|
|
|
//保存贴合参数
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化工位参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void InitPositionEntities()
|
|
|
|
|
{
|
|
|
|
|
zxRecipePositionParaEntity.Clear();
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 1
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 2
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 31
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 32
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 41
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 42
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 51
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
zxRecipePositionParaEntity.Add(new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
Position = 52
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 替换工位信息中的元素
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
|
private void ChangePositionEntities(ZxRecipePositionParaEntity entity)
|
|
|
|
|
{
|
|
|
|
|
int index = zxRecipePositionParaEntity.FindIndex(x => x.Position == entity.Position);
|
|
|
|
|
if (index == -1)
|
|
|
|
|
{
|
|
|
|
|
BaseForm.LogRefreshAction.Invoke("数据保存失败,请重新启动页面");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
zxRecipePositionParaEntity[index] = entity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置显示的贴合参数字段值
|
|
|
|
|
/// </summary>
|
|
|
|
@ -621,7 +665,6 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
E8TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E8);
|
|
|
|
|
E9TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E9);
|
|
|
|
|
E10TextBox.Text = GeneralUtils.IntEmptyOrToString(entity.E10);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -645,28 +688,41 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
LightWidthTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.LightWidth);
|
|
|
|
|
SlowDistanceTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.SlowDistance);
|
|
|
|
|
StopDistanceTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.StopDistance);
|
|
|
|
|
TireWeightTextBox.Text = GeneralUtils.IntEmptyOrToString(paraEntity.TireWeight);
|
|
|
|
|
TireWeightTextBox.Text = paraEntity.TireWeight == null ? "0" : paraEntity.TireWeight.ToString();
|
|
|
|
|
//SpecNoLabel.Text = GeneralUtils.IntEmptyOrToString(paraEntity.SpecCode);
|
|
|
|
|
//SpecNameLabel.Text = paraEntity.SpecName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取界面上的配方参数
|
|
|
|
|
/// 贴合参数获取值 存到实体
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>获取到的配方参数值</returns>
|
|
|
|
|
private void GetParaValue()
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private void GetPrivateParaValue(int flag)
|
|
|
|
|
{
|
|
|
|
|
zxRecipePositionParaEntity.E1 = GeneralUtils.StringNullOrToInt(E1TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E2 = GeneralUtils.StringNullOrToInt(E2TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E3 = GeneralUtils.StringNullOrToInt(E3TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E4 = GeneralUtils.StringNullOrToInt(E4TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E5 = GeneralUtils.StringNullOrToInt(E5TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E6 = GeneralUtils.StringNullOrToInt(E6TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E7 = GeneralUtils.StringNullOrToInt(E7TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E8 = GeneralUtils.StringNullOrToInt(E8TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E9 = GeneralUtils.StringNullOrToInt(E9TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.E10 = GeneralUtils.StringNullOrToInt(E10TextBox.Text);
|
|
|
|
|
zxRecipePositionParaEntity.Position = GetSelectIndex();
|
|
|
|
|
zxRecipePositionParaEntity.RecipeCode = NowRecipeCode;
|
|
|
|
|
var e = zxRecipePositionParaEntity.FirstOrDefault(x => x.Position == flag);
|
|
|
|
|
|
|
|
|
|
e.E1 = GeneralUtils.StringNullOrToInt(E1TextBox.Text);
|
|
|
|
|
e.E2 = GeneralUtils.StringNullOrToInt(E2TextBox.Text);
|
|
|
|
|
e.E3 = GeneralUtils.StringNullOrToInt(E3TextBox.Text);
|
|
|
|
|
e.E4 = GeneralUtils.StringNullOrToInt(E4TextBox.Text);
|
|
|
|
|
e.E5 = GeneralUtils.StringNullOrToInt(E5TextBox.Text);
|
|
|
|
|
e.E6 = GeneralUtils.StringNullOrToInt(E6TextBox.Text);
|
|
|
|
|
e.E7 = GeneralUtils.StringNullOrToInt(E7TextBox.Text);
|
|
|
|
|
e.E8 = GeneralUtils.StringNullOrToInt(E8TextBox.Text);
|
|
|
|
|
e.E9 = GeneralUtils.StringNullOrToInt(E9TextBox.Text);
|
|
|
|
|
e.E10 = GeneralUtils.StringNullOrToInt(E10TextBox.Text);
|
|
|
|
|
e.Position = GetSelectIndex();
|
|
|
|
|
e.RecipeCode = NowRecipeCode;
|
|
|
|
|
|
|
|
|
|
ChangePositionEntities(e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 公共参数获取值 存到实体
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private void GetPublicParaValue()
|
|
|
|
|
{
|
|
|
|
|
zxRecipeParaEntity.S0 = S0Check.Checked;
|
|
|
|
|
zxRecipeParaEntity.S1 = S1Check.Checked;
|
|
|
|
|
zxRecipeParaEntity.S2 = S2Check.Checked;
|
|
|
|
@ -681,12 +737,20 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
zxRecipeParaEntity.LightWidth = GeneralUtils.StringNullOrToInt(LightWidthTextBox.Text);
|
|
|
|
|
zxRecipeParaEntity.SlowDistance = GeneralUtils.StringNullOrToInt(SlowDistanceTextBox.Text);
|
|
|
|
|
zxRecipeParaEntity.StopDistance = GeneralUtils.StringNullOrToInt(StopDistanceTextBox.Text);
|
|
|
|
|
zxRecipeParaEntity.TireWeight = GeneralUtils.StringNullOrToInt(TireWeightTextBox.Text);
|
|
|
|
|
zxRecipeParaEntity.RecipeCode = NowRecipeCode;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
zxRecipeParaEntity.TireWeight = float.Parse(TireWeightTextBox.Text == string.Empty ? "0" : TireWeightTextBox.Text);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("胎体重量请输入整数或小数");
|
|
|
|
|
}
|
|
|
|
|
zxRecipeParaEntity.SpecCode = SpecNoLabel.Text;
|
|
|
|
|
zxRecipeParaEntity.SpecName = SpecNameLabel.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工位改变
|
|
|
|
|
/// 工位改变 保存现在的,显示换的
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
@ -698,8 +762,9 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
{
|
|
|
|
|
int flag = GetSelectIndex();
|
|
|
|
|
|
|
|
|
|
SetParaView(flag);
|
|
|
|
|
if(flag < 10)
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity.Where(x => x.Position == flag).FirstOrDefault());
|
|
|
|
|
|
|
|
|
|
if (flag < 10)
|
|
|
|
|
{
|
|
|
|
|
BodyRadioButton.Enabled = false;
|
|
|
|
|
SideRadioButton.Enabled = false;
|
|
|
|
@ -712,21 +777,6 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 读取数据库设置贴合参数字段
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="flag"></param>
|
|
|
|
|
/// <param name="recipeCode"></param>
|
|
|
|
|
private void SetParaView(int flag)
|
|
|
|
|
{
|
|
|
|
|
zxRecipePositionParaEntity = zxRecipePositionParaService.GetRecipePositionParaInfos(x => x.Position == flag && x.RecipeCode == NowRecipeCode).FirstOrDefault();
|
|
|
|
|
if (zxRecipePositionParaEntity == null)
|
|
|
|
|
{
|
|
|
|
|
zxRecipePositionParaEntity = new ZxRecipePositionParaEntity();
|
|
|
|
|
}
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取选择的工位包边
|
|
|
|
|
/// </summary>
|
|
|
|
@ -784,5 +834,214 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 暂存工位参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void PositionRadioButton_MouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = GetSelectIndex();
|
|
|
|
|
|
|
|
|
|
GetPrivateParaValue(index);
|
|
|
|
|
|
|
|
|
|
BaseForm.LogRefreshAction.Invoke($"[{index.ToString()}] 工位参数已暂存");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 公共参数复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void CopyParaButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ParaCopyBoard = zxRecipeParaEntity;
|
|
|
|
|
NowCopyLabel.Text = NowRecipeCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 公共参数粘贴
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void PasteParaButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (ParaCopyBoard == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("剪切板为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetPublicParaValue(ParaCopyBoard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 贴合参数复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void CopyPositionButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var index = GetSelectIndex();
|
|
|
|
|
GetPrivateParaValue(index);
|
|
|
|
|
SingalPositionParaCopyBoard = zxRecipePositionParaEntity.FirstOrDefault(x => x.Position == index);
|
|
|
|
|
PositionCopyBoardLabel.Text = index.ToString() + "|" + NowRecipeCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 贴合参数粘贴
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void PastePositionButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (SingalPositionParaCopyBoard == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("剪切板为空!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SetPrivateParaValue(SingalPositionParaCopyBoard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整体复制
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void CopyAllButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int index = GetSelectIndex();
|
|
|
|
|
GetPrivateParaValue(index);
|
|
|
|
|
ParaCopyBoard = new ZxRecipeParaEntity()
|
|
|
|
|
{
|
|
|
|
|
S0 = zxRecipeParaEntity.S0 ?? false,
|
|
|
|
|
S1 = zxRecipeParaEntity.S1 ?? false,
|
|
|
|
|
S2 = zxRecipeParaEntity.S2 ?? false,
|
|
|
|
|
S3 = zxRecipeParaEntity.S3 ?? false,
|
|
|
|
|
S4 = zxRecipeParaEntity.S4 ?? false,
|
|
|
|
|
S5 = zxRecipeParaEntity.S5 ?? false,
|
|
|
|
|
S6 = zxRecipeParaEntity.S6 ?? false,
|
|
|
|
|
S7 = zxRecipeParaEntity.S7 ?? false,
|
|
|
|
|
S8 = zxRecipeParaEntity.S8 ?? false,
|
|
|
|
|
S9 = zxRecipeParaEntity.S9 ?? false,
|
|
|
|
|
|
|
|
|
|
RimInch = zxRecipeParaEntity.RimInch,
|
|
|
|
|
LightWidth = zxRecipeParaEntity.LightWidth,
|
|
|
|
|
SlowDistance = zxRecipeParaEntity.SlowDistance,
|
|
|
|
|
StopDistance = zxRecipeParaEntity.StopDistance,
|
|
|
|
|
TireWeight = zxRecipeParaEntity.TireWeight,
|
|
|
|
|
};
|
|
|
|
|
PositionParaCopyBoard.Clear();
|
|
|
|
|
foreach (var entity in zxRecipePositionParaEntity)
|
|
|
|
|
{
|
|
|
|
|
var clone = new ZxRecipePositionParaEntity()
|
|
|
|
|
{
|
|
|
|
|
E1 = entity.E1,
|
|
|
|
|
E2 = entity.E2,
|
|
|
|
|
E3 = entity.E3,
|
|
|
|
|
E4 = entity.E4,
|
|
|
|
|
E5 = entity.E5,
|
|
|
|
|
E6 = entity.E6,
|
|
|
|
|
E7 = entity.E7,
|
|
|
|
|
E8 = entity.E8,
|
|
|
|
|
E9 = entity.E9,
|
|
|
|
|
E10 = entity.E10,
|
|
|
|
|
Position = entity.Position,
|
|
|
|
|
};
|
|
|
|
|
PositionParaCopyBoard.Add(clone);
|
|
|
|
|
}
|
|
|
|
|
//PositionParaCopyBoard = zxRecipePositionParaEntity;
|
|
|
|
|
NowCopyLabel.Text = NowRecipeCode + " 全复制";
|
|
|
|
|
PositionCopyBoardLabel.Text = "全复制";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 整体粘贴
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void PasteAllButton_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (zxRecipeParaEntity != null && (zxRecipePositionParaEntity != null || zxRecipePositionParaEntity.Count != 8))
|
|
|
|
|
{
|
|
|
|
|
zxRecipePositionParaEntity = PositionParaCopyBoard;
|
|
|
|
|
zxRecipeParaEntity = ParaCopyBoard;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("粘贴失败,请重新复制数据");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetPublicParaValue(zxRecipeParaEntity);
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity.First(x => x.Position == GetSelectIndex()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 清除脏数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void ClearDirtyData_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show($"确定要清除脏数据?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (zxRecipeParaService.DeleteDirtyData() &&
|
|
|
|
|
zxRecipePositionParaService.DeleteDirtyData())
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("清除成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("清除失败");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上载到plc
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void UploadToPlc_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show($"是否要将此配方下传到PLC?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
GetPublicParaValue();
|
|
|
|
|
GetPrivateParaValue(GetSelectIndex());
|
|
|
|
|
if (recipeParaHelper.UploadToPLC(zxRecipeParaEntity, zxRecipePositionParaEntity))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("下发到PLC成功");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("下发到PLC失败");
|
|
|
|
|
}
|
|
|
|
|
PlcSpecNameLabel.Text = zxRecipeParaEntity.SpecName.Trim();
|
|
|
|
|
PlcSpecNoLabel.Text = zxRecipeParaEntity.SpecCode.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 从plc读取
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
private void DownloadFromPlc_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show($"是否要从PLC读取配方?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
zxRecipePositionParaEntity = recipeParaHelper.DownLoadFormPlc(ref zxRecipeParaEntity);
|
|
|
|
|
SetPublicParaValue(zxRecipeParaEntity);
|
|
|
|
|
SetPrivateParaValue(zxRecipePositionParaEntity.First(x => x.Position == GetSelectIndex()));
|
|
|
|
|
PlcSpecNameLabel.Text = zxRecipeParaEntity.SpecName.Trim();
|
|
|
|
|
PlcSpecNoLabel.Text = zxRecipeParaEntity.SpecCode.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|