public int GetIntBlock(String CanAddress, int timeout, out bool is_timeout) { int ret = 0; if (CanAddress == null) { ErrorSystem.WriteActError("地址为空", true, false); is_timeout = true; return(ret); } String key = CanAddress.ToUpper(); int timecount = 0; timeout = timeout / 10; is_timeout = false; if (key.Length == 0) { return(ret); } while (!RegisterMap.ContainsKey(key)) { Thread.Sleep(1); timecount++; if (timecount > timeout) { last_error = "错误代码:" + CanAddress + " time:" + timeout * 10 + " src:" + GetStacktRace(); ErrorSystem.WriteCanError(last_error); is_timeout = true; return(0); } } ret = RegisterMap[key]; return(ret); }
public bool GetBoolBlock(String CanAddress, bool value, int timeout, bool is_check_value, out bool is_timeout) { bool ret = false; String key = CanAddress.ToUpper(); int timecount = 0; timeout = timeout / 10; is_timeout = false; if (key.Length == 0) { return(ret); } while (!CoilMap.ContainsKey(key) || (value != CoilMap[key] && is_check_value)) { Thread.Sleep(5); timecount++; if (timecount > timeout) { last_error = "错误代码:" + CanAddress + " time:" + timeout * 10 + " src:" + GetStacktRace(); ErrorSystem.WriteCanError(last_error); //Console.WriteLine(last_error); is_timeout = true; return(false); } } ret = CoilMap[key]; return(ret); }