diff --git a/App.razor b/App.razor index 6fd3ed1..bc45625 100644 --- a/App.razor +++ b/App.razor @@ -1,12 +1,14 @@ - - - - - - - Not found - -

Sorry, there's nothing at this address.

-
-
-
+ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
+
\ No newline at end of file diff --git a/Components/RTD8TMChanelComponent.razor b/Components/RTD8TMChanelComponent.razor new file mode 100644 index 0000000..c64fe9d --- /dev/null +++ b/Components/RTD8TMChanelComponent.razor @@ -0,0 +1,84 @@ +@using Blazored.Modal.Services +@using UI_SequentMicrosystems.Components +@using UI_SequentMicrosystems.Constants +@using UI_SequentMicrosystems.Services +@using Blazored.Modal + + +
+
@(RecalculateValues(RTD8tmService.GetActualData(StackID, ChanelID), RTD8tmService.GetValueType(StackID, ChanelID)))
+ + @if (Edit) + { +
@(ValueType(RTD8tmService.GetValueType(StackID, ChanelID)))
+ } + else + { +
@(ValueType(RTD8tmService.GetValueType(StackID, ChanelID)))
+ } + + @if (Edit) + { +
+ +
+ } + else + { +
@(RTD8tmService.GetChanelName(StackID, ChanelID))
+ } + +
+ + +@code { + + [Parameter] + public byte StackID { get; set; } + + [Parameter] + public byte ChanelID { get; set; } + + [Parameter] + public bool Edit { get; set; } + + [Parameter] + public RTD8TMService RTD8tmService { get; set; } + + private string ModalTitle = "Select value Type"; + [CascadingParameter] public IModalService Modal { get; set; } = default!; + + /// + /// Internal event for Name Change + /// + /// + private void ChangeName(string NewName) + { + RTD8tmService.SetChanelNames(StackID, ChanelID, NewName); + } + + + + private float RecalculateValues(float resistance, byte Type = 0) + { + if (Type == RTD8TMSensorTypes.PT100) + { + return (float)Math.Round(Calculations.Electric.RTD.PT100.ResistanceToTemperature(resistance), 2); + } + else + { + return resistance; + } + } + private string ValueType(byte Type) + { + if (Type == RTD8TMSensorTypes.PT100) + { + return "°C"; + } + else + { + return "Ω"; + } + } +} diff --git a/Components/RTD8TMSensorTypeModal.razor b/Components/RTD8TMSensorTypeModal.razor new file mode 100644 index 0000000..9b50c2c --- /dev/null +++ b/Components/RTD8TMSensorTypeModal.razor @@ -0,0 +1,44 @@ +@using Blazored.Modal +@using Blazored.Modal.Services +@using UI_SequentMicrosystems.Constants +@using UI_SequentMicrosystems.Services + +@inject RTD8TMService _RTD8TMService + +
+
+ +
+
+ +
+ + + + + +
+ + + + + +@code { + [CascadingParameter] BlazoredModalInstance BlazoredModal { get; set; } = default!; + + [Parameter] + public byte StackID { get; set; } + + [Parameter] + public byte ChanelID { get; set; } + + private void Select(byte type) + { + _RTD8TMService.SetValueType(StackID, ChanelID, type); + SubmitForm(); + } + + private async void SubmitForm() => await BlazoredModal.CloseAsync(); + + +} diff --git a/Constants/RTD8TMSensorTypes.cs b/Constants/RTD8TMSensorTypes.cs new file mode 100644 index 0000000..dba00ce --- /dev/null +++ b/Constants/RTD8TMSensorTypes.cs @@ -0,0 +1,16 @@ + +namespace UI_SequentMicrosystems.Constants +{ + public static class RTD8TMSensorTypes + { + public readonly static byte Resistance = 0; + public readonly static byte PT100 = 1; + + + + + + + + } +} diff --git a/Layout/NavMenu.razor b/Layout/NavMenu.razor index 2d89f45..716cc77 100644 --- a/Layout/NavMenu.razor +++ b/Layout/NavMenu.razor @@ -15,7 +15,7 @@ diff --git a/Pages/Counter.razor b/Pages/Counter.razor deleted file mode 100644 index 8f420e8..0000000 --- a/Pages/Counter.razor +++ /dev/null @@ -1,34 +0,0 @@ -@page "/counter" -@using UI_SequentMicrosystems.Services - -@inject NavigationManager Navigator -@inject RTD8TMService _RTD8TMService - -Counter - -

Counter

-

@Navigator.BaseUri --> @address

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - - } - private string address = ""; - - protected override void OnInitialized() - { - _RTD8TMService.SetAddress(Navigator.BaseUri); - - - - - } -} diff --git a/Pages/RTD8TMPage.razor b/Pages/RTD8TMPage.razor new file mode 100644 index 0000000..cb6d3f3 --- /dev/null +++ b/Pages/RTD8TMPage.razor @@ -0,0 +1,95 @@ +@page "/RTD8TM" +@using Blazored.Modal.Services +@using UI_SequentMicrosystems.Components +@using UI_SequentMicrosystems.Services +@using Blazored.Modal + +@inject NavigationManager Navigator +@inject RTD8TMService _RTD8TMService + +Temperature + + +
+
Device Address: @_RTD8TMService.GetAddress() | DataUpdate: @_UpdateCounter |
+
+
+ @if (EditName) + { + + } + else + { + + } + +
+
+ @if (EditName) + { +
+ +
+
+ +
+ } +
+ +
+
+
+ 1 - Future Graph +
+
+
+
+ @foreach(byte StackID in _RTD8TMService.GetActualData().Keys) + { +
+
Stack ID: @StackID
+ @for (byte chanel = 0; chanel < 8; chanel++) + { + + } +
+ } +
+
+
+ + + +@code { + public int _UpdateCounter = 0; + private bool EditName = false; + + [CascadingParameter] public IModalService Modal { get; set; } = default!; + + protected override void OnInitialized() + { + _RTD8TMService.SetAddress("http://10.1.20.5/");//Navigator.BaseUri); + _RTD8TMService.EventUpdateValues += UpdateView; + } + + public async Task UpdateView(object? o, bool b) + { + await InvokeAsync(() => + { + StateHasChanged(); + _UpdateCounter++; + }); + } + + + + + + + +} diff --git a/Pages/Start.razor b/Pages/Start.razor index 41c8cb9..fc2f45e 100644 --- a/Pages/Start.razor +++ b/Pages/Start.razor @@ -17,7 +17,7 @@ Welcome to your new app. protected override void OnInitialized() { - _RTD8TMService.SetAddress(Navigator.BaseUri); + _RTD8TMService.SetAddress("http://10.1.20.5/");// Navigator.BaseUri); diff --git a/Program.cs b/Program.cs index 8d2c4bd..40445fa 100644 --- a/Program.cs +++ b/Program.cs @@ -1,3 +1,4 @@ +using Blazored.Modal; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using UI_SequentMicrosystems.Services; @@ -12,6 +13,7 @@ namespace UI_SequentMicrosystems builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); + builder.Services.AddBlazoredModal(); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddSingleton(); diff --git a/Services/RTD8TMService.cs b/Services/RTD8TMService.cs index 9e03bc6..b3f4630 100644 --- a/Services/RTD8TMService.cs +++ b/Services/RTD8TMService.cs @@ -6,9 +6,9 @@ namespace UI_SequentMicrosystems.Services { public class RTD8TMService { - private SortedList ChanelNames = new SortedList(); private SortedList ActualValues = new SortedList(); + private SortedList ValuesType = new SortedList(); private List GraphData = new(); private byte GraphDataCounterCount = 10; private byte GraphDataCounter = 0; @@ -18,6 +18,8 @@ namespace UI_SequentMicrosystems.Services private RTD8TM _RTD8TM = new RTD8TM(); private System.Timers.Timer _timer = new(1000); + public delegate Task AsyncEventHandler(object? sender, TEventArgs? e); + public event AsyncEventHandler? EventUpdateValues; public RTD8TMService() { @@ -37,6 +39,7 @@ namespace UI_SequentMicrosystems.Services { Address = address; GetChanelsNames(); + GetValueTypes(); } /// @@ -55,13 +58,15 @@ namespace UI_SequentMicrosystems.Services } } + //Actual Data + /// /// Read Actual values from Device /// - public async void GetActualValues() + private async void GetActualValues() { if (Address == null) { return; } - + ActualValues = await _RTD8TM.Get(Address); if (GraphDataCounter >= GraphDataCounterCount) @@ -73,9 +78,37 @@ namespace UI_SequentMicrosystems.Services { GraphDataCounter++; } - } + /// + /// Request for actual data + /// + /// + public SortedList GetActualData() + { + return ActualValues; + } + + /// + /// Get actual data Value + /// + /// Stack ID + /// Chanel ID + /// Measure Resistance + public float GetActualData(byte stack, byte chanel) + { + if (ActualValues.ContainsKey(stack)) + { + return ActualValues[stack][chanel]; + } + else + { + return 0; + } + } + + //ChanelsNames + /// /// Read configured chanels Names from Device /// @@ -93,11 +126,9 @@ namespace UI_SequentMicrosystems.Services /// /// chanels names sorted list #pragma warning disable CS1998 // V této asynchronní metodě chybí operátory await a spustí se synchronně. - public async Task SetChanelsNames(SortedList names) + public async Task SetChanelsNames() #pragma warning restore CS1998 // V této asynchronní metodě chybí operátory await a spustí se synchronně. { - ChanelNames = names; - if (Address == null) return; @@ -114,6 +145,11 @@ namespace UI_SequentMicrosystems.Services foreach (byte key in ActualValues.Keys) { + if (!ChanelNames.ContainsKey(key)) + { + ChanelNames.Add(key, new string[8]); + } + for (int i = 0; i < 8; i++) { if (ChanelNames[key][i] == null) @@ -124,16 +160,152 @@ namespace UI_SequentMicrosystems.Services } } + /// + /// Get chanel names + /// + /// Chanels names object + public SortedList GetChanelNames() + { + return ChanelNames; + } - private void TimerElapsed(object? o, ElapsedEventArgs? e) + /// + /// Set chanel Name + /// + /// Stack ID + /// Chanel ID + /// New Name + public void SetChanelNames(byte stack, byte chanel, string name) + { + if (!ChanelNames.ContainsKey(stack)) + { + ChanelNames.Add(stack, new string[8]); + } + + ChanelNames[stack][chanel] = name; + } + + /// + /// Read chanel name + /// + /// Stack ID + /// Chanel ID + /// Chanel name + public string GetChanelName(byte stack, byte chanel) + { + if (ChanelNames.ContainsKey(stack)) + { + return ChanelNames[stack][chanel]; + } + else + { + return "----------"; + } + } + + /// + /// Clear chanels Names to default + /// + public void ClearChanelNames() + { + ChanelNames.Clear(); + AutoUpdateChanelsName(); + } + + //Timer + + private async void TimerElapsed(object? o, ElapsedEventArgs? e) { GetActualValues(); AutoUpdateChanelsName(); + + if (EventUpdateValues != null) + { + await EventUpdateValues.Invoke(this, true); + } + } + + //Graph Data + + /// + /// Get data for graph visualize + /// + /// saved Graphn Data + public List GetGraphData() + { + return GraphData; + } + + /// + /// Clear data from Graph + /// + public void ClearGraph() + { + GraphData.Clear(); } + //Values Types + /// + /// Set Value Type identifier + /// + /// Stack ID + /// Chanel ID + /// Value Type + public void SetValueType(byte StackID, byte ChanelID, byte Type) + { + if (!ValuesType.ContainsKey(StackID)) + { + ValuesType.Add(StackID, new byte[8]); + } + + ValuesType[StackID][ChanelID] = Type; + } + + /// + /// Get Value Type + /// + /// Stack ID + /// Chanel ID + /// Value Type + public byte GetValueType(byte StackID, byte ChanelID) + { + if (ValuesType.ContainsKey(StackID)) + { + return ValuesType[StackID][ChanelID]; + } + else + { + return 0; + } + } + + /// + /// Get ValueTypes From API + /// + public async void GetValueTypes() + { + if (Address == null) { return; } + + ValuesType = await _RTD8TM.GetValueTypes(Address); + } + + /// + /// Post ValueTypes to API + /// + public void PostValueTypes() + { + if (Address == null) { return; } + + _RTD8TM.PostValueTypes(Address, ValuesType); + } + + public void ClearValueTypes() + { + ValuesType.Clear(); + } } diff --git a/UI_SequentMicrosystems.csproj b/UI_SequentMicrosystems.csproj index 7127504..fd8339f 100644 --- a/UI_SequentMicrosystems.csproj +++ b/UI_SequentMicrosystems.csproj @@ -8,11 +8,13 @@ + + diff --git a/UI_SequentMicrosystems.sln b/UI_SequentMicrosystems.sln index 644383d..dc519c1 100644 --- a/UI_SequentMicrosystems.sln +++ b/UI_SequentMicrosystems.sln @@ -3,15 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UI_SequentMicrosystems", "UI_SequentMicrosystems.csproj", "{5CA9656E-173B-495E-8407-209AE67BAA13}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UI_SequentMicrosystems", "UI_SequentMicrosystems.csproj", "{5CA9656E-173B-495E-8407-209AE67BAA13}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wrapper_Api_SequentMicrosystems", "..\Wrapper_Api_SequentMicrosystems\Wrapper_Api_SequentMicrosystems.csproj", "{54BC70B0-BE0E-4C2C-8DE2-7A9BEA7C0E94}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wrapper_Api_SequentMicrosystems", "..\Wrapper_Api_SequentMicrosystems\Wrapper_Api_SequentMicrosystems.csproj", "{54BC70B0-BE0E-4C2C-8DE2-7A9BEA7C0E94}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DEAA95EC-24FE-42EC-B078-723C4A6173E6}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Calculations", "..\CalculationsLib\Calculations.csproj", "{67349A12-2544-4A15-93F6-AC6E039F5F52}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,6 +28,10 @@ Global {54BC70B0-BE0E-4C2C-8DE2-7A9BEA7C0E94}.Debug|Any CPU.Build.0 = Debug|Any CPU {54BC70B0-BE0E-4C2C-8DE2-7A9BEA7C0E94}.Release|Any CPU.ActiveCfg = Release|Any CPU {54BC70B0-BE0E-4C2C-8DE2-7A9BEA7C0E94}.Release|Any CPU.Build.0 = Release|Any CPU + {67349A12-2544-4A15-93F6-AC6E039F5F52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67349A12-2544-4A15-93F6-AC6E039F5F52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67349A12-2544-4A15-93F6-AC6E039F5F52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67349A12-2544-4A15-93F6-AC6E039F5F52}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/wwwroot/css/Custom.css b/wwwroot/css/Custom.css index ae9a2ef..d008172 100644 --- a/wwwroot/css/Custom.css +++ b/wwwroot/css/Custom.css @@ -4,6 +4,18 @@ } +.graybg { + background: gray; + color: yellow; +} + + +.no-border { + border: 0; + box-shadow: none; /* You may want to include this as bootstrap applies these styles too */ +} + + @@ -11,8 +23,3 @@ - - - - -