public String get(String ipname, int trials, int pause) { String retval = "***"; System.Net.IPAddress ipaddress = System.Net.IPAddress.Parse(ipname); EthSystemConnector conn = new EthSystemConnector(ipaddress); conn.UserName = "******"; DataManSystem dataman = new DataManSystem(conn); int counter = 0; Boolean found = false; while ((found == false) && (counter < trials)) { try { dataman.Connect(); DmccResponse response = dataman.SendCommand("GET RESULT"); retval = response.PayLoad; found = true; } catch (Exception) { System.Threading.Thread.Sleep(pause * 1000); } finally { dataman.Disconnect(); counter++; } } return(retval); }
public void OnResponseReceived(DataManSystem dataManSystem, DmccResponse response) { if (Element != null) { Element.OnResponseReceived(response.PayLoad, response.Error?.LocalizedMessage); } }
/// <summary> /// 定时器周期触发事件处理函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Timer1_Tick(object sender, EventArgs e) { if (dataManSystem == null) { this.Invoke(DiscoverScanner); } else { try { ///关断定时器,防止重复触发 this.timer1.Stop(); ///使用“GET DEVICE.NAME”命令,检测扫码枪是否掉线 DmccResponse dmccResponse = dataManSystem.SendCommand("GET DEVICE.NAME", 1000); } catch (Exception) { dataManSystem.Disconnect(); dataManSystem = null; this.comboBox1.Items.Clear(); systemInfos.Clear(); } this.timer1.Start(); } }