codesysultra 1.0.8 → 1.1.0
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/dist/templates/get_all_tools.py +68 -68
- package/package.json +2 -1
|
@@ -5,16 +5,16 @@ import inspect
|
|
|
5
5
|
|
|
6
6
|
def get_codesys_system_api():
|
|
7
7
|
try:
|
|
8
|
-
print
|
|
8
|
+
print "\n=== CODESYS Script Engine System API ===\n"
|
|
9
9
|
|
|
10
|
-
print
|
|
11
|
-
print
|
|
10
|
+
print "=== Script Engine Modules ==="
|
|
11
|
+
print "scriptengine module:"
|
|
12
12
|
for name in dir(script_engine):
|
|
13
13
|
if not name.startswith('_'):
|
|
14
14
|
try:
|
|
15
15
|
obj = getattr(script_engine, name)
|
|
16
16
|
obj_type = type(obj).__name__
|
|
17
|
-
print
|
|
17
|
+
print " %s (%s)" % (name, obj_type)
|
|
18
18
|
|
|
19
19
|
if inspect.isclass(obj):
|
|
20
20
|
try:
|
|
@@ -23,26 +23,26 @@ def get_codesys_system_api():
|
|
|
23
23
|
if not m.startswith('_') and callable(getattr(obj, m)):
|
|
24
24
|
methods.append(m)
|
|
25
25
|
if methods:
|
|
26
|
-
print
|
|
26
|
+
print " Available methods:"
|
|
27
27
|
for method in sorted(methods)[:20]:
|
|
28
|
-
print
|
|
28
|
+
print " - %s" % method
|
|
29
29
|
if len(methods) > 20:
|
|
30
|
-
print
|
|
31
|
-
except Exception
|
|
32
|
-
print
|
|
33
|
-
except Exception
|
|
34
|
-
print
|
|
30
|
+
print " ... and %d more" % (len(methods) - 20)
|
|
31
|
+
except Exception, e:
|
|
32
|
+
print " Error listing methods: %s" % e
|
|
33
|
+
except Exception, e:
|
|
34
|
+
print " Error: %s" % e
|
|
35
35
|
|
|
36
|
-
print
|
|
36
|
+
print "\n=== Script Engine Functions ==="
|
|
37
37
|
script_functions = []
|
|
38
38
|
for name in dir(script_engine):
|
|
39
39
|
if not name.startswith('_') and callable(getattr(script_engine, name)):
|
|
40
40
|
script_functions.append(name)
|
|
41
41
|
|
|
42
42
|
for func in sorted(script_functions):
|
|
43
|
-
print
|
|
43
|
+
print " - %s()" % func
|
|
44
44
|
|
|
45
|
-
print
|
|
45
|
+
print "\n=== Available Enums ==="
|
|
46
46
|
try:
|
|
47
47
|
enums = []
|
|
48
48
|
for name in dir(script_engine):
|
|
@@ -51,7 +51,7 @@ def get_codesys_system_api():
|
|
|
51
51
|
enums.append((name, obj))
|
|
52
52
|
|
|
53
53
|
for enum_name, enum_obj in sorted(enums):
|
|
54
|
-
print
|
|
54
|
+
print "\n%s:" % enum_name
|
|
55
55
|
try:
|
|
56
56
|
members = []
|
|
57
57
|
for name in dir(enum_obj):
|
|
@@ -60,25 +60,25 @@ def get_codesys_system_api():
|
|
|
60
60
|
for member_name in sorted(members):
|
|
61
61
|
try:
|
|
62
62
|
member_value = getattr(enum_obj, member_name)
|
|
63
|
-
print
|
|
64
|
-
except Exception
|
|
65
|
-
print
|
|
66
|
-
except Exception
|
|
67
|
-
print
|
|
68
|
-
except Exception
|
|
69
|
-
print
|
|
63
|
+
print " %s = %s" % (member_name, member_value)
|
|
64
|
+
except Exception, e:
|
|
65
|
+
print " Error: %s" % e
|
|
66
|
+
except Exception, e:
|
|
67
|
+
print " Error: %s" % e
|
|
68
|
+
except Exception, e:
|
|
69
|
+
print " Error: %s" % e
|
|
70
70
|
|
|
71
|
-
print
|
|
72
|
-
print
|
|
71
|
+
print "\n=== Project Management ==="
|
|
72
|
+
print "script_engine.projects module functions:"
|
|
73
73
|
project_functions = []
|
|
74
74
|
for name in dir(script_engine.projects):
|
|
75
75
|
if not name.startswith('_') and callable(getattr(script_engine.projects, name)):
|
|
76
76
|
project_functions.append(name)
|
|
77
77
|
|
|
78
78
|
for func in sorted(project_functions):
|
|
79
|
-
print
|
|
79
|
+
print " - %s()" % func
|
|
80
80
|
|
|
81
|
-
print
|
|
81
|
+
print "\n=== POU Types ==="
|
|
82
82
|
try:
|
|
83
83
|
pou_types = []
|
|
84
84
|
for name in dir(script_engine):
|
|
@@ -87,7 +87,7 @@ def get_codesys_system_api():
|
|
|
87
87
|
pou_types.append((name, obj))
|
|
88
88
|
|
|
89
89
|
for type_name, type_obj in pou_types:
|
|
90
|
-
print
|
|
90
|
+
print " %s:" % type_name
|
|
91
91
|
try:
|
|
92
92
|
values = []
|
|
93
93
|
for name in dir(type_obj):
|
|
@@ -96,15 +96,15 @@ def get_codesys_system_api():
|
|
|
96
96
|
for value_name in sorted(values):
|
|
97
97
|
try:
|
|
98
98
|
value_value = getattr(type_obj, value_name)
|
|
99
|
-
print
|
|
100
|
-
except Exception
|
|
101
|
-
print
|
|
102
|
-
except Exception
|
|
103
|
-
print
|
|
104
|
-
except Exception
|
|
105
|
-
print
|
|
99
|
+
print " %s = %s" % (value_name, value_value)
|
|
100
|
+
except Exception, e:
|
|
101
|
+
print " Error: %s" % e
|
|
102
|
+
except Exception, e:
|
|
103
|
+
print " Error: %s" % e
|
|
104
|
+
except Exception, e:
|
|
105
|
+
print " Error: %s" % e
|
|
106
106
|
|
|
107
|
-
print
|
|
107
|
+
print "\n=== Implementation Languages ==="
|
|
108
108
|
try:
|
|
109
109
|
impl_langs = []
|
|
110
110
|
for name in dir(script_engine):
|
|
@@ -113,7 +113,7 @@ def get_codesys_system_api():
|
|
|
113
113
|
impl_langs.append((name, obj))
|
|
114
114
|
|
|
115
115
|
for lang_name, lang_obj in impl_langs:
|
|
116
|
-
print
|
|
116
|
+
print " %s:" % lang_name
|
|
117
117
|
try:
|
|
118
118
|
values = []
|
|
119
119
|
for name in dir(lang_obj):
|
|
@@ -122,46 +122,46 @@ def get_codesys_system_api():
|
|
|
122
122
|
for value_name in sorted(values):
|
|
123
123
|
try:
|
|
124
124
|
value_value = getattr(lang_obj, value_name)
|
|
125
|
-
print
|
|
126
|
-
except Exception
|
|
127
|
-
print
|
|
128
|
-
except Exception
|
|
129
|
-
print
|
|
130
|
-
except Exception
|
|
131
|
-
print
|
|
125
|
+
print " %s = %s" % (value_name, value_value)
|
|
126
|
+
except Exception, e:
|
|
127
|
+
print " Error: %s" % e
|
|
128
|
+
except Exception, e:
|
|
129
|
+
print " Error: %s" % e
|
|
130
|
+
except Exception, e:
|
|
131
|
+
print " Error: %s" % e
|
|
132
132
|
|
|
133
|
-
print
|
|
133
|
+
print "\n=== Version Info ==="
|
|
134
134
|
try:
|
|
135
135
|
version = getattr(script_engine, '__version__', 'Unknown')
|
|
136
|
-
print
|
|
137
|
-
except Exception
|
|
138
|
-
print
|
|
136
|
+
print " Script Engine Version: %s" % version
|
|
137
|
+
except Exception, e:
|
|
138
|
+
print " Error getting version: %s" % e
|
|
139
139
|
|
|
140
|
-
print
|
|
141
|
-
print
|
|
142
|
-
print
|
|
143
|
-
print
|
|
144
|
-
print
|
|
145
|
-
print
|
|
146
|
-
print
|
|
147
|
-
print
|
|
148
|
-
print
|
|
149
|
-
print
|
|
150
|
-
print
|
|
151
|
-
print
|
|
152
|
-
print
|
|
153
|
-
print
|
|
154
|
-
print
|
|
140
|
+
print "\n=== API Usage Examples ==="
|
|
141
|
+
print "Example 1: Open a project"
|
|
142
|
+
print " project = script_engine.projects.open('C:/Projects/MyProject.project')"
|
|
143
|
+
print ""
|
|
144
|
+
print "Example 2: Create a POU"
|
|
145
|
+
print " parent = project.get_children()[0]"
|
|
146
|
+
print " pou = parent.create_pou(name='MyPOU', type=script_engine.PouType.Program)"
|
|
147
|
+
print ""
|
|
148
|
+
print "Example 3: Get project structure"
|
|
149
|
+
print " def analyze(obj, indent=0):"
|
|
150
|
+
print " print ' ' * indent + obj.get_name()"
|
|
151
|
+
print " if hasattr(obj, 'get_children'):"
|
|
152
|
+
print " for child in obj.get_children():"
|
|
153
|
+
print " analyze(child, indent+1)"
|
|
154
|
+
print " analyze(project)"
|
|
155
155
|
|
|
156
|
-
print
|
|
157
|
-
print
|
|
156
|
+
print "\n=== Analysis Complete ==="
|
|
157
|
+
print "SCRIPT_SUCCESS: CODESYS system API retrieved successfully."
|
|
158
158
|
sys.exit(0)
|
|
159
159
|
|
|
160
|
-
except Exception
|
|
160
|
+
except Exception, e:
|
|
161
161
|
detailed_error = traceback.format_exc()
|
|
162
|
-
error_message = "Error retrieving CODESYS system API:
|
|
163
|
-
print
|
|
164
|
-
print
|
|
162
|
+
error_message = "Error retrieving CODESYS system API: %s\n%s" % (e, detailed_error)
|
|
163
|
+
print error_message
|
|
164
|
+
print "SCRIPT_ERROR: %s" % error_message
|
|
165
165
|
sys.exit(1)
|
|
166
166
|
|
|
167
167
|
if __name__ == "__main__":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesysultra",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Model Context Protocol (MCP) server for CODESYS automation platform",
|
|
5
5
|
"main": "dist/server.js",
|
|
6
6
|
"bin": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@modelcontextprotocol/sdk": "^1.10.2",
|
|
38
38
|
"axios": "^1.6.8",
|
|
39
|
+
"codesysultra": "^1.0.9",
|
|
39
40
|
"commander": "^11.1.0",
|
|
40
41
|
"yargs": "^17.7.2",
|
|
41
42
|
"zod": "^3.24.3"
|