Skip to content

Commit

Permalink
* remove menu commands
Browse files Browse the repository at this point in the history
  for OPC UA server
  • Loading branch information
festo-i40 committed Jul 27, 2024
1 parent 4eb4930 commit d404bf5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 73 deletions.
46 changes: 0 additions & 46 deletions src/AasxPackageExplorer/MainWindow.CommandBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,6 @@ private async Task CommandBinding_GeneralDispatch(
if (cmd == "importdictsubmodel" || cmd == "importdictsubmodelelements")
CommandBinding_ImportDictToSubmodel(cmd, ticket);

// TODO (MIHO, 2022-11-19): stays in WPF (tightly integrated, command line shall do own version)
if (cmd == "opcuaexportnodesetuaplugin")
await CommandBinding_ExportNodesetUaPlugin(cmd, ticket);

// stays in WPF
if (cmd == "serverrest")
CommandBinding_ServerRest();
Expand Down Expand Up @@ -320,11 +316,6 @@ private async Task CommandBinding_GeneralDispatch(
CommandBinding_ExecutePluginServer(
"EmptySample", "server-start", "server-stop", "Empty sample plug-in.");

// REFACTOR: STAYS HERE
if (cmd == "serverpluginopcua")
CommandBinding_ExecutePluginServer(
"AasxPluginUaNetServer", "server-start", "server-stop", "Plug-in for OPC UA Server for AASX.");

// REFACTOR: STAYS HERE
if (cmd == "serverpluginmqtt")
CommandBinding_ExecutePluginServer(
Expand Down Expand Up @@ -1303,43 +1294,6 @@ public void CommandBinding_ImportDictToSubmodel(
}
}


public async Task CommandBinding_ExportNodesetUaPlugin(
string cmd,
AasxMenuActionTicket ticket)
{
if (cmd == "opcuaexportnodesetuaplugin")
{
// filename
// ReSharper disable UnusedVariable
var uc = await DisplayContext.MenuSelectSaveFilenameAsync(
ticket, "File",
"Select Nodeset2.XML file to be exported",
"new.xml",
"OPC UA Nodeset2 files (*.xml)|*.xml|All files (*.*)|*.*",
"Export OPC UA Nodeset2 via plugin: No valid filename.");
if (uc?.Result != true)
return;
// ReSharper enable UnusedVariable
try
{
RememberForInitialDirectory(uc.TargetFileName);
CommandBinding_ExecutePluginServer(
"AasxPluginUaNetServer",
"server-start",
"server-stop",
"Export Nodeset2 via OPC UA Server...",
new[] { "-export-nodeset", uc.TargetFileName }
);
}
catch (Exception ex)
{
Log.Singleton.Error(
ex, "When exporting UA nodeset via plug-in, an error occurred");
}
}
}

public async Task CommandBinding_ExportImportTableUml(
string cmd,
AasxMenuActionTicket ticket,
Expand Down
10 changes: 1 addition & 9 deletions src/AasxPackageLogic/ExplorerMenuFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,12 @@ public static AasxMenu CreateMainMenu()
args: new AasxMenuListOfArgDefs()
.Add("File", "OPC UA Nodeset2.xml file to write.")
.Add("Location", "Location selection", hidden: true))
.AddWpfBlazor(name: "OpcUaExportNodeSetUaPlugin",
header: "Export OPC UA Nodeset2.xml (via UA server plug-in) …",
help: "Export OPC UA Nodeset2.xml format by starting OPC UA server in plugin and " +
"execute a post-process command.",
args: new AasxMenuListOfArgDefs()
.Add("File", "OPC UA Nodeset2.xml file to write.")
.Add("Location", "Location selection", hidden: true))
.AddWpfBlazor(name: "CopyClipboardElementJson",
header: "Copy selected element JSON to clipboard", inputGesture: "Shift+Ctrl+C")
.AddWpfBlazor(name: "ExportGenericForms",
header: "Export Submodel as options for GenericForms …",
args: new AasxMenuListOfArgDefs()
.Add("File", "OPC UA Nodeset2.xml file to write.")
.Add("File", "Export file to write.")
.Add("Location", "Location selection", hidden: true))
.AddWpfBlazor(name: "ExportPredefineConcepts",
header: "Export Submodel as snippet for PredefinedConcepts …",
Expand Down Expand Up @@ -247,7 +240,6 @@ public static AasxMenu CreateMainMenu()
.AddWpf(name: "MQTTPub", header: "Publish AAS via MQTT …")
.AddSeparator()
.AddWpf(name: "ServerPluginEmptySample", header: "Plugin: Empty Sample …")
.AddWpf(name: "ServerPluginOPCUA", header: "Plugin: OPC UA …")
.AddWpf(name: "ServerPluginMQTT", header: "Plugin: MQTT …"))
.AddSeparator(filter: AasxMenuFilter.NotBlazor)
.AddMenu(header: "System …", filter: AasxMenuFilter.NotBlazor,
Expand Down
27 changes: 18 additions & 9 deletions src/AasxPluginUaNetClient/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public AasxPluginActionDescriptionBase[] ListActions()

} catch (Exception ex)
{
LogInternally.That.CompletelyIgnoredError(ex);
_log?.Error(ex, "create OPC UA client");
}

return null;
Expand All @@ -222,15 +222,24 @@ public AasxPluginActionDescriptionBase[] ListActions()
var nodeName = args[1] as string;
var nsIndex = (int)args[2];

// make the call
var nid = client?.CreateNodeId(nodeName, nsIndex);
var value = (await client?.ReadNodeIdAsync(nid))?.Value;
try
{

// return as plain object
var res = new AasxPluginResultBaseObject();
res.strType = "value object";
res.obj = value;
return res;
// make the call
var nid = client?.CreateNodeId(nodeName, nsIndex);
var value = (await client?.ReadNodeIdAsync(nid))?.Value;

// return as plain object
var res = new AasxPluginResultBaseObject();
res.strType = "value object";
res.obj = value;
return res;

}
catch (Exception ex)
{
_log?.Error(ex, "read node");
}
}

#endif
Expand Down
9 changes: 0 additions & 9 deletions src/BlazorExplorer/Data/BlazorSession.CommandBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,6 @@ await BlazorUI.Utils.BlazorUtils.ShowNewBrowserWindow(renderJsRuntime,
return;
}

// REFACTOR: WPF required
if (cmd == "opcuaexportnodesetuaplugin")
{
Logic.LogErrorToTicket(ticket, "OpcUaExportNodesetUaPlugin not implemented, yet.");

return;
}

// REFACTOR: WPF required
if (cmd == "serverrest"
|| cmd == "mqttpub"
Expand All @@ -312,7 +304,6 @@ await BlazorUI.Utils.BlazorUtils.ShowNewBrowserWindow(renderJsRuntime,
// dead-csharp on
// REFACTOR: WPF required
if (cmd == "serverpluginemptysample"
|| cmd == "serverpluginopcua"
|| cmd == "serverpluginmqtt")
{
Logic.LogErrorToTicket(ticket, "Some servers not implemented, yet.");
Expand Down

0 comments on commit d404bf5

Please sign in to comment.