コード例 #1
0
		/// <summary>
		/// Copies the ObisDevices to an System.Array, starting at a particular System.Array index.
		/// </summary>
		/// <param name="array">The array that is the destination of the ObisDevices.</param>
		/// <param name="index">The zero-based index in array at which copying begins.</param>
		public void CopyTo(ObisDevice[] array, int index)
		{
			List.CopyTo(array, index);
		}
コード例 #2
0
		/// <summary>
		/// Determines whether the ObisDevices contains a specific device.
		/// </summary>
		/// <param name="device">The device to locate.</param>
		/// <returns>True if the device was located.</returns>
		public bool Contains(ObisDevice device)
		{
			return List.Contains(device);
		}
コード例 #3
0
		/// <summary>
		/// Returns the zero-based index of the first occurrence of a value in the ObisDevices.
		/// </summary>
		/// <param name="device">The device to locate.</param>
		/// <returns>The index where the device was located or -1 if it was not found.</returns>
		public int IndexOf(ObisDevice device)
		{
			return List.IndexOf(device);
		}
コード例 #4
0
		/// <summary>
		/// Removes the first occurrence of a specific object from the ObisDevices.
		/// </summary>
		/// <param name="device">The removed device.</param>
		public void Remove(ObisDevice device)
		{
			List.Remove(device);
		}
コード例 #5
0
		/// <summary>
		/// Inserts an item to the ObisDevices at the specified index.
		/// </summary>
		/// <param name="index">The target index.</param>
		/// <param name="device">The inserted device.</param>
		public void Insert(int index, ObisDevice device)
		{
			List.Insert(index, device);
		}
コード例 #6
0
		public int Add(ObisDevice device)
		{
			return List.Add(device);
		}
コード例 #7
0
		private void LoadXmlFile(string filePath)
		{
			XmlTextReader reader = new XmlTextReader(filePath);
			try
			{
				XmlDocument doc = new XmlDocument();
				XmlNode rootNode = doc.ReadNode(reader);
				if (rootNode.Name != "Manufacturer")
				{
					throw new Exception("Incorret OBIS file");
				}
				m_Name = rootNode.Attributes["Name"].Value;
				m_Type = int.Parse(rootNode.Attributes["Type"].Value);
				m_Description = rootNode.Attributes["Description"].Value;

				if (rootNode.ChildNodes.Count > 1)
				{
					for (int i = 0; i < rootNode.ChildNodes.Count; ++i)
					{
						XmlNode node = rootNode.ChildNodes[i];
						//Whitespace check
						if (node is XmlWhitespace)
						{
							continue;
						}
						//Common Properies
						else if (node.Name == "CommonProperties")
						{
							XmlNode common = rootNode.ChildNodes[i];
							foreach (XmlNode item in common.ChildNodes)
							{
								if (item is XmlElement)
								{
									m_CommonProperties.Add(ParseObisItem(item));
								}
							}

						}
						else if (node.Name == "Device")
						{
							ObisDevice obde = new ObisDevice();
							obde.Name = node.Attributes["Name"].Value;
							obde.Description = node.Attributes["Description"].Value;
							obde.Type = int.Parse(node.Attributes["Type"].Value);
							try
							{
								obde.PrimaryDefaultID = int.Parse(node.Attributes["PrimaryDefaultID"].Value);
								obde.PrimaryDefaultIDSize = int.Parse(node.Attributes["PrimaryDefaultIDSize"].Value);
								obde.PrimaryLowID = int.Parse(node.Attributes["PrimaryLowID"].Value);
								obde.PrimaryLowIDSize = int.Parse(node.Attributes["PrimaryLowIDSize"].Value);
								obde.PrimaryHighID = int.Parse(node.Attributes["PrimaryHighID"].Value);
								obde.PrimaryHighIDSize = int.Parse(node.Attributes["PrimaryHighIDSize"].Value);
							}
							catch
							{
								MessageBox.Show("Primary ID is not set for all Access Levels");
							}
							obde.SecondaryID = int.Parse(node.Attributes["SecondaryID"].Value);
							obde.SecondaryIDSize = int.Parse(node.Attributes["SecondaryIDSize"].Value);
							obde.UseLN = Convert.ToBoolean(int.Parse(node.Attributes["UseLN"].Value));
							System.Xml.XmlAttribute att = node.Attributes["SupportNetworkSpecificSettings"];
							if (att != null)
							{
								obde.SupportNetworkSpecificSettings = Convert.ToBoolean(int.Parse(att.Value));
							}
							foreach (XmlNode item in node.ChildNodes)
							{
								if (item is XmlElement)
								{
									obde.Items.Add(ParseObisItem(item));
								}
							}
							m_Devices.Add(obde);
						}
					}
				}
			}
			finally
			{
				reader.Close();
			}
		}
コード例 #8
0
		private void AddMnu_Click(object sender, System.EventArgs e)
		{
			if (ObisTree.SelectedNode == null || ObisTree.SelectedNode.Tag == null)
			{
				//Do nothing, because this should not happen
			}
			else if (ObisTree.SelectedNode.Tag is ObisManufacturer)
			{
				//Add device
				ObisDevice dev = new ObisDevice("Device");
				m_Manufacturer.Devices.Add(dev);
				TreeNode newNode = new TreeNode("Device");
				newNode.Tag = dev;
				ObisTree.SelectedNode.Nodes.Add(newNode);
				ObisTree.SelectedNode.Expand();
				ObisTree.SelectedNode = newNode;
			}
			else if(ObisTree.SelectedNode.Tag is ObisDevice)
			{
				ObisItem newItem = AddItem(((ObisDevice) ObisTree.SelectedNode.Tag).Items);
				TreeNode newNode = new TreeNode(newItem.LN);
				newNode.Tag = newItem;
				ObisTree.SelectedNode.Nodes.Add(newNode);
				ObisTree.SelectedNode.Expand();
				ObisTree.SelectedNode = newNode;
			}
			else if(ObisTree.SelectedNode.Tag is ObisItems)
			{
				ObisItem newItem = AddItem((ObisItems)ObisTree.SelectedNode.Tag);
				TreeNode newNode = new TreeNode(newItem.LN);
				newNode.Tag = newItem;
				ObisTree.SelectedNode.Nodes.Add(newNode);
				ObisTree.SelectedNode.Expand();
				ObisTree.SelectedNode = newNode;
			}
			else if(ObisTree.SelectedNode.Tag is ObisItem)
			{
				ObisItem newItem = null;
				if (ObisTree.SelectedNode.Parent.Tag is ObisDevice)
				{
					newItem = AddItem(((ObisDevice) ObisTree.SelectedNode.Parent.Tag).Items);
				}
				else
				{
					newItem = AddItem(((ObisItems) ObisTree.SelectedNode.Parent.Tag));
				}
				TreeNode newNode = new TreeNode(newItem.LN);
				newNode.Tag = newItem;
				ObisTree.SelectedNode.Parent.Nodes.Add(newNode);
				ObisTree.SelectedNode = newNode;
			}
			m_Dirty = true;
		}