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 ;