Skip to content

[Feature] Bulk reading in smaller chunks with inter-dealy #407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 31, 2025

Conversation

PTKu
Copy link
Contributor

@PTKu PTKu commented May 30, 2025

This pull request introduces significant enhancements to the WebAPI connector, focusing on batch operations, improved prioritization, and better handling of communication with Siemens S7 PLCs. It also includes code cleanup and documentation updates for better maintainability and usability.

Enhancements to Batch Operations:

  • Added support for enhanced batch reading and writing operations with configurable priority levels (eAccessPriority) and chunk settings. This allows for optimized data exchange with PLCs. (docfx/articles/connectors/WebAPI.md, src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs) [1] [2] [3] [4] [5] [6]

Code Cleanup:

  • Removed unused imports to streamline the codebase in WebApiConnector.cs. (src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs) [1] [2]

Improved Documentation:

  • Updated XML comments for constructors and methods in WebApiConnector to provide clearer descriptions and default values for parameters. (src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs) [1] [2] [3] [4] [5] [6] [7] [8]

Throttling and Concurrency Management:

  • Introduced a SemaphoreSlim for managing concurrent requests, replacing the obsolete anti-throttling methods. (src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs) [1] [2] [3] [4]

Error Handling:

  • Added a method to handle communication failures during batch operations, logging errors and attempting recovery from permission changes. (src/AXSharp.connectors/src/AXSharp.Connector.S71500.WebAPI/WebApiConnector.cs)

closes #406

@PTKu PTKu linked an issue May 30, 2025 that may be closed by this pull request
PTKu added 6 commits May 30, 2025 14:28
Introduce a `_throttle` field using `SemaphoreSlim` to manage concurrent requests based on `ConcurrentRequestMaxCount`. Add `AntiThrottling` and `ReleaseConcurrent` methods to handle semaphore operations without parameters, simplifying the code. These changes improve the efficiency and reliability of handling multiple requests.
- Updated `TestConnector.cs` to use hardcoded values for credentials and modified `CertificatePath`.
- Added new configuration sections for `HardwareIDs` and `IoAddresses` in `plc_line_HwIdentifiers.st` and `plc_line_IoAddresses.st`.
- Significant updates to `apax-lock.json` and `apax.yml` to reflect new dependencies and versions.
- Added new certificate files for secure communication.
- Created `plc_line.HardwareIdentifiers.json` and `plc_line.IoAddresses.json` for structured data storage.
- Updated multiple YAML files for Siemens PLCs with new templates, service parameters, and user management roles.
- Modified security configuration with updates to `server.csr` and `server_cert_ext.cnf`.
This commit introduces an `eAccessPriority` parameter to the asynchronous methods in the `WebApiConnector`, `Connector`, and `DummyConnector` classes, allowing for prioritized access when reading and writing batches of `ITwinPrimitive` items. A new enumeration for access priorities has been added in `AccessPriority.cs`, defining levels: `Normal`, `Low`, and `Prioritare`. Method signatures for `ReadBatchAsync` and `WriteBatchAsync` have been updated accordingly, and the implementations of cyclic methods have been modified to support the new parameter. Additionally, test files have been updated to reflect these changes, and unused `using` directives have been removed from `WebApiConnector.cs` for cleaner code.
@PTKu PTKu marked this pull request as ready for review May 31, 2025 11:39
@PTKu PTKu marked this pull request as draft May 31, 2025 11:39
Refactor bulk read and write test methods to use custom access priority.
Renamed methods to reflect the change:
- `should_bulk_read_low_priority_with_alternating_parameters`
  to `should_bulk_read_custom_priority_with_alternating_parameters`
- `should_bulk_write_low_priority_with_alternating_parameters`
  to `should_bulk_write_custom_priority_with_alternating_parameters`.
Updated `ReadBatchAsync` and `WriteBatchAsync` calls to use
`eAccessPriority.Custom` instead of `eAccessPriority.Low`.
@PTKu PTKu marked this pull request as ready for review May 31, 2025 12:17
@PTKu PTKu merged commit a0101e1 into dev May 31, 2025
2 checks passed
@PTKu PTKu deleted the 406-feature-bulk-reading-in-smaller-chunks-with-inter-dealy branch May 31, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Bulk reading in smaller chunks with inter-dealy
1 participant