123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Serialization;
- using MECF.Framework.Common.Equipment;
- namespace MECF.Framework.Common.FAServices
- {
- [Serializable]
- [XmlRoot("DataItems")]
- public class VIDItem
- {
- private string name;
- [XmlAttribute("Name")]
- public string Name
- {
- get { return name; }
- set
- {
- name = value;
- AnalyseName(value);
- }
- }
- [XmlAttribute("Index")]
- public int Index { get; set; }
- [XmlAttribute("DataType")]
- public string DataType { get; set; }
- [XmlArray("LinkableVID")]
- public int[] LinkableVid { get; set; }
- [XmlAttribute("Description")]
- public string Description { get; set; }
- [XmlAttribute("Module")]
- public string Module { get; set; } = "";
- [XmlAttribute("Type")]
- public string Type { get; set; } = "";
- [XmlAttribute("Unit")]
- public string Unit { get; set; } = "";
- [XmlAttribute("Parameter")]
- public string Parameter { get; set; }
- private int moduleIndex;
- [XmlIgnore]
- public int ModuleIndex
- {
- get { return moduleIndex; }
- set
- {
- moduleIndex = value;
- }
- }
- private int typeIndex;
- [XmlIgnore]
- public int TypeIndex
- {
- get { return typeIndex; }
- set
- {
- typeIndex = value;
- }
- }
- private int unitIndex;
- [XmlIgnore]
- public int UnitIndex
- {
- get { return unitIndex; }
- set
- {
- unitIndex = value;
- }
- }
- private int parameterIndex;
- [XmlIgnore]
- public int ParameterIndex
- {
- get { return parameterIndex; }
- set
- {
- parameterIndex = value;
- }
- }
- void AnalyseName(string name)
- {
- if (string.IsNullOrEmpty(name))
- return;
- string[] names = name.Split('.');
- Module = ModuleName.System.ToString();
- if (names.Length >= 1)
- {
- Parameter = names[names.Length - 1];
- if (names.Length >= 2)
- {
- Module = names[0];
- ModuleIndex = (Enum.TryParse(Module, out ModuleName moduleIndex) ? (int)moduleIndex : 0) + 1;
- if (names.Length >= 3)
- {
- Unit = names[names.Length - 2];
- if (names.Length >= 4)
- {
- for (int j = 1; j < names.Length - 2; j++)
- {
- Type += names[j];
- if (j != names.Length - 3)
- Type += ".";
- }
- }
- }
- }
- }
- }
- }
- }
|