/// <summary> /// Отобразить свойства команды /// </summary> private void ShowCmdProps(Modbus.Cmd cmd) { procChangedEv = false; gbElemGroup.Visible = false; gbElem.Visible = false; gbCmd.Visible = true; if (cmd == null) { cbCmdTableType.SelectedIndex = 0; numCmdAddress.Value = 1; numCmdElemCnt.Value = 1; numCmdNum.Value = 1; txtCmdName.Text = ""; gbCmd.Enabled = false; } else { cbCmdTableType.SelectedIndex = cmd.TableType == Modbus.TableTypes.Coils ? 0 : 1; chkCmdMultiple.Checked = cmd.Multiple; numCmdAddress.Value = cmd.Address + 1; numCmdElemCnt.Value = cmd.ElemCnt; numCmdElemCnt.Enabled = cmd.Multiple; numCmdNum.Value = cmd.CmdNum; txtCmdName.Text = cmd.Name; gbCmd.Enabled = true; } procChangedEv = true; }
/// <summary> /// Создать узел команды /// </summary> private TreeNode NewCmdNode(Modbus.Cmd cmd) { string name = cmd.Name == "" ? KpPhrases.DefCmdName : cmd.Name; TreeNode cmdNode = new TreeNode(name + " (" + Modbus.GetTableTypeName(cmd.TableType) + ", " + (cmd.Address + 1) + ")"); cmdNode.ImageKey = cmdNode.SelectedImageKey = "cmd.png"; cmdNode.Tag = cmd; return cmdNode; }
/// <summary> /// Отобразить свойства группы элементов /// </summary> private void ShowElemGroupProps(Modbus.ElemGroup elemGroup) { procChangedEv = false; gbElemGroup.Visible = true; gbElem.Visible = false; gbCmd.Visible = false; if (elemGroup == null) { txtGrName.Text = ""; cbGrTableType.SelectedIndex = 0; numGrAddress.Value = 1; numGrElemCnt.Value = 1; gbElemGroup.Enabled = false; } else { txtGrName.Text = elemGroup.Name; cbGrTableType.SelectedIndex = (int)elemGroup.TableType; numGrAddress.Value = elemGroup.Address + 1; numGrElemCnt.Value = 1; numGrElemCnt.Maximum = Modbus.ElemGroup.GetMaxElemCnt(elemGroup.TableType); numGrElemCnt.Value = elemGroup.Elems.Count; gbElemGroup.Enabled = true; } procChangedEv = true; }
/// <summary> /// Создать узел группы элементов /// </summary> private TreeNode NewElemGroupNode(Modbus.ElemGroup elemGroup) { string name = elemGroup.Name == "" ? KpPhrases.DefGrName : elemGroup.Name; TreeNode grNode = new TreeNode(name + " (" + Modbus.GetTableTypeName(elemGroup.TableType) + ")"); grNode.ImageKey = grNode.SelectedImageKey = "group.png"; grNode.Tag = elemGroup; ushort elemAddr = elemGroup.Address; int elemSig = elemGroup.StartKPTagInd + 1; foreach (Modbus.Elem elem in elemGroup.Elems) { ElemInfo elemInfo = new ElemInfo(); elemInfo.Elem = elem; elemInfo.ElemGroup = elemGroup; elemInfo.Address = elemAddr; elemInfo.Signal = elemSig++; grNode.Nodes.Add(NewElemNode(elemInfo)); elemAddr += (ushort)elem.Length; } return grNode; }