Example #1
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);
        }
Example #2
0
        /// <summary>
        /// Returns the given Relationshipelement as RelationshipElement of Adminshell
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public AdminShellNS.AdminShell.RelationshipElement GetPortsAsRelation(IOput input, IOput output, int type = 0)
        {
            AdminShellNS.AdminShell.Submodel submodel = new AdminShellNS.AdminShell.Submodel();

            submodel.identification.id     = "urn:itsowl.tedz.com:sm:instance:9053_7072_4002_2783";
            submodel.identification.idType = "IRI";


            // Finden der zugehörigen properties der in und out
            AdminShellNS.AdminShell.Entity entity = new AdminShellNS.AdminShell.Entity();
            entity.idShort = input.Owner;
            entity.parent  = submodel;

            AdminShellNS.AdminShell.Property property = new AdminShellNS.AdminShell.Property();
            property.idShort = input.IdShort;
            property.parent  = entity;


            AdminShellNS.AdminShell.Entity outentity = new AdminShellNS.AdminShell.Entity();
            outentity.idShort = output.Owner;
            outentity.parent  = submodel;

            AdminShellNS.AdminShell.Property outproperty = new AdminShellNS.AdminShell.Property();
            outproperty.idShort = output.IdShort;
            outproperty.parent  = outentity;


            // setzen als first bzw second

            AdminShellNS.AdminShell.RelationshipElement relationshipElement =
                new AdminShellNS.AdminShell.RelationshipElement();

            relationshipElement.first      = outproperty.GetReference();
            relationshipElement.second     = property.GetReference();
            relationshipElement.semanticId = SetSemanticIdRelEle(input, output, type);
            relationshipElement.idShort    = $"{relCount++}";


            return(relationshipElement);
        }