/// <summary>
 /// Creates a new component
 /// </summary>
 internal Component(XElement xmlComponent)
 {
     Type       = xmlComponent.Name.ToString() ?? String.Empty;
     id         = ParseUtility.GetAttribute(xmlComponent, "id");
     Name       = ParseUtility.GetAttribute(xmlComponent, "name") == String.Empty ? id : ParseUtility.GetAttribute(xmlComponent, "name");
     NativeName = ParseUtility.GetAttribute(xmlComponent, "nativeName");
     dataItems  = ParseUtility.GetDataItems(xmlComponent);
     components = ParseUtility.GetComponents(xmlComponent);
 }
 /// <summary>
 /// Creates a new DataItem
 /// </summary>
 /// <param name="xmlDataItem">The XElement which defines the DataItem</param>
 internal DataItem(XElement xmlDataItem)
 {
     BufferSize  = 100;
     id          = ParseUtility.GetAttribute(xmlDataItem, "id");
     Name        = ParseUtility.GetAttribute(xmlDataItem, "name");
     Category    = ParseUtility.GetAttribute(xmlDataItem, "category");
     Type        = ParseUtility.GetAttribute(xmlDataItem, "type");
     SubType     = ParseUtility.GetAttribute(xmlDataItem, "subType");
     Units       = ParseUtility.GetAttribute(xmlDataItem, "units");
     NativeUnits = ParseUtility.GetAttribute(xmlDataItem, "nativeUnits");
 }
Exemple #3
0
        /// <summary>
        /// Creates a new DataItem
        /// </summary>
        /// <param name="xmlDataItem">The XElement which defines the DataItem</param>
        internal DataItem(XElement xmlDataItem)
        {
            SampleHistory = new ReadOnlyObservableCollection <DataItemSample>(_dataItemSamples);

            BufferSize  = 100;
            Id          = ParseUtility.GetAttribute(xmlDataItem, "id");
            Name        = ParseUtility.GetAttribute(xmlDataItem, "name");
            Category    = ParseUtility.GetAttribute(xmlDataItem, "category");
            Type        = ParseUtility.GetAttribute(xmlDataItem, "type");
            SubType     = ParseUtility.GetAttribute(xmlDataItem, "subType");
            Units       = ParseUtility.GetAttribute(xmlDataItem, "units");
            NativeUnits = ParseUtility.GetAttribute(xmlDataItem, "nativeUnits");
        }
 /// <summary>
 /// Creates a new device from an MTConnect XML device node
 /// </summary>
 /// <param name="xElem">The MTConnect XML node which defines the device</param>
 internal Device(XElement xElem)
 {
     if (xElem.Name.LocalName == "Device")
     {
         // Populate basic fields
         id   = ParseUtility.GetAttribute(xElem, "id");
         Name = ParseUtility.GetAttribute(xElem, "name");
         XElement desc = xElem.Descendants().First(x => x.Name.LocalName == "Description");
         Description  = desc.Value ?? String.Empty;
         Manufacturer = ParseUtility.GetAttribute(desc, "manufacturer");
         SerialNumber = ParseUtility.GetAttribute(desc, "serialNumber");
         dataItems    = ParseUtility.GetDataItems(xElem);
         components   = ParseUtility.GetComponents(xElem);
     }
 }
Exemple #5
0
        /// <summary>
        /// Creates a new component
        /// </summary>
        internal Component(XElement xmlComponent)
        {
            Type = xmlComponent.Name?.ToString() ?? string.Empty;
            Id   = ParseUtility.GetAttribute(xmlComponent, "id");
            Name = ParseUtility.GetAttribute(xmlComponent, "name");
            if (string.IsNullOrEmpty(Name))
            {
                Name = Id;
            }
            NativeName = ParseUtility.GetAttribute(xmlComponent, "nativeName");

            _dataItems = new ObservableCollection <DataItem>(ParseUtility.GetDataItems(xmlComponent));
            DataItems  = new ReadOnlyObservableCollection <DataItem>(_dataItems);

            _components = new ObservableCollection <Component>(ParseUtility.GetComponents(xmlComponent));
            Components  = new ReadOnlyObservableCollection <Component>(_components);
        }
Exemple #6
0
        /// <summary>
        /// Creates a new device from an MTConnect XML device node
        /// </summary>
        /// <param name="xElem">The MTConnect XML node which defines the device</param>
        internal Device(XElement xElem = null)
        {
            DataItems  = new ReadOnlyObservableCollection <DataItem>(_dataItems);
            Components = new ReadOnlyObservableCollection <Component>(_components);

            if (xElem?.Name.LocalName == "Device")
            {
                // Populate basic fields
                Id   = ParseUtility.GetAttribute(xElem, "id");
                Name = ParseUtility.GetAttribute(xElem, "name");

                var descXml = xElem.Descendants().First(x => x.Name.LocalName == "Description");
                Description  = descXml.Value ?? string.Empty;
                Manufacturer = ParseUtility.GetAttribute(descXml, "manufacturer");
                SerialNumber = ParseUtility.GetAttribute(descXml, "serialNumber");

                _dataItems.AddRange(ParseUtility.GetDataItems(xElem));
                _components.AddRange(ParseUtility.GetComponents(xElem));
            }
        }