@codesys/mcp-toolkit 1.1.12 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.14] - 2025-05-06
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed path handling for CODESYS objects to correctly handle dot and slash separators
|
|
12
|
+
- Added automatic detection of common CODESYS structure paths like "PLCWinNT/Plc Logic/Application"
|
|
13
|
+
- Improved object path traversal in find_object_by_path function
|
|
14
|
+
|
|
15
|
+
## [1.1.13] - 2025-05-06
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
- Fixed remaining f-string formatting in create_pou.py script
|
|
19
|
+
- Restored compatibility with older Python versions in path formatting
|
|
20
|
+
|
|
8
21
|
## [1.1.12] - 2025-05-06
|
|
9
22
|
|
|
10
23
|
### Fixed
|
|
@@ -40,22 +40,24 @@ try:
|
|
|
40
40
|
# Get project name from file path to build the likely full path
|
|
41
41
|
project_name = os.path.splitext(os.path.basename(PROJECT_FILE_PATH))[0]
|
|
42
42
|
potential_paths = [
|
|
43
|
-
PARENT_PATH_REL,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
PARENT_PATH_REL, # Original "Application"
|
|
44
|
+
"%s.%s" % (project_name, PARENT_PATH_REL), # "projectName.Application"
|
|
45
|
+
"%s/%s" % (project_name, PARENT_PATH_REL), # "projectName/Application"
|
|
46
|
+
"PLCWinNT/Plc Logic/Application", # Common CODESYS structure
|
|
47
|
+
"PLCWinNT.Plc Logic.Application", # Using dots instead
|
|
48
|
+
project_name # Just the project name itself might work
|
|
47
49
|
]
|
|
48
50
|
|
|
49
|
-
print(
|
|
51
|
+
print("DEBUG: Parent path is simply 'Application', trying several variants to find it")
|
|
50
52
|
|
|
51
53
|
# Try each potential path until one works
|
|
52
54
|
parent_object = None
|
|
53
55
|
for path in potential_paths:
|
|
54
|
-
print(
|
|
56
|
+
print("DEBUG: Attempting to find parent with path: '%s'" % path)
|
|
55
57
|
parent_candidate = find_object_by_path_robust(primary_project, path, "parent container")
|
|
56
58
|
if parent_candidate:
|
|
57
59
|
parent_object = parent_candidate
|
|
58
|
-
print(
|
|
60
|
+
print("DEBUG: Successfully found parent using path: '%s'" % path)
|
|
59
61
|
break
|
|
60
62
|
|
|
61
63
|
if not parent_object:
|
|
@@ -66,14 +68,14 @@ try:
|
|
|
66
68
|
app = primary_project.active_application
|
|
67
69
|
if app:
|
|
68
70
|
parent_object = app
|
|
69
|
-
print(
|
|
71
|
+
print("DEBUG: Found application object directly: %s" % app.get_name())
|
|
70
72
|
if not parent_object and hasattr(primary_project, 'find'):
|
|
71
73
|
apps = primary_project.find("Application", True)
|
|
72
74
|
if apps:
|
|
73
75
|
parent_object = apps[0]
|
|
74
|
-
print(
|
|
76
|
+
print("DEBUG: Found application via search: %s" % parent_object.get_name())
|
|
75
77
|
except Exception as e:
|
|
76
|
-
print(
|
|
78
|
+
print("ERROR: Direct application access also failed: %s" % e)
|
|
77
79
|
else:
|
|
78
80
|
# Use the provided path normally
|
|
79
81
|
parent_object = find_object_by_path_robust(primary_project, PARENT_PATH_REL, "parent container")
|
|
@@ -2,7 +2,12 @@ import traceback
|
|
|
2
2
|
# --- Find object by path function ---
|
|
3
3
|
def find_object_by_path_robust(start_node, full_path, target_type_name="object"):
|
|
4
4
|
print("DEBUG: Finding %s by path: '%s'" % (target_type_name, full_path))
|
|
5
|
-
|
|
5
|
+
# Handle both dot and slash separators
|
|
6
|
+
# First replace backslashes with forward slashes
|
|
7
|
+
path_with_slashes = full_path.replace('\\', '/').strip('/')
|
|
8
|
+
# Then replace dots with slashes (CODESYS sometimes uses dots)
|
|
9
|
+
normalized_path = path_with_slashes.replace('.', '/')
|
|
10
|
+
# Split into parts
|
|
6
11
|
path_parts = normalized_path.split('/')
|
|
7
12
|
if not path_parts:
|
|
8
13
|
print("ERROR: Path is empty.")
|
package/package.json
CHANGED
|
@@ -40,22 +40,24 @@ try:
|
|
|
40
40
|
# Get project name from file path to build the likely full path
|
|
41
41
|
project_name = os.path.splitext(os.path.basename(PROJECT_FILE_PATH))[0]
|
|
42
42
|
potential_paths = [
|
|
43
|
-
PARENT_PATH_REL,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
PARENT_PATH_REL, # Original "Application"
|
|
44
|
+
"%s.%s" % (project_name, PARENT_PATH_REL), # "projectName.Application"
|
|
45
|
+
"%s/%s" % (project_name, PARENT_PATH_REL), # "projectName/Application"
|
|
46
|
+
"PLCWinNT/Plc Logic/Application", # Common CODESYS structure
|
|
47
|
+
"PLCWinNT.Plc Logic.Application", # Using dots instead
|
|
48
|
+
project_name # Just the project name itself might work
|
|
47
49
|
]
|
|
48
50
|
|
|
49
|
-
print(
|
|
51
|
+
print("DEBUG: Parent path is simply 'Application', trying several variants to find it")
|
|
50
52
|
|
|
51
53
|
# Try each potential path until one works
|
|
52
54
|
parent_object = None
|
|
53
55
|
for path in potential_paths:
|
|
54
|
-
print(
|
|
56
|
+
print("DEBUG: Attempting to find parent with path: '%s'" % path)
|
|
55
57
|
parent_candidate = find_object_by_path_robust(primary_project, path, "parent container")
|
|
56
58
|
if parent_candidate:
|
|
57
59
|
parent_object = parent_candidate
|
|
58
|
-
print(
|
|
60
|
+
print("DEBUG: Successfully found parent using path: '%s'" % path)
|
|
59
61
|
break
|
|
60
62
|
|
|
61
63
|
if not parent_object:
|
|
@@ -66,14 +68,14 @@ try:
|
|
|
66
68
|
app = primary_project.active_application
|
|
67
69
|
if app:
|
|
68
70
|
parent_object = app
|
|
69
|
-
print(
|
|
71
|
+
print("DEBUG: Found application object directly: %s" % app.get_name())
|
|
70
72
|
if not parent_object and hasattr(primary_project, 'find'):
|
|
71
73
|
apps = primary_project.find("Application", True)
|
|
72
74
|
if apps:
|
|
73
75
|
parent_object = apps[0]
|
|
74
|
-
print(
|
|
76
|
+
print("DEBUG: Found application via search: %s" % parent_object.get_name())
|
|
75
77
|
except Exception as e:
|
|
76
|
-
print(
|
|
78
|
+
print("ERROR: Direct application access also failed: %s" % e)
|
|
77
79
|
else:
|
|
78
80
|
# Use the provided path normally
|
|
79
81
|
parent_object = find_object_by_path_robust(primary_project, PARENT_PATH_REL, "parent container")
|
|
@@ -2,7 +2,12 @@ import traceback
|
|
|
2
2
|
# --- Find object by path function ---
|
|
3
3
|
def find_object_by_path_robust(start_node, full_path, target_type_name="object"):
|
|
4
4
|
print("DEBUG: Finding %s by path: '%s'" % (target_type_name, full_path))
|
|
5
|
-
|
|
5
|
+
# Handle both dot and slash separators
|
|
6
|
+
# First replace backslashes with forward slashes
|
|
7
|
+
path_with_slashes = full_path.replace('\\', '/').strip('/')
|
|
8
|
+
# Then replace dots with slashes (CODESYS sometimes uses dots)
|
|
9
|
+
normalized_path = path_with_slashes.replace('.', '/')
|
|
10
|
+
# Split into parts
|
|
6
11
|
path_parts = normalized_path.split('/')
|
|
7
12
|
if not path_parts:
|
|
8
13
|
print("ERROR: Path is empty.")
|