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

Commit

Permalink
* modbus v0.1 working
Browse files Browse the repository at this point in the history
  • Loading branch information
festo-i40 committed Jan 6, 2024
1 parent 6d6331f commit 9365e07
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AasxPluginAssetInterfaceDesc/AidInterfaceStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void UpdateItemValue(AidModbusConnection conn, AidIfxItemStatus item)
if (item.FormData.Modbus_function.Trim().ToLower() == "readholdingregisters")
{
// readHoldingRegisters
id = conn.Client.ReadHoldingRegisters<byte>(99, address, quantity).ToArray();
id = conn.Client.ReadHoldingRegisters<byte>(99, address, 2 * quantity).ToArray();
// time
conn.LastActive = DateTime.Now;
}
Expand Down
49 changes: 45 additions & 4 deletions src/AasxPluginAssetInterfaceDesc/AssetInterfaceAnyUiControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class AssetInterfaceAnyUiControl
private AssetInterfaceOptions _options = null;
private PluginEventStack _eventStack = null;
private AnyUiStackPanel _panel = null;
private AasxPluginBase _plugin = null;

private AidAllInterfaceStatus _allInterfaceStatus = null;

Expand Down Expand Up @@ -73,6 +74,7 @@ public void Start(
AssetInterfaceOptions theOptions,
PluginEventStack eventStack,
AnyUiStackPanel panel,
AasxPluginBase plugin,
AidAllInterfaceStatus ifxStatus)
{
// internal members
Expand All @@ -82,6 +84,7 @@ public void Start(
_options = theOptions;
_eventStack = eventStack;
_panel = panel;
_plugin = plugin;
_allInterfaceStatus = ifxStatus;

// some required logos
Expand Down Expand Up @@ -112,6 +115,7 @@ public static AssetInterfaceAnyUiControl FillWithAnyUiControls(
AssetInterfaceOptions options,
PluginEventStack eventStack,
object opanel,
AasxPluginBase plugin,
AidAllInterfaceStatus ifxStatus)
{
// access
Expand All @@ -126,7 +130,7 @@ public static AssetInterfaceAnyUiControl FillWithAnyUiControls(

// factory this object
var aidCntl = new AssetInterfaceAnyUiControl();
aidCntl.Start(log, package, sm, options, eventStack, panel, ifxStatus);
aidCntl.Start(log, package, sm, options, eventStack, panel, plugin, ifxStatus);

// return shelf
return aidCntl;
Expand Down Expand Up @@ -239,11 +243,40 @@ protected void RenderPanelInner(
var grid = view.Add(uitk.AddSmallGrid(rows: 3, cols: 2, colWidths: new[] { "110:", "*" }));

uitk.AddSmallLabelTo(grid, 0, 0, content: "Debug:");

AnyUiUIElement.RegisterControl(
uitk.AddSmallButtonTo(grid, 0, 1,
margin: new AnyUiThickness(2), setHeight: 21,
padding: new AnyUiThickness(2, 0, 2, 0),
content: "Test .."),
content: "Create status items"),
(o) =>
{
try
{
// build up data structures
_allInterfaceStatus.InterfaceStatus = PrepareAidInformation(sm);

// trigger a complete redraw, as the regions might emit
// events or not, depending on this flag
return new AnyUiLambdaActionPluginUpdateAnyUi()
{
PluginName = _plugin?.GetPluginName(),
UpdateMode = AnyUiRenderMode.All,
UseInnerGrid = true
};
}
catch (Exception ex)
{
;
}
return new AnyUiLambdaActionNone();
});

AnyUiUIElement.RegisterControl(
uitk.AddSmallButtonTo(grid, 1, 1,
margin: new AnyUiThickness(2), setHeight: 21,
padding: new AnyUiThickness(2, 0, 2, 0),
content: "Single update .."),
(o) =>
{
try
Expand All @@ -253,6 +286,15 @@ protected void RenderPanelInner(
//var byteData = client.ReadHoldingRegisters<byte>(99, 1, 8);

_allInterfaceStatus?.UpdateValuesSingleShot();

// trigger a complete redraw, as the regions might emit
// events or not, depending on this flag
return new AnyUiLambdaActionPluginUpdateAnyUi()
{
PluginName = _plugin?.GetPluginName(),
UpdateMode = AnyUiRenderMode.All,
UseInnerGrid = true
};
}
catch (Exception ex)
{
Expand All @@ -261,8 +303,7 @@ protected void RenderPanelInner(
return new AnyUiLambdaActionNone();
});

// get SM data and
_allInterfaceStatus.InterfaceStatus = PrepareAidInformation(sm);
// get SM data and
RenderTripleRowData(view, uitk, _allInterfaceStatus.InterfaceStatus);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AasxPluginAssetInterfaceDesc/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public class Session : PluginSessionBase
// create session and call
var session = _sessions.CreateNewSession<Session>(args[4]);
session.AnyUiControl = AasxPluginAssetInterfaceDescription.AssetInterfaceAnyUiControl.FillWithAnyUiControls(
_log, args[0], args[1], _options, _eventStack, args[2], _allInterfaceStatus);
_log, args[0], args[1], _options, _eventStack, args[2], this, _allInterfaceStatus);

// give object back
var res = new AasxPluginResultBaseObject();
Expand Down

0 comments on commit 9365e07

Please sign in to comment.