From 8d979b89fc3920ab4bbbdf65bf899c1957047d61 Mon Sep 17 00:00:00 2001 From: PTKu Date: Tue, 2 May 2023 12:54:07 +0200 Subject: [PATCH 1/4] Create draft PR for #168 From 28ccdc099074bc8591953326b7706854d9e32caf Mon Sep 17 00:00:00 2001 From: Peter <61538034+PTKu@users.noreply.github.com> Date: Tue, 2 May 2023 12:54:57 +0200 Subject: [PATCH 2/4] add polling for rcc on init and releases on dispose as before --- .../RenderableContent/RenderableContentControl.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.cs b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.cs index 87b29af2..33929c2a 100644 --- a/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.cs +++ b/src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.cs @@ -29,7 +29,12 @@ namespace AXSharp.Presentation.Blazor.Controls.RenderableContent public partial class RenderableContentControl : ComponentBase, IDisposable { private string _presentation; - + + /// + /// Gets or sets polling interval for this control and nested controls. + /// [!NOTE] Nested element can have different polling setting that will override this property. + /// + [Parameter] public int PollingInterval { get; set; } = 250; /// /// Parameter Context accept ITwinElement instance, which is used as base model for UI generation. @@ -87,6 +92,7 @@ protected override void OnInitialized() try { _context = (ITwinElement)Context; + _context.StartPolling(this.PollingInterval); } catch { @@ -368,6 +374,7 @@ private string GetDisplayPresentationIfEmpty() public virtual void Dispose() { + _context?.StopPolling(); _viewModelCache.ResetCounter(); } } From 3695b3190ec1ff249611ce06336ccf5f52233cdd Mon Sep 17 00:00:00 2001 From: PTKu Date: Thu, 4 May 2023 10:36:26 +0200 Subject: [PATCH 3/4] Create draft PR for #170 From 09e17b2ab46d3d5b77742834bf14f8924a62fa5f Mon Sep 17 00:00:00 2001 From: Peter <61538034+PTKu@users.noreply.github.com> Date: Thu, 4 May 2023 10:39:16 +0200 Subject: [PATCH 4/4] LTIME to ms range unable to use full range not settable in plc --- .../BuiltInWrappers/WebApiLTime.cs | 26 +++++++++++++++---- .../ValueTypes/Onlines/OnlinerLTime.cs | 4 +-- .../tests/ax-test-project/src/program.st | 6 +++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/BuiltInWrappers/WebApiLTime.cs b/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/BuiltInWrappers/WebApiLTime.cs index 1f298a11..c496e98d 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/BuiltInWrappers/WebApiLTime.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/BuiltInWrappers/WebApiLTime.cs @@ -59,27 +59,43 @@ ApiPlcWriteRequest IWebApiPrimitive.PlcWriteRequestData get { // TODO: review this casting to string... reason: there is some problem while creating request from long. - _plcWriteRequestData = WebApiConnector.CreateWriteRequest(Symbol, CyclicToWrite.Ticks.ToString(), _webApiConnector.DBName); + _plcWriteRequestData = WebApiConnector.CreateWriteRequest(Symbol, ToMicroSeconds(CyclicToWrite), _webApiConnector.DBName); return _plcWriteRequestData; } } /// - public void Read(string value) + public void Read(string result) { - UpdateRead(TimeSpan.FromTicks(long.Parse(value))); + UpdateRead(TimeSpan.FromMilliseconds(ToMilliseconds(long.Parse(result)))); + } + + + private long ToMilliseconds(long nanoseconds) + { + return nanoseconds / 1000000L; + } + + private long ToNanoseconds(long nanoseconds) + { + return nanoseconds * 1000000L; + } + + private string ToMicroSeconds(TimeSpan value) + { + return ToNanoseconds((long)value.TotalMilliseconds).ToString(); } /// public override async Task GetAsync() { - return TimeSpan.FromTicks(long.Parse(await _webApiConnector.ReadAsync(this))); + return TimeSpan.FromMilliseconds(ToMilliseconds(long.Parse(await _webApiConnector.ReadAsync(this)))); } /// public override async Task SetAsync(TimeSpan value) { - await _webApiConnector.WriteAsync(this, value.Ticks.ToString()); + await _webApiConnector.WriteAsync(this, ToNanoseconds((long)value.TotalMilliseconds).ToString()); return value; } } \ No newline at end of file diff --git a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLTime.cs b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLTime.cs index caea1d72..f4dd2fe5 100644 --- a/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLTime.cs +++ b/src/AXSharp.connectors/src/AXSharp.Connector/ValueTypes/Onlines/OnlinerLTime.cs @@ -40,12 +40,12 @@ public OnlinerLTime(ITwinObject parent, string readableTail, string symbolTail) /// /// Gets the max value of . /// - public static TimeSpan MaxValue { get; } = TimeSpan.FromTicks(9223372036854775807 / 100); + public static TimeSpan MaxValue { get; } = TimeSpan.FromTicks(92233720368540000); /// /// Gets the min value of . /// - public static TimeSpan MinValue { get; } = TimeSpan.FromTicks(-9223372036854775808 / 100); + public static TimeSpan MinValue { get; } = TimeSpan.FromTicks(-92233720368540000); /// /// Gets the max value for this instance. diff --git a/src/AXSharp.connectors/tests/ax-test-project/src/program.st b/src/AXSharp.connectors/tests/ax-test-project/src/program.st index ee6fabf4..0e6190f0 100644 --- a/src/AXSharp.connectors/tests/ax-test-project/src/program.st +++ b/src/AXSharp.connectors/tests/ax-test-project/src/program.st @@ -62,7 +62,7 @@ PROGRAM MyProgram mins.myREAL := REAL#-3.402823e+38 ; mins.myLREAL := LREAL#-1.79769313486231e+308; mins.myTIME := TIME#-106751d23h47m16s854ms; - mins.myLTIME := LTIME#-1067d12h28m40s368ms547us758ns; + mins.myLTIME := LTIME#-106751d23h47m16s854ms; mins.myDATE := DATE#1970-01-01 ; mins.myLDATE := LDATE#1970-01-01 ; mins.myTIME_OF_DAY := TOD#0:0:0.0 ; @@ -91,7 +91,9 @@ PROGRAM MyProgram maxs.myREAL := REAL#+3.402823e+38 ; maxs.myLREAL := LREAL#1.79769313486231e+308; maxs.myTIME := TIME#106751d23h47m16s854ms; - maxs.myLTIME := LTIME#1067d12h28m40s368ms547us758ns; + maxs.myLTIME := LTIME#106751d23h47m16s854ms; + maxs.myLTIME := LTIME#106751d23h47m16s854ms; + // maxs.myLTIME := LTIME#1067d12h28m40s368ms547us758ns; maxs.myDATE := DATE#2262-04-11 ; maxs.myLDATE := LDATE#2262-04-11 ; maxs.myTIME_OF_DAY := TOD#23:59:59.999000000 ;