77 lines
2.7 KiB
Markdown
77 lines
2.7 KiB
Markdown
|
|
### 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/
|
|
│ │ └── ...
|
|
│ └── ...
|
|
└── ... |