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.
74 lines
1.9 KiB
74 lines
1.9 KiB
namespace Module.HMeter.ModBusTcp
|
|
{
|
|
/// <summary>
|
|
/// 温湿度仪表管理类
|
|
/// </summary>
|
|
public class HumiMeterEqmManger
|
|
{
|
|
#region 定义锁
|
|
private object lockObj = new object(); //线程同步锁
|
|
#endregion 定义锁
|
|
|
|
#region 字段属性
|
|
/// <summary>
|
|
/// 决定去读取参数
|
|
/// </summary>
|
|
private bool _is_read = true;
|
|
/// <summary>
|
|
/// 决定去读取参数
|
|
/// </summary>
|
|
public bool F_IsRead
|
|
{
|
|
get
|
|
{
|
|
return _is_read;
|
|
}
|
|
set
|
|
{
|
|
lock (lockObj)
|
|
{
|
|
_is_read = value;
|
|
}
|
|
}
|
|
}
|
|
#endregion 字段属性
|
|
|
|
|
|
/// <summary>
|
|
/// 温湿度通讯连接线程
|
|
/// </summary>
|
|
public void HumiNetConnectThread()
|
|
{
|
|
Thread humiConnectThread = new Thread(HumiMeterNetConnectFunc);
|
|
humiConnectThread.IsBackground = true;
|
|
humiConnectThread.Start();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 温湿度通讯连接
|
|
/// </summary>
|
|
private void HumiMeterNetConnectFunc()
|
|
{
|
|
CmnHumiMeterBaseInfo.HUM01.F_EqmCode = "H001";
|
|
CmnHumiMeterBaseInfo.HUM02.F_EqmCode = "H002";
|
|
CmnHumiMeterBaseInfo.HUM03.F_EqmCode = "H003";
|
|
|
|
if (!CmnHumiMeterBaseInfo.HUM01.F_NetConnected)
|
|
{
|
|
CmnHumiMeterBaseInfo.HUM01.Connect();
|
|
}
|
|
Thread.Sleep(100);
|
|
if (!CmnHumiMeterBaseInfo.HUM02.F_NetConnected)
|
|
{
|
|
CmnHumiMeterBaseInfo.HUM02.Connect();
|
|
}
|
|
Thread.Sleep(100);
|
|
if (!CmnHumiMeterBaseInfo.HUM03.F_NetConnected)
|
|
{
|
|
CmnHumiMeterBaseInfo.HUM03.Connect();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
} |