public void InitPlugin(string[] args) { // start .. Log.Info("InitPlugin() called with args = {0}", (args == null) ? "" : string.Join(", ", args)); // .. with built-in options options = AasxPluginPlotting.PlottingOptions.CreateDefault(); // try load defaults options from assy directory try { var newOpt = AasxPluginOptionsBase.LoadDefaultOptionsFromAssemblyDir < AasxPluginPlotting.PlottingOptions>( this.GetPluginName(), Assembly.GetExecutingAssembly()); if (newOpt != null) { this.options = newOpt; } } catch (Exception ex) { Log.Error(ex, "Exception when reading default options {1}"); } }
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); }