ParamManagerScripts/backend/script_groups/S7_DB_Utils
Miguel a82ef44fb8 Add x4.py for S7 source code generation and documentation
- Implemented functions to format data types, generate variable declarations, and create S7 source code from JSON data.
- Added recursive functions to handle STRUCTs and UDTs, including generating assignments for the BEGIN block.
- Created a Markdown documentation generator for DBs.
- Enhanced error handling and logging in x3.py, addressing issues with missing attributes in the DB_Parser module.
- Updated log.txt to reflect the execution flow and errors encountered during the process.
2025-05-17 14:06:22 +02:00
..
DB_Parser.py Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
data.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
db1001_data.db Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
db1001_format.csv Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
db1001_format.db.txt Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
description.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
documentation_db_HMI_Blender_Parameters.md Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
esquema_group.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
esquema_work.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
log_x1.txt Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
log_x2.txt Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
log_x3.txt Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
parsed_s7_data_expanded.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
readme.md Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
reconstructed_s7_source_v2.txt Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
script_config.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
scripts_description.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
work_dir.json Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
x1.py Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
x2.py Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
x3.py Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00
x4.py Add x4.py for S7 source code generation and documentation 2025-05-17 14:06:22 +02:00

readme.md

How to work with config setup Example

script_root = os.path.dirname( os.path.dirname(os.path.dirname(os.path.dirname(file))) ) sys.path.append(script_root) from backend.script_utils import load_configuration

if name == "main": """ Load configuration from script_config.json in the current script directory.

Returns:
    Dict containing configurations with levels 1, 2, 3 and working_directory

Example usage in scripts:
    from script_utils import load_configuration

    configs = load_configuration()
    level1_config = configs.get("level1", {})
    level2_config = configs.get("level2", {})
    level3_config = configs.get("level3", {})
    working_dir = configs.get("working_directory", "")

""""

configs = load_configuration()
working_directory = configs.get("working_directory")

# Acceder a la configuración específica del grupo
group_config = configs.get("level2", {})

# Leer parámetros con valores por defecto (usando los defaults del esquema como guía)
# Parámetros necesarios para x4
cfg_scl_output_dirname = group_config.get("scl_output_dir", "scl_output")
cfg_xref_output_dirname = group_config.get("xref_output_dir", "xref_output")
cfg_xref_source_subdir = group_config.get("xref_source_subdir", "source")

Directory structure for Tia Portal scripts

<working_directory>/ ├── <Project_Name>_CAx_Export.aml ├── <PLC1_Name>/ │ ├── ProgramBlocks_XML/ │ │ └── ... (archivos XML de bloques) │ ├── ProgramBlocks_SCL/ │ │ └── ... (archivos SCL de bloques) │ ├── ProgramBlocks_CR/ │ │ └── ... (archivos XML de referencias cruzadas de bloques) │ ├── PlcTags/ │ │ └── ... (archivos XML de tablas de tags) │ ├── PlcTags_CR/ │ │ └── ... (archivos XML de referencias cruzadas de tablas de tags) │ ├── PlcDataTypes_CR/ │ │ └── ... (archivos XML de referencias cruzadas de UDTs) │ ├── SystemBlocks_CR/ │ │ └── ... │ └── SoftwareUnits_CR/ │ └── ... │ └── Documentation/ │ └── Source │ └── ... (archivos md de bloques de programa) │ └── JSON │ └── ... (archivos JSON temporales) │ └── xref_calls_tree.md │ └── xref_db_usage_summary.md │ └── xref_plc_tags_summary.md │ └── full_project_representation.md │ └── <Project_Name>_CAx_Export_Hardware_Tree.md

├── <PLC2_Name>/ │ ├── ProgramBlocks_XML/ │ │ └── ... │ └── ... └── ...