Rtop 106 create multiple addr access debug function#37
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new debug function for accessing multiple variable addresses simultaneously, along with supporting functions for variable size retrieval and value manipulation. The implementation provides a Python API wrapper around C functions that enable batch retrieval of variable addresses from the debug system.
Key changes:
- Added
get_var_listfunction to retrieve multiple variable addresses in a single call - Implemented helper functions for variable size queries and type inference
- Extended Python plugin interface with methods for reading/writing variable values based on size
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/drivers/plugins/python/shared/python_plugin_types.py | Adds Python wrapper methods for the new debug API including get_var_list, get_var_size, get_var_value, set_var_value, and get_var_info |
| core/src/drivers/plugin_utils.h | Declares C function prototypes for get_var_list and get_var_size |
| core/src/drivers/plugin_utils.c | Implements wrapper functions that interface with the existing debug system |
| core/src/drivers/plugin_driver.h | Extends the plugin runtime args structure with new function pointers |
| core/src/drivers/plugin_driver.c | Initializes the new function pointers in the plugin args structure |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ttps://github.com/Autonomy-Logic/openplc-runtime into RTOP-106-Create-multiple-addr-access-debug-function
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| # Singleton instance | ||
| _buffer_types_instance = None | ||
|
|
||
| def get_buffer_types() -> BufferTypes: | ||
| """Get the singleton BufferTypes instance""" | ||
| global _buffer_types_instance | ||
| if _buffer_types_instance is None: | ||
| _buffer_types_instance = BufferTypes() | ||
| return _buffer_types_instance |
There was a problem hiding this comment.
é realmente necessário esta abordagem singleton? caso não forem mutáveis, usar algo como:
BUFFER_TYPES = {
'bool': BoolBufferType(),
'byte': ByteBufferType(),
# ...
}
|
python_plugin_types.py não foi modificado neste RTOP mas ele é um arquivo GIGANTE, talvez separar em pequenos arquivos |
O arquivo from shared.python_plugin_types import (
SafeBufferAccess
)Para from shared import SafeBufferAccess |
This pull request introduces several enhancements and refactoring to the OpenPLC core and Python plugin infrastructure, focusing on improved buffer access, batch operation support, and clearer API definitions. The most significant changes include the addition of new utility functions for variable access in the C core, a comprehensive refactored Python buffer access API, and the implementation of a batch processor for efficient buffer operations. These updates aim to improve performance, maintain backward compatibility, and provide clearer extension points for plugin developers.
C Core Enhancements
Plugin variable access utilities:
get_var_list,get_var_size,get_var_count) inplugin_utils.cand exposed them viaplugin_utils.hfor structured variable access from plugins. These functions are now integrated into the plugin driver argument structure and initialization, enabling plugins to query variable addresses, sizes, and counts in a standardized way. [1] [2] [3] [4]CMakeLists.txtto includeplugin_utils.cin the build, ensuring the new utilities are compiled and available.plugin_driver.candplugin_driver.hfor the new utility functions and types. [1] [2]Python Plugin System Refactoring
Shared components and API definition:
__init__.pyin the shared Python plugin package to clarify its role, explicitly export the newSafeBufferAccessclass, legacy compatibility types, configuration models, and extension interfaces. This makes the package structure clearer and easier to use for plugin authors.API_SPECIFICATION.md) for theSafeBufferAccessclass, outlining all public methods, parameters, return types, error handling, thread safety, batch operation formats, and compatibility requirements. This serves as a contract for future refactoring and extension.Batch operations support:
BatchProcessorclass inbatch_processor.py, providing efficient batch read, write, and mixed operations for buffer access. The processor acquires the mutex only once per batch, improving performance for plugins that need to access multiple buffers simultaneously. It also includes validation and error handling for batch operations.References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10]