master
CZ 6 months ago
parent bc18b36369
commit f22e2c8d5d

@ -182,12 +182,18 @@ public class PlcMgr
return false; return false;
} }
static bool heart = false;
/// <summary>
/// 发送心跳
/// </summary>
/// <returns></returns>
public static bool SendHear() public static bool SendHear()
{ {
if (PlcClient != null) if (PlcClient != null)
{ {
HostToPlc writeHostToPlc = new HostToPlc(); HostToPlc writeHostToPlc = new HostToPlc();
heart = !heart;
writeHostToPlc.CommunicationDiagnosis.Value = (ushort)(heart ? 1 : 0);
writeHostToPlc.Years.Value = (ushort)DateTime.Now.Year; writeHostToPlc.Years.Value = (ushort)DateTime.Now.Year;
writeHostToPlc.Month.Value = (ushort)DateTime.Now.Month; writeHostToPlc.Month.Value = (ushort)DateTime.Now.Month;
writeHostToPlc.Day.Value = (ushort)DateTime.Now.Day; writeHostToPlc.Day.Value = (ushort)DateTime.Now.Day;
@ -195,6 +201,7 @@ public class PlcMgr
writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute; writeHostToPlc.Points.Value = (ushort)DateTime.Now.Minute;
writeHostToPlc.Seconds.Value = (ushort)DateTime.Now.Second; writeHostToPlc.Seconds.Value = (ushort)DateTime.Now.Second;
bool write1 = PlcClient.WriteValue(writeHostToPlc.CommunicationDiagnosis);
bool write1 = PlcClient.WriteValue(writeHostToPlc.Years); bool write1 = PlcClient.WriteValue(writeHostToPlc.Years);
bool write2 = PlcClient.WriteValue(writeHostToPlc.Month); bool write2 = PlcClient.WriteValue(writeHostToPlc.Month);
bool write3 = PlcClient.WriteValue(writeHostToPlc.Day); bool write3 = PlcClient.WriteValue(writeHostToPlc.Day);

Loading…
Cancel
Save