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.

43 lines
1.9 KiB
C#

using Mesnac.Action.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.DeviceParamManage
{
public class WriteDeviceParamInfo : ChemicalWeighingAction, IAction
{
public void Run(RuntimeParameter runtime)
{
try
{
base.RunIni(runtime); //必须要调用
foreach (var item in BasePlcHelper.Instance.dataKeyValues)
{
if (item.Name == "VccHighWei" || item.Name == "VccLowWei" || item.Name == "VccJogWei" || item.Name == "VccExcWei" || item.Name == "GFAHighWei" || item.Name == "GFALowWei" || item.Name == "GFAJogWei" || item.Name == "GFAExcWei" || item.Name == "ResinHighWei" || item.Name == "ResinLowWei" || item.Name == "ResinJogWei" || item.Name == "ResinExcWei")
{
TextBox comboBox = base.GetControlById(item.Name) as TextBox;
decimal WriteValue = decimal.Parse(comboBox.Text);
var writeResult10 = BasePlcHelper.Instance.PlcWriteFloatByDataKey(item, (float)WriteValue);
}
else
{
TextBox comboBox = base.GetControlById(item.Name) as TextBox;
int WriteValue = int.Parse(comboBox.Text);
var writeResult4 = BasePlcHelper.Instance.PlcWriteByDataKey(item, new object[] { WriteValue });
}
}
MessageBox.Show("修改成功!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show("修改失败!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}