예제 #1
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                if (this.options != null && this.options.Records != null)
                {
                    foreach (var rec in this.options.Records)
                    {
                        if (rec.AllowSubmodelSemanticId != null)
                        {
                            foreach (var x in rec.AllowSubmodelSemanticId)
                            {
                                if (sm.semanticId != null && sm.semanticId.Matches(x))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("MTP", "Module Type Package - View");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt = JsonConvert.DeserializeObject <AasxPluginMtpViewer.MtpViewerOptions>(args[0] as string);
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = JsonConvert.SerializeObject(this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense = "The AutomationML.Engine is licensed under the MIT license (MIT) (see below).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension" && this.viewerControl != null)
            {
                // arguments
                if (args?.Length < 3)
                {
                    return(null);
                }

                // call
                var resobj = AasxPluginMtpViewer.WpfMtpControlWrapper.FillWithWpfControls(args?[0], args?[1],
                                                                                          this.options, this.eventStack, args?[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = resobj;
                return(res);
            }

            // default
            return(null);
        }
예제 #2
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                // ReSharper disable once UnusedVariable
                foreach (var rec in _options.LookupAllIndexKey <DocumentShelfOptionsRecord>(
                             sm.semanticId?.GetAsExactlyOneKey()))
                {
                    found = true;
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("DOC", "Document Shelf");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <DocumentShelfOptions>(
                        (args[0] as string));
                if (newOpt != null)
                {
                    _options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    _options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense = "The CountryFlag library (NuGet) is licensed under the MIT license (MIT).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && _eventStack != null)
            {
                // try access
                return(_eventStack.PopEvent());
            }

            if (action == "event-return" && args != null &&
                args.Length >= 1 && args[0] is AasxPluginEventReturnBase &&
                _shelfControl != null)
            {
                _shelfControl.HandleEventReturn(args[0] as AasxPluginEventReturnBase);
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension")
            {
                // arguments
                if (args == null || args.Length < 3)
                {
                    return(null);
                }

                // call
                _shelfControl = ShelfControl.FillWithWpfControls(
                    _log, args[0], args[1], _options, _eventStack, args[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = _shelfControl;
                return(res);
            }

            if (action == "get-list-new-submodel")
            {
                // prepare list
                var list = new List <string>();
                list.Add("Document (recommended version)");
                list.Add("Document (development version V1.1)");

                // make result
                var res = new AasxPluginResultBaseObject();
                res.obj = list;
                return(res);
            }

            if (action == "generate-submodel" && args != null && args.Length >= 1 && args[0] is string)
            {
                // get arguments
                var smName = args[0] as string;
                if (smName == null)
                {
                    return(null);
                }

                // generate (by hand)
                var sm = new AdminShell.Submodel();
                if (smName.Contains("V1.1"))
                {
                    sm.semanticId = new AdminShell.SemanticId(
                        AasxPredefinedConcepts.VDI2770v11.Static.SM_ManufacturerDocumentation.GetSemanticKey());
                    sm.idShort = "ManufacturerDocumentation";
                }
                else
                {
                    sm.semanticId = new AdminShell.SemanticId(DocuShelfSemanticConfig.Singleton.SemIdDocumentation);
                    sm.idShort    = "Documentation";
                }

                // make result
                var res = new AasxPluginResultBaseObject();
                res.strType = "OK";
                res.obj     = sm;
                return(res);
            }

            // default
            return(null);
        }
예제 #3
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            try
            {
                // for speed reasons, have the most often used at top!
                if (action == "call-check-visual-extension")
                {
                    // arguments
                    if (args.Length < 1)
                    {
                        return(null);
                    }

                    // looking only for Submodels
                    var sm = args[0] as AdminShell.Submodel;
                    if (sm == null)
                    {
                        return(null);
                    }

                    // check for a record in options, that matches Submodel
                    var found = this.options?.MatchRecordsForSemanticId(sm.semanticId);
                    if (found == null)
                    {
                        return(null);
                    }

                    // success prepare record
                    var cve = new AasxPluginResultVisualExtension(found.FormTag, found.FormTitle);

                    // ok
                    return(cve);
                }

                // rest follows

                if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
                {
                    var settings =
                        AasxPluginOptionSerialization.GetDefaultJsonSettings(
                            new[] {
                        typeof(AasxPluginGenericForms.GenericFormOptions),
                        typeof(AasForms.FormDescBase)
                    });
                    var newOpt =
                        Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginGenericForms.GenericFormOptions>(
                            (args[0] as string), settings);
                    if (newOpt != null)
                    {
                        this.options = newOpt;
                    }
                }

                if (action == "get-json-options")
                {
                    var settings = AasxPluginOptionSerialization.GetDefaultJsonSettings(
                        new[] {
                        typeof(AasxPluginGenericForms.GenericFormOptions),
                        typeof(AasForms.FormDescBase)
                    });
                    var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                        this.options, typeof(AasxPluginGenericForms.GenericFormOptions), settings);
                    return(new AasxPluginResultBaseObject("OK", json));
                }

                if (action == "get-licenses")
                {
                    var lic = new AasxPluginResultLicense();
                    lic.shortLicense = "";

                    lic.isStandardLicense = true;
                    lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                        "LICENSE.txt", Assembly.GetExecutingAssembly());

                    return(lic);
                }

                if (action == "get-events" && this.eventStack != null)
                {
                    // try access
                    return(this.eventStack.PopEvent());
                }

                if (action == "event-return" && args != null &&
                    args.Length >= 1 && args[0] is AasxPluginEventReturnBase &&
                    this.formsControl != null)
                {
                    this.formsControl.HandleEventReturn(args[0] as AasxPluginEventReturnBase);
                }

                if (action == "get-check-visual-extension")
                {
                    var cve = new AasxPluginResultBaseObject();
                    cve.strType = "True";
                    cve.obj     = true;
                    return(cve);
                }

                if (action == "fill-panel-visual-extension")
                {
                    // arguments
                    if (args == null || args.Length < 3)
                    {
                        return(null);
                    }

                    // call
                    this.formsControl = AasxPluginGenericForms.GenericFormsControl.FillWithWpfControls(
                        Log, args[0], args[1], this.options, this.eventStack, args[2]);

                    // give object back
                    var res = new AasxPluginResultBaseObject();
                    res.obj = this.formsControl;
                    return(res);
                }

                if (action == "get-list-new-submodel")
                {
                    // prepare list
                    var list = new List <string>();

                    // check
                    if (options != null && options.Records != null)
                    {
                        foreach (var rec in options.Records)
                        {
                            if (rec.FormTitle != null)
                            {
                                list.Add("" + rec.FormTitle);
                            }
                        }
                    }

                    // make result
                    var res = new AasxPluginResultBaseObject();
                    res.strType = "OK";
                    res.obj     = list;
                    return(res);
                }

                if (action == "generate-submodel" && args != null && args.Length >= 1 && args[0] is string)
                {
                    // get arguments
                    var smName = args[0] as string;
                    if (smName == null)
                    {
                        return(null);
                    }

                    // identify record
                    AasxPluginGenericForms.GenericFormsOptionsRecord foundRec = null;
                    if (options != null && options.Records != null)
                    {
                        foreach (var rec in options.Records)
                        {
                            if (rec.FormTitle != null && rec.FormTitle == smName)
                            {
                                foundRec = rec;
                            }
                        }
                    }
                    if (foundRec == null || foundRec.FormSubmodel == null)
                    {
                        return(null);
                    }

                    // generate
                    var sm = foundRec.FormSubmodel.GenerateDefault();

                    // make result
                    var res = new AasxPluginResultGenerateSubmodel();
                    res.sm  = sm;
                    res.cds = foundRec.ConceptDescriptions;
                    return(res);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "");
            }

            // default
            return(null);
        }
예제 #4
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
#if __old
                var found = false;

                if (_options != null && _options.Records != null)
                {
                    foreach (var rec in _options.Records)
                    {
                        if (rec.AllowSubmodelSemanticId != null)
                        {
                            foreach (var x in rec.AllowSubmodelSemanticId)
                            {
                                if (sm.semanticId != null && sm.semanticId.Matches(x))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
#else
                bool found = _options?.ContainsIndexKey(sm?.semanticId?.GetAsExactlyOneKey()) ?? false;
#endif
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("KNO", "Known Submodel Templates");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt = JsonConvert.DeserializeObject <AasxPluginKnownSubmodels.KnownSubmodelsOptions>(
                    args[0] as string);
                if (newOpt != null)
                {
                    _options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = JsonConvert.SerializeObject(_options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense      = "";
                lic.longLicense       = "";
                lic.isStandardLicense = true;

                return(lic);
            }

            if (action == "get-events" && _eventStack != null)
            {
                // try access
                return(_eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension" && _viewerControl != null)
            {
                // arguments
                if (args?.Length < 3)
                {
                    return(null);
                }

                // call
                var resobj = AasxPluginKnownSubmodels.KnownSubmodelsControl.FillWithWpfControls(
                    _log, args?[0], args?[1],
                    _options, _eventStack, args?[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = resobj;
                return(res);
            }

            // default
            return(null);
        }
예제 #5
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                if (this.options != null && this.options.Records != null)
                {
                    foreach (var rec in this.options.Records)
                    {
                        if (rec.AllowSubmodelSemanticId != null)
                        {
                            foreach (var x in rec.AllowSubmodelSemanticId)
                            {
                                if (sm.semanticId != null && sm.semanticId.Matches(x))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("IMG", "Image Map");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt = JsonConvert.DeserializeObject <AasxPluginImageMap.ImageMapOptions>(args[0] as string);
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = JsonConvert.SerializeObject(this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense      = "";
                lic.longLicense       = "";
                lic.isStandardLicense = true;

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension" && this.viewerControl != null)
            {
                // arguments
                if (args?.Length < 3)
                {
                    return(null);
                }

                // call
                var resobj = AasxPluginImageMap.ImageMapControl.FillWithWpfControls(Log, args?[0], args?[1],
                                                                                    this.options, this.eventStack, args?[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = resobj;
                return(res);
            }

            if (action == "get-list-new-submodel")
            {
                // prepare list
                var list = new List <string>();
                list.Add("ImageMap");

                // make result
                var res = new AasxPluginResultBaseObject();
                res.obj = list;
                return(res);
            }

            if (action == "generate-submodel" && args != null && args.Length >= 1 && args[0] is string)
            {
                // get arguments
                var smName = args[0] as string;
                if (smName == null)
                {
                    return(null);
                }

                // generate (by hand)
                var sm = new AdminShell.Submodel();
                sm.semanticId = new AdminShell.SemanticId(AasxPredefinedConcepts.ImageMap.Static.SEM_ImageMapSubmodel);
                sm.idShort    = "ImageMap";

                sm.SmeForWrite.CreateSMEForCD <AdminShell.File>(AasxPredefinedConcepts.ImageMap.Static.CD_ImageFile,
                                                                idShort: "ImageFile", addSme: true);

                var ent = sm.SmeForWrite.CreateSMEForCD <AdminShell.Entity>(
                    AasxPredefinedConcepts.ImageMap.Static.CD_EntityOfImageMap,
                    idShort: "Entity00", addSme: true);

                ent.statements.CreateSMEForCD <AdminShell.Property>(
                    AasxPredefinedConcepts.ImageMap.Static.CD_RegionRect,
                    idShort: "RegionRect", addSme: true)?.Set("string", "[ 10, 10, 30, 30 ]");

                ent.statements.CreateSMEForCD <AdminShell.Property>(
                    AasxPredefinedConcepts.ImageMap.Static.CD_RegionCircle,
                    idShort: "RegionCircle", addSme: true)?.Set("string", "[ 40, 40, 10 ]");

                ent.statements.CreateSMEForCD <AdminShell.Property>(
                    AasxPredefinedConcepts.ImageMap.Static.CD_RegionPolygon,
                    idShort: "RegionPolygon", addSme: true)?.Set("string", "[ 20, 20, 50, 20, 40, 30 ]");

                ent.statements.CreateSMEForCD <AdminShell.ReferenceElement>(
                    AasxPredefinedConcepts.ImageMap.Static.CD_NavigateTo,
                    idShort: "NavigateTo", addSme: true);

                // make result
                var res = new AasxPluginResultBaseObject();
                res.strType = "OK";
                res.obj     = sm;
                return(res);
            }

            // default
            return(null);
        }
예제 #6
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null || _options == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                // ReSharper disable UnusedVariable
                foreach (var x in _options.MatchingRecords(sm.semanticId))
                {
                    found = true;
                    break;
                }
                if (!found)
                {
                    return(null);
                }
                // ReSharper enable UnusedVariable

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("BOM", "Bill of Material - Graph display");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginBomStructure.BomStructureOptions>(
                        (args[0] as string));
                if (newOpt != null)
                {
                    this._options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    this._options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense =
                    "The Microsoft Microsoft Automatic Graph Layout, MSAGL, is licensed under the MIT license (MIT).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this._eventStack != null)
            {
                // try access
                return(this._eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension" && this._bomControl != null)
            {
                // arguments
                if (args == null || args.Length < 3)
                {
                    return(null);
                }

                // call
                this._bomControl.SetEventStack(this._eventStack);
                var resobj = this._bomControl.FillWithWpfControls(_options, args[0], args[1], args[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = resobj;
                return(res);
            }

            // default
            return(null);
        }
예제 #7
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                if (this.options.AllowSubmodelSemanticIds != null)
                {
                    foreach (var x in this.options.AllowSubmodelSemanticIds)
                    {
                        if (sm.semanticId != null && sm.semanticId.Matches(x))
                        {
                            found = true;
                            break;
                        }
                    }
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("DOC", "Document Shelf");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginDocumentShelf.DocumentShelfOptions>(
                        (args[0] as string));
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense = "The CountryFlag library (NuGet) is licensed under the MIT license (MIT).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension")
            {
                // arguments
                if (args == null || args.Length < 3)
                {
                    return(null);
                }

                // call
                var resobj = AasxPluginDocumentShelf.ShelfControl.FillWithWpfControls(
                    Log, args[0], args[1], this.options, this.eventStack, args[2]);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = resobj;
                return(res);
            }

            if (action == "get-list-new-submodel")
            {
                // prepare list
                var list = new List <string>();
                list.Add("Document");

                // make result
                var res = new AasxPluginResultBaseObject();
                res.obj = list;
                return(res);
            }

            if (action == "generate-submodel" && args != null && args.Length >= 1 && args[0] is string)
            {
                // get arguments
                var smName = args[0] as string;
                if (smName == null)
                {
                    return(null);
                }

                // generate (by hand)
                var sm = new AdminShell.Submodel();
                sm.semanticId = new AdminShell.SemanticId(options.SemIdDocumentation);
                sm.idShort    = "Documentation";

                // make result
                var res = new AasxPluginResultBaseObject();
                res.strType = "OK";
                res.obj     = sm;
                return(res);
            }

            // default
            return(null);
        }
예제 #8
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                if (this.options != null && this.options.Records != null)
                {
                    foreach (var rec in this.options.Records)
                    {
                        if (rec.AllowSubmodelSemanticId != null)
                        {
                            foreach (var x in rec.AllowSubmodelSemanticId)
                            {
                                if (sm.semanticId != null && sm.semanticId.Matches(x))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("TED", "Technical Data Viewer");

                // ok
                return(cve);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginTechnicalData.TechnicalDataOptions>(
                        (args[0] as string));
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense =
                    "The application uses one class provided under The Code Project Open License (CPOL).";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "fill-panel-visual-extension" && args != null && args.Length >= 3)
            {
                // access
                var package = args[0] as AdminShellPackageEnv;
                var sm      = args[1] as AdminShell.Submodel;
                var master  = args[2] as DockPanel;
                if (package == null || sm == null || master == null)
                {
                    return(null);
                }

                // the Submodel elements need to have parents
                sm.SetAllParents();

                // create TOP control
                this.viewControl = new AasxPluginTechnicalData.TechnicalDataViewControl();
                this.viewControl.Start(package, sm, options, eventStack);
                master.Children.Add(this.viewControl);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = this.viewControl;
                return(res);
            }

            // default
            return(null);
        }
예제 #9
0
        public AasxPluginResultBase ActivateAction(string action, params object[] args)
        {
            // for speed reasons, have the most often used at top!
            if (action == "call-check-visual-extension")
            {
                // arguments
                if (args.Length < 1)
                {
                    return(null);
                }

                // looking only for Submodels
                var sm = args[0] as AdminShell.Submodel;
                if (sm == null)
                {
                    return(null);
                }

                // check for a record in options, that matches Submodel
                var found = false;
                if (this.options != null && this.options.Records != null)
                {
                    foreach (var rec in this.options.Records)
                    {
                        if (rec.AllowSubmodelSemanticId != null)
                        {
                            foreach (var x in rec.AllowSubmodelSemanticId)
                            {
                                if (sm.semanticId != null && sm.semanticId.Matches(x))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (!found)
                {
                    return(null);
                }

                // success prepare record
                var cve = new AasxPluginResultVisualExtension("PLOT", "Plotting of data");

                // ok
                return(cve);
            }

            if (action == "push-aas-event")
            {
                // arguments
                if (args.Length < 1 || !(args[0] is AasEventMsgEnvelope ev))
                {
                    return(null);
                }

                _viewControl?.PushEvent(ev);
            }

            // rest follows

            if (action == "set-json-options" && args != null && args.Length >= 1 && args[0] is string)
            {
                var newOpt =
                    Newtonsoft.Json.JsonConvert.DeserializeObject <AasxPluginPlotting.PlottingOptions>(
                        (args[0] as string));
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }

            if (action == "get-json-options")
            {
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(
                    this.options, Newtonsoft.Json.Formatting.Indented);
                return(new AasxPluginResultBaseObject("OK", json));
            }

            if (action == "get-licenses")
            {
                var lic = new AasxPluginResultLicense();
                lic.shortLicense =
                    "The application uses the ScottPlot NuGet package, which is under the MIT license.";

                lic.isStandardLicense = true;
                lic.longLicense       = AasxPluginHelper.LoadLicenseTxtFromAssemblyDir(
                    "LICENSE.txt", Assembly.GetExecutingAssembly());

                return(lic);
            }

            if (action == "get-events" && this.eventStack != null)
            {
                // try access
                return(this.eventStack.PopEvent());
            }

            if (action == "get-check-visual-extension")
            {
                var cve = new AasxPluginResultBaseObject();
                cve.strType = "True";
                cve.obj     = true;
                return(cve);
            }

            if (action == "clear-panel-visual-extension")
            {
                // simple delete reference to view control
                // this shall also stop event notifications!
                if (_viewControl != null)
                {
                    _viewControl.Stop();
                }
                _viewControl = null;
            }

            if (action == "fill-panel-visual-extension" && args != null && args.Length >= 3)
            {
                // access
                var package = args[0] as AdminShellPackageEnv;
                var sm      = args[1] as AdminShell.Submodel;
                var master  = args[2] as DockPanel;
                if (package == null || sm == null || master == null)
                {
                    return(null);
                }

                // the Submodel elements need to have parents
                sm.SetAllParents();

                // create TOP control
                _viewControl = new AasxPluginPlotting.PlottingViewControl();
                _viewControl.Start(package, sm, options, eventStack, Log);
                master.Children.Add(_viewControl);

                // give object back
                var res = new AasxPluginResultBaseObject();
                res.obj = _viewControl;
                return(res);
            }

            // default
            return(null);
        }