Beispiel #1
0
            public void BuildEntites(AasEntityBuilder builder)
            {
                // build up entities, which are in the UA specs, but not in this Stack
                BaseInterfaceType       = new AasUaNamespaceZeroEntity(builder, 17602);
                HasDictionaryEntry      = new AasUaNamespaceZeroReference(builder, 17597);
                HasInterface            = new AasUaNamespaceZeroReference(builder, 17603);
                HasAddIn                = new AasUaNamespaceZeroReference(builder, 17604);
                DictionaryEntryType     = new AasUaNamespaceZeroEntity(builder, 17589);
                UriDictionaryEntryType  = new AasUaNamespaceZeroEntity(builder, 17600);
                IrdiDictionaryEntryType = new AasUaNamespaceZeroEntity(builder, 17598);
                DictionaryFolderType    = new AasUaNamespaceZeroEntity(builder, 17591);

                // AAS DataTypes
                PathType = new AasUaEntityPathType(builder);
                MimeType = new AasUaEntityMimeType(builder);

                // first entities
                Referable      = new AasUaEntityReferable(builder, 1004);
                Identification = new AasUaEntityIdentification(builder, 1000);
                Administration = new AasUaEntityAdministration(builder, 1001);

                // interfaces
                IAASReferableType = new AasUaInterfaceAASReferableType(
                    builder, 2001); // dependencies: Referable
                IAASIdentifiableType = new AasUaInterfaceAASIdentifiableType(
                    builder, 2000); // dependencies: IAASReferable

                // AAS References
                ReferenceBase   = new AasUaEntityReferenceBase(builder, 0);
                Reference       = new AasUaEntityReference(builder, 1005);
                SemanticId      = new AasUaEntitySemanticId(builder, 1006);         // dependecies: Reference
                HasAasReference = new AasUaReferenceHasAasReference(builder, 4000); // dependencies: Referable

                // Data Specifications
                DataSpecification         = new AasUaEntityDataSpecification(builder, 3000);
                DataSpecificationIEC61360 = new AasUaEntityDataSpecificationIEC61360(
                    builder, 3001); // dependencies: Reference, Identification, Administration

                // rest
                Qualifier           = new AasUaEntityQualifier(builder, 1002); // dependencies: SemanticId, Reference
                AssetKind           = new AasUaEntityAssetKind(builder, 1025);
                ModelingKind        = new AasUaEntityModelingKind(builder, 1003);
                SubmodelElement     = new AasUaEntitySubmodelElement(builder, 1008);
                SubmodelWrapper     = new AasUaEntitySubmodelWrapper(builder, 1012); // dependencies: SubmodelElement
                Submodel            = new AasUaEntitySubmodel(builder, 1007);        // dependencies: SubmodelWrapper
                Property            = new AasUaEntityProperty(builder, 1009);
                Collection          = new AasUaEntityCollection(builder, 1010);      // needs 2 ids!
                FileType            = new AasUaEntityFileType(builder, 1014);
                File                = new AasUaEntityFile(builder, 1013);            // dependencies: FileType
                Blob                = new AasUaEntityBlob(builder, 1015);
                ReferenceElement    = new AasUaEntityReferenceElement(builder, 1016);
                RelationshipElement = new AasUaEntityRelationshipElement(builder, 1017);
                OperationVariable   = new AasUaEntityOperationVariable(builder, 1018);
                Operation           = new AasUaEntityOperation(builder, 1019);
                ConceptDictionary   = new AasUaEntityConceptDictionary(builder, 1020);
                ConceptDescription  = new AasUaEntityConceptDescription(builder, 1021);
                View                = new AasUaEntityView(builder, 1022);
                Asset               = new AasUaEntityAsset(builder, 1023);
                AAS = new AasUaEntityAAS(builder, 1024);
            }
Beispiel #2
0
        /// <summary>
        /// Does any initialization required before the address space can be used.
        /// </summary>
        /// <remarks>
        /// The externalReferences is an out parameter that allows the node manager to link to nodes
        /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and
        /// should have a reference to the root folder node(s) exposed by this node manager.
        /// </remarks>
        public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences)
        {
            lock (Lock)
            {
                base.CreateAddressSpace(externalReferences);


                if (true)
                {
                    var builder = new AasEntityBuilder(this, thePackageEnv, null, this.theServerOptions);
                    var x       = builder.CreateAddObject(null, "AASROOT");
                    // this one is special, needs to link to external reference
                    this.AddExternalReference(new NodeId(85, 0), ReferenceTypeIds.Organizes, false, x.NodeId, externalReferences);

                    for (int i = 0; i < thePackageEnv.Length; i++)
                    {
                        if (thePackageEnv[i] != null)
                        {
                            builder.AasTypes.AAS.CreateAddInstanceObject(x, thePackageEnv[i].AasEnv, thePackageEnv[i].AasEnv.AdministrationShells[0]);
                        }
                    }
                }

                Debug.WriteLine("Done with custom address space?!");
                Utils.Trace("Done with custom address space?!");
            }
        }
Beispiel #3
0
 public AasUaEntityFileType(AasEntityBuilder entityBuilder, uint preferredTypeNumId = 0)
     : base(entityBuilder)
 {
     // do NOT create type object, as they shall be all there in the UA constants
 }
Beispiel #4
0
        /// <summary>
        /// Does any initialization required before the address space can be used.
        /// </summary>
        /// <remarks>
        /// The externalReferences is an out parameter that allows the node manager to link to nodes
        /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and
        /// should have a reference to the root folder node(s) exposed by this node manager.
        /// </remarks>
        public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences)
        {
            lock (Lock)
            {
                base.CreateAddressSpace(externalReferences);

                // Note: might be helpful for debugging
                //// var env = new AdminShell.PackageEnv("Festo-USB-stick-sample-admin-shell.aasx");

                if (true)
                {
                    var builder = new AasEntityBuilder(this, thePackageEnv, null, this.theServerOptions);

                    // Root of whole structure is special, needs to link to external reference
                    builder.RootAAS = builder.CreateAddFolder(null, "AASROOT");
                    // Note: this is TOTALLY WEIRD, but it establishes an inverse reference .. somehow
                    this.AddExternalReferencePublic(new NodeId(85, 0), ReferenceTypeIds.Organizes, false,
                                                    builder.RootAAS.NodeId, externalReferences);
                    this.AddExternalReferencePublic(builder.RootAAS.NodeId, ReferenceTypeIds.Organizes, true,
                                                    new NodeId(85, 0), externalReferences);


                    // Folders for DataSpecs
                    // DO NOT USE THIS FEATURE -> Data Spec are "under" the CDs
                    //// builder.RootDataSpecifications = builder.CreateAddFolder(
                    //// builder.RootAAS, "DataSpecifications");
                    //// builder.RootDataSpecifications = builder.CreateAddObject(
                    //// builder.RootAAS, "DataSpecifications");

                    if (false)
                    // ReSharper disable once HeuristicUnreachableCode
#pragma warning disable 162
                    {
                        // Folders for Concept Descriptions
                        // ReSharper disable once HeuristicUnreachableCode
                        builder.RootConceptDescriptions = builder.CreateAddFolder(
                            builder.RootAAS, "ConceptDescriptions");

                        // create missing dictionary entries
                        builder.RootMissingDictionaryEntries = builder.CreateAddFolder(
                            builder.RootAAS, "DictionaryEntries");
                    }
#pragma warning restore 162
                    else
                    {
                        // create folder(s) under root
                        var topOfDict = builder.CreateAddObject(null, "Dictionaries",
                                                                referenceTypeFromParentId: null,
                                                                typeDefinitionId: builder.AasTypes.DictionaryFolderType.GetTypeNodeId());
                        // Note: this is TOTALLY WEIRD, but it establishes an inverse reference .. somehow
                        // 2253 = Objects?
                        this.AddExternalReferencePublic(new NodeId(2253, 0),
                                                        ReferenceTypeIds.HasComponent, false, topOfDict.NodeId, externalReferences);
                        this.AddExternalReferencePublic(topOfDict.NodeId,
                                                        ReferenceTypeIds.HasComponent, true, new NodeId(2253, 0), externalReferences);

                        // now, create a dictionary under ..
                        // Folders for Concept Descriptions
                        builder.RootConceptDescriptions = builder.CreateAddObject(topOfDict, "ConceptDescriptions",
                                                                                  referenceTypeFromParentId: ReferenceTypeIds.HasComponent,
                                                                                  typeDefinitionId: builder.AasTypes.DictionaryFolderType.GetTypeNodeId());

                        // create missing dictionary entries
                        builder.RootMissingDictionaryEntries = builder.CreateAddObject(topOfDict, "DictionaryEntries",
                                                                                       referenceTypeFromParentId: ReferenceTypeIds.HasComponent,
                                                                                       typeDefinitionId: builder.AasTypes.DictionaryFolderType.GetTypeNodeId());
                    }

                    // start process
                    builder.CreateAddInstanceObjects(thePackageEnv.AasEnv);
                }

                // Try: ensure the reverse refernces exist.
                //// AddReverseReferences(externalReferences);

                if (theServerOptions != null &&
                    theServerOptions.SpecialJob == AasxUaServerOptions.JobType.ExportNodesetXml)
                {
                    try
                    {
                        // empty list
                        var nodesToExport = new NodeStateCollection();

                        // apply filter criteria
                        foreach (var y in this.PredefinedNodes)
                        {
                            var node = y.Value;
                            if (theServerOptions.ExportFilterNamespaceIndex != null &&
                                !theServerOptions.ExportFilterNamespaceIndex.Contains(node.NodeId.NamespaceIndex))
                            {
                                continue;
                            }
                            nodesToExport.Add(node);
                        }

                        // export
                        Utils.Trace("Writing export file: " + theServerOptions.ExportFilename);
                        var stream = new StreamWriter(theServerOptions.ExportFilename);

                        //// nodesToExport.SaveAsNodeSet2(this.SystemContext, stream.BaseStream, null,
                        //// theServerOptions != null && theServerOptions.FilterForSingleNodeIds);

                        try
                        {
                            stream.Close();
                        }
                        // ReSharper disable once EmptyGeneralCatchClause
                        catch { }

                        // stop afterwards
                        if (theServerOptions.FinalizeAction != null)
                        {
                            Utils.Trace("Requesting to shut down application..");
                            theServerOptions.FinalizeAction();
                        }
                    }
                    catch (Exception ex)
                    {
                        Utils.Trace(ex, "When exporting to {0}", "" + theServerOptions.ExportFilename);
                    }

                    // shutdown ..
                }

                Debug.WriteLine("Done creating custom address space!");
                Utils.Trace("Done creating custom address space!");
            }
        }
Beispiel #5
0
        /// <summary>
        /// Does any initialization required before the address space can be used.
        /// </summary>
        /// <remarks>
        /// The externalReferences is an out parameter that allows the node manager to link to nodes
        /// in other node managers. For example, the 'Objects' node is managed by the CoreNodeManager and
        /// should have a reference to the root folder node(s) exposed by this node manager.
        /// </remarks>
        public override void CreateAddressSpace(IDictionary <NodeId, IList <IReference> > externalReferences)
        {
            lock (Lock)
            {
                base.CreateAddressSpace(externalReferences);

                // Note: might be helpful for debugging
                //// var env = new AdminShell.PackageEnv("Festo-USB-stick-sample-admin-shell.aasx");

                if (true)
                {
                    var builder = new AasEntityBuilder(this, thePackageEnv, null, this.theServerOptions);

                    // Overall root node is "Objects"
                    // Note: it would be better to already have the "Objects" NodeState, but not
                    // clear how to find ..
                    var fakeObjects = new BaseObjectState(null)
                    {
                        NodeId = new NodeId(85, 0)
                    };
                    var fakeServer = new BaseObjectState(null)
                    {
                        NodeId = new NodeId(2253, 0)
                    };

                    // remark: set parent to null, to disable for no HasComponent
                    if (!theServerOptions.LinkRootAsComponent)
                    {
                        fakeObjects = null;
                        fakeServer  = null;
                    }

                    // Root of whole structure is special, needs to link to external reference
                    builder.RootAAS = builder.CreateAddFolder(AasUaBaseEntity.CreateMode.Instance,
                                                              fakeObjects, "AASROOT",
                                                              doNotAddToParent: true);
                    if (!theServerOptions.LinkRootAsComponent)
                    {
                        builder.RootAAS.AddReference(ReferenceTypeIds.Organizes, isInverse: true, fakeObjects?.NodeId);
                    }

                    // Note: this is TOTALLY WEIRD, but it establishes an inverse reference .. somehow
                    this.AddExternalReferencePublic(new NodeId(85, 0), ReferenceTypeIds.Organizes, false,
                                                    builder.RootAAS.NodeId, externalReferences);
                    this.AddExternalReferencePublic(builder.RootAAS.NodeId, ReferenceTypeIds.Organizes, true,
                                                    new NodeId(85, 0), externalReferences);

                    // Folders for DataSpecs
                    // DO NOT USE THIS FEATURE -> Data Spec are "under" the CDs
                    //// builder.RootDataSpecifications = builder.CreateAddFolder(
                    //// builder.RootAAS, "DataSpecifications");
                    //// builder.RootDataSpecifications = builder.CreateAddObject(
                    //// builder.RootAAS, "DataSpecifications");

#if _not_used
#pragma warning disable 162
                    {
                        // Folders for Concept Descriptions
                        // ReSharper disable once HeuristicUnreachableCode
                        builder.RootConceptDescriptions = builder.CreateAddFolder(
                            AasUaBaseEntity.CreateMode.Instance,
                            builder.RootAAS, "ConceptDescriptions");

                        // create missing dictionary entries
                        builder.RootMissingDictionaryEntries = builder.CreateAddFolder(
                            AasUaBaseEntity.CreateMode.Instance,
                            builder.RootAAS, "DictionaryEntries");
                    }
#pragma warning restore 162
#else
                    {
                        // create folder(s) under "Objects"
                        var topOfDict = new BaseObjectState(null)
                        {
                            NodeId = new NodeId(17594, 0)
                        };

                        // it seems, that CeateDictionariesFolder always have to be true!
                        // adding references to a node outside the own node space seems not to work
                        if (theServerOptions.CeateDictionariesFolder)
                        {
                            topOfDict = builder.CreateAddObject(
                                fakeServer,
                                AasOpcUaServer.AasUaBaseEntity.CreateMode.Instance, "Dictionaries",
                                referenceTypeFromParentId: null,
                                typeDefinitionId: builder.AasTypes.DictionaryFolderType.GetTypeNodeId());
                        }

                        topOfDict.AddReference(ReferenceTypeIds.Organizes, isInverse: true, fakeServer?.NodeId);

                        // Note: this is TOTALLY WEIRD, but it establishes an inverse reference .. somehow
                        // 2253 = Server.Dictionaries ?
                        this.AddExternalReferencePublic(new NodeId(2253, 0),
                                                        ReferenceTypeIds.HasComponent, false, topOfDict.NodeId, externalReferences);
                        this.AddExternalReferencePublic(topOfDict.NodeId,
                                                        ReferenceTypeIds.HasComponent, true, new NodeId(2253, 0), externalReferences);

                        // now, create a dictionary under ..
                        // Folders for Concept Descriptions
                        builder.RootConceptDescriptions = builder.CreateAddObject(topOfDict,
                                                                                  AasOpcUaServer.AasUaBaseEntity.CreateMode.Instance, "ConceptDescriptions",
                                                                                  referenceTypeFromParentId: ReferenceTypeIds.HasComponent,
                                                                                  typeDefinitionId: builder.AasTypes.DictionaryFolderType.GetTypeNodeId());

                        // create missing dictionary entries
                        builder.RootMissingDictionaryEntries = builder.CreateAddObject(topOfDict,
                                                                                       AasOpcUaServer.AasUaBaseEntity.CreateMode.Instance, "DictionaryEntries",
                                                                                       referenceTypeFromParentId: ReferenceTypeIds.HasComponent,
                                                                                       typeDefinitionId: builder.AasTypes.DictionaryFolderType.GetTypeNodeId());
                    }

                    // start process
                    builder.CreateAddInstanceObjects(thePackageEnv.AasEnv);
#endif

                    // Try: ensure the reverse refernces exist.
                    //// AddReverseReferences(externalReferences);

                    if (theServerOptions != null &&
                        theServerOptions.SpecialJob == AasxUaServerOptions.JobType.ExportNodesetXml)
                    {
                        try
                        {
                            // empty list
                            var nodesToExport = new NodeStateCollection();

                            // apply filter criteria
                            foreach (var y in this.PredefinedNodes)
                            {
                                var node = y.Value;

                                if (theServerOptions.ExportFilterNamespaceIndex != null &&
                                    !theServerOptions.ExportFilterNamespaceIndex.Contains(
                                        node.NodeId.NamespaceIndex))
                                {
                                    continue;
                                }

                                nodesToExport.Add(node);
                            }

                            // export
                            Utils.Trace(Utils.TraceMasks.Operation,
                                        "Writing export file: " + theServerOptions.ExportFilename);
                            var stream = new StreamWriter(theServerOptions.ExportFilename);

                            //// nodesToExport.SaveAsNodeSet2(this.SystemContext, stream.BaseStream, null,
                            //// theServerOptions != null && theServerOptions.FilterForSingleNodeIds);

                            //// nodesToExport.SaveAsNodeSet2(this.SystemContext, stream.BaseStream);
                            SaveNodestateCollectionAsNodeSet2(this.SystemContext, nodesToExport, stream.BaseStream,
                                                              filterSingleNodeIds: theServerOptions != null &&
                                                              theServerOptions.FilterForSingleNodeIds,
                                                              addRootItem: theServerOptions != null && theServerOptions.AddRootItem,
                                                              builder.RootAAS);

                            try
                            {
                                stream.Close();
                            }
                            catch (Exception ex)
                            {
                                AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                            }

                            Utils.Trace(Utils.TraceMasks.Operation,
                                        "Export file *** completely written! ***");

                            // stop afterwards
                            if (theServerOptions.FinalizeAction != null)
                            {
                                Utils.Trace(Utils.TraceMasks.Operation,
                                            "Requesting to shut down application..");
                                theServerOptions.FinalizeAction();
                            }
                        }
                        catch (Exception ex)
                        {
                            Utils.Trace(ex, "When exporting to {0}", "" + theServerOptions.ExportFilename);
                        }

                        // shutdown ..
                    }
                }

                Debug.WriteLine("Done creating custom address space!");
                Utils.Trace(Utils.TraceMasks.Operation,
                            "Done creating custom address space!");
            }
        }