Esempio n. 1
0
        /// <summary>
        /// Parses the given JObject to a BillOfMaterial Object
        /// </summary>
        /// <param name="jObject"></param>
        /// <returns></returns>
        public static BillOfMaterial Parse(JObject jObject)
        {
            if (jObject.SelectToken("idShort") != null || jObject.SelectToken("submodelElements") != null)
            {
                BillOfMaterial billOfMaterial = new BillOfMaterial();
                billOfMaterial.AsJson = jObject;

                if (jObject.ToString().Contains("statement"))
                {
                    billOfMaterial.SetReferenceToAsset(jObject);
                    billOfMaterial.SetSemanticIdDict(jObject);



                    billOfMaterial.SetSubmodelElementsAsEntity(jObject);

                    billOfMaterial.SetRelationshipElements((JArray)jObject["submodelElements"]);
                }

                billOfMaterial.idShort = (String)jObject["idShort"];


                return(billOfMaterial);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Gets and adds the missing Boms to the BillOfMaterials list
 /// </summary>
 /// <param name="componentNames"></param>
 private static void setMissingBoms(HashSet <string> componentNames)
 {
     foreach (var component in componentNames)
     {
         if (!BillOfMaterials.ContainsKey(component))
         {
             BillOfMaterial bom = AASRestClient.GetBillofmaterialWithRelationshipElements(component);
             BillOfMaterials.Add(component, bom);
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Returns a  BillOfMaterial with the currently necessary information
        /// </summary>
        /// <param name="aasID"></param>
        /// <returns></returns>
        public static BillOfMaterial GetBillofmaterialWithRelationshipElements(string aasID)
        {
            JObject json = GetJson($"aas/{aasID}/submodels/billofmaterial/complete").Result;

            if (json == null || json.SelectToken("hasDataSpecification") == null)
            {
                return(null);
            }

            BillOfMaterial billOfMaterial = BillOfMaterial.Parse(json);

            billOfMaterial.BomName = aasID;
            return(billOfMaterial);
        }