/// <summary>下拉框显示串口</summary> public void ShowPorts() { if (_nextport > DateTime.Now) { return; } _nextport = DateTime.Now.AddSeconds(1); var ps = SerialTransport.GetPortNames(); var str = String.Join(",", ps); // 如果端口有所改变,则重新绑定 if (_ports != str) { _ports = str; this.Invoke(() => { var old = cbName.SelectedItem + ""; cbName.DataSource = ps; if (!String.IsNullOrEmpty(old) && Array.IndexOf(ps, old) >= 0) { cbName.SelectedItem = old; } }); } }
/// <summary>下拉框显示串口</summary> public void ShowPorts() { if (_nextport > DateTime.Now) { return; } _nextport = DateTime.Now.AddSeconds(1); var ps = SerialTransport.GetPortNames(); var str = String.Join(",", ps); // 如果端口有所改变,则重新绑定 if (_ports != str) { if (_ports != null) { "串口有改变".SpeechTip(); } _ports = str; Application.Invoke((s, e) => { var old = cbName.GetActiveObject() + ""; cbName.AppendValues(ps.ToList()); if (!String.IsNullOrEmpty(old) && Array.IndexOf(ps, old) >= 0) { cbName.SetActive(old); } }); } }
protected override Object GetLoginInfo() { var rs = base.GetLoginInfo().ToDictionary(); if (_hardInfo == null) { _hardInfo = new MachineInfo(); } var ps = SerialTransport.GetPortNames(); // 如果设备编码不存在,则需要提交产品证书 var pkey = ""; var psecret = ""; if (UserName.IsNullOrEmpty()) { var set = Setting.Current; pkey = set.ProductKey; psecret = set.ProductSecret.MD5(); WriteLog("动态注册产品:{0}", pkey); } var ext = new { ProductKey = pkey, ProductSecret = psecret, _hardInfo.OSName, _hardInfo.OSVersion, _hardInfo.Memory, _hardInfo.AvailableMemory, _hardInfo.Processor, _hardInfo.CpuID, _hardInfo.CpuRate, _hardInfo.UUID, _hardInfo.MachineGuid, COMs = ps.Join(","), }; return(rs.Merge(ext, true)); }
protected override Object GetPingInfo() { var rs = base.GetPingInfo().ToDictionary(); if (_hardInfo == null) { _hardInfo = new MachineInfo(); } var ps = SerialTransport.GetPortNames(); var ext = new { _hardInfo.AvailableMemory, _hardInfo.CpuRate, COMs = ps.Join(","), Time = DateTime.Now, Delay = (Int32)Delay.TotalMilliseconds, }; return(rs.Merge(ext, true)); }