コード例 #1
0
ファイル: GraphEditor.cs プロジェクト: j-prox/blueprint41
        private void GraphEditor_MouseUp(object sender, MsaglMouseEventArgs e)
        {
            if (e.RightButtonIsPressed)
            {
                return;
            }

            var    point = new GeometryPoint(e.X, e.Y);
            object obj   = gViewer.GetObjectAt((int)point.X, (int)point.Y);

            if (obj is DNode && SelectedEntities.Count > 0)
            {
                Submodel displayedModel = null;

                if (this.Viewer.Tag != null && this.Viewer.Tag is Submodel)
                {
                    displayedModel = this.Viewer.Tag as Submodel;
                }

                if (displayedModel != null && displayedModel.Model != null)
                {
                    displayedModel.Model.CaptureCoordinates();
                }
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: j-prox/blueprint41
        void AddNewEntitiesToSubModel(string submodelName)
        {
            Submodel subModel = Model.Submodels.Submodel.FirstOrDefault(submodel => submodel.Name == submodelName);

            if (subModel == null)
            {
                throw new ArgumentNullException($"Submodel '{submodelName}' does not exist in the current model.");
            }

            IEnumerable <string> mainModelNodeLabels = subModel.Node.Select(node => node.Label).OrderBy(label => label);
            IEnumerable <string> entityLabels        = Model.Entities.Entity.Select(entity => entity.Label).OrderBy(label => label);

            List <Entity> entitiesToAddToMainModel = new List <Entity>();

            foreach (var entityLabel in entityLabels.Except(mainModelNodeLabels))
            {
                entitiesToAddToMainModel.Add(Model.Entities.Entity.FirstOrDefault(label => label.Label == entityLabel));
            }

            subModel.AddEntities(entitiesToAddToMainModel, 0, 0);

            Model.CaptureCoordinates();

            if (this.entityEditor.IsEditable)
            {
                entityEditor.Reload();
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: j-prox/blueprint41
        void InitializeSubmodel()
        {
            if (Model.DisplayedSubmodel == null)
            {
                if (Model.Submodels.Submodel.Count == 0)
                {
                    Submodel main = new Submodel(Model);
                    main.Name = Constants.MainModel;
                    Model.Submodels.Submodel.Add(main);
                }

                Model.DisplayedSubmodel = Model.Submodels.Submodel.Where(m => m.Name == RegistryHandler.LastOpenedSubmodel).FirstOrDefault();
                Model.MainSubmodel      = mainSubmodel;

                if (Model.DisplayedSubmodel == null)
                {
                    Model.DisplayedSubmodel = mainSubmodel;
                }
            }

            FillSubmodelComboBox(Model.DisplayedSubmodel);
            InitializeGraphNodeTypes();
            entityEditor.EnableDisableControlsForType(Model.ModellerType);

            btnShowLabels.Checked = Model.ShowRelationshipLabels;
            btnShowInheritedRelationships.Checked = Model.ShowInheritedRelationships;
            idcounter = 0;
        }
コード例 #4
0
        public static AssetAdministrationShell GetAssetAdministrationShell()
        {
            AssetAdministrationShell aas = new AssetAdministrationShell()
            {
                IdShort        = "SimpleAAS",
                Identification = new Identifier("http://basys40.de/shells/SimpleAAS/" + Guid.NewGuid().ToString(), KeyType.IRI),
                Description    = new LangStringSet()
                {
                    new LangString("de-DE", "Einfache VWS"),
                    new LangString("en-US", "Simple AAS")
                },
                Administration = new AdministrativeInformation()
                {
                    Version  = "1.0",
                    Revision = "120"
                },
                Asset = new Asset()
                {
                    IdShort        = "SimpleAsset",
                    Identification = new Identifier("http://basys40.de/assets/SimpleAsset/" + Guid.NewGuid().ToString(), KeyType.IRI),
                    Kind           = AssetKind.Instance,
                    Description    = new LangStringSet()
                    {
                        new LangString("de-DE", "Einfaches Asset"),
                        new LangString("en-US", "Simple Asset")
                    }
                }
            };

            Submodel testSubmodel = GetTestSubmodel();

            aas.Submodels.Add(testSubmodel);

            return(aas);
        }
コード例 #5
0
        private static Submodel createSubmodel(UAObject submodel)
        {
            //Submodel
            //  -> AASSubmodelElement (multiple)
            //  -> AASSemanticId
            //  -> Property (Category)
            //  -> ModellingKind


            if (isSubmodel(submodel))
            {
                //set Submodelparameters
                Identification iden = GetIdentification(submodel);
                Submodel       sub  = Submodel.CreateNew(iden.idType, iden.id);
                sub.idShort = makePretty(submodel.BrowseName);
                sub.kind    = getKind(submodel);


                sub.submodelElements = new SubmodelElementWrapperCollection();

                foreach (Reference _ref in submodel.References)
                {
                    if (_ref.ReferenceType == "HasComponent")
                    {
                        var    node = findNode(_ref.Value);
                        string type = getTypeDefinition(node);

                        //Set SemanticId
                        if (type == "1:AASSemanticIdType")
                        {
                            addSemanticID(sub, (UAVariable)node);
                        }

                        //Set SubmodelElements
                        if (type == "1:AASSubmodelElementType")
                        {
                            sub.submodelElements.Add(createSubmodelElement(node));
                        }
                    }

                    //set Kind and Category
                    if (_ref.ReferenceType == "HasProperty")
                    {
                        var var = findNode(_ref.Value);
                        if (var.BrowseName == "1:ModellingKind")
                        {
                            sub.kind = getKind(var);
                        }
                        if (var.BrowseName == "1:Category")
                        {
                            sub.category = getCategory(var);
                        }
                    }
                }

                return(sub);
            }
            return(null);
        }
コード例 #6
0
 public ManageSubmodelForm(Model modeller, Submodel submodel)
 {
     InitializeComponent();
     Model       = modeller;
     Submodel    = submodel;
     IsMainModel = submodel.Name == Constants.MainModel;
     IsNewModel  = submodel.Name == null;
     AssignToUi();
     Text = "Edit Submodel";
 }
コード例 #7
0
 public SubmodelRule(ICollection <Entity> entities)
     : base(entities)
 {
     foreach (Entity e in entities)
     {
         if (e is Submodel)
         {
             submodel      = e as Submodel;
             this.entities = submodel.Entities;
         }
     }
 }
コード例 #8
0
ファイル: MainForm.cs プロジェクト: j-prox/blueprint41
        void FillSubmodelComboBox(Submodel selectedSub = null)
        {
            cmbSubmodels.Items.Clear();
            cmbSubmodels.Items.Add(NEWSUBMODEL);
            foreach (Submodel submodel in Model.Submodels.Submodel)
            {
                cmbSubmodels.Items.Add(submodel);
            }

            if (selectedSub == null)
            {
                cmbSubmodels.SelectedIndex = 1;
            }
            else
            {
                cmbSubmodels.SelectedItem = selectedSub;
            }
        }
コード例 #9
0
ファイル: Extensions.cs プロジェクト: j-prox/blueprint41
        /// <summary>
        /// Gets all the relationships from this submodel
        /// </summary>
        /// <param name="model"></param>
        /// <param name="includeInherited"></param>
        /// <returns></returns>
        public static List <Relationship> GetRelationships(this Submodel model, bool includeInherited = false)
        {
            // Gets all the relationships from the matching entities of submodel
            Dictionary <string, Submodel.NodeLocalType> nodeLookup = model.Node.ToDictionary(x => x.Label);

            model.Model.Relationships.Relationship
            .Where(item => string.IsNullOrEmpty(item.Source.Label) || string.IsNullOrEmpty(item.Target.Label)).ToList()
            .ForEach(item => model.Model.Relationships.Relationship.Remove(item));

            var relationships = model.Model.Relationships.Relationship
                                .Where(item => nodeLookup.ContainsKey(item.Source.Label) && nodeLookup.ContainsKey(item.Target.Label)).ToList();

            if (includeInherited == false)
            {
                return(relationships);
            }

            List <Relationship> inheritedRelationships = new List <Relationship>();

            foreach (var node in model.Node)
            {
                Dictionary <RelationshipDirection, List <Relationship> > inheritedPropertyByDirection = node.Entity.GetInheritedRelationships(model);

                foreach (var item in inheritedPropertyByDirection[RelationshipDirection.In])
                {
                    Relationship relationship = new Relationship(model.Model, (relationship)item.Xml.Clone());
                    relationship.Source.Label = node.Label;
                    inheritedRelationships.Add(relationship);
                    model.CreatedInheritedRelationships.Add(relationship);
                }

                foreach (var item in inheritedPropertyByDirection[RelationshipDirection.Out])
                {
                    Relationship relationship = new Relationship(model.Model, (relationship)item.Xml.Clone());
                    relationship.Target.Label = node.Label;
                    inheritedRelationships.Add(relationship);
                    model.CreatedInheritedRelationships.Add(relationship);
                }
            }

            relationships.AddRange(inheritedRelationships);
            return(relationships);
        }
コード例 #10
0
ファイル: SubmodelExtensions.cs プロジェクト: i-Asset/basyx
        public static ISubmodel CreateSubmodelFromObject(this object target)
        {
            if (target == null)
            {
                return(null);
            }

            Type     type     = target.GetType();
            Submodel submodel = new Submodel()
            {
                IdShort        = type.Name,
                Identification = new Identifier(type.FullName, KeyType.Custom)
            };

            foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                ISubmodelElement smElement = property.CreateSubmodelElement(target);
                submodel.SubmodelElements.Add(smElement);
            }
            return(submodel);
        }
コード例 #11
0
        public Entities.Entity transform(UIEntity entity)
        {
            if (cyclicDependencyChecker)
            {
                return(null);
            }

            TransformerService ts       = new TransformerService();
            SubDiagram         sd       = entity as SubDiagram;
            Submodel           submodel = new Submodel()
            {
                name = entity.EntityName, id = entity.Id
            };

            cyclicDependencyChecker = true;
            submodel.setEntites(ts.transform(new FileService().open(sd.ProjectItem.FullPath).Children));
            cyclicDependencyChecker = false;

            submodel.setResources(ts.getResources());
            return(submodel);
        }
コード例 #12
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Submodel.Name         = txtName.Text;
            Submodel.Chapter      = numericChapter.Value == 0 ? null : (int?)numericChapter.Value;
            Submodel.IsDraft      = chkIsDraft.Checked;
            Submodel.IsLaboratory = chkIsLaboratory.Checked;
            Submodel.Explaination = ToXmlEscape(hteExplaination.GetHTMLAsText());

            foreach (Submodel.NodeLocalType node in Submodel.Node.Where(item => !lbExisting.Items.Contains(item.Label)).ToList())
            {
                Submodel.Node.Remove(node);
            }

            foreach (string item in lbExisting.Items.Cast <string>().Where(item => !Submodel.Node.Any(node => node.Label == item)).ToList())
            {
                Submodel.AddEntities(Submodel.Model.Entities.Entity.Where(entity => entity.Label == item).ToList(), 0, 0);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #13
0
        private static void addSemanticID(Submodel sub, UAVariable sem)
        {
            foreach (Reference _ref in sem.References)
            {
                if (_ref.ReferenceType != "HasTypeDefinition")
                {
                    UAVariable key  = (UAVariable)findNode(_ref.Value);
                    Key        _key = new Key();
                    foreach (Reference _InnerRef in key.References)
                    {
                        if (_InnerRef.ReferenceType != "HasTypeDefinition")
                        {
                            UAVariable value = (UAVariable)findNode(_InnerRef.Value);
                            switch (value.BrowseName)
                            {
                            case "1:IdType":
                                _key.idType = value.Value.InnerText;
                                break;

                            case "1:Local":
                                _key.local = bool.Parse(value.Value.InnerText);
                                break;

                            case "1:Type":
                                _key.type = value.Value.InnerText;
                                break;

                            case "1:Value":
                                _key.value = value.Value.InnerText;
                                break;
                            }
                        }
                    }
                    sub.semanticId.Keys.Add(_key);
                }
            }
        }
コード例 #14
0
        private static void ConvertToAssetAdministrationShell(AssetAdministrationShellEnvironment_V2_0 environment)
        {
            foreach (var envAsset in environment.EnvironmentAssets)
            {
                Asset asset = new Asset
                {
                    Administration           = envAsset.Administration,
                    Category                 = envAsset.Category,
                    Description              = envAsset.Description,
                    Identification           = envAsset.Identification,
                    IdShort                  = envAsset.IdShort,
                    Kind                     = envAsset.Kind,
                    AssetIdentificationModel = envAsset.AssetIdentificationModelReference?.ToReference_V2_0 <ISubmodel>()
                };
                environment.Assets.Add(asset);
            }
            foreach (var envConceptDescription in environment.EnvironmentConceptDescriptions)
            {
                ConceptDescription conceptDescription = new ConceptDescription()
                {
                    Administration             = envConceptDescription.Administration,
                    Category                   = envConceptDescription.Category,
                    Description                = envConceptDescription.Description,
                    Identification             = envConceptDescription.Identification,
                    IdShort                    = envConceptDescription.IdShort,
                    IsCaseOf                   = envConceptDescription.IsCaseOf?.ConvertAll(c => c.ToReference_V2_0()),
                    EmbeddedDataSpecifications = (envConceptDescription.EmbeddedDataSpecification?.DataSpecificationContent?.DataSpecificationIEC61360 != null) ? new List <DataSpecificationIEC61360>() : null
                };
                if (conceptDescription.EmbeddedDataSpecifications != null)
                {
                    DataSpecificationIEC61360 dataSpecification = envConceptDescription
                                                                  .EmbeddedDataSpecification
                                                                  .DataSpecificationContent
                                                                  .DataSpecificationIEC61360
                                                                  .ToDataSpecificationIEC61360();

                    (conceptDescription.EmbeddedDataSpecifications as List <DataSpecificationIEC61360>).Add(dataSpecification);
                }
                environment.ConceptDescriptions.Add(conceptDescription);
            }
            foreach (var envSubmodel in environment.EnvironmentSubmodels)
            {
                Submodel submodel = new Submodel()
                {
                    Administration = envSubmodel.Administration,
                    Category       = envSubmodel.Category,
                    Description    = envSubmodel.Description,
                    Identification = envSubmodel.Identification,
                    IdShort        = envSubmodel.IdShort,
                    Kind           = envSubmodel.Kind,
                    Parent         = string.IsNullOrEmpty(envSubmodel.Parent) ? null :
                                     new Reference(
                        new Key(KeyElements.AssetAdministrationShell, KeyType.IRI, envSubmodel.Parent, true)),
                    SemanticId         = envSubmodel.SemanticId?.ToReference_V2_0(),
                    ConceptDescription = null,
                };
                List <ISubmodelElement> smElements = envSubmodel.SubmodelElements.ConvertAll(c => c.submodelElement?.ToSubmodelElement(environment.ConceptDescriptions));
                foreach (var smElement in smElements)
                {
                    submodel.SubmodelElements.Add(smElement);
                }

                environment.Submodels.Add(submodel);
            }
            foreach (var envAssetAdministrationShell in environment.EnvironmentAssetAdministationShells)
            {
                AssetAdministrationShell assetAdministrationShell = new AssetAdministrationShell()
                {
                    Administration = envAssetAdministrationShell.Administration,
                    Category       = envAssetAdministrationShell.Category,
                    DerivedFrom    = envAssetAdministrationShell.DerivedFrom?.ToReference_V2_0 <IAssetAdministrationShell>(),
                    Description    = envAssetAdministrationShell.Description,
                    Identification = envAssetAdministrationShell.Identification,
                    IdShort        = envAssetAdministrationShell.IdShort
                };

                IAsset asset = environment.Assets.Find(a => a.Identification.Id == envAssetAdministrationShell.AssetReference?.Keys?.FirstOrDefault()?.Value);
                assetAdministrationShell.Asset = asset;

                foreach (var envSubmodelRef in envAssetAdministrationShell.SubmodelReferences)
                {
                    ISubmodel submodel = environment.Submodels.Find(s => s.Identification.Id == envSubmodelRef.Keys?.FirstOrDefault()?.Value);
                    if (submodel != null)
                    {
                        assetAdministrationShell.Submodels.Add(submodel);
                    }
                }

                environment.AssetAdministrationShells.Add(assetAdministrationShell);
            }
        }
コード例 #15
0
        public static int Main(string[] args)
        {
            int            retval = 0;
            SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

            // create the document
            SBMLDocument document = new SBMLDocument(sbmlns);

            // create the Model
            Model model = document.createModel();

            // create a replacement parameter
            Parameter parameter = model.createParameter();

            parameter.setId("x");
            parameter.setConstant(true);

            // create a parameter to be a conversion factor
            Parameter param2 = model.createParameter();

            param2.setId("x_conv");
            param2.setMetaId("_110013");
            param2.setConstant(true);

            // create a parameter to be a conversion factor
            Parameter param3 = model.createParameter();

            param3.setId("lcf");
            param3.setConstant(true);

            // Convert parameter to the plugin version so we can add the new attributes and replacements to it.
            CompSBasePlugin splugin = (CompSBasePlugin)(parameter.getPlugin("comp"));

            // Add a replaced element.
            ReplacedElement rep1 = splugin.createReplacedElement();
            int             rv   = rep1.setSubmodelRef("submod1");

            rv = rep1.setConversionFactor("x_conv");
            rv = rep1.setIdRef("param1");

            // Add a second replaced element in a different way.
            ReplacedElement rep2 = new ReplacedElement();

            rv = rep2.setSubmodelRef("submod2");
            rv = rep2.setDeletion("del1");
            rv = splugin.addReplacedElement(rep2);

            //Now create a replaced element that points into a submodel.
            rep2.unsetDeletion();
            rep2.setIdRef("submod2");
            SBaseRef sbr5 = rep2.createSBaseRef();

            sbr5.setIdRef("submodelG");
            SBaseRef sbr6 = sbr5.createSBaseRef();

            sbr6.setIdRef("buriedElement");
            splugin.addReplacedElement(rep2);


            // Create a submodel
            CompModelPlugin        mplugin = (CompModelPlugin)(model.getPlugin("comp"));
            CompSBMLDocumentPlugin compdoc = (CompSBMLDocumentPlugin)(document.getPlugin("comp"));

            compdoc.setRequired(true);

            ModelDefinition moddef1 = compdoc.createModelDefinition();

            moddef1.setId("Mod1");
            Parameter m1param1 = moddef1.createParameter();

            m1param1.setId("param1");
            m1param1.setConstant(true);
            Parameter m1param2 = moddef1.createParameter();

            m1param2.setId("param2");
            m1param2.setConstant(false);
            m1param2.setValue(3.2);

            ModelDefinition moddef2 = new ModelDefinition();

            moddef2.setId("Mod2");
            Parameter subparam2 = moddef2.createParameter();

            subparam2.setId("subparam2");
            subparam2.setConstant(false);
            compdoc.addModelDefinition(moddef2);


            ExternalModelDefinition extmod1 = compdoc.createExternalModelDefinition();

            extmod1.setId("ExtMod1");
            extmod1.setSource("urn:miriam:biomodels.db:BIOMD0000000127");

            ExternalModelDefinition extmod2 = new ExternalModelDefinition();

            extmod2.setId("ExtMod2");
            extmod2.setSource("otherfile.xml");
            extmod2.setModelRef("modelnamethere");
            extmod2.setMd5("406022s908ge74sklj");
            compdoc.addExternalModelDefinition(extmod2);

            Submodel submod1 = mplugin.createSubmodel();

            submod1.setId("submod1");
            submod1.setModelRef("Mod1");
            Deletion del1 = submod1.createDeletion();

            del1.setId("deletionA");
            del1.setIdRef("param2");

            Submodel submod2 = new Submodel();

            submod2.setId("submod2");
            submod2.setModelRef("ExtMod1");
            submod2.setSubstanceConversionFactor("subcf");
            submod2.setTimeConversionFactor("tcf");
            submod2.setExtentConversionFactor("xtf");
            Deletion del2 = new Deletion();

            del2.setId("deletionB");
            del2.setMetaIdRef("_0010110");
            rv = submod2.addDeletion(del2);
            del2.setId("deletionC");
            del2.unsetMetaIdRef();
            del2.setPortRef("port2");
            rv = submod2.addDeletion(del2);
            del2.unsetId();
            del2.unsetPortRef();
            del2.setUnitRef("mph");
            rv = submod2.addDeletion(del2);
            del2.unsetUnitRef();
            del2.setIdRef("submodG");
            SBaseRef sbr = del2.createSBaseRef();

            sbr.setIdRef("element5");
            rv = submod2.addDeletion(del2);
            Deletion del3 = new Deletion();

            del3.setIdRef("submodG");
            SBaseRef sbr2 = new SBaseRef();

            sbr2.setIdRef("subsubmodQ");
            SBaseRef subsbr = sbr2.createSBaseRef();

            subsbr.setPortRef("toBdel");
            del3.setSBaseRef(sbr2);
            submod2.addDeletion(del3);
            mplugin.addSubmodel(submod2);

            Port port1 = mplugin.createPort();

            port1.setId("port1");
            port1.setMetaIdRef("_110013");
            Port port2 = new Port();

            port2.setId("port2");
            port2.setIdRef("x");
            mplugin.addPort(port2);
            port2.setId("port3");
            port2.setIdRef("submod2");
            port2.setSBaseRef(sbr2);
            mplugin.addPort(port2);

            libsbml.writeSBMLToFile(document, "comp_example1.xml");
            document = libsbml.readSBMLFromFile("comp_example1.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");
                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    OStringStream stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "comp_example1_rt.xml");
            }

            return(retval);
        }
コード例 #16
0
 public static AspectModel ToAspectModel(Submodel submodel)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
        public static int Main(string[] args)
        {
            int retval = 0;
              SBMLNamespaces sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

              // create the document
              SBMLDocument document = new SBMLDocument(sbmlns);

              // create the Model
              Model model = document.createModel();

              // create a replacement parameter
              Parameter parameter = model.createParameter();
              parameter.setId("x");
              parameter.setConstant(true);

              // create a parameter to be a conversion factor
              Parameter param2 = model.createParameter();
              param2.setId("x_conv");
              param2.setMetaId("_110013");
              param2.setConstant(true);

              // create a parameter to be a conversion factor
              Parameter param3 = model.createParameter();
              param3.setId("lcf");
              param3.setConstant(true);

              // Convert parameter to the plugin version so we can add the new attributes and replacements to it.
              CompSBasePlugin splugin = (CompSBasePlugin) (parameter.getPlugin("comp"));

              // Add a replaced element.
              ReplacedElement rep1 = splugin.createReplacedElement();
              int rv = rep1.setSubmodelRef("submod1");
              rv = rep1.setConversionFactor("x_conv");
              rv = rep1.setIdRef("param1");

              // Add a second replaced element in a different way.
              ReplacedElement rep2 = new ReplacedElement();
              rv = rep2.setSubmodelRef("submod2");
              rv = rep2.setDeletion("del1");
              rv = splugin.addReplacedElement(rep2);

              //Now create a replaced element that points into a submodel.
              rep2.unsetDeletion();
              rep2.setIdRef("submod2");
              SBaseRef sbr5 = rep2.createSBaseRef();
              sbr5.setIdRef("submodelG");
              SBaseRef sbr6 = sbr5.createSBaseRef();
              sbr6.setIdRef("buriedElement");
              splugin.addReplacedElement(rep2);

              // Create a submodel
              CompModelPlugin mplugin = (CompModelPlugin) (model.getPlugin("comp"));
              CompSBMLDocumentPlugin compdoc = (CompSBMLDocumentPlugin) (document.getPlugin("comp"));
              compdoc.setRequired(true);

              ModelDefinition moddef1 = compdoc.createModelDefinition();
              moddef1.setId("Mod1");
              Parameter m1param1 = moddef1.createParameter();
              m1param1.setId("param1");
              m1param1.setConstant(true);
              Parameter m1param2 = moddef1.createParameter();
              m1param2.setId("param2");
              m1param2.setConstant(false);
              m1param2.setValue(3.2);

              ModelDefinition moddef2 = new ModelDefinition();
              moddef2.setId("Mod2");
              Parameter subparam2 = moddef2.createParameter();
              subparam2.setId("subparam2");
              subparam2.setConstant(false);
              compdoc.addModelDefinition(moddef2);

              ExternalModelDefinition extmod1 = compdoc.createExternalModelDefinition();
              extmod1.setId("ExtMod1");
              extmod1.setSource("urn:miriam:biomodels.db:BIOMD0000000127");

              ExternalModelDefinition extmod2 = new ExternalModelDefinition();
              extmod2.setId("ExtMod2");
              extmod2.setSource("otherfile.xml");
              extmod2.setModelRef("modelnamethere");
              extmod2.setMd5("406022s908ge74sklj");
              compdoc.addExternalModelDefinition(extmod2);

              Submodel submod1 = mplugin.createSubmodel();
              submod1.setId("submod1");
              submod1.setModelRef("Mod1");
              Deletion del1 = submod1.createDeletion();
              del1.setId("deletionA");
              del1.setIdRef("param2");

              Submodel submod2 = new Submodel();
              submod2.setId("submod2");
              submod2.setModelRef("ExtMod1");
              submod2.setSubstanceConversionFactor("subcf");
              submod2.setTimeConversionFactor("tcf");
              submod2.setExtentConversionFactor("xtf");
              Deletion del2 = new Deletion();
              del2.setId("deletionB");
              del2.setMetaIdRef("_0010110");
              rv = submod2.addDeletion(del2);
              del2.setId("deletionC");
              del2.unsetMetaIdRef();
              del2.setPortRef("port2");
              rv = submod2.addDeletion(del2);
              del2.unsetId();
              del2.unsetPortRef();
              del2.setUnitRef("mph");
              rv = submod2.addDeletion(del2);
              del2.unsetUnitRef();
              del2.setIdRef("submodG");
              SBaseRef sbr = del2.createSBaseRef();
              sbr.setIdRef("element5");
              rv = submod2.addDeletion(del2);
              Deletion del3 = new Deletion();
              del3.setIdRef("submodG");
              SBaseRef sbr2 = new SBaseRef();
              sbr2.setIdRef("subsubmodQ");
              SBaseRef subsbr = sbr2.createSBaseRef();
              subsbr.setPortRef("toBdel");
              del3.setSBaseRef(sbr2);
              submod2.addDeletion(del3);
              mplugin.addSubmodel(submod2);

              Port port1 = mplugin.createPort();
              port1.setId("port1");
              port1.setMetaIdRef("_110013");
              Port port2 = new Port();
              port2.setId("port2");
              port2.setIdRef("x");
              mplugin.addPort(port2);
              port2.setId("port3");
              port2.setIdRef("submod2");
              port2.setSBaseRef(sbr2);
              mplugin.addPort(port2);

              libsbml.writeSBMLToFile(document, "comp_example1.xml");
              document = libsbml.readSBMLFromFile("comp_example1.xml");
              if (document == null)
              {
            Console.WriteLine("Error reading back in file.");
            retval = -1;
              }
              else
              {
            document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
            document.checkConsistency();
            if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
            document.getErrorLog().getNumFailsWithSeverity(3) > 0)
            {
              OStringStream stream = new OStringStream();
              document.printErrors(stream);
              Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                            stream.str());
              retval = -1;
            }
            libsbml.writeSBMLToFile(document, "comp_example1_rt.xml");
              }

              return retval;
        }
コード例 #18
0
        private static int Main(string[] args)
        {
            var retval = 0;
            var sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

            // create the document
            var document = new SBMLDocument(sbmlns);

            //Create our submodel
            var compdoc = (CompSBMLDocumentPlugin)(document.getPlugin("comp"));

            compdoc.setRequired(true);
            var mod1 = compdoc.createModelDefinition();

            mod1.setId("enzyme");
            mod1.setName("enzyme");
            var comp = mod1.createCompartment();

            comp.setSpatialDimensions(3);
            comp.setConstant(true);
            comp.setId("comp");
            comp.setSize(1L);
            var spec = new Species(3, 1);

            spec.setCompartment("comp");
            spec.setHasOnlySubstanceUnits(false);
            spec.setConstant(false);
            spec.setBoundaryCondition(false);
            spec.setId("S");
            mod1.addSpecies(spec);
            spec.setId("E");
            mod1.addSpecies(spec);
            spec.setId("D");
            mod1.addSpecies(spec);
            spec.setId("ES");
            mod1.addSpecies(spec);
            var rxn = new Reaction(3, 1);

            rxn.setReversible(true);
            rxn.setFast(false);
            var rxn2 = new Reaction(rxn);

            rxn.setId("J0");
            rxn2.setId("J1");
            var sr = new SpeciesReference(3, 1);

            sr.setConstant(true);
            sr.setStoichiometry(1);
            sr.setSpecies("S");
            rxn.addReactant(sr);
            sr.setSpecies("E");
            rxn.addReactant(sr);
            rxn2.addProduct(sr);
            sr.setSpecies("ES");
            rxn.addProduct(sr);
            rxn2.addReactant(sr);
            sr.setSpecies("D");
            rxn2.addProduct(sr);

            mod1.addReaction(rxn);
            mod1.addReaction(rxn2);

            // create the Model
            var model = document.createModel();

            model.setId("aggregate");

            // Create a submodel
            var mplugin = (CompModelPlugin)(model.getPlugin("comp"));
            var submod1 = mplugin.createSubmodel();

            submod1.setId("submod1");
            submod1.setModelRef("enzyme");

            var submod2 = new Submodel();

            submod2.setId("submod2");
            submod2.setModelRef("enzyme");
            mplugin.addSubmodel(submod2);

            libsbml.writeSBMLToFile(document, "enzyme_model.xml");
            document = libsbml.readSBMLFromFile("enzyme_model.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");
                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    var stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "enzyme_model_rt.xml");
            }
            return(retval);
        }
コード例 #19
0
        private static int Main(string[] args)
        {
            var retval = 0;
            var sbmlns = new SBMLNamespaces(3, 1, "comp", 1);

            // create the document
            var document = new SBMLDocument(sbmlns);

            //Create our submodel
            var compdoc = (CompSBMLDocumentPlugin) (document.getPlugin("comp"));
            compdoc.setRequired(true);
            var mod1 = compdoc.createModelDefinition();
            mod1.setId("enzyme");
            mod1.setName("enzyme");
            var comp = mod1.createCompartment();
            comp.setSpatialDimensions(3);
            comp.setConstant(true);
            comp.setId("comp");
            comp.setSize(1L);
            var spec = new Species(3, 1);
            spec.setCompartment("comp");
            spec.setHasOnlySubstanceUnits(false);
            spec.setConstant(false);
            spec.setBoundaryCondition(false);
            spec.setId("S");
            mod1.addSpecies(spec);
            spec.setId("E");
            mod1.addSpecies(spec);
            spec.setId("D");
            mod1.addSpecies(spec);
            spec.setId("ES");
            mod1.addSpecies(spec);
            var rxn = new Reaction(3, 1);
            rxn.setReversible(true);
            rxn.setFast(false);
            var rxn2 = new Reaction(rxn);
            rxn.setId("J0");
            rxn2.setId("J1");
            var sr = new SpeciesReference(3, 1);
            sr.setConstant(true);
            sr.setStoichiometry(1);
            sr.setSpecies("S");
            rxn.addReactant(sr);
            sr.setSpecies("E");
            rxn.addReactant(sr);
            rxn2.addProduct(sr);
            sr.setSpecies("ES");
            rxn.addProduct(sr);
            rxn2.addReactant(sr);
            sr.setSpecies("D");
            rxn2.addProduct(sr);

            mod1.addReaction(rxn);
            mod1.addReaction(rxn2);

            // create the Model
            var model = document.createModel();
            model.setId("aggregate");

            // Create a submodel
            var mplugin = (CompModelPlugin) (model.getPlugin("comp"));
            var submod1 = mplugin.createSubmodel();
            submod1.setId("submod1");
            submod1.setModelRef("enzyme");

            var submod2 = new Submodel();
            submod2.setId("submod2");
            submod2.setModelRef("enzyme");
            mplugin.addSubmodel(submod2);

            libsbml.writeSBMLToFile(document, "enzyme_model.xml");
            document = libsbml.readSBMLFromFile("enzyme_model.xml");
            if (document == null)
            {
                Console.WriteLine("Error reading back in file.");
                retval = -1;
            }
            else
            {
                document.setConsistencyChecks(libsbml.LIBSBML_CAT_UNITS_CONSISTENCY, false);
                document.checkConsistency();
                if (document.getErrorLog().getNumFailsWithSeverity(2) > 0 ||
                    document.getErrorLog().getNumFailsWithSeverity(3) > 0)
                {
                    var stream = new OStringStream();
                    document.printErrors(stream);
                    Console.WriteLine("Errors encoutered when round-tripping  SBML file: \n" +
                                      stream.str());
                    retval = -1;
                }
                libsbml.writeSBMLToFile(document, "enzyme_model_rt.xml");
            }
            return retval;
        }
コード例 #20
0
ファイル: GraphEditor.cs プロジェクト: j-prox/blueprint41
        protected virtual ContextMenuStrip BuildContextMenu(GeometryPoint point)
        {
            ContextMenuStrip cm = new ContextMenuStrip();

            ToolStripMenuItem mi;

            foreach (NodeTypeEntry nte in NodeTypes)
            {
                mi = new ToolStripMenuItem()
                {
                    Text = "Insert " + nte.Name
                };
                mi.Click  += InsertNode_Click;
                mi.Enabled = !this.Viewer.InsertingEdge;

                cm.Items.Add(mi);
            }

            BuildSelectionModeContextMenu(cm);

            mi        = new ToolStripMenuItem("Edit Submodel");
            mi.Click += EditSubmodel;
            cm.Items.Add(mi);

            ToolStripSeparator separator = new ToolStripSeparator();

            cm.Items.Add(separator);

            object obj = gViewer.GetObjectAt((int)point.X, (int)point.Y);

            if (obj is DNode && SelectedEntities.Count > 0)
            {
                Submodel displayedModel = null;

                if (this.Viewer.Tag != null && this.Viewer.Tag is Submodel)
                {
                    displayedModel = this.Viewer.Tag as Submodel;
                }

                if (displayedModel != null && displayedModel.Name != Constants.MainModel)
                {
                    mi        = new ToolStripMenuItem();
                    mi.Text   = "Exclude from Model";
                    mi.Click += ExcludeEntityClick;
                    cm.Items.Add(mi);
                }

                mi           = new ToolStripMenuItem();
                mi.Text      = $"Delete {EntityNodeName}";
                mi.ForeColor = Styles.FORMS_WARNING;
                mi.Click    += RemoveEntityClick;
                cm.Items.Add(mi);
            }

            mi        = new ToolStripMenuItem();
            mi.Text   = "Redo layout";
            mi.Click += RedoLayout_Click;
            cm.Items.Add(mi);

            return(cm);
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: i-Asset/basyx
        public static void LoadMultipleSubmodels()
        {
            ServerSettings submodelRepositorySettings = ServerSettings.CreateSettings();

            submodelRepositorySettings.ServerConfig.Hosting.ContentPath = "Content";
            submodelRepositorySettings.ServerConfig.Hosting.Urls.Add("http://+:6999");

            MultiSubmodelHttpServer           multiServer       = new MultiSubmodelHttpServer(submodelRepositorySettings);
            SubmodelRepositoryServiceProvider repositoryService = new SubmodelRepositoryServiceProvider();

            for (int i = 0; i < 3; i++)
            {
                Submodel submodel = new Submodel()
                {
                    IdShort        = "MultiSubmodel_" + i,
                    Identification = new Identifier("http://basys40.de/submodel/MultiSubmodel/" + Guid.NewGuid().ToString(), KeyType.IRI),
                    Description    = new LangStringSet()
                    {
                        new LangString("de-DE", i + ". Teilmodell"),
                        new LangString("en-US", i + ". Submodel")
                    },
                    Administration = new AdministrativeInformation()
                    {
                        Version  = "1.0",
                        Revision = "120"
                    },
                    SubmodelElements = new ElementContainer <ISubmodelElement>()
                    {
                        new Property <string>()
                        {
                            IdShort = "Property_" + i,
                            Value   = "TestValue_" + i
                        },
                        new SubmodelElementCollection()
                        {
                            IdShort = "Coll_" + i,
                            Value   = new ElementContainer <ISubmodelElement>()
                            {
                                new Property <string>()
                                {
                                    IdShort = "SubProperty_" + i,
                                    Value   = "TestSubValue_" + i
                                }
                            }
                        }
                    }
                };

                var submodelServiceProvider = submodel.CreateServiceProvider();
                repositoryService.RegisterSubmodelServiceProvider(submodel.IdShort, submodelServiceProvider);
            }

            List <HttpEndpoint> endpoints = multiServer.Settings.ServerConfig.Hosting.Urls.ConvertAll(c => new HttpEndpoint(c.Replace("+", "127.0.0.1")));

            repositoryService.UseDefaultEndpointRegistration(endpoints);

            multiServer.SetServiceProvider(repositoryService);
            multiServer.ApplicationStopping = () =>
            {
                for (int i = 0; i < repositoryService.ServiceDescriptor.SubmodelDescriptors.Count; i++)
                {
                    registryClient.DeleteSubmodel("http://basyx.de/shells/MultiAAS/" + i, repositoryService.ServiceDescriptor.SubmodelDescriptors[i].IdShort);
                }
            };

            multiServer.RunAsync();

            var shells = registryClient.RetrieveAssetAdministrationShells();
            var shell  = shells.Entity?.FirstOrDefault(f => f.Identification.Id.Contains("SimpleAAS"));

            for (int i = 0; i < repositoryService.ServiceDescriptor.SubmodelDescriptors.Count; i++)
            {
                registryClient.CreateSubmodel("http://basyx.de/shells/MultiAAS/" + i, repositoryService.ServiceDescriptor.SubmodelDescriptors[i]);

                if (shell != null)
                {
                    registryClient.CreateSubmodel(shell.Identification.Id, repositoryService.ServiceDescriptor.SubmodelDescriptors[i]);
                }
            }
        }
コード例 #22
0
        public static Submodel GetTestSubmodel()
        {
            string propertyValue = "TestFromInside";
            int    i             = 0;
            double y             = 2.0;

            Submodel testSubmodel = new Submodel()
            {
                IdShort          = "TestSubmodel",
                Identification   = new Identifier(Guid.NewGuid().ToString(), KeyType.Custom),
                SubmodelElements = new ElementContainer <ISubmodelElement>()
                {
                    new Property <string>()
                    {
                        IdShort = "TestProperty1",
                        Set     = (prop, val) => propertyValue = val,
                        Get     = prop => { return(propertyValue + "_" + i++); }
                    },
                    new Property <string>()
                    {
                        IdShort = "TestProperty2",
                        Set     = (prop, val) => propertyValue = val,
                        Get     = prop => { return(propertyValue + "_" + i++); }
                    },
                    new Property <int>()
                    {
                        IdShort = "TestProperty3",
                        Set     = (prop, val) => i = val,
                        Get     = prop => { return(i++); }
                    },
                    new Property <double>()
                    {
                        IdShort = "TestProperty4",
                        Set     = (prop, val) => y = val,
                        Get     = prop => { return(Math.Pow(y, i)); }
                    },
                    new Operation()
                    {
                        IdShort         = "GetTime",
                        OutputVariables = new OperationVariableSet()
                        {
                            new Property <string>()
                            {
                                IdShort = "Date"
                            },
                            new Property <string>()
                            {
                                IdShort = "Time"
                            },
                            new Property <string>()
                            {
                                IdShort = "Ticks"
                            },
                        },
                        OnMethodCalled = (op, inArgs, outArgs) =>
                        {
                            outArgs.Add(new Property <string>()
                            {
                                IdShort = "Date", Value = "Heute ist der " + DateTime.Now.Date.ToString()
                            });
                            outArgs.Add(new Property <string>()
                            {
                                IdShort = "Time", Value = "Es ist " + DateTime.Now.TimeOfDay.ToString() + " Uhr"
                            });
                            outArgs.Add(new Property <string>()
                            {
                                IdShort = "Ticks", Value = "Ticks: " + DateTime.Now.Ticks.ToString()
                            });
                            return(new OperationResult(true));
                        }
                    },
                    new Operation()
                    {
                        IdShort     = "Calculate",
                        Description = new LangStringSet()
                        {
                            new LangString("DE", "Taschenrechner mit simulierter langer Rechenzeit zum Testen von asynchronen Aufrufen"),
                            new LangString("EN", "Calculator with simulated long-running computing time for testing asynchronous calls")
                        },
                        InputVariables = new OperationVariableSet()
                        {
                            new Property <string>()
                            {
                                IdShort     = "Expression",
                                Description = new LangStringSet()
                                {
                                    new LangString("DE", "Ein mathematischer Ausdruck (z.B. 5*9)"),
                                    new LangString("EN", "A mathematical expression (e.g. 5*9)")
                                }
                            },
                            new Property <int>()
                            {
                                IdShort     = "ComputingTime",
                                Description = new LangStringSet()
                                {
                                    new LangString("DE", "Die Bearbeitungszeit in Millisekunden"),
                                    new LangString("EN", "The computation time in milliseconds")
                                }
                            }
                        },
                        OutputVariables = new OperationVariableSet()
                        {
                            new Property <double>()
                            {
                                IdShort = "Result"
                            }
                        },
                        OnMethodCalled = async(op, inArgs, outArgs) =>
                        {
                            string expression    = inArgs.Get("Expression")?.Cast <IProperty>()?.ToObject <string>();
                            int?   computingTime = inArgs.Get("ComputingTime")?.Cast <IProperty>()?.ToObject <int>();

                            if (computingTime.HasValue)
                            {
                                await Task.Delay(computingTime.Value);
                            }

                            double value = CalulcateExpression(expression);

                            outArgs.Add(new Property <double>()
                            {
                                IdShort = "Result", Value = value
                            });

                            return(new OperationResult(true));
                        }
                    }
                }
            };

            return(testSubmodel);
        }
コード例 #23
0
        public override IAssetAdministrationShell GenerateAssetAdministrationShell()
        {
            AssetAdministrationShell aas = new AssetAdministrationShell();

            aas.IdShort        = "HelloAAS";
            aas.Identification = new Identifier("http://basys40.de/shells/HelloAAS/" + Guid.NewGuid().ToString(), KeyType.IRI);
            aas.Description    = new LangStringSet()
            {
                new LangString("en-US", "This is an exemplary Asset Administration Shell for starters")
            };

            aas.Asset = new Asset()
            {
                Description = new LangStringSet()
                {
                    new LangString("en-US", "This is an exemplary Asset reference from the Asset Administration Shell")
                },
                IdShort        = "HelloAsset",
                Identification = new Identifier("http://basys40.de/assets/HelloAsset/" + Guid.NewGuid().ToString(), KeyType.IRI),
                Kind           = AssetKind.Instance,
                SemanticId     = new Reference(new GlobalKey(KeyElements.Asset, KeyType.IRI, "urn:basys:org.eclipse.basyx:assets:HelloAsset:1.0.0"))
            };

            Submodel helloSubmodel = new Submodel
            {
                Description = new LangStringSet()
                {
                    new LangString("en-US", "This is an exemplary Submodel")
                },
                IdShort        = "HelloSubmodel",
                Identification = new Identifier("http://basys40.de/submodels/HelloSubmodel/" + Guid.NewGuid().ToString(), KeyType.IRI),
                Kind           = ModelingKind.Instance,
                SemanticId     = new Reference(new GlobalKey(KeyElements.Submodel, KeyType.IRI, "urn:basys:org.eclipse.basyx:submodels:HelloSubmodel:1.0.0"))
            };

            helloSubmodel.SubmodelElements = new ElementContainer <ISubmodelElement>();
            helloSubmodel.SubmodelElements.Add(new Property <string>()
            {
                Description = new LangStringSet()
                {
                    new LangString("en-US", "This is an exemplary property")
                },
                IdShort    = "HelloProperty",
                Kind       = ModelingKind.Instance,
                Value      = "TestValue",
                SemanticId = new Reference(new GlobalKey(KeyElements.Property, KeyType.IRI, "urn:basys:org.eclipse.basyx:dataElements:HelloProperty:1.0.0"))
            });

            helloSubmodel.SubmodelElements.Add(new File()
            {
                Description = new LangStringSet()
                {
                    new LangString("en-US", "This is an exemplary file attached to the Asset Administration Shell")
                },
                IdShort  = "HelloFile",
                Kind     = ModelingKind.Instance,
                MimeType = "application/pdf",
                Value    = "/HelloAssetAdministrationShell.pdf"
            });


            var helloOperation_ConceptDescription = new ConceptDescription()
            {
                Identification             = new Identifier("urn:basys:org.eclipse.basyx:dataSpecifications:EndpointSpecification:1.0.0", KeyType.IRI),
                EmbeddedDataSpecifications = new List <IEmbeddedDataSpecification>()
                {
                    new EndpointSpecification(
                        new EndpointSpecificationContent()
                    {
                        Endpoints = new List <IEndpoint>()
                        {
                            new OpcUaEndpoint("opc.tcp://127.0.0.1:4840/Objects/1:HelloAAS/1:SERVICE/1:TestOperation")
                        }
                    })
                }
            };

            helloSubmodel.SubmodelElements.Add(new Operation()
            {
                Description = new LangStringSet()
                {
                    new LangString("en-US", "This is an exemplary operation returning the input argument with 'Hello' as prefix")
                },
                IdShort        = "HelloOperation",
                InputVariables = new OperationVariableSet()
                {
                    new Property <string>()
                    {
                        IdShort = "Text"
                    }
                },
                OutputVariables = new OperationVariableSet()
                {
                    new Property <string>()
                    {
                        IdShort = "ReturnValue"
                    }
                },
                ConceptDescription = helloOperation_ConceptDescription
            });

            helloSubmodel.SubmodelElements.Add(new Event()
            {
                Description = new LangStringSet()
                {
                    new LangString("en-US", "This is an exemplary event with only one property as event payload")
                },
                IdShort      = "HelloEvent",
                Kind         = ModelingKind.Template,
                DataElements = new ElementContainer <ISubmodelElement>()
                {
                    new Property <string>()
                    {
                        IdShort = "HelloEvent_Property",
                        Kind    = ModelingKind.Template
                    }
                }
            });

            aas.Submodels = new ElementContainer <ISubmodel>();
            aas.Submodels.Add(helloSubmodel);

            var assetIdentificationSubmodel = new Submodel();

            assetIdentificationSubmodel.IdShort        = "AssetIdentification";
            assetIdentificationSubmodel.Identification = new Identifier(Guid.NewGuid().ToString(), KeyType.Custom);
            assetIdentificationSubmodel.Kind           = ModelingKind.Instance;
            assetIdentificationSubmodel.Parent         = new Reference <IAssetAdministrationShell>(aas);

            var productTypeProp = new Property <string>()
            {
                IdShort    = "ProductType",
                Kind       = ModelingKind.Instance,
                SemanticId = new Reference(
                    new GlobalKey(
                        KeyElements.Property,
                        KeyType.IRDI,
                        "0173-1#02-AAO057#002")),
                Value = "HelloAsset_ProductType"
            };

            ConceptDescription orderNumberCD = new ConceptDescription()
            {
                Identification             = new Identifier("0173-1#02-AAO689#001", KeyType.IRDI),
                EmbeddedDataSpecifications = new List <IEmbeddedDataSpecification>()
                {
                    new DataSpecificationIEC61360(new DataSpecificationIEC61360Content()
                    {
                        PreferredName = new LangStringSet {
                            new LangString("EN", "identifying order number")
                        },
                        Definition = new LangStringSet {
                            new LangString("EN", "unique classifying number that enables to name an object and to order it from a supplier or manufacturer")
                        },
                        DataType = DataTypeIEC61360.STRING
                    })
                }
            };

            var orderNumber = new Property <string>()
            {
                IdShort    = "OrderNumber",
                Kind       = ModelingKind.Instance,
                SemanticId = new Reference(
                    new GlobalKey(
                        KeyElements.Property,
                        KeyType.IRDI,
                        "0173-1#02-AAO689#001")),
                Value = "HelloAsset_OrderNumber",
                ConceptDescription = orderNumberCD
            };

            var serialNumber = new Property <string>()
            {
                IdShort = "SerialNumber",
                Kind    = ModelingKind.Instance,
                Value   = "HelloAsset_SerialNumber"
            };

            assetIdentificationSubmodel.SubmodelElements.Add(productTypeProp);
            assetIdentificationSubmodel.SubmodelElements.Add(orderNumber);
            assetIdentificationSubmodel.SubmodelElements.Add(serialNumber);

            (aas.Asset as Asset).AssetIdentificationModel = new Reference <ISubmodel>(assetIdentificationSubmodel);

            aas.Submodels.Add(assetIdentificationSubmodel);

            return(aas);
        }
コード例 #24
0
ファイル: Extensions.cs プロジェクト: j-prox/blueprint41
        public static List <Relationship> GetCurrentRelationshipsInGraph(this Entity entity, Submodel model)
        {
            List <Relationship> relationships = model.Relationships.Where(item => item.Source?.Label == entity.Label || item.Target?.Label == entity.Label).ToList();

            foreach (Relationship relationship in model.CreatedInheritedRelationships.Where(rel => rel.InEntity == entity.Label || rel.OutEntity == entity.Label))
            {
                relationships.Add(relationship);
            }

            return(relationships);
        }