| | |
| | | { |
| | | public class Control |
| | | { |
| | | public bool IsCanShowTip; |
| | | public System.DateTime LatestDateTime = System.DateTime.Now; |
| | | |
| | | /// <summary> |
| | |
| | | /// 发送数据,等待有反馈 |
| | | /// </summary> |
| | | /// <returns>The bytes send has return.</returns> |
| | | public static byte [] ControlBytesSendHasReturn (Command command, byte subnetID, byte deviceID, byte [] gatewayBytes, bool isShow = true) |
| | | public static byte [] ControlBytesSendHasReturn (Command command, byte subnetID, byte deviceID, byte [] gatewayBytes, string ip = "") |
| | | { |
| | | |
| | | Control control = new Control () { IsCanShowTip = isShow }; |
| | | Control control = new Control (); |
| | | var sendIp = CommonPage.EndPoint; |
| | | if (!string.IsNullOrEmpty (ip)) { |
| | | sendIp = new System.Net.IPEndPoint (System.Net.IPAddress.Parse (ip), 9999); |
| | | } |
| | | control.Send (new Target () { |
| | | IPEndPoint = CommonPage.EndPoint, |
| | | IPEndPoint = sendIp, |
| | | Command = command, |
| | | SubnetID = subnetID, |
| | | DeviceID = deviceID, |
| | | AddData = gatewayBytes, |
| | | }, SendCount.Three, true); |
| | | |
| | | return control.UsefulBytes; |
| | | } |
| | | |
| | |
| | | public static void ControlBytesSend (Command command, byte subnetID, byte deviceID, byte [] gatewayBytes, SendCount sendCount = SendCount.Three, System.Net.IPEndPoint ipEndpoint = null, bool isShowTip = true) |
| | | { |
| | | |
| | | Control control = new Control () { IsCanShowTip = isShowTip }; |
| | | Control control = new Control (); |
| | | control.Send (new Target () { |
| | | IPEndPoint = ipEndpoint == null ? CommonPage.EndPoint : ipEndpoint,//new System.Net.IPEndPoint (System.Net.IPAddress.Parse (new Net.NetWiFi ().BroadcastIpAddress.ToString ()), 6000), |
| | | Command = command, |
| | |
| | | for (int i = 0; i < controlList.Count; i++) { |
| | | try { |
| | | Control control = controlList [i]; |
| | | if (control.SendFlag == receiveFlag) { |
| | | if (control.SendFlag == receiveFlag && (control.Packet.RemoteEndPoint.ToString() == remoteEndPoint.ToString()|| |
| | | control.Packet.RemoteEndPoint.ToString().Contains("6000"))) { |
| | | control.LatestDateTime = System.DateTime.Now; |
| | | control.UsefulBytes = usefulBytes;// |
| | | control.run (); |
| | |
| | | Console.WriteLine ("managerSendCount:" + ex.ToString ()); |
| | | } finally { |
| | | allDone.Set (); |
| | | if (Packet.HaveSendCount == 3 && IsCanShowTip) { |
| | | //MainPage.AddTip (Language.StringByID (SimpleControl.R.MyInternationalizationString.OperationFailed)); |
| | | } |
| | | } |
| | | return; |
| | | //if (Shared.SimpleControl.CommonPage.IsRemote && !isLocal) { |