|
|
@ -59,7 +59,10 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
/// <param name="e"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void ReadButton_Click(object sender, EventArgs e)
|
|
|
|
private void ReadButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = PlcConnect.PlcRead(PlcAddress.Text, (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue));
|
|
|
|
DataTypeEnum type = (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue);
|
|
|
|
|
|
|
|
Type t = GeneralUtils.GetTypeByEnum(type);
|
|
|
|
|
|
|
|
var result = PlcConnect.PlcRead(PlcAddress.Text, type);
|
|
|
|
|
|
|
|
PlcShowValue.Text = Convert.ToDecimal(result).ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -69,7 +72,10 @@ namespace HighWayIot.Winform.UserControlPages
|
|
|
|
/// <param name="e"></param>
|
|
|
|
/// <param name="e"></param>
|
|
|
|
private void WriteButton_Click(object sender, EventArgs e)
|
|
|
|
private void WriteButton_Click(object sender, EventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
decimal.TryParse(PlcValue.Text, out decimal value);
|
|
|
|
if(!decimal.TryParse(PlcValue.Text, out decimal value))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MessageBox.Show("类型转换错误!");
|
|
|
|
|
|
|
|
}
|
|
|
|
var result = PlcConnect.PlcWrite(PlcAddress.Text, value, (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue));
|
|
|
|
var result = PlcConnect.PlcWrite(PlcAddress.Text, value, (DataTypeEnum)Convert.ToInt32(PlcType.SelectedValue));
|
|
|
|
bool r = result.IsSuccess;
|
|
|
|
bool r = result.IsSuccess;
|
|
|
|
PlcShowValue.Text = r.ToString();
|
|
|
|
PlcShowValue.Text = r.ToString();
|
|
|
|