コード例 #1
0
        //
        // Functions required by the connector
        //

        public async Task <Tuple <AdminShell.AdministrationShell, AdminShell.Asset> > GetAasAssetCore(string index)
        {
            // access
            if (!IsValid())
            {
                throw new PackageConnectorException("PackageConnector connection not valid!");
            }
            if (!index.HasContent())
            {
                throw new PackageConnectorException("PackageConnector::GetAasAssetCore() requires to have " +
                                                    "valid index data!");
            }

            // do the actual query
            var response = await _client.GetAsync(StartQuery("aas", index, "core"));

            response.EnsureSuccessStatusCode();
            var frame = Newtonsoft.Json.Linq.JObject.Parse(await response.Content.ReadAsStringAsync());

            // proudly to the parsing
            AdminShell.AdministrationShell aas = null;
            AdminShell.Asset asset             = null;

            if (frame.ContainsKey("AAS"))
            {
                aas = AdminShellSerializationHelper.DeserializeFromJSON <AdminShell.AdministrationShell>(frame["AAS"]);
            }
            if (frame.ContainsKey("Asset"))
            {
                asset = AdminShellSerializationHelper.DeserializeFromJSON <AdminShell.Asset>(frame["Asset"]);
            }

            // result
            return(new Tuple <AdminShell.AdministrationShell, AdminShell.Asset>(aas, asset));
        }
コード例 #2
0
        private void PublishSingleValues_FirstTimeSubmodel(
            AdminShell.AdministrationShell aas,
            AdminShell.Submodel sm,
            AdminShell.KeyList startPath)
        {
            // trivial
            if (aas == null || sm == null)
            {
                return;
            }

            // give this to (recursive) function
            sm.RecurseOnSubmodelElements(null, (o, parents, sme) =>
            {
                // assumption is, the sme is now "leaf" of a SME-hierarchy
                if (sme is AdminShell.IEnumerateChildren)
                {
                    return(true);
                }

                // value of the leaf
                var valStr = sme.ValueAsText();

                // build a complete path of keys
                var path    = startPath + parents.ToKeyList() + sme?.ToKey();
                var pathStr = path.BuildIdShortPath();

                // publish
                if (_diaData.LogDebug)
                {
                    _logger?.Info("Publish single value (first time)");
                }

                var msg = new MqttApplicationMessageBuilder()
                          .WithTopic(GenerateTopic(
                                         _diaData.SingleValueTopic, defaultIfNull: "SingleValue",
                                         aasIdShort: aas.idShort, aasId: aas.identification,
                                         smIdShort: sm.idShort, smId: sm.identification,
                                         path: pathStr))
                          .WithPayload(valStr)
                          .WithExactlyOnceQoS()
                          .WithRetainFlag(_diaData.MqttRetain)
                          .Build();
                _mqttClient.PublishAsync(msg).GetAwaiter().GetResult();
                LogStatus(incSingleValue: 1);

                // recurse
                return(true);
            });
        }
コード例 #3
0
ファイル: VisualAasxElements.cs プロジェクト: i-Asset/basyx
 public VisualElementAdminShell(VisualElementGeneric parent, TreeViewLineCache cache, AdminShell.AdministrationShellEnv env, AdminShell.AdministrationShell aas)
     : base()
 {
     this.Parent     = parent;
     this.Cache      = cache;
     this.theEnv     = env;
     this.theAas     = aas;
     this.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#88A6D2"));
     this.Border     = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4370B3"));
     this.TagString  = "AAS";
     this.TagBg      = this.Border;
     this.TagFg      = Brushes.White;
     RefreshFromMainData();
     RestoreFromCache();
 }
コード例 #4
0
        //
        // Converters & generators
        //

        public void PopulateFakePackage(AdminShellPackageEnv pkg)
        {
            // access
            if (pkg == null)
            {
                return;
            }

            // all files
            int i = 0;

            foreach (var fi in this.FileMap)
            {
                // sure?
                if (fi == null)
                {
                    continue;
                }
                i++;

                // aas
                if (fi.AasIds != null)
                {
                    foreach (var id in fi.AasIds)
                    {
                        var aas = new AdminShell.AdministrationShell(String.Format("AAS{0:00}_{1}", i, fi.Tag));
                        aas.AddDescription("en?", "" + fi.Description);
                        aas.identification = new AdminShell.Identification(
                            AdminShell.Identification.IRI, "" + id);
                        pkg.AasEnv?.AdministrationShells.Add(aas);
                    }
                }

                // asset
                if (fi.AssetIds != null)
                {
                    foreach (var id in fi.AssetIds)
                    {
                        var asset = new AdminShell.Asset(String.Format("Asset{0:00}_{1}", i, fi.Tag));
                        asset.AddDescription("en?", "" + fi.Description);
                        asset.identification = new AdminShell.Identification(
                            AdminShell.Identification.IRI, "" + id);
                        pkg.AasEnv?.Assets.Add(asset);
                    }
                }
            }
        }
コード例 #5
0
        public VisualElementAdminShell(
            VisualElementGeneric parent, TreeViewLineCache cache, AdminShellPackageEnv package,
            AdminShell.AdministrationShellEnv env, AdminShell.AdministrationShell aas)
            : base()
        {
            this.Parent     = parent;
            this.Cache      = cache;
            this.thePackage = package;
            this.theEnv     = env;
            this.theAas     = aas;

            this.Background = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkAccentColor"];
            this.Border     = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagBg      = (SolidColorBrush)System.Windows.Application.Current.Resources["DarkestAccentColor"];
            this.TagFg      = Brushes.White;

            this.TagString = "AAS";
            RefreshFromMainData();
            RestoreFromCache();
        }
コード例 #6
0
        // Converter

        public AdminShellPackageEnv MakeUpFakePackage()
        {
            // create fake
            var pkg = new AdminShellPackageEnv();

            // all files
            int i = 0;

            foreach (var fi in this.FileMap)
            {
                // sure?
                if (fi == null)
                {
                    continue;
                }
                i++;

                // aas
                var aas = new AdminShell.AdministrationShell(String.Format("AAS{0:00}_{1}", i, fi.Tag));
                aas.AddDescription("en?", "" + fi.Description);
                aas.identification = new AdminShell.Identification(
                    AdminShell.Identification.IRI, "" + fi.AasId);

                // asset
                var asset = new AdminShell.Asset(String.Format("Asset{0:00}_{1}", i, fi.Tag));
                asset.AddDescription("en?", "" + fi.Description);
                asset.identification = new AdminShell.Identification(
                    AdminShell.Identification.IRI, "" + fi.AssetId);
                aas.assetRef = asset.GetAssetReference();

                // add
                pkg.AasEnv?.AdministrationShells.Add(aas);
                pkg.AasEnv?.Assets.Add(asset);
            }

            //ok
            return(pkg);
        }
コード例 #7
0
        public void AddByAas(AdminShell.AdministrationShellEnv env, AdminShell.AdministrationShell aas, string fn)
        {
            // access
            if (env == null || aas?.identification == null)
            {
                return;
            }
            var aasId = "" + aas.identification.id;

            // demand also asset
            var asset = env.FindAsset(aas.assetRef);

            if (asset?.identification == null)
            {
                return;
            }
            var assetId = "" + asset.identification.id;

            // try determine tag
            // ReSharper disable ConditionIsAlwaysTrueOrFalse
            var tag = "";

            try
            {
                var threeFn = Path.GetFileNameWithoutExtension(fn);
                tag = AdminShellUtil.ExtractPascalCasingLetters(asset.idShort);
                if (tag == null || tag.Length < 2)
                {
                    tag = AdminShellUtil.ExtractPascalCasingLetters(threeFn).SubstringMax(0, 3);
                }
                if (tag == null || tag.Length < 2)
                {
                    tag = ("" + asset.idShort).SubstringMax(0, 3).ToUpper();
                }
                if (tag == null || tag.Length < 3)
                {
                    tag = ("" + threeFn).SubstringMax(0, 3).ToUpper();
                }
            }
            catch (Exception ex)
            {
                AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
            }
            // ReSharper enable ConditionIsAlwaysTrueOrFalse

            // build description
            var desc = "";

            if (aas.idShort.HasContent())
            {
                desc += $"\"{aas.idShort}\"";
            }
            if (asset.idShort.HasContent())
            {
                if (desc.HasContent())
                {
                    desc += ",";
                }
                desc += $"\"{asset.idShort}\"";
            }

            // ok, add
            var fi = new FileItem(
                assetId: assetId, aasId: aasId, fn: fn, tag: "" + tag, description: desc);

            fi.VisualState = FileItem.VisualStateEnum.ReadFrom;
            fi.VisualTime  = 2.0;
            this.Add(fi);
        }
コード例 #8
0
        public DisplayRenderHints DisplayOrEditVisualAasxElement(
            PackageCentral packages,
            ListOfVisualElementBasic entities,
            bool editMode, bool hintMode = false, bool showIriMode = false,
            VisualElementEnvironmentItem.ConceptDescSortOrder?cdSortOrder = null,
            IFlyoutProvider flyoutProvider         = null,
            IPushApplicationEvent appEventProvider = null,
            DispEditHighlight.HighlightFieldInfo hightlightField = null)
        {
            //
            // Start
            //

            // hint mode disable, when not edit
            hintMode = hintMode && editMode;

            // remember objects for UI thread / redrawing
            this._packages            = packages;
            this._theEntities         = entities;
            _helper.packages          = packages;
            _helper.highlightField    = hightlightField;
            _helper.appEventsProvider = appEventProvider;

            // primary access
            var renderHints = new DisplayRenderHints();

            if (theMasterPanel == null || entities == null || entities.Count < 1)
            {
                renderHints.showDataPanel = false;
                return(renderHints);
            }

#if MONOUI
            var stack = ClearDisplayDefautlStack();
#else
            var stack = new AnyUiStackPanel();
#endif

            // create display context for WPF
            _displayContext     = new AnyUiDisplayContextWpf(flyoutProvider, packages);
            _helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);

            // modify repository
            ModifyRepo repo = null;
            if (editMode)
            {
                // some functionality still uses repo != null to detect editMode!!
                repo = new ModifyRepo();
            }
            _helper.editMode    = editMode;
            _helper.hintMode    = hintMode;
            _helper.repo        = repo;
            _helper.showIriMode = showIriMode;
            _helper.context     = _displayContext;

            // inform plug that their potential panel might not shown anymore
            Plugins.AllPluginsInvoke("clear-panel-visual-extension");

            //
            // Test for Blazor
            //
#if __test_blazor
            if (false)
            {
                var lab = new AnyUiLabel();
                lab.Content    = "Hallo";
                lab.Foreground = AnyUiBrushes.DarkBlue;
                stack.Children.Add(lab);

                if (editMode)
                {
                    var tb = new AnyUiTextBox();
                    tb.Foreground = AnyUiBrushes.Black;
                    tb.Text       = "Initial";
                    stack.Children.Add(tb);
                    repo.RegisterControl(tb, (o) =>
                    {
                        Log.Singleton.Info($"Text changed to .. {""+o}");
                        return(new AnyUiLambdaActionNone());
                    });

                    var btn = new AnyUiButton();
                    btn.Content = "Click me!";
                    stack.Children.Add(btn);
                    repo.RegisterControl(btn, (o) =>
                    {
                        Log.Singleton.Error("Button clicked!");
                        return(new AnyUiLambdaActionRedrawAllElements(null));
                    });
                }
            }
#endif

            var inhibitRenderStackToPanel = false;

            if (entities.ExactlyOne)
            {
                //
                // Dispatch: ONE item
                //
                var entity = entities.First();

                // maintain parent. If in doubt, set null
                ListOfVisualElement.SetParentsBasedOnChildHierarchy(entity);

                //
                // Dispatch
                //

                if (entity is VisualElementEnvironmentItem veei)
                {
                    _helper.DisplayOrEditAasEntityAasEnv(
                        packages, veei.theEnv, veei, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAdminShell veaas)
                {
                    _helper.DisplayOrEditAasEntityAas(
                        packages, veaas.theEnv, veaas.theAas, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAsset veas)
                {
                    _helper.DisplayOrEditAasEntityAsset(
                        packages, veas.theEnv, veas.theAsset, editMode, repo, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelRef vesmref)
                {
                    // data
                    AdminShell.AdministrationShell aas = null;
                    if (vesmref.Parent is VisualElementAdminShell xpaas)
                    {
                        aas = xpaas.theAas;
                    }

                    // edit
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesmref.theEnv, aas, vesmref.theSubmodelRef, vesmref.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodel vesm && vesm.theSubmodel != null)
                {
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesm.theEnv, null, null, vesm.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelElement vesme)
                {
                    _helper.DisplayOrEditAasEntitySubmodelElement(
                        packages, vesme.theEnv, vesme.theContainer, vesme.theWrapper, vesme.theWrapper.submodelElement,
                        editMode,
                        repo, stack, hintMode: hintMode,
                        nestedCds: cdSortOrder.HasValue &&
                        cdSortOrder.Value == VisualElementEnvironmentItem.ConceptDescSortOrder.BySme);
                }
                else if (entity is VisualElementOperationVariable vepv)
                {
                    _helper.DisplayOrEditAasEntityOperationVariable(
                        packages, vepv.theEnv, vepv.theContainer, vepv.theOpVar, editMode,
                        stack, hintMode: hintMode);
                }
                else if (entity is VisualElementConceptDescription vecd)
                {
                    _helper.DisplayOrEditAasEntityConceptDescription(
                        packages, vecd.theEnv, null, vecd.theCD, editMode, repo, stack, hintMode: hintMode,
                        preventMove: cdSortOrder.HasValue &&
                        cdSortOrder.Value != VisualElementEnvironmentItem.ConceptDescSortOrder.None);
                }
                else if (entity is VisualElementView vevw)
                {
                    if (vevw.Parent != null && vevw.Parent is VisualElementAdminShell xpaas)
                    {
                        _helper.DisplayOrEditAasEntityView(
                            packages, vevw.theEnv, xpaas.theAas, vevw.theView, editMode, stack,
                            hintMode: hintMode);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "View is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else if (entity is VisualElementReference verf)
                {
                    if (verf.Parent != null && verf.Parent is VisualElementView xpev)
                    {
                        _helper.DisplayOrEditAasEntityViewReference(
                            packages, verf.theEnv, xpev.theView, (AdminShell.ContainedElementRef)verf.theReference,
                            editMode, stack);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "Reference is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else
                if (entity is VisualElementSupplementalFile vesf)
                {
                    _helper.DisplayOrEditAasEntitySupplementaryFile(packages, vesf.theFile, editMode, stack);
                }
                else if (entity is VisualElementPluginExtension vepe)
                {
                    // create controls
                    object result = null;

                    try
                    {
                        // replace at top level
                        theMasterPanel.Children.Clear();
                        if (vepe.thePlugin != null)
                        {
                            result = vepe.thePlugin.InvokeAction(
                                "fill-panel-visual-extension", vepe.thePackage, vepe.theReferable, theMasterPanel);
                        }
                    }
                    catch (Exception ex)
                    {
                        AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                    }

                    // add?
                    if (result == null)
                    {
                        // re-init display!
#if MONOUI
                        stack = ClearDisplayDefautlStack();
#else
                        stack = new AnyUiStackPanel();
#endif

                        // helping message
                        _helper.AddGroup(
                            stack, "Entity from Plugin cannot be rendered!", _helper.levelColors.MainSection);
                    }
                    else
                    {
                        // this is natively done; do NOT render Any UI to WPF
                        inhibitRenderStackToPanel = true;
                    }

                    // show no panel nor scroll
                    renderHints.scrollingPanel = false;
                    renderHints.showDataPanel  = false;
                }
                else
                {
                    _helper.AddGroup(stack, "Entity is unknown!", _helper.levelColors.MainSection);
                }
            }
コード例 #9
0
        //Annotations
        //  Procedure:
        //  1. find submodel node
        //  2. create submodel node as submodel
        //  3. find children of submodel node
        //  4. create children of submodel node -> a (SubmodelElement)
        //      4.1. find children of a
        //      4.2. create children of a -> b (SubmodelElement)
        //          4.2.1. find children of b
        //          ...
        //      4.3. set a as SubmodelElement of submodel
        //  5. add Submodel
        //
        //
        //  most Methods are built the same way:
        //  1. iterate through all References of the node
        //  2. check that the ReferenceType is not HasTypeDefinition
        //  3. check for the Type or BrowseName

        public static AdminShellNS.AdminShellPackageEnv Import(UANodeSet model)
        {
            thePackageEnv    = new AdminShellNS.AdminShellPackageEnv();
            InformationModel = model;

            //Initialize everything needed
            AdminShell.AdministrationShellEnv env = thePackageEnv.AasEnv;
            var aas = new AdminShell.AdministrationShell();

            aas.views       = new Views();
            aas.views.views = new List <View>();
            env.AdministrationShells.Add(aas);

            //search for the root Node
            var root = getRoot();

            //see Annotations
            if (root != null)
            {
                foreach (Reference _ref in root.References)
                {
                    if (_ref.ReferenceType == "HasComponent")
                    {
                        var node = findNode(_ref.Value);
                        //create Submodel
                        if (getTypeDefinition(node) == "1:AASSubmodelType")
                        {
                            var submodel = createSubmodel((UAObject)node);

                            if (submodel != null)
                            {
                                //add Submodel and its SubmodelRef
                                env.Submodels.Add(submodel);
                                var smr = new AdminShell.SubmodelRef();
                                smr.Keys.Add(
                                    new AdminShell.Key(
                                        "Submodel", true, submodel.identification.idType, submodel.identification.id));
                                aas.submodelRefs.Add(smr);
                            }
                        }
                        //create ConceptDictionary
                        else if (getTypeDefinition(node) == "1:AASConceptDictionaryType")
                        {
                            createConceptDictionary((UAObject)node);
                        }
                        //create Asset
                        else if (getTypeDefinition(node) == "1:AASAssetType")
                        {
                            Asset ass = createAsset(node);
                            thePackageEnv.AasEnv.Assets.Add(ass);
                        }
                        //create Views
                        else if (getTypeDefinition(node) == "1:AASViewType")
                        {
                            aas.views.views.Add(createView(node));
                        }
                        //set DerivedFrom
                        else if (node.BrowseName == "1:DerivedFrom")
                        {
                            List <Key> keys = addSemanticID(node);
                            if (keys.Count > 0)
                            {
                                aas.derivedFrom = new AssetAdministrationShellRef(keys[0]);
                            }
                        }
                        //create HasDataSpecification
                        else if (node.BrowseName == "1:DataSpecification")
                        {
                            aas.hasDataSpecification = CreateHasDataSpecification(node);
                        }
                        //create AssetRef
                        else if (node.BrowseName == "1:AssetRef")
                        {
                            aas.assetRef = createAssetRef(node);
                        }
                        else if (node.BrowseName == "1:Identification" &&
                                 getTypeDefinition(node) == "1:AASIdentifierType")
                        {
                            aas.identification = createIdentification(node);
                        }
                    }
                    else if (_ref.ReferenceType == "HasProperty")
                    {
                        var node = findNode(_ref.Value);
                        if (node.BrowseName == "1:idShort")
                        {
                            var vari = (UAVariable)node;
                            aas.idShort = vari.Value.InnerText;
                        }
                    }
                }
            }

            return(thePackageEnv);
        }
コード例 #10
0
        public DisplayRenderHints DisplayOrEditVisualAasxElement(
            PackageCentral packages,
            ListOfVisualElementBasic entities,
            bool editMode, bool hintMode = false, bool showIriMode = false,
            VisualElementEnvironmentItem.ConceptDescSortOrder?cdSortOrder = null,
            IFlyoutProvider flyoutProvider         = null,
            IPushApplicationEvent appEventProvider = null,
            DispEditHighlight.HighlightFieldInfo hightlightField = null)
        {
            //
            // Start
            //

            // hint mode disable, when not edit
            hintMode = hintMode && editMode;

            // remember objects for UI thread / redrawing
            this._packages            = packages;
            this._theEntities         = entities;
            _helper.packages          = packages;
            _helper.highlightField    = hightlightField;
            _helper.appEventsProvider = appEventProvider;

            // primary access
            var renderHints = new DisplayRenderHints();

            if (theMasterPanel == null || entities == null || entities.Count < 1)
            {
                renderHints.showDataPanel = false;
                return(renderHints);
            }

#if MONOUI
            var stack = ClearDisplayDefautlStack();
#else
            var stack = new AnyUiStackPanel();
#endif

            // create display context for WPF
            _displayContext     = new AnyUiDisplayContextWpf(flyoutProvider, packages);
            _helper.levelColors = DispLevelColors.GetLevelColorsFromOptions(Options.Curr);

            // modify repository
            ModifyRepo repo = null;
            if (editMode)
            {
                // some functionality still uses repo != null to detect editMode!!
                repo = new ModifyRepo();
            }
            _helper.editMode    = editMode;
            _helper.hintMode    = hintMode;
            _helper.repo        = repo;
            _helper.showIriMode = showIriMode;
            _helper.context     = _displayContext;

            //
            // Test for Blazor
            //
#if __test_blazor
            if (false)
            {
                var lab = new AnyUiLabel();
                lab.Content    = "Hallo";
                lab.Foreground = AnyUiBrushes.DarkBlue;
                stack.Children.Add(lab);

                if (editMode)
                {
                    var tb = new AnyUiTextBox();
                    tb.Foreground = AnyUiBrushes.Black;
                    tb.Text       = "Initial";
                    stack.Children.Add(tb);
                    repo.RegisterControl(tb, (o) =>
                    {
                        Log.Singleton.Info($"Text changed to .. {""+o}");
                        return(new AnyUiLambdaActionNone());
                    });

                    var btn = new AnyUiButton();
                    btn.Content = "Click me!";
                    stack.Children.Add(btn);
                    repo.RegisterControl(btn, (o) =>
                    {
                        Log.Singleton.Error("Button clicked!");
                        return(new AnyUiLambdaActionRedrawAllElements(null));
                    });
                }
            }
#endif

            var inhibitRenderStackToPanel = false;

            if (entities.ExactlyOne)
            {
                //
                // Dispatch: ONE item
                //
                var entity = entities.First();

                if (entity is VisualElementEnvironmentItem veei)
                {
                    _helper.DisplayOrEditAasEntityAasEnv(
                        packages, veei.theEnv, veei, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAdminShell veaas)
                {
                    _helper.DisplayOrEditAasEntityAas(
                        packages, veaas.theEnv, veaas.theAas, editMode, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementAsset veas)
                {
                    _helper.DisplayOrEditAasEntityAsset(
                        packages, veas.theEnv, veas.theAsset, editMode, repo, stack, hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelRef vesmref)
                {
                    AdminShell.AdministrationShell aas = null;
                    if (vesmref.Parent is VisualElementAdminShell xpaas)
                    {
                        aas = xpaas.theAas;
                    }
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesmref.theEnv, aas, vesmref.theSubmodelRef, vesmref.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodel vesm)
                {
                    _helper.DisplayOrEditAasEntitySubmodelOrRef(
                        packages, vesm.theEnv, null, null, vesm.theSubmodel, editMode, stack,
                        hintMode: hintMode);
                }
                else if (entity is VisualElementSubmodelElement vesme)
                {
                    _helper.DisplayOrEditAasEntitySubmodelElement(
                        packages, vesme.theEnv, vesme.theContainer, vesme.theWrapper, vesme.theWrapper.submodelElement,
                        editMode,
                        repo, stack, hintMode: hintMode,
                        nestedCds: cdSortOrder.HasValue &&
                        cdSortOrder.Value == VisualElementEnvironmentItem.ConceptDescSortOrder.BySme);
                }
                else if (entity is VisualElementOperationVariable vepv)
                {
                    _helper.DisplayOrEditAasEntityOperationVariable(
                        packages, vepv.theEnv, vepv.theContainer, vepv.theOpVar, editMode,
                        stack, hintMode: hintMode);
                }
                else if (entity is VisualElementConceptDescription vecd)
                {
                    _helper.DisplayOrEditAasEntityConceptDescription(
                        packages, vecd.theEnv, null, vecd.theCD, editMode, repo, stack, hintMode: hintMode,
                        preventMove: cdSortOrder.HasValue &&
                        cdSortOrder.Value != VisualElementEnvironmentItem.ConceptDescSortOrder.None);
                }
                else if (entity is VisualElementView vevw)
                {
                    if (vevw.Parent != null && vevw.Parent is VisualElementAdminShell xpaas)
                    {
                        _helper.DisplayOrEditAasEntityView(
                            packages, vevw.theEnv, xpaas.theAas, vevw.theView, editMode, stack,
                            hintMode: hintMode);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "View is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else if (entity is VisualElementReference verf)
                {
                    if (verf.Parent != null && verf.Parent is VisualElementView xpev)
                    {
                        _helper.DisplayOrEditAasEntityViewReference(
                            packages, verf.theEnv, xpev.theView, (AdminShell.ContainedElementRef)verf.theReference,
                            editMode, stack);
                    }
                    else
                    {
                        _helper.AddGroup(stack, "Reference is corrupted!", _helper.levelColors.MainSection);
                    }
                }
                else
                if (entity is VisualElementSupplementalFile vesf)
                {
                    _helper.DisplayOrEditAasEntitySupplementaryFile(packages, vesf.theFile, editMode, stack);
                }
                else if (entity is VisualElementPluginExtension vepe)
                {
                    // create controls
                    object result = null;

                    try
                    {
                        // replace at top level
                        theMasterPanel.Children.Clear();
                        if (vepe.thePlugin != null)
                        {
                            result = vepe.thePlugin.InvokeAction(
                                "fill-panel-visual-extension", vepe.thePackage, vepe.theReferable, theMasterPanel);
                        }
                    }
                    catch (Exception ex)
                    {
                        AdminShellNS.LogInternally.That.SilentlyIgnoredError(ex);
                    }

                    // add?
                    if (result == null)
                    {
                        // re-init display!
#if MONOUI
                        stack = ClearDisplayDefautlStack();
#else
                        stack = new AnyUiStackPanel();
#endif

                        // helping message
                        _helper.AddGroup(
                            stack, "Entity from Plugin cannot be rendered!", _helper.levelColors.MainSection);
                    }
                    else
                    {
                        // this is natively done; do NOT render Any UI to WPF
                        inhibitRenderStackToPanel = true;
                    }

                    // show no panel nor scroll
                    renderHints.scrollingPanel = false;
                    renderHints.showDataPanel  = false;
                }
                else
                {
                    _helper.AddGroup(stack, "Entity is unknown!", _helper.levelColors.MainSection);
                }
            }
            else
            {
                //
                // Dispatch: MULTIPLE items
                //
                _helper.DisplayOrEditAasEntityMultipleElements(packages, entities, editMode, stack, cdSortOrder);
            }

            // now render master stack
#if __export_BLAZOR
            var fn = @"fileEdit.json";
            if (!editMode)
            {
                count = 0;
                var jsonSerializerSettings = new JsonSerializerSettings()
                {
                    TypeNameHandling = TypeNameHandling.All,
                    Formatting       = Formatting.Indented
                };
                var json = JsonConvert.SerializeObject(stack, jsonSerializerSettings);
                System.IO.File.WriteAllText(fn, json);
            }
            if (editMode)
            {
                if (true && count == 2)
                {
                    count = 0;
                    JsonSerializerSettings settings = new JsonSerializerSettings
                    {
                        // SerializationBinder = new DisplayNameSerializationBinder(
                        //    new[] { typeof(AasxIntegrationBase.AasForms.FormDescListOfElement),
                        //      typeof(AasxIntegrationBase.AasForms.FormDescProperty) }),
                        // SerializationBinder = new DisplayNameSerializationBinder(
                        //     new[] { typeof(AnyUiStackPanel), typeof(AnyUiUIElement) }),
                        // NullValueHandling = NullValueHandling.Ignore,
                        ReferenceLoopHandling = ReferenceLoopHandling.Error,
                        TypeNameHandling      = TypeNameHandling.All,
                        Formatting            = Formatting.Indented
                    };

                    //if (stack is AnyUiPanel pan)
                    //{
                    //    for (int i = 0; i < pan.Children.Count; i++)
                    //    {
                    //        var json = JsonConvert.SerializeObject(pan.Children[i], settings);
                    //        System.IO.File.WriteAllText(fn+"."+i, json);
                    //    }
                    //}
                    var json = JsonConvert.SerializeObject(stack, settings);
                    System.IO.File.WriteAllText(fn, json);
                }
                count++;

                /*
                 * var writer = new System.Xml.Serialization.XmlSerializer(typeof(AnyUiUIElement));
                 * var wfile = new System.IO.StreamWriter(@"c:\development\fileEdit.xml");
                 * writer.Serialize(wfile, stack);
                 * wfile.Close();
                 */
            }
#endif
#if MONOUI
#else
            // render Any UI to WPF?
            if (!inhibitRenderStackToPanel)
            {
                // rendering
                theMasterPanel.Children.Clear();
                var spwpf = _displayContext.GetOrCreateWpfElement(stack);
                _helper.ShowLastHighlights();
                DockPanel.SetDock(spwpf, Dock.Top);
                theMasterPanel.Children.Add(spwpf);

                // register key shortcuts
                var num = _displayContext.PrepareNameList(stack);
                if (num > 0)
                {
                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-up", ModifierKeys.Shift | ModifierKeys.Control, Key.Up,
                        "Move current AAS element up by one position.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-down", ModifierKeys.Shift | ModifierKeys.Control, Key.Down,
                        "Move current AAS element down by one position.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-top", ModifierKeys.Shift | ModifierKeys.Control, Key.Home,
                        "Move current AAS element to the first position of the respective list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-move-end", ModifierKeys.Shift | ModifierKeys.Control, Key.End,
                        "Move current AAS element to the last position of the respective list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-delete", ModifierKeys.Shift | ModifierKeys.Control, Key.Delete,
                        "Delete current AAS element in the respective list. Shift key skips dialogue.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-cut", ModifierKeys.Shift | ModifierKeys.Control, Key.X,
                        "Transfers current AAS element into paste buffer and deletes in respective list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-copy", ModifierKeys.Shift | ModifierKeys.Control, Key.C,
                        "Copies current AAS element into paste buffer for later pasting.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-paste-into", ModifierKeys.Shift | ModifierKeys.Control, Key.V,
                        "Copy existing paste buffer into the child list of the current AAS element.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-paste-above", ModifierKeys.Shift | ModifierKeys.Control, Key.W,
                        "Copy existing paste buffer above the current AAS element in the same list.");

                    _displayContext.RegisterKeyShortcut(
                        "aas-elem-paste-below", ModifierKeys.Shift | ModifierKeys.Control, Key.Y,
                        "Copy existing paste buffer below the current AAS element in the same list.");
                }
            }

            // keep the stack
            _lastRenderedRootElement = stack;
#endif

            // return render hints
            return(renderHints);
        }