You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

68 lines
1.4 KiB

using Leit.FrameWork;
using Leit.FrameWork.Log;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Leit.StationFunction
{
public static class HeartBeat
{
public static void SendMsgToStation()
{
try
{
MsgStruct msg = new MsgStruct();
msg.MsgSource = "Scada";
msg.MsgTarget = "WorkStation";
msg.StationCode = "";
msg.MsgVerifyCode = "";
msg.MsgContent = new object();
msg.datetime = DateTime.Now;
UpperCommunication.Mq_Adapter.SendMsg(msg);
}
catch (Exception ex)
{
LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
}
}
static int HeartCycleTime = 0;
public static void HeartBeatCycle()
{
Task.Run(()=> {
try
{
if (HeartCycleTime++ >= 4)
{
SendMsgToStation();
HeartCycleTime = 0;
}
}
catch (Exception ex)
{
LogHelper.WriteLog(LogHelper.GetMethodInfo(), ex);
}
});
}
}
}