public static WpfMtpControlWrapper FillWithWpfControls(
            object opackage, object osm,
            AasxPluginMtpViewer.MtpViewerOptions options,
            PluginEventStack eventStack,
            object masterDockPanel)
        {
            // access
            var package = opackage as AdminShellPackageEnv;
            var sm      = osm as AdminShell.Submodel;
            var master  = masterDockPanel as DockPanel;

            if (package == null || sm == null || master == null)
            {
                return(null);
            }

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

            // create TOP control
            var wrapperCntl = new WpfMtpControlWrapper();

            wrapperCntl.Start(package, sm, options, eventStack);
            master.Children.Add(wrapperCntl);

            // return shelf
            return(wrapperCntl);
        }
 public void Start(
     AdminShellPackageEnv thePackage,
     AdminShell.Submodel theSubmodel,
     AasxPluginMtpViewer.MtpViewerOptions theOptions,
     PluginEventStack eventStack)
 {
     this.thePackage    = thePackage;
     this.theSubmodel   = theSubmodel;
     this.theOptions    = theOptions;
     this.theEventStack = eventStack;
 }
Esempio n. 3
0
        public void Start(
            AdminShellPackageEnv thePackage,
            AdminShell.Submodel theSubmodel,
            AasxPluginMtpViewer.MtpViewerOptions theOptions,
            PluginEventStack eventStack)
        {
            this.thePackage    = thePackage;
            this.theSubmodel   = theSubmodel;
            this.theOptions    = theOptions;
            this.theEventStack = eventStack;

            this.theDefs = new DefinitionsMTP.ModuleTypePackage(new DefinitionsMTP());
        }
Esempio n. 4
0
        public void InitPlugin(string[] args)
        {
            // start ..
            Log.Info("InitPlugin() called with args = {0}", (args == null) ? "" : string.Join(", ", args));

            // .. with built-in options
            options = AasxPluginMtpViewer.MtpViewerOptions.CreateDefault();

            // try load defaults options from assy directory
            try
            {
                var newOpt =
                    AasxPluginOptionsBase.LoadDefaultOptionsFromAssemblyDir <AasxPluginMtpViewer.MtpViewerOptions>(
                        this.GetPluginName(), Assembly.GetExecutingAssembly());
                if (newOpt != null)
                {
                    this.options = newOpt;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exception when reading default options {1}");
            }
        }
Esempio n. 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("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);
        }