1
0
Fork 0

test - 添加测试代码 准备合并

master
SoulStar 4 weeks ago
parent 57cc190a41
commit d97b3ee3da

@ -36,31 +36,37 @@ namespace HighWayIot.Plc
SocketKeepAliveTime = -1,
IsPersistentConnection = true,
};
plc.ConnectServer();
var a = plc.ConnectServer();
logHelper.Info($"Plc连接 信息:[{a.Message}] 是否成功:[{a.IsSuccess.ToString()}] 错误代码:[{a.ErrorCode}]");
}
catch (Exception ex)
{
logHelper.Error("初始化PLC服务器发生错误", ex);
}
//string s = IsConnect ? "成功" : "失败";
//logHelper.Info($"PLC连接{s}");
return plc;
}
/// <summary>
/// plc 是不是保持链接
/// </summary>
public static bool IsConnect
{
get
///// <summary>
///// plc 是不是保持链接
///// </summary>
//public static bool IsConnect
//{
// get
// {
// if (MelsecInstance == null) return false;
// var result = MelsecInstance.ReadPlcType();
// logHelper.Info($"PLC型号{result.Content}");
// return result.IsSuccess;
// }
//}
public static int Test()
{
if (MelsecInstance == null) return false;
var result = MelsecInstance.ReadPlcType();
logHelper.Info($"PLC型号{result.Content}");
return result.IsSuccess;
}
return MelsecInstance.ReadInt16("D1").Content;
}
/// <summary>

@ -48,8 +48,8 @@ namespace HighWayIot.Winform.UserControlPages
private void button2_Click(object sender, EventArgs e)
{
SqlLogHelper.AddLog("wdas", 7, 1231535246, 9);
SqlLogHelper.AddErrorLog("wocasda", 4, 5, 6);
var res = PlcConnect.Test();
PlcShowValue.Text = res.ToString();
}
/// <summary>

Loading…
Cancel
Save