Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
* MQTT Server dialogue on
Browse files Browse the repository at this point in the history
  AnyUI
* updates
  • Loading branch information
festo-i40 committed Aug 2, 2023
1 parent b77b6ac commit e045cd0
Show file tree
Hide file tree
Showing 7 changed files with 265 additions and 73 deletions.
6 changes: 4 additions & 2 deletions src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
This source code may use other Open Source software components (see LICENSE.txt).
*/
using AdminShellNS;
using Extensions;
using System.Collections.Generic;
using System.Linq;
using AdminShellNS;
using Aas = AasCore.Aas3_0;

namespace Extensions
{
Expand Down Expand Up @@ -143,7 +144,7 @@ public static List<IKey> Parse(string input)
}

/// <summary>
/// Take only idShort, ignore all other key-types and create a '/'-separated list
/// Take only idShort from Referables, ignore all other key-types and create a '/'-separated list
/// </summary>
/// <returns>Empty string or list of idShorts</returns>
public static string BuildIdShortPath(this List<IKey> keyList,
Expand All @@ -157,6 +158,7 @@ public static string BuildIdShortPath(this List<IKey> keyList,
{
nr++;
//// if (keyList[i].Type.Trim().ToLower() == Key.IdShort.Trim().ToLower())
if (Aas.Constants.AasReferableNonIdentifiables.Contains(keyList[i].Type))
{
if (res != "")
res += "/";
Expand Down
160 changes: 154 additions & 6 deletions src/AasxPackageExplorer/MainWindow.CommandBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This source code may use other Open Source software components (see LICENSE.txt)
*/

using AasxIntegrationBase;
using AasxMqttClient;
using AasxPackageLogic;
using AasxPackageLogic.PackageCentral;
using AdminShellNS;
Expand Down Expand Up @@ -279,7 +280,7 @@ private async Task CommandBinding_GeneralDispatch(

// stays in WPF
if (cmd == "mqttpub")
CommandBinding_MQTTPub();
await CommandBinding_MQTTPub(ticket);

// stays in WPF
if (cmd == "connectintegrated")
Expand Down Expand Up @@ -660,22 +661,169 @@ public class FlyoutAgentMqttPublisher : FlyoutAgentBase
public BackgroundWorker Worker;
}

public void CommandBinding_MQTTPub()
public async Task CommandBinding_MQTTPub(AasxMenuActionTicket ticket)
{

// make an agent
var agent = new FlyoutAgentMqttPublisher();

// ask for preferences
agent.DiaData = AasxMqttClient.AnyUiDialogueDataMqttPublisher.CreateWithOptions("AASQ MQTT publisher ..",
// ask for preferences
#if __WPF_based
agent.DiaData = AasxMqttClient.AnyUiDialogueDataMqttPublisher.CreateWithOptions("AASX MQTT publisher ..",
jtoken: Options.Curr.MqttPublisherOptions);
var uc1 = new MqttPublisherFlyout(agent.DiaData);
this.StartFlyoverModal(uc1);
if (!uc1.Result)
return;
#else
agent.DiaData = AasxMqttClient.AnyUiDialogueDataMqttPublisher.CreateWithOptions("AASX MQTT publisher ..",
jtoken: Options.Curr.MqttPublisherOptions);
var uc1 = new AnyUiDialogueDataModalPanel(agent.DiaData.Caption);
uc1.DisableScrollArea = true;
uc1.ActivateRenderPanel(agent.DiaData,
(uci) =>
{
// create panel
var panel = new AnyUiStackPanel();
var helper = new AnyUiSmallWidgetToolkit();
var data = uci.Data as AnyUiDialogueDataMqttPublisher;
if (data == null)
return panel;
// outer grid
var g = helper.AddSmallGrid(13, 3, new[] { "#", "5:", "*" },
padding: new AnyUiThickness(0, 5, 0, 5));
int row = 0;
// Row : MQTT broker
helper.AddSmallLabelTo(g, row, 0, content: "Format:", verticalCenter: true);
AnyUiUIElement.SetStringFromControl(
helper.AddSmallTextBoxTo(g, row, 2,
margin: new AnyUiThickness(0, 2, 2, 2),
text: "" + data.BrokerUrl,
verticalCenter: true),
(str) => { data.BrokerUrl = str; });
// Row : retain
AnyUiUIElement.SetBoolFromControl(
helper.Set(
helper.AddSmallCheckBoxTo(g, ++row, 2,
content: "Set retain flag in MQTT messages",
isChecked: data.MqttRetain,
verticalContentAlignment: AnyUiVerticalAlignment.Center)),
(b) => { data.MqttRetain = b; });
// VSpace
helper.AddVerticalSpaceTo(g, ++row);
// Row : first time publish
helper.AddSmallLabelTo(g, ++row, 0, content: "First time publish:", verticalCenter: true);
AnyUiUIElement.SetBoolFromControl(
helper.AddSmallCheckBoxTo(g, row, 2,
content: "Enable publishing",
isChecked: data.EnableFirstPublish,
verticalContentAlignment: AnyUiVerticalAlignment.Center),
(b) => { data.EnableFirstPublish = b; });
// Row : Topic AAS
helper.Set(
helper.AddSmallLabelTo(g, ++row, 0, content: "Topic AAS:", verticalCenter: true),
horizontalAlignment: AnyUiHorizontalAlignment.Right,
horizontalContentAlignment: AnyUiHorizontalAlignment.Right);
AnyUiUIElement.SetStringFromControl(
helper.AddSmallTextBoxTo(g, row, 2,
margin: new AnyUiThickness(0, 2, 2, 2),
text: "" + data.FirstTopicAAS,
verticalCenter: true),
(str) => { data.FirstTopicAAS = str; });
// Row : Topic Submodel
helper.Set(
helper.AddSmallLabelTo(g, ++row, 0, content: "Topic Submodel:", verticalCenter: true),
horizontalAlignment: AnyUiHorizontalAlignment.Right,
horizontalContentAlignment: AnyUiHorizontalAlignment.Right);
AnyUiUIElement.SetStringFromControl(
helper.AddSmallTextBoxTo(g, row, 2,
margin: new AnyUiThickness(0, 2, 2, 2),
text: "" + data.FirstTopicSubmodel,
verticalCenter: true),
(str) => { data.FirstTopicSubmodel = str; });
// VSpace
helper.AddVerticalSpaceTo(g, ++row);
// Row : continous event time publish
helper.AddSmallLabelTo(g, ++row, 0, content: "Continous event publish:", verticalCenter: true);
AnyUiUIElement.SetBoolFromControl(
helper.AddSmallCheckBoxTo(g, row, 2,
content: "Enable publishing",
isChecked: data.EnableEventPublish,
verticalContentAlignment: AnyUiVerticalAlignment.Center),
(b) => { data.EnableEventPublish = b; });
// Row : Topic event publish
helper.Set(
helper.AddSmallLabelTo(g, ++row, 0, content: "Topic:", verticalCenter: true),
horizontalAlignment: AnyUiHorizontalAlignment.Right,
horizontalContentAlignment: AnyUiHorizontalAlignment.Right);
AnyUiUIElement.SetStringFromControl(
helper.AddSmallTextBoxTo(g, row, 2,
margin: new AnyUiThickness(0, 2, 2, 2),
text: "" + data.EventTopic,
verticalCenter: true),
(str) => { data.EventTopic = str; });
// VSpace
helper.AddVerticalSpaceTo(g, ++row);
// Row : single value publish
helper.AddSmallLabelTo(g, ++row, 0, content: "Single value publish:", verticalCenter: true);
AnyUiUIElement.SetBoolFromControl(
helper.AddSmallCheckBoxTo(g, row, 2,
content: "Enable publishing",
isChecked: data.SingleValuePublish,
verticalContentAlignment: AnyUiVerticalAlignment.Center),
(b) => { data.SingleValuePublish = b; });
// Row : single value first time
AnyUiUIElement.SetBoolFromControl(
helper.AddSmallCheckBoxTo(g, ++row, 2,
content: "First time",
isChecked: data.SingleValueFirstTime,
verticalContentAlignment: AnyUiVerticalAlignment.Center),
(b) => { data.SingleValueFirstTime = b; });
// Row : Topic single value publish
helper.Set(
helper.AddSmallLabelTo(g, ++row, 0, content: "Topic:", verticalCenter: true),
horizontalAlignment: AnyUiHorizontalAlignment.Right,
horizontalContentAlignment: AnyUiHorizontalAlignment.Right);
AnyUiUIElement.SetStringFromControl(
helper.AddSmallTextBoxTo(g, row, 2,
margin: new AnyUiThickness(0, 2, 2, 2),
text: "" + data.SingleValueTopic,
verticalCenter: true),
(str) => { data.SingleValueTopic = str; });
// give back
return g;
});

if (!ticket.ScriptMode)
{
// do the dialogue
if (!(await DisplayContext.StartFlyoverModalAsync(uc1)))
return;

// stop
await Task.Delay(2000);
}
#endif

// make a logger
agent.Logger = new AasxMqttClient.GrapevineLoggerToStoredPrints();
// make a logger
agent.Logger = new AasxMqttClient.GrapevineLoggerToStoredPrints();

// make listing flyout
var uc2 = new LogMessageFlyout("AASX MQTT Publisher", "Starting MQTT Client ..", () =>
Expand Down
96 changes: 53 additions & 43 deletions src/AasxPackageExplorer/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,11 @@ public void UiLoadPackageWithNew(
return;
}

// establish parents (only for main)
if (!onlyAuxiliary)
foreach (var sm in PackageCentral.Main?.AasEnv?.OverSubmodelsOrEmpty())
sm?.SetAllParents();

// displaying
try
{
Expand Down Expand Up @@ -1926,6 +1931,8 @@ private void MainTimer_CheckAnimationElements(
if (env == null || significantElems == null || MainMenu?.IsChecked("AnimateElements") != true)
return;

var animated = false;

// find elements?
foreach (var rec in significantElems.Retrieve(env, SignificantAasElement.ValueAnimation))
{
Expand Down Expand Up @@ -1955,11 +1962,14 @@ private void MainTimer_CheckAnimationElements(
Info = "Animated value update"
}
});
animated = true;
});
}


}

// if any ..
if (animated)
CheckIfToFlushEvents();
}

private void MainTimer_CheckDiaryDateToEmitEvents(
Expand Down Expand Up @@ -3082,48 +3092,48 @@ public void StartFlyoverModal(UserControl uc, Action closingAction = null)

// agent behaviour
var preventClosingAction = false;
// dead-csharp off
// if (uc is IFlyoutAgent ucag)
// {
// // register for minimize
// ucag.ControlMinimize += () =>
//{
// only execute if preconditions are well
// if (ucag.GetAgent() != null && ucag.GetAgent().GenerateFlyoutMini != null)
//{
// do not execute directly
// preventClosingAction = true;

// make a mini
// var mini = ucag.GetAgent().GenerateFlyoutMini.Invoke();

// be careful
// if (mini is UserControl miniUc)
// {
// push the agent
// UserControlAgentsView.Add(miniUc);

// wrap provided closing action in own closing action
// if (ucag.GetAgent() != null)
// ucag.GetAgent().ClosingAction = () =>
// {
// 1st delete agent
// UserControlAgentsView.Remove(miniUc);

// finally, call user provided closing action
// closingAction?.Invoke();
// };

// show the panel
// PanelConcurrentSetVisibleIfRequired(true, targetAgents: true);

// remove the flyover
// frame.Continue = false; // stops the frame
// }
// }
// };
//} */
// dead-csharp on
if (uc is IFlyoutAgent ucag)
{
// register for minimize
ucag.ControlMinimize += () =>
{
// only execute if preconditions are well
if (ucag.GetAgent() != null && ucag.GetAgent().GenerateFlyoutMini != null)
{
// do not execute directly
preventClosingAction = true;
// make a mini
var mini = ucag.GetAgent().GenerateFlyoutMini.Invoke();
// be careful
if (mini is UserControl miniUc)
{
// push the agent
UserControlAgentsView.Add(miniUc);
// wrap provided closing action in own closing action
if (ucag.GetAgent() != null)
ucag.GetAgent().ClosingAction = () =>
{
// 1st delete agent
UserControlAgentsView.Remove(miniUc);
// finally, call user provided closing action
closingAction?.Invoke();
};
// show the panel
PanelConcurrentSetVisibleIfRequired(true, targetAgents: true);
// remove the flyover
frame.Continue = false; // stops the frame
}
}
};
}

// start (focus)
ucfoc.ControlStart();

Expand Down
17 changes: 9 additions & 8 deletions src/AasxPackageExplorer/options-debug.MIHO.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
/* "AasxToLoad": "C:\\Users\\miho\\Desktop\\Festo_SPAU_VR3_UA.aasx", */
/* "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\Festo_SPAU_VR3.aasx", */
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\PxC_aasT_2900542_ELR_H3_I_SC__24DC_500AC_0_6.aasx",
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\Festo_SPAU-B2R-H-G18FD-L-PNLK-PNVBA-M8U_V3a.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\01_Festo_SPAU_VR3_DPPV2.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\Festo_SPAU-B2R-H-G18FD-L-PNLK-PNVBA-M8U_V3a.aasx",
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\01_Festo_SPAU_VR3_DPPV2.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\bomtest1.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\IDTA 02006-2-1_Template_Digital Nameplate_V3_lang.aasx",
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SMT_Sample_B.aasx",
Expand Down Expand Up @@ -68,7 +68,7 @@
/* "DefaultConnectRepositoryLocation": "https://admin-shell-io.com:51711", */
"DefaultConnectRepositoryLocation": "https://admin-shell-io.com/51711",
"MqttPublisherOptions": {
"BrokerUrl": "192.168.178.97:1883",
"BrokerUrl": "localhost:1883",
"MqttRetain": false,
"EnableFirstPublish": true,
"FirstTopicAAS": "AAS",
Expand Down Expand Up @@ -150,8 +150,13 @@
{
"Path": "..\\..\\..\\..\\..\\AasxPluginExportTable\\bin\\Debug\\net6.0-windows\\AasxPluginExportTable.dll",
"Args": []
} /* ,
},
{
"Path": "..\\..\\..\\..\\..\\AasxPluginWebBrowser\\bin\\x64\\Debug\\net6.0-windows\\AasxPluginWebBrowser.dll",
"Args": []
}

/* ,
// Festo specific from here on
{
"Path": "..\\..\\..\\..\\..\\..\\..\\AasxFesto\\AasxFesto\\AasxPluginFluiddrawViewer\\bin\\Debug\\net6.0-windows\\AasxPluginFluiddrawViewer.dll",
Expand All @@ -161,10 +166,6 @@
"Path": "..\\..\\..\\..\\..\\..\\..\\AasxFesto\\AasxFesto\\AasxPluginFluiddrawBom\\bin\\Debug\\net6.0-windows\\AasxPluginFluiddrawBom.dll",
"Args": []
}
{
"Path": "..\\..\\..\\..\\..\\AasxPluginWebBrowser\\bin\\x64\\Debug\\net6.0-windows\\AasxPluginWebBrowser.dll",
"Args": []
}
// Festo specific from here on
{
"Path": "..\\..\\..\\..\\..\\..\\..\\AasxFesto\\AasxFesto\\AasxPluginFluiddrawViewer\\bin\\Debug\\AasxPluginFluiddrawViewer.dll",
Expand Down
Loading

0 comments on commit e045cd0

Please sign in to comment.