You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.8 KiB
C#
123 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Net.NetworkInformation;
|
|
using System.Text;
|
|
using System.Linq;
|
|
using System.Data;
|
|
using System.Threading;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Controls.Base;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Codd.Session;
|
|
using System.IO;
|
|
using Mesnac.Controls.Default;
|
|
using Mesnac.Action.Feeding.BasicInfo;
|
|
|
|
namespace Mesnac.Action.Feeding.FeedingPlc
|
|
{
|
|
/// <summary>
|
|
/// 修改称量次数
|
|
/// </summary>
|
|
public class ModifyWeightNum : FeedingAction, IAction
|
|
{
|
|
private bool IsHaveXiaoliao()
|
|
{
|
|
List<RecipeData.RecipeWeightInfo> lst = new RecipeData().GetCurrentRecipeWeightInfo();
|
|
foreach (RecipeData.RecipeWeightInfo item in lst)
|
|
{
|
|
if (item.WeightType == (int)RecipeData.WeightType.小料)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
private int ModifyAddress(string key)
|
|
{
|
|
if (key == PlcData.Instance.CarbonFinishedCount.FieldKey)
|
|
{
|
|
return 1;
|
|
}
|
|
if (key == PlcData.Instance.PloyFinishedCount.FieldKey)
|
|
{
|
|
return 2;
|
|
}
|
|
if (key == PlcData.Instance.OilFinishedCount.FieldKey)
|
|
{
|
|
return 4;
|
|
}
|
|
if (key == PlcData.Instance.XiaoLiaoFinishedCount.FieldKey)
|
|
{
|
|
return 8;
|
|
}
|
|
if (key == PlcData.Instance.MixingFinishedCount.FieldKey)
|
|
{
|
|
return 16;
|
|
}
|
|
return 0;
|
|
}
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime);
|
|
|
|
string msg = String.Empty;
|
|
|
|
#region 判断当班计划界面是否打开
|
|
|
|
//if (PlanCommon.IsInit == false)
|
|
//{
|
|
// msg = "当班计划还为初始化,请先打开当班计划,再进行此操作!";
|
|
// ShowMsg(msg, Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
// return;
|
|
//}
|
|
|
|
#endregion
|
|
|
|
if (MessageBox.Show("确认修改称量次数吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
{
|
|
return;
|
|
}
|
|
IBaseControl c = base.GetMCControlByKey("MCTextBox1").FirstOrDefault();
|
|
int Num = 0;
|
|
if (!int.TryParse(c.MCValue.ToString(), out Num))
|
|
{
|
|
MessageBox.Show("请填写正确的次数!");
|
|
return;
|
|
}
|
|
base.LogDebug("修改称量次数为" + Num);
|
|
bool isSuccess = false;
|
|
List<MCRadioButton> lst = base.GetTControls<MCRadioButton>();
|
|
string key = string.Empty;
|
|
foreach (MCRadioButton rb in lst)
|
|
{
|
|
if (rb.Checked)
|
|
{
|
|
key = rb.MCKey;
|
|
PlcData.DataKeyValue data = PlcData.Instance.GetDataKeyValue(key);
|
|
if (data!=null && PlcData.Instance.PlcWriteByDataKey(data,new object[] { Num }))
|
|
{
|
|
isSuccess = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if (isSuccess)
|
|
{
|
|
if (IsHaveXiaoliao())
|
|
{
|
|
Num = ModifyAddress(key);
|
|
if (Num > 0)
|
|
{
|
|
PlcData.Instance.PlcWriteByDataKey(PlcData.Instance.XiaoLiaoCountChange, new object[] { Num });
|
|
}
|
|
}
|
|
MessageBox.Show("修改称量次数成功!");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("修改称量次数失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|