Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion docfx/articles/connectors/WebAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,19 @@ Entry.Plc.Connector.SetLoggerConfiguration(new LoggerConfiguration()
```

> [!WARNING]
> **Enabling monitoring will impact the connector perfomance.**
> **Enabling monitoring will impact the connector perfomance.**

## Performance

Communication via WebAPI has inherent performance constraints based on the target system, request frequency, and payload size. The S71500.WebAPI connector tackles the 64kB limit for single requests by fragmenting them into manageable chunks. However, there is a restriction on the number of requests that can be sent to the controller simultaneously. The maximum threshold is four simultaneous requests, though this can be reduced. Any requests exceeding this limit will be queued and processed after a specified waiting period.

> [!NOTE]
> It's worth noting that the controller might be communicating with other devices like HMI or OPC-UA, further intensifying the overall communication load.

Here's a C# code snippet demonstrating how to adjust the concurrent request limit and the associated delay:

```C#
Entry.Plc.Connector.ConcurrentRequestMaxCount = 1; // Reducing to a single request
Entry.Plc.Connector.ConcurrentRequestDelay = 100; // Setting the waiting period to 100ms
```

Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void Read(string value)
/// <inheritdoc />
public override async Task<DateOnly> GetAsync()
{
var dt = await _webApiConnector.ReadAsync<long>(this);
return GetFromBinary(dt);
return await _webApiConnector.ReadAsync<DateOnly>(this);
}

private DateOnly GetFromBinary(string value)
Expand All @@ -100,7 +99,6 @@ private string GetFromDate(DateOnly date)
/// <inheritdoc />
public override async Task<DateOnly> SetAsync(DateOnly value)
{
await _webApiConnector.WriteAsync(this, GetFromDate(value));
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void Read(string value)
/// <inheritdoc />
public override async Task<DateTime> GetAsync()
{
var dt = await _webApiConnector.ReadAsync<long>(this);
return GetFromBinary(dt);
return await _webApiConnector.ReadAsync<DateTime>(this);
}

private DateTime GetFromBinary(string val)
Expand All @@ -99,7 +98,6 @@ private string GetFromDate(DateTime dateTime)
/// <inheritdoc />
public override async Task<DateTime> SetAsync(DateTime value)
{
await _webApiConnector.WriteAsync(this, GetFromDate(value));
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void Read(string value)
/// <inheritdoc />
public override async Task<DateOnly> GetAsync()
{
var dt = await _webApiConnector.ReadAsync<long>(this);
return GetFromBinary(dt);
return await _webApiConnector.ReadAsync<DateOnly>(this);
}


Expand Down Expand Up @@ -101,7 +100,6 @@ private string GetFromDate(DateOnly date)
/// <inheritdoc />
public override async Task<DateOnly> SetAsync(DateOnly value)
{
await _webApiConnector.WriteAsync(this, GetFromDate(value));
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ public void Read(string value)
/// <inheritdoc />
public override async Task<DateTime> GetAsync()
{
var dt = await _webApiConnector.ReadAsync<long>(this);
return GetFromBinary(dt);
return await _webApiConnector.ReadAsync<DateTime>(this);
}

private DateTime GetFromBinary(string val)
Expand All @@ -100,7 +99,6 @@ private string GetFromDate(DateTime dateTime)
/// <inheritdoc />
public override async Task<DateTime> SetAsync(DateTime value)
{
await _webApiConnector.WriteAsync(this, GetFromDate(value));
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public override async Task<long> GetAsync()
/// <inheritdoc />
public override async Task<long> SetAsync(long value)
{
await _webApiConnector.WriteAsync(this, value.ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Third party licenses: https://github.com/ix-ax/axsharp/blob/master/notices.md

using AXSharp.Connector.ValueTypes;
using Newtonsoft.Json.Linq;

namespace AXSharp.Connector.S71500.WebApi;

Expand Down Expand Up @@ -89,13 +90,12 @@ private string ToMicroSeconds(TimeSpan value)
/// <inheritdoc />
public override async Task<TimeSpan> GetAsync()
{
return TimeSpan.FromMilliseconds(ToMilliseconds(long.Parse(await _webApiConnector.ReadAsync<string>(this))));
return await _webApiConnector.ReadAsync<TimeSpan>(this);
}

/// <inheritdoc />
public override async Task<TimeSpan> SetAsync(TimeSpan value)
{
await _webApiConnector.WriteAsync(this, ToNanoseconds((long)value.TotalMilliseconds).ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ public void Read(string value)
/// <inheritdoc />
public override async Task<TimeSpan> GetAsync()
{
return TimeSpan.FromMilliseconds(long.Parse(await _webApiConnector.ReadAsync<string>(this)) / 1000000);
return await _webApiConnector.ReadAsync<TimeSpan>(this);
}

/// <inheritdoc />
public override async Task<TimeSpan> SetAsync(TimeSpan value)
{
await _webApiConnector.WriteAsync(this, ((long)value.TotalMilliseconds * 1000000).ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ public void Read(string result)
/// <inheritdoc />
public override async Task<ulong> GetAsync()
{
return await _webApiConnector.ReadAsync(this, LastValue);
return await _webApiConnector.ReadAsync<ulong>(this);
}

/// <inheritdoc />
public override async Task<ulong> SetAsync(ulong value)
{
await _webApiConnector.WriteAsync(this, value.ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,12 @@ private string ToMicroSeconds(TimeSpan value)
/// <inheritdoc />
public override async Task<TimeSpan> GetAsync()
{
return TimeSpan.FromMilliseconds(ToMilliseconds(long.Parse(await _webApiConnector.ReadAsync<string>(this))));
return await _webApiConnector.ReadAsync<TimeSpan>(this);
}

/// <inheritdoc />
public override async Task<TimeSpan> SetAsync(TimeSpan value)
{
await _webApiConnector.WriteAsync(this, ToNanoseconds((long)value.TotalMilliseconds).ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,12 @@ public void Read(string result)
/// <inheritdoc />
public override async Task<TimeSpan> GetAsync()
{
return TimeSpan.FromMilliseconds(long.Parse(await _webApiConnector.ReadAsync<string>(this)) / 1000000);
return await _webApiConnector.ReadAsync<TimeSpan>(this);
}

/// <inheritdoc />
public override async Task<TimeSpan> SetAsync(TimeSpan value)
{
await _webApiConnector.WriteAsync(this, ((long)value.TotalMilliseconds * 1000000).ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public override async Task<ulong> GetAsync()
/// <inheritdoc />
public override async Task<ulong> SetAsync(ulong value)
{
await _webApiConnector.WriteAsync(this, value.ToString());
return value;
return await _webApiConnector.WriteAsync(this, value);
}
}
Loading