/// <summary> /// 保存到数据库 /// </summary> /// <param name="closeOnSuccess">成功后是否关闭窗口</param> internal void saveToServer(bool closeOnSuccess) { if (_pointModel.Name.IsBlank() || _pointModel.Desc.IsBlank()) { MessageBox.Show(MainWindow.Instance, "请输入点名和描述"); return; } if (_pointModel.Name.StartsWith("/") == false) { MessageBox.Show(MainWindow.Instance, "点名必须以“/”反斜杠为起始字符"); return; } _container.Cursor = Cursors.Hand; try { _pointModel.AddrSetting = _PointJsonDict.ToJsonString(); _pointModel.Address = gatewayClient.GetPointAddress(_PointJsonDict); } catch (Exception ex) { _container.Cursor = null; MessageBox.Show(MainWindow.Instance, ex.Message); return; } Helper.Remote.Invoke <int>("UpdatePoint", (ret, err) => { _container.Cursor = null; if (err != null) { MessageBox.Show(MainWindow.Instance, err); } else { //更新TabItem的文字 this._container.Title = _pointModel.Desc; if (_pointModel.id == null) { //是添加的新点 _pointModel.id = ret; _parentNode.Nodes.Add(new DevicePointNode(_pointModel)); } _pointModel.ChangedProperties.Clear(); OriginalModel.CopyValue(_pointModel); OriginalModel.ChangedProperties.Clear(); if (closeOnSuccess) { //关闭当前document MainWindow.Instance.CloseDocument(_container); } } }, _pointModel); }
public void GetPointAddressTest() { SunRizModbusTcpDriver.ModbusDriverServer server = new ModbusDriverServer(588); server.Start(); SunRizDriver.SunRizDriverClient client = new SunRizDriver.SunRizDriverClient("127.0.0.1", 588); var result = client.GetPointAddress(new System.Collections.Generic.Dictionary <string, string>() { { "Modbus功能码", "1" }, { "Modbus点地址", "12" } }); server.Stop(); }