| | |
| | | //发送数据 |
| | | myGateway.Send(sendTopic, sendData); |
| | | |
| | | //超时时间 |
| | | int TimeOut = 0; |
| | | waitTime = 20 * waitTime; |
| | | while (listCheckTopic.Count != listReceiptTopic.Count && TimeOut < waitTime) |
| | | { |
| | | //全部接收才退出 |
| | | System.Threading.Thread.Sleep(50); |
| | | TimeOut++; |
| | | } |
| | | myGateway.Actions -= receiptAction; |
| | | receiptAction = null; |
| | | |
| | | int receveCount = listCheckTopic.Count; |
| | | if (receveCount > 1) |
| | | { |
| | |
| | | receveCount = listTemp.Count; |
| | | } |
| | | |
| | | //超时时间 |
| | | int TimeOut = 0; |
| | | waitTime = 20 * waitTime; |
| | | while (receveCount != listReceiptTopic.Count && TimeOut < waitTime) |
| | | { |
| | | //全部接收才退出 |
| | | System.Threading.Thread.Sleep(50); |
| | | TimeOut++; |
| | | } |
| | | myGateway.Actions -= receiptAction; |
| | | receiptAction = null; |
| | | if (receveCount != listReceiptTopic.Count) |
| | | { |
| | | reResult.ErrorMsgDiv = 0; |
| | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 计算灯的亮度值所占的百分比(例如:返回35,代表是35%) |
| | | /// </summary> |
| | | /// <param name="i_Level">灯的亮度值</param> |
| | | /// <returns></returns> |
| | | public int CalculateLightLevelPersent(decimal i_Level) |
| | | { |
| | | return (int)((i_Level / 255) * 100); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 计算指定百分比对应灯的亮度值 |
| | | /// </summary> |
| | | /// <param name="i_Persent">百分比值(比如35,代表35%)</param> |
| | | /// <returns></returns> |
| | | public int CalculateLightLevel(decimal i_Persent) |
| | | { |
| | | //需要向上取整,才能得出 |
| | | return (int)Math.Ceiling((i_Persent / 100) * 255); |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |