/// <summary> /// Accept new settings. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OkBtn_Click(object sender, EventArgs e) { try { Target = (GXDLMSMeter)DevicesCb.SelectedItem; } catch (Exception ex) { DialogResult = DialogResult.None; MessageBox.Show(this, ex.Message, "Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ReadCMnu_Click(object sender, EventArgs e) { try { if (Devices.SelectedNode != null) { GXDLMSMeter dev = Devices.SelectedNode.Tag as GXDLMSMeter; List <KeyValuePair <GXDLMSObject, byte> > objects = new List <KeyValuePair <GXDLMSObject, byte> >(); //Read association view if there are no objects on the meter. if (dev.Objects.Count == 0) { objects.Add(new KeyValuePair <GXDLMSObject, byte>(new GXDLMSAssociationLogicalName(), 2)); } target.ReadObjects(new GXDLMSMeter[] { dev }, objects); if (dev.Objects.Count == 0) { //Add all objects. TreeNode n = nodes[dev]; List <TreeNode> list = new List <TreeNode>(); foreach (GXDLMSObject it in (objects[0].Key as GXDLMSAssociationLogicalName).ObjectList) { GXManufacturer m = Manufacturers.FindByIdentification(dev.Manufacturer); if (m.ObisCodes != null) { GXDLMSConverter c = new GXDLMSConverter(); GXObisCode oc = m.ObisCodes.FindByLN(it.ObjectType, it.LogicalName, null); if (string.IsNullOrEmpty(it.Description)) { it.Description = c.GetDescription(it.LogicalName, it.ObjectType)[0]; } if (oc != null) { MainForm.UpdateAttributes(it, oc); } } TreeNode t = new TreeNode(it.LogicalName + " " + it.Description); t.Tag = it; list.Add(t); } n.Nodes.AddRange(list.ToArray()); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
private void DeleteCMnu_Click(object sender, EventArgs e) { try { if (Devices.SelectedNode != null) { GXDLMSMeter m = Devices.SelectedNode.Tag as GXDLMSMeter; if (MessageBox.Show(this, GXDLMSDirector.Properties.Resources.RemoveDeviceConfirmation, GXDLMSDirector.Properties.Resources.GXDLMSDirectorTxt, MessageBoxButtons.YesNoCancel) != DialogResult.Yes) { return; } target.RemoveDevices(new GXDLMSMeter[] { m }); } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
private void PropertiesCMnu_Click(object sender, EventArgs e) { try { if (Devices.SelectedNode != null) { GXDLMSMeter m = Devices.SelectedNode.Tag as GXDLMSMeter; DevicePropertiesForm dlg = new DevicePropertiesForm(Manufacturers, m); if (dlg.ShowDialog(this) == DialogResult.OK) { target.EditDevices(new GXDLMSMeter[] { dlg.Device }); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }