Пример #1
0
        public static AdminShellV20.Submodel CreateSubmodel(
            AdminShellV20.AdministrationShellEnv env,
            AdminShellV20.AdministrationShell adminShell, Iec61360Data data)
        {
            // We need this to ensure that we don't use the same AAS ID twice when importing multiple submodels (as
            // GenerateIdAccordingTemplate uses the timestamp as part of the ID).
            Thread.Sleep(1000);
            var submodel = new AdminShellV20.Submodel()
            {
                identification = new AdminShellV20.Identification(
                    AdminShellV20.Identification.IRI,
                    AasxPackageExplorer.Options.Curr.GenerateIdAccordingTemplate(
                        AasxPackageExplorer.Options.Curr.TemplateIdSubmodelInstance)),
                idShort = data.IdShort,
                kind    = AdminShellV20.ModelingKind.CreateAsInstance(),
            };

            AddDescriptions(submodel, data);
            AddDataSpecification(env, submodel, data);

            adminShell.AddSubmodelRef(submodel.GetReference() as AdminShellV20.SubmodelRef);
            env.Submodels.Add(submodel);

            return(submodel);
        }
Пример #2
0
        private static void AddDataSpecification(AdminShellV20.AdministrationShellEnv env,
                                                 AdminShellV20.Submodel submodel, Iec61360Data data)
        {
            var cd = CreateConceptDescription(env, data);

            // cd should already contain IEC61360Spec; add data spec
            // TODO (Robin, 2020-09-03): MIHO is not sure, if the data spec reference is correct; please check
            var eds = cd.IEC61360DataSpec;

            if (eds != null)
            {
                eds.dataSpecification = new AdminShellV20.DataSpecificationRef(cd.GetReference());
            }

            submodel.semanticId = new AdminShellV20.SemanticId(cd.GetReference());
        }
Пример #3
0
        public static AdminShellV20.Submodel CreateSubmodel(
            AdminShellV20.AdministrationShellEnv env,
            AdminShellV20.AdministrationShell adminShell, Iec61360Data data)
        {
            var submodel = new AdminShellV20.Submodel()
            {
                identification = new AdminShellV20.Identification(
                    AdminShellV20.Identification.IRI,
                    AasxPackageExplorer.Options.Curr.GenerateIdAccordingTemplate(
                        AasxPackageExplorer.Options.Curr.TemplateIdSubmodelInstance)),
                idShort = data.IdShort,
                kind    = AdminShellV20.ModelingKind.CreateAsInstance(),
            };

            AddDescriptions(submodel, data);
            AddDataSpecification(env, submodel, data);

            adminShell.AddSubmodelRef(submodel.GetReference() as AdminShellV20.SubmodelRef);
            env.Submodels.Add(submodel);

            return(submodel);
        }
Пример #4
0
        private static string CreateAASSubmodel(AdminShellV20.Submodel submodel)
        {
            UAObject sub = new UAObject();

            sub.NodeId     = "ns=1;i=" + masterID.ToString();
            sub.BrowseName = "1:" + submodel.idShort;
            masterID++;
            List <Reference> refs = new List <Reference>();

            if (submodel.kind != null)
            {
                refs.Add(
                    CreateReference(
                        "HasProperty",
                        CreateProperty(
                            submodel.kind.kind, "1:AASModelingKindDataType", "ModellingKind", "String")));
            }
            refs.Add(CreateHasTypeDefinition("1:AASSubmodelType"));
            refs.Add(
                CreateReference(
                    "HasProperty", CreateProperty(submodel.category, "PropertyType", "Category", "String")));
            refs.Add(CreateReference("HasComponent", CreateSemanticId(submodel.semanticId)));

            //set Identifiable
            if (submodel.administration == null)
            {
                refs.Add(
                    CreateReference(
                        "HasInterface",
                        CreateIdentifiable(submodel.identification.id, submodel.identification.idType, null, null)));
            }
            else if (submodel.identification == null)
            {
                refs.Add(
                    CreateReference(
                        "HasInterface",
                        CreateIdentifiable(null, null, submodel.administration.version,
                                           submodel.administration.revision)));
            }
            else
            {
                refs.Add(
                    CreateReference(
                        "HasInterface",
                        CreateIdentifiable(
                            submodel.identification.id, submodel.identification.idType,
                            submodel.administration.version, submodel.administration.revision)));
            }

            //set Qualifier if it exists
            if (submodel.qualifiers != null)
            {
                foreach (AdminShellV20.Qualifier qualifier in submodel.qualifiers)
                {
                    refs.Add(
                        CreateReference(
                            "HasComponent", CreateAASQualifier(qualifier.type, qualifier.value, qualifier.valueId)));
                }
            }

            //add Elements
            foreach (AdminShellV20.SubmodelElementWrapper element in submodel.submodelElements)
            {
                string id = CreateSubmodelElement(element.submodelElement);
                refs.Add(CreateReference("HasComponent", id));
            }

            sub.References = refs.ToArray();
            root.Add((UANode)sub);
            return(sub.NodeId);
        }