namespace Module.HMeter.ModBusTcp { /// /// 温湿度仪表管理类 /// public class HumiMeterEqmManger { #region 定义锁 private object lockObj = new object(); //线程同步锁 #endregion 定义锁 #region 字段属性 /// /// 决定去读取参数 /// private bool _is_read = true; /// /// 决定去读取参数 /// public bool F_IsRead { get { return _is_read; } set { lock (lockObj) { _is_read = value; } } } #endregion 字段属性 /// /// 温湿度通讯连接线程 /// public void HumiNetConnectThread() { Thread humiConnectThread = new Thread(HumiMeterNetConnectFunc); humiConnectThread.IsBackground = true; humiConnectThread.Start(); } /// /// 温湿度通讯连接 /// 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(); } } } }