dc/Common/MESHeartBit.cs

83 行
2.6 KiB
C#

2022-04-01 17:03:54 +08:00
#region << >>
/*----------------------------------------------------------------
* 13118
* 2022/3/17 15:08:35
* V1.0.0
*
*
* ----------------------------------------------------------------
*
*
*
*
* V1.0.1
*----------------------------------------------------------------*/
#endregion << >>
using ARI.EAP.HOST.SRD;
using ARI.EAP.HOST.Utilities;
using Glorysoft.SECS.EQP.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace ARI.EAP.HOST.Common
{
/// <summary>
/// MESHeartBit 的摘要说明
2022-12-16 13:01:24 +08:00
/// 提供与MES的连接心跳和monitor的心跳
2022-04-01 17:03:54 +08:00
/// </summary>
public class MESHeartBit
{
2022-12-16 13:01:24 +08:00
private Timer timer1;
private string url = Configurations.conf.httpConfiguration.heartBitUrl;
2022-04-01 17:03:54 +08:00
public MESHeartBit()
{
2022-12-16 13:01:24 +08:00
timer1 = new Timer(60000);
timer1.Elapsed += new ElapsedEventHandler(Method);
timer1.AutoReset = true;
timer1.Enabled = true;
2022-04-01 17:03:54 +08:00
}
public void Method(object source, ElapsedEventArgs e)
{
string httpContent = SECSUtil.ToJson<MESHeartBitParam>(new MESHeartBitParam());
HttpUtils.sentPOST(url,httpContent);
2022-12-16 13:01:24 +08:00
EquipmentStatus.socketClient.SendMessage(httpContent);
2022-04-01 17:03:54 +08:00
}
public void Method()
{
string httpContent = SECSUtil.ToJson<MESHeartBitParam>(new MESHeartBitParam());
HttpUtils.sentPOST(url, httpContent);
2022-12-16 13:01:24 +08:00
EquipmentStatus.socketClient.SendMessage(httpContent);
2022-04-01 17:03:54 +08:00
}
}
[Serializable]
public class MESHeartBitParam
{
public string connectStatus { get; set; }
public string deviceId { get; set; }
public string eapStatus { get; set; }
public string equipmentName { get; set; }
public string ip { get; set; }
public string mqStatus { get; set; }
public string port { get; set; }
public MESHeartBitParam()
{
2022-12-16 13:01:24 +08:00
this.deviceId = Configurations.conf.connectSetting.deviceId;
2023-02-23 11:33:23 +08:00
this.equipmentName = Configurations.conf.connectSetting.equipmentName1;
2022-12-16 13:01:24 +08:00
this.ip = Configurations.conf.connectSetting.remoteIp;
this.port = Configurations.conf.connectSetting.remotePort;
2022-07-27 14:46:20 +08:00
this.connectStatus = EquipmentStatus.EqConnectState;
this.mqStatus = EquipmentStatus.MQstate;
this.eapStatus = EquipmentStatus.EapState.ToString();
2022-04-01 17:03:54 +08:00
}
}
}