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);
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|