codesysultra 1.0.6 → 1.0.8

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.
@@ -1,8 +1,11 @@
1
- import sys, scriptengine as script_engine, os, traceback, inspect, pkgutil
1
+ import sys
2
+ import scriptengine as script_engine
3
+ import traceback
4
+ import inspect
2
5
 
3
6
  def get_codesys_system_api():
4
7
  try:
5
- print("\\n=== CODESYS Script Engine System API ===\\n")
8
+ print("\n=== CODESYS Script Engine System API ===\n")
6
9
 
7
10
  print("=== Script Engine Modules ===")
8
11
  print("scriptengine module:")
@@ -11,34 +14,35 @@ def get_codesys_system_api():
11
14
  try:
12
15
  obj = getattr(script_engine, name)
13
16
  obj_type = type(obj).__name__
14
- print(" %s (%s)" % (name, obj_type))
17
+ print(" {} ({})".format(name, obj_type))
15
18
 
16
19
  if inspect.isclass(obj):
17
20
  try:
18
- methods = [m for m in dir(obj) if not m.startswith('_') and callable(getattr(obj, m))]
21
+ methods = []
22
+ for m in dir(obj):
23
+ if not m.startswith('_') and callable(getattr(obj, m)):
24
+ methods.append(m)
19
25
  if methods:
20
26
  print(" Available methods:")
21
27
  for method in sorted(methods)[:20]:
22
- print(" - %s" % method)
28
+ print(" - {}".format(method))
23
29
  if len(methods) > 20:
24
- print(" ... and %d more" % (len(methods) - 20))
30
+ print(" ... and {} more".format(len(methods) - 20))
25
31
  except Exception as e:
26
- print(" Error listing methods: %s" % e)
32
+ print(" Error listing methods: {}".format(e))
27
33
  except Exception as e:
28
- print(" Error: %s" % e)
29
- except Exception as e:
30
- print(" Error: %s" % e)
34
+ print(" Error: {}".format(e))
31
35
 
32
- print("\\n=== Script Engine Functions ===")
36
+ print("\n=== Script Engine Functions ===")
33
37
  script_functions = []
34
38
  for name in dir(script_engine):
35
39
  if not name.startswith('_') and callable(getattr(script_engine, name)):
36
40
  script_functions.append(name)
37
41
 
38
42
  for func in sorted(script_functions):
39
- print(" - %s()" % func)
43
+ print(" - {}()".format(func))
40
44
 
41
- print("\\n=== Available Enums ===")
45
+ print("\n=== Available Enums ===")
42
46
  try:
43
47
  enums = []
44
48
  for name in dir(script_engine):
@@ -47,17 +51,24 @@ def get_codesys_system_api():
47
51
  enums.append((name, obj))
48
52
 
49
53
  for enum_name, enum_obj in sorted(enums):
50
- print("\\n%s:" % enum_name)
54
+ print("\n{}:".format(enum_name))
51
55
  try:
52
- members = [(name, value) for name, value in enum_obj.__dict__.items() if not name.startswith('_')]
53
- for member_name, member_value in sorted(members, key=lambda x: x[0]):
54
- print(" %s = %s" % (member_name, member_value))
56
+ members = []
57
+ for name in dir(enum_obj):
58
+ if not name.startswith('_'):
59
+ members.append(name)
60
+ for member_name in sorted(members):
61
+ try:
62
+ member_value = getattr(enum_obj, member_name)
63
+ print(" {} = {}".format(member_name, member_value))
64
+ except Exception as e:
65
+ print(" Error: {}".format(e))
55
66
  except Exception as e:
56
- print(" Error: %s" % e)
67
+ print(" Error: {}".format(e))
57
68
  except Exception as e:
58
- print(" Error listing enums: %s" % e)
69
+ print(" Error: {}".format(e))
59
70
 
60
- print("\\n=== Project Management ===")
71
+ print("\n=== Project Management ===")
61
72
  print("script_engine.projects module functions:")
62
73
  project_functions = []
63
74
  for name in dir(script_engine.projects):
@@ -65,54 +76,68 @@ def get_codesys_system_api():
65
76
  project_functions.append(name)
66
77
 
67
78
  for func in sorted(project_functions):
68
- print(" - %s()" % func)
79
+ print(" - {}()".format(func))
69
80
 
70
- print("\\n=== POU Types ===")
81
+ print("\n=== POU Types ===")
71
82
  try:
72
83
  pou_types = []
73
84
  for name in dir(script_engine):
74
85
  obj = getattr(script_engine, name)
75
- if inspect.isclass(obj) and 'PouType' in name:
86
+ if 'PouType' in name:
76
87
  pou_types.append((name, obj))
77
88
 
78
89
  for type_name, type_obj in pou_types:
79
- print(" %s:" % type_name)
90
+ print(" {}:".format(type_name))
80
91
  try:
81
- values = [(name, getattr(type_obj, name)) for name in dir(type_obj) if not name.startswith('_') and name.isupper()]
82
- for value_name, value_value in values:
83
- print(" %s = %s" % (value_name, value_value))
92
+ values = []
93
+ for name in dir(type_obj):
94
+ if not name.startswith('_') and name.isupper():
95
+ values.append(name)
96
+ for value_name in sorted(values):
97
+ try:
98
+ value_value = getattr(type_obj, value_name)
99
+ print(" {} = {}".format(value_name, value_value))
100
+ except Exception as e:
101
+ print(" Error: {}".format(e))
84
102
  except Exception as e:
85
- print(" Error: %s" % e)
103
+ print(" Error: {}".format(e))
86
104
  except Exception as e:
87
- print(" Error: %s" % e)
105
+ print(" Error: {}".format(e))
88
106
 
89
- print("\\n=== Implementation Languages ===")
107
+ print("\n=== Implementation Languages ===")
90
108
  try:
91
109
  impl_langs = []
92
110
  for name in dir(script_engine):
93
111
  obj = getattr(script_engine, name)
94
- if inspect.isclass(obj) and 'ImplementationLanguage' in name:
112
+ if 'ImplementationLanguage' in name:
95
113
  impl_langs.append((name, obj))
96
114
 
97
115
  for lang_name, lang_obj in impl_langs:
98
- print(" %s:" % lang_name)
116
+ print(" {}:".format(lang_name))
99
117
  try:
100
- values = [(name, getattr(lang_obj, name)) for name in dir(lang_obj) if not name.startswith('_') and name.isupper()]
101
- for value_name, value_value in values:
102
- print(" %s = %s" % (value_name, value_value))
118
+ values = []
119
+ for name in dir(lang_obj):
120
+ if not name.startswith('_') and name.isupper():
121
+ values.append(name)
122
+ for value_name in sorted(values):
123
+ try:
124
+ value_value = getattr(lang_obj, value_name)
125
+ print(" {} = {}".format(value_name, value_value))
126
+ except Exception as e:
127
+ print(" Error: {}".format(e))
103
128
  except Exception as e:
104
- print(" Error: %s" % e)
129
+ print(" Error: {}".format(e))
105
130
  except Exception as e:
106
- print(" Error: %s" % e)
131
+ print(" Error: {}".format(e))
107
132
 
108
- print("\\n=== Version Info ===")
133
+ print("\n=== Version Info ===")
109
134
  try:
110
135
  version = getattr(script_engine, '__version__', 'Unknown')
111
- print(" Script Engine Version: %s" % version)
136
+ print(" Script Engine Version: {}".format(version))
112
137
  except Exception as e:
113
- print(" Error getting version: %s" % e)
138
+ print(" Error getting version: {}".format(e))
114
139
 
115
- print("\\n=== API Usage Examples ===")
140
+ print("\n=== API Usage Examples ===")
116
141
  print("Example 1: Open a project")
117
142
  print(" project = script_engine.projects.open('C:/Projects/MyProject.project')")
118
143
  print("")
@@ -128,15 +153,15 @@ def get_codesys_system_api():
128
153
  print(" analyze(child, indent+1)")
129
154
  print(" analyze(project)")
130
155
 
131
- print("\\n=== Analysis Complete ===")
156
+ print("\n=== Analysis Complete ===")
132
157
  print("SCRIPT_SUCCESS: CODESYS system API retrieved successfully.")
133
158
  sys.exit(0)
134
159
 
135
160
  except Exception as e:
136
161
  detailed_error = traceback.format_exc()
137
- error_message = "Error retrieving CODESYS system API: %s\\n%s" % (e, detailed_error)
162
+ error_message = "Error retrieving CODESYS system API: {}\n{}".format(e, detailed_error)
138
163
  print(error_message)
139
- print("SCRIPT_ERROR: %s" % error_message)
164
+ print("SCRIPT_ERROR: {}".format(error_message))
140
165
  sys.exit(1)
141
166
 
142
167
  if __name__ == "__main__":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codesysultra",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Model Context Protocol (MCP) server for CODESYS automation platform",
5
5
  "main": "dist/server.js",
6
6
  "bin": {
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-16"?>
2
+ <Single xml:space="preserve" Type="{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}" Method="IArchivable">
3
+ <Single Name="Name" Type="string">&lt;MachineProjectRoot&gt;</Single>
4
+ <Dictionary Type="System.Collections.Hashtable" Name="SubKeys" />
5
+ <Dictionary Type="System.Collections.Hashtable" Name="Values" />
6
+ </Single>
@@ -0,0 +1,73 @@
1
+ <?xml version="1.0" encoding="utf-16"?>
2
+ <Single xml:space="preserve" Type="{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}" Method="IArchivable">
3
+ <Single Name="Name" Type="string">&lt;UserProjectRoot&gt;</Single>
4
+ <Dictionary Type="System.Collections.Hashtable" Name="SubKeys">
5
+ <Entry>
6
+ <Key>
7
+ <Single Type="string">{4F76D0CF-5F2B-4f90-B443-B3FED105365A}</Single>
8
+ </Key>
9
+ <Value>
10
+ <Single Type="{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}" Method="IArchivable">
11
+ <Single Name="Name" Type="string">{4F76D0CF-5F2B-4f90-B443-B3FED105365A}</Single>
12
+ <Dictionary Type="System.Collections.Hashtable" Name="SubKeys" />
13
+ <Dictionary Type="System.Collections.Hashtable" Name="Values" />
14
+ </Single>
15
+ </Value>
16
+ </Entry>
17
+ <Entry>
18
+ <Key>
19
+ <Single Type="string">{79968A73-AAAA-46E3-B71D-DD238D1A198A}</Single>
20
+ </Key>
21
+ <Value>
22
+ <Single Type="{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}" Method="IArchivable">
23
+ <Single Name="Name" Type="string">{79968A73-AAAA-46E3-B71D-DD238D1A198A}</Single>
24
+ <Dictionary Type="System.Collections.Hashtable" Name="SubKeys" />
25
+ <Dictionary Type="System.Collections.Hashtable" Name="Values">
26
+ <Entry>
27
+ <Key>
28
+ <Single Type="string">DefaultLocalizationCulture</Single>
29
+ </Key>
30
+ <Value>
31
+ <Single Type="string"></Single>
32
+ </Value>
33
+ </Entry>
34
+ </Dictionary>
35
+ </Single>
36
+ </Value>
37
+ </Entry>
38
+ <Entry>
39
+ <Key>
40
+ <Single Type="string">{B431F4F6-68E9-4767-9143-6471A69719A9}</Single>
41
+ </Key>
42
+ <Value>
43
+ <Single Type="{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}" Method="IArchivable">
44
+ <Single Name="Name" Type="string">{B431F4F6-68E9-4767-9143-6471A69719A9}</Single>
45
+ <Dictionary Type="System.Collections.Hashtable" Name="SubKeys" />
46
+ <Dictionary Type="System.Collections.Hashtable" Name="Values">
47
+ <Entry>
48
+ <Key>
49
+ <Single Type="string">ActiveApplicationGuid</Single>
50
+ </Key>
51
+ <Value>
52
+ <Single Type="string">{26f81cb7-7a7b-4e0d-b781-333c7c0256f9}</Single>
53
+ </Value>
54
+ </Entry>
55
+ </Dictionary>
56
+ </Single>
57
+ </Value>
58
+ </Entry>
59
+ <Entry>
60
+ <Key>
61
+ <Single Type="string">{E958CDB5-7DE4-41af-8650-09D402301787}</Single>
62
+ </Key>
63
+ <Value>
64
+ <Single Type="{54dd0eac-a6d8-46f2-8c27-2f43c7e49861}" Method="IArchivable">
65
+ <Single Name="Name" Type="string">{E958CDB5-7DE4-41af-8650-09D402301787}</Single>
66
+ <Dictionary Type="System.Collections.Hashtable" Name="SubKeys" />
67
+ <Dictionary Type="System.Collections.Hashtable" Name="Values" />
68
+ </Single>
69
+ </Value>
70
+ </Entry>
71
+ </Dictionary>
72
+ <Dictionary Type="System.Collections.Hashtable" Name="Values" />
73
+ </Single>
Binary file