Skip to content

Commit 512855f

Browse files
committed
Merge branch 'Development' into 'main'
MAUI: update hio monitor app See merge request tools/hio-dotnet!6
2 parents a49b2a9 + 5765973 commit 512855f

File tree

20 files changed

+1310
-458
lines changed

20 files changed

+1310
-458
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace hio_dotnet.Demos.HardwarioMonitor
8+
{
9+
public class AppConfig
10+
{
11+
public string AppName { get; set; } = string.Empty;
12+
public string AppVersion { get; set; } = string.Empty;
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@using Services
2+
3+
@inject ConsoleService ConsoleService
4+
5+
<RadzenRow Style=@getLeftMargin>
6+
<RadzenColumn>
7+
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Start" JustifyContent="JustifyContent.Left">
8+
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Start">
9+
@if (ConsoleService.IsConsoleListening)
10+
{
11+
<div style="margin-top:-2px;">
12+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
13+
<circle cx="8" cy="8" r="7" fill="green" />
14+
</svg>
15+
</div>
16+
}
17+
else
18+
{
19+
<div style="margin-top:-2px;">
20+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
21+
<circle cx="8" cy="8" r="7" fill="red" />
22+
</svg>
23+
</div>
24+
}
25+
<RadzenText Text="@connectionStatus" style="margin-left:5px;" />
26+
</RadzenStack>
27+
28+
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Start">
29+
@if (ConsoleService.IsPPK2Connected())
30+
{
31+
<div style="margin-top:-2px;">
32+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
33+
<circle cx="8" cy="8" r="7" fill="green" />
34+
</svg>
35+
</div>
36+
}
37+
else
38+
{
39+
<div style="margin-top:-2px;">
40+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
41+
<circle cx="8" cy="8" r="7" fill="red" />
42+
</svg>
43+
</div>
44+
}
45+
<RadzenText Text="@ppkconnectionStatus" style="margin-left:5px;" />
46+
</RadzenStack>
47+
48+
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Start">
49+
@if (ConsoleService.IsDeviceOn)
50+
{
51+
<div style="margin-top:-2px;">
52+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
53+
<circle cx="8" cy="8" r="7" fill="green" />
54+
</svg>
55+
</div>
56+
}
57+
else
58+
{
59+
<div style="margin-top:-2px;">
60+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
61+
<circle cx="8" cy="8" r="7" fill="red" />
62+
</svg>
63+
</div>
64+
}
65+
<RadzenText Text="@ppkVoltageStatus" style="margin-left:5px;" />
66+
</RadzenStack>
67+
</RadzenStack>
68+
</RadzenColumn>
69+
</RadzenRow>
70+
71+
@code {
72+
[Parameter] public int LeftMargin { get; set; } = 5;
73+
74+
string getLeftMargin => $"margin-left:{LeftMargin}px;";
75+
bool sidebarExpanded = true;
76+
77+
public string connectionStatus => ConsoleService.IsConsoleListening ? $"JLink Connection Status: Connected" : "JLink Connection Status: Not Connected";
78+
public string ppkconnectionStatus => ConsoleService.IsPPK2Connected() ? $"PPK2 Connection Status: Connected" : "PPK2 Connection Status: Not Connected";
79+
public string ppkVoltageStatus => ConsoleService.IsDeviceOn ? $"PPK2 Voltage On: {ConsoleService.DeviceVoltage} mV " : "PPK2 Voltage Off";
80+
81+
protected override async Task OnInitializedAsync()
82+
{
83+
await base.OnInitializedAsync();
84+
85+
ConsoleService.OnIsJLinkConnected += Refresh;
86+
ConsoleService.OnIsJLinkDisconnected += Refresh;
87+
ConsoleService.OnIsPPKConnected += Refresh;
88+
ConsoleService.OnIsPPKDisconnected += Refresh;
89+
ConsoleService.OnIsPPKVoltageOutputConnected += Refresh;
90+
ConsoleService.OnIsPPKVoltageOutputDisconnected += Refresh;
91+
}
92+
93+
private void Refresh(object sender, bool e)
94+
{
95+
InvokeAsync(StateHasChanged);
96+
}
97+
98+
public async Task ChangeLeftMargin(int margin)
99+
{
100+
LeftMargin = margin;
101+
await InvokeAsync(StateHasChanged);
102+
}
103+
}
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,70 @@
11
@inherits LayoutComponentBase
22

3-
<div class="page">
4-
<div class="sidebar">
5-
<NavMenu />
6-
</div>
3+
@inject TooltipService TooltipService
74

8-
<main>
9-
<div class="top-row px-4">
10-
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
11-
</div>
5+
<RadzenLayout>
6+
<RadzenHeader>
7+
<RadzenRow>
8+
<RadzenColumn>
9+
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" Gap="0" JustifyContent="JustifyContent.Start">
10+
<RadzenSidebarToggle Click="@sidebarToggle" Style="margin-left:4px;" />
11+
<img src="resources/hw_logo_pos.svg" alt="HARDWARIO" style="width:100px;height:100%;" />
12+
</RadzenStack>
13+
</RadzenColumn>
14+
</RadzenRow>
15+
</RadzenHeader>
16+
<RadzenSidebar Responsive="false" Style="width: max-content;height:100%;">
17+
<RadzenStack Orientation="Orientation.Vertical" Style="height:100%;">
18+
<RadzenRow>
19+
<RadzenColumn Style="height:100%;">
20+
<RadzenPanelMenu DisplayStyle="@(sidebarExpanded ? MenuItemDisplayStyle.IconAndText : MenuItemDisplayStyle.Icon)" ShowArrow="false">
21+
<RadzenPanelMenuItem Text="Home" Icon="home" Path="/" MouseEnter="@(args => ShowTooltip(args, new TooltipOptions() { Text = "Home", Position = TooltipPosition.Right }) )" />
22+
<RadzenPanelMenuItem Text="Graph" Icon="monitoring" Path="/graph" MouseEnter="@(args => ShowTooltip(args, new TooltipOptions() { Text = "Counter", Position = TooltipPosition.Right }) )" />
23+
<RadzenPanelMenuItem Text="Configs" Icon="manufacturing" Path="/configs" MouseEnter="@(args => ShowTooltip(args, new TooltipOptions() { Text = "Configs", Position = TooltipPosition.Right }) )" />
24+
</RadzenPanelMenu>
25+
</RadzenColumn>
26+
</RadzenRow>
27+
@if (sidebarExpanded)
28+
{
29+
<RadzenRow Style="height:100%;">
30+
<RadzenColumn Style="height:100%;">
31+
<RadzenStack Style="height: 100%;" Orientation="Orientation.Horizontal" AlignItems="AlignItems.End" JustifyContent="JustifyContent.Center">
32+
<RadzenText Text="@GetVersion()" />
33+
</RadzenStack>
34+
</RadzenColumn>
35+
</RadzenRow>
36+
}
37+
</RadzenStack>
38+
</RadzenSidebar>
39+
<RadzenBody Style="padding:0px;">
40+
@Body
41+
</RadzenBody>
42+
<RadzenFooter>
43+
<Footer @ref=footerRef />
44+
</RadzenFooter>
45+
</RadzenLayout>
1246

13-
<article class="content px-4">
14-
@Body
15-
</article>
16-
</main>
17-
</div>
47+
<RadzenComponents />
48+
49+
@code {
50+
bool sidebarExpanded = true;
51+
Footer? footerRef;
52+
53+
public string GetVersion()
54+
{
55+
return $"Version: {MainDataContext.Config.AppVersion}";
56+
}
57+
58+
private async Task sidebarToggle()
59+
{
60+
sidebarExpanded = !sidebarExpanded;
61+
}
62+
63+
void ShowTooltip(ElementReference elementReference, TooltipOptions options = null)
64+
{
65+
if (!sidebarExpanded)
66+
{
67+
TooltipService.Open(elementReference, options.Text, options);
68+
}
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
@using Services
2+
@page "/configs"
3+
4+
@inject ConsoleService ConsoleService
5+
6+
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center">
7+
<!-- Loading overlay -->
8+
@if (isBusy)
9+
{
10+
<RadzenCard Style="z-index: 3; text-align: center; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, .5)">
11+
<div style="display: flex; justify-content: center; align-items: center; height: 100%; width: 100%;">
12+
<RadzenProgressBarCircular ShowValue="true" Mode="ProgressBarMode.Indeterminate" Size="ProgressBarCircularSize.Medium">
13+
<Template>Wait</Template>
14+
</RadzenProgressBarCircular>
15+
</div>
16+
</RadzenCard>
17+
}
18+
</RadzenStack>
19+
20+
<RadzenLayout Style="height: 100%; grid-template-rows: 1fr; grid-template-columns: 1fr auto; grid-template-areas: 'rz-body rz-sidebar'">
21+
<RadzenSidebar Style="padding: 5px;">
22+
23+
@if (!ConsoleService.IsConsoleListening)
24+
{
25+
<RadzenButton Click="OnInitConsoleHandler" Style="margin-top: 5px; width: 100%;">Init Console</RadzenButton>
26+
}
27+
else
28+
{
29+
<RadzenButton Click="OnInitConsoleHandler" Disabled="true" Style="margin-top: 5px; width: 100%;">Init Console</RadzenButton>
30+
}
31+
32+
<RadzenButton Click="LoadConfigFromDevice" Disabled="@isDisabled" Style="margin-top: 5px; width: 100%;">Load Config From Device</RadzenButton>
33+
34+
</RadzenSidebar>
35+
<RadzenBody>
36+
<RadzenRow Style="height: 100%;">
37+
<RadzenColumn Style="height: 100%;">
38+
39+
<RadzenRow>
40+
<RadzenColumn>
41+
<hio_dotnet.UI.BlazorComponents.Radzen.CHESTER.Configs.LoRa.LoRaWANConfigCompleteForm @ref=LoRaConfigFormRef Config="@ConsoleService.LoRaWANConfig" />
42+
</RadzenColumn>
43+
</RadzenRow>
44+
<RadzenRow>
45+
<RadzenColumn>
46+
<RadzenButton Disabled="@isDisabled" Click="ApplyLoRaSettings">Apply LoRa Settings</RadzenButton>
47+
</RadzenColumn>
48+
</RadzenRow>
49+
50+
</RadzenColumn>
51+
<RadzenColumn Style="height: 100%;">
52+
53+
<RadzenRow>
54+
<RadzenColumn>
55+
<hio_dotnet.UI.BlazorComponents.Radzen.CHESTER.Configs.LTE.LTEConfigCompleteForm @ref=LTEConfigFormRef Config="@ConsoleService.LTEConfig" />
56+
</RadzenColumn>
57+
</RadzenRow>
58+
<RadzenRow>
59+
<RadzenColumn>
60+
<RadzenButton Disabled="@isDisabled" Click="ApplyLTESettings">Apply LTE Settings</RadzenButton>
61+
</RadzenColumn>
62+
</RadzenRow>
63+
64+
</RadzenColumn>
65+
</RadzenRow>
66+
</RadzenBody>
67+
</RadzenLayout>
68+
69+
70+
@code {
71+
private bool isBusy = false;
72+
private bool isDisabled = false;
73+
74+
hio_dotnet.UI.BlazorComponents.Radzen.CHESTER.Configs.LoRa.LoRaWANConfigCompleteForm? LoRaConfigFormRef;
75+
hio_dotnet.UI.BlazorComponents.Radzen.CHESTER.Configs.LTE.LTEConfigCompleteForm? LTEConfigFormRef;
76+
77+
78+
public int Voltage { get; set; } = 3300;
79+
80+
protected override void OnInitialized()
81+
{
82+
ConsoleService.InitArrays();
83+
ConsoleService.NewRTTMessageLineReceived += NewLineReceived;
84+
ConsoleService.OnIsBusy += (s, e) =>
85+
{
86+
isBusy = e;
87+
Refresh();
88+
};
89+
90+
ConsoleService.OnIsJLinkConnected += (s, e) =>
91+
{
92+
isDisabled = false;
93+
InvokeAsync(StateHasChanged);
94+
};
95+
ConsoleService.OnIsJLinkDisconnected += (s, e) =>
96+
{
97+
isDisabled = true;
98+
InvokeAsync(StateHasChanged);
99+
};
100+
101+
if (ConsoleService.IsConsoleListening)
102+
{
103+
isDisabled = false;
104+
}
105+
else
106+
{
107+
isDisabled = true;
108+
}
109+
}
110+
111+
protected override async Task OnParametersSetAsync()
112+
{
113+
if (ConsoleService.IsConsoleListening)
114+
{
115+
isDisabled = false;
116+
}
117+
else
118+
{
119+
isDisabled = true;
120+
}
121+
await base.OnParametersSetAsync();
122+
}
123+
124+
public async Task Refresh()
125+
{
126+
await InvokeAsync(StateHasChanged);
127+
}
128+
129+
public async Task OnInitConsoleHandler()
130+
{
131+
await ConsoleService.StartListening();
132+
}
133+
134+
135+
public void NewLineReceived(object sender, Tuple<string, MultiRTTClientBase> data)
136+
{
137+
if (data?.Item2.Channel == 0)
138+
{
139+
InvokeAsync(async () =>
140+
{
141+
await InvokeAsync(StateHasChanged);
142+
});
143+
}
144+
}
145+
146+
private async Task ApplyLoRaSettings()
147+
{
148+
await ConsoleService.ApplyLoRaSettings();
149+
}
150+
151+
private async Task ApplyLTESettings()
152+
{
153+
await ConsoleService.ApplyLTESettings();
154+
}
155+
156+
private async Task HandleSendCommand(string command)
157+
{
158+
await ConsoleService.SendCommand(command.ToLower().Trim() + "\n");
159+
}
160+
161+
private async Task LoadConfigFromDevice()
162+
{
163+
await ConsoleService.SendCommand("config show\n");
164+
}
165+
166+
}

hio-dotnet.Demos.HardwarioMonitor/Components/Pages/Counter.razor

-16
This file was deleted.

0 commit comments

Comments
 (0)