示例#1
0
        /// <summary>
        /// Adds the component and its ports to the BillOfMaterial
        /// </summary>
        /// <param name="name"></param>
        /// <param name="name_sm"></param>
        /// <returns></returns>
        private bool AddComponentInfos(string name, string name_sm)
        {
            bool allsuccess = true;

            foreach (var sim in SimulationModels)
            {
                if (!((sim.Inputs.Count == 0 && sim.Outputs.Count == 0) && sim.PhysicalPorts.Count == 0))
                {
                    AdminShellNS.AdminShell.Entity simAsEntity = GetSimModelAsEntity(sim, name_sm);
                    foreach (var port in GetPortsAsProp(sim))
                    {
                        simAsEntity.Add(port);
                    }
                    string test_ent_json = Newtonsoft.Json.JsonConvert.SerializeObject(simAsEntity);

                    SimModelsAsEntities.Add(sim.Name, simAsEntity);

                    if (!AASRestClient.PutEntity(test_ent_json, name, name_sm, ""))
                    {
                        allsuccess = false;
                    }
                }
            }

            return(allsuccess);
        }
示例#2
0
        /// <summary>
        /// Creates a SMD by reading the BillOfMaterial and getting the RelationshipElements and
        /// collecting the SimulationModels for the Relations in a list which is a property of the class
        /// </summary>
        /// <param name="host"></param>
        /// <param name="maschine"></param>
        public bool CreateSMD(String host, String maschine)
        {
            AASRestClient.Start(host);

            // Einlesen der billofmaterial der maschine und der zugehörigen RelElement
            BillOfMaterial = AASRestClient.GetBillofmaterialWithRelationshipElements(maschine);

            if (BillOfMaterial == null)
            {
                return(false);
            }

            RelationshipElements = BillOfMaterial.RelationshipElements;
            foreach (var bom in BillOfMaterial.BillOfMaterials.Values)
            {
                RelationshipElements = RelationshipElements.Concat(bom.RelationshipElements).ToList();
            }



            foreach (var rel in RelationshipElements)
            {
                if (rel == null)
                {
                    return(false);
                }
            }

            DeleteDuplicateRelationshipsElements();

            // Einlesen der beiden simModelle für die einzelnen reletionships elemente in ein Dictionary
            SimulationsModels = GetSimulationModelsFromRelationshipElements();

            return(true);
        }
示例#3
0
        /// <summary>
        /// Returns the SimulationModel of the given Submodel
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static SimulationModel GetSimulationModel(string name)
        {
            JObject simulationModelJson
                = AASRestClient.GetJson($"aas/{name}/submodels/SimulationModels/complete").Result;
            SimulationModel ret = SimulationModel.Parse(simulationModelJson, name);

            return(ret);
        }
示例#4
0
        /// <summary>
        /// Adds the name of the aas with the asset id from submodel to the given set.
        /// </summary>
        /// <param name="componentNames"></param>
        /// <param name="submodel"></param>
        private static void addEntityName(HashSet <string> componentNames, JToken submodel)
        {
            JToken locToken = submodel.SelectToken("asset.keys(0).value");

            if (locToken != null)
            {
                string assetId    = locToken.ToString();
                string bom_entity = AASRestClient.GetAASNameForAssetId(assetId);
                componentNames.Add(bom_entity);
            }
        }
示例#5
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);
         }
     }
 }
示例#6
0
        /// <summary>
        /// Gets the simulationmodel with the given name and adds it to the given list
        /// </summary>
        /// <param name="simulationsModels"></param>
        /// <param name="name"></param>
        private void addSimulationModelToList(Dictionary <string, SimulationModel> simulationsModels, string name)
        {
            SimulationModel simModel = AASRestClient.GetSimulationModel(name);



            if (simModel.AsJson != null)
            {
                simulationsModels.Add(name, simModel);
            }
            else
            {
            }
        }
示例#7
0
        public static string GetAASNameForAssetId(string assetId)
        {
            try
            {
                assetId = WebUtility.UrlEncode(assetId);
                var path = $"assets/@qs?qs=IRI,{assetId}";

                JArray jObject = AASRestClient.GetJArray(path).Result;

                return((string)jObject[0]["idShort"]);
            }
            catch (Exception)
            {
                // Could not get asset with assetId
                return("");
            }
        }
示例#8
0
        /// <summary>
        /// Gets the right value for the assetId
        /// </summary>
        /// <param name="assetId"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        private static string getValuesAccordingToAssetHelper(string assetId, string value)
        {
            try
            {
                assetId = WebUtility.UrlEncode(assetId);
                var path = $"assets/@qs?qs=IRI,{assetId}";

                JArray jObject = AASRestClient.GetJArray(path).Result;

                return((string)jObject[0]["idShort"]);
            }
            catch (Exception)
            {
                // Could not get asset with assetId
                return(value);
            }
        }
示例#9
0
        /// <summary>
        /// Adds the AAS with the given name
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        private bool AddAas(string name)
        {
            AdminShellNS.AdminShell.AdministrationShell aas = new AdminShellNS.AdminShell.AdministrationShell();

            aas.idShort               = name;
            aas.identification.id     = "urn:itsowl.tedz.com:demo:aas:1:1:123";
            aas.identification.idType = "IRI";

            String smd = Newtonsoft.Json.JsonConvert.SerializeObject(aas);

            //Put SMD
            if (AASRestClient.PutAAS(smd, name))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#10
0
        /// <summary>
        /// Adds the Relationships to the billOfMaterial. The relations are all the ports which are connected.
        /// Thus we need to iterate over all simulationmodels and its input ports to connect get all signalflow ports.
        /// And additionally all physical ports.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="name_sm"></param>
        /// <returns></returns>
        private bool AddRelationshipInfo(string name, string name_sm)
        {
            bool allsuccess = true;

            foreach (var sim in SimulationModels)
            {
                foreach (var input in sim.Inputs)
                {
                    foreach (var output in input.ConnectedTo)
                    {
                        AdminShellNS.AdminShell.RelationshipElement portAsRel = GetPortsAsRelation(input, output);

                        string test_ent_json = Newtonsoft.Json.JsonConvert.SerializeObject(portAsRel);

                        if (!AASRestClient.PutEntity(test_ent_json, name, name_sm, ""))
                        {
                            allsuccess = false;
                        }
                    }
                }



                if (sim.IsNode)
                {
                    foreach (var port in sim.PhysicalPorts)
                    {
                        AdminShellNS.AdminShell.RelationshipElement portAsRel =
                            GetPortsAsRelation(port, port.ConnectedTo[0], 1);

                        string test_ent_json = Newtonsoft.Json.JsonConvert.SerializeObject(portAsRel);

                        if (!AASRestClient.PutEntity(test_ent_json, name, name_sm, ""))
                        {
                            allsuccess = false;
                        }
                    }
                }
            }
            return(allsuccess);
        }
示例#11
0
        /// <summary>
        /// Adds the BillOfMaterial Submodel to the AAS
        /// </summary>
        /// <param name="name"></param>
        /// <param name="name_sm"></param>
        /// <returns></returns>
        private bool AddBomSubmodel(string name, string name_sm)
        {
            Bom                       = new AdminShellNS.AdminShell.Submodel();
            Bom.idShort               = name_sm;
            Bom.identification.id     = "urn:itsowl.tedz.com:sm:instance:9053_7072_4002_2783";
            Bom.identification.idType = "IRI";
            Bom.semanticId            = new AdminShellNS.AdminShell.SemanticId();
            Bom.semanticId.Keys.Add(new AdminShellNS.AdminShell.Key());
            Bom.semanticId.Keys[0].value  = "http://example.com/id/type/submodel/BOM/1/1";
            Bom.semanticId.Keys[0].type   = "Submodel";
            Bom.semanticId.Keys[0].idType = "IRI";

            String bom_json = Newtonsoft.Json.JsonConvert.SerializeObject(Bom);

            if (AASRestClient.PutSubmodel(bom_json, name_sm, name))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }