@codesys/mcp-toolkit 1.0.3 → 1.0.4
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 +26 -45
- package/CONTRIBUTING.md +72 -72
- package/LICENSE +21 -21
- package/README.md +254 -79
- package/README.md.enhanced +155 -155
- package/dist/codesys_interop.js +55 -45
- package/dist/server.js +879 -879
- package/docs/configuration.md +119 -119
- package/docs/index.md +26 -26
- package/docs/installation.md +84 -84
- package/examples/README.md +78 -78
- package/examples/sample_config.json +32 -33
- package/package.json +47 -47
- package/dist/codesys_interop - Copy.js +0 -180
- package/dist/server - Copy.js +0 -1444
package/CHANGELOG.md
CHANGED
|
@@ -1,45 +1,26 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [1.0.
|
|
9
|
-
|
|
10
|
-
###
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
## [1.0.0] - 2025-04-20
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
- Initial release of the MCP server for CODESYS
|
|
31
|
-
- Command-line interface with configuration options
|
|
32
|
-
- Project management functionality:
|
|
33
|
-
- Opening existing CODESYS projects
|
|
34
|
-
- Creating new CODESYS projects
|
|
35
|
-
- Saving projects
|
|
36
|
-
- POU (Program Organization Unit) management:
|
|
37
|
-
- Creating POUs (Programs, Function Blocks, Functions)
|
|
38
|
-
- Setting POU code (declaration and implementation)
|
|
39
|
-
- Creating properties and methods for Function Blocks
|
|
40
|
-
- Project compilation support
|
|
41
|
-
- Resources for querying:
|
|
42
|
-
- Project status
|
|
43
|
-
- Project structure
|
|
44
|
-
- POU code
|
|
45
|
-
- Documentation for installation and usage
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2025-04-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of the MCP server for CODESYS
|
|
12
|
+
- Command-line interface with configuration options
|
|
13
|
+
- Project management functionality:
|
|
14
|
+
- Opening existing CODESYS projects
|
|
15
|
+
- Creating new CODESYS projects
|
|
16
|
+
- Saving projects
|
|
17
|
+
- POU (Program Organization Unit) management:
|
|
18
|
+
- Creating POUs (Programs, Function Blocks, Functions)
|
|
19
|
+
- Setting POU code (declaration and implementation)
|
|
20
|
+
- Creating properties and methods for Function Blocks
|
|
21
|
+
- Project compilation support
|
|
22
|
+
- Resources for querying:
|
|
23
|
+
- Project status
|
|
24
|
+
- Project structure
|
|
25
|
+
- POU code
|
|
26
|
+
- Documentation for installation and usage
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
# Contributing to @codesys/mcp-toolkit
|
|
2
|
-
|
|
3
|
-
Thank you for considering contributing to the CODESYS MCP Toolkit! This document provides guidelines and steps for contributing.
|
|
4
|
-
|
|
5
|
-
## Code of Conduct
|
|
6
|
-
|
|
7
|
-
Please be respectful and considerate of others when contributing to this project. We aim to foster an inclusive and welcoming community.
|
|
8
|
-
|
|
9
|
-
## How Can I Contribute?
|
|
10
|
-
|
|
11
|
-
### Reporting Bugs
|
|
12
|
-
|
|
13
|
-
Bug reports help improve the project! When reporting bugs:
|
|
14
|
-
|
|
15
|
-
1. Check if the bug has already been reported
|
|
16
|
-
2. Use the bug report template
|
|
17
|
-
3. Include detailed steps to reproduce the issue
|
|
18
|
-
4. Describe the expected vs. actual behavior
|
|
19
|
-
5. Include screenshots if applicable
|
|
20
|
-
6. Provide environment details (OS, Node.js version, etc.)
|
|
21
|
-
|
|
22
|
-
### Suggesting Features
|
|
23
|
-
|
|
24
|
-
We welcome feature suggestions! When suggesting features:
|
|
25
|
-
|
|
26
|
-
1. Describe the problem your feature would solve
|
|
27
|
-
2. Explain how your feature would work
|
|
28
|
-
3. Consider potential alternatives
|
|
29
|
-
4. Provide examples of similar features in other projects (if applicable)
|
|
30
|
-
|
|
31
|
-
### Pull Requests
|
|
32
|
-
|
|
33
|
-
1. Fork the repository
|
|
34
|
-
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
35
|
-
3. Make your changes
|
|
36
|
-
4. Run tests and ensure they pass
|
|
37
|
-
5. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
38
|
-
6. Push to your branch (`git push origin feature/amazing-feature`)
|
|
39
|
-
7. Open a Pull Request
|
|
40
|
-
|
|
41
|
-
## Development Setup
|
|
42
|
-
|
|
43
|
-
1. Clone the repository
|
|
44
|
-
```bash
|
|
45
|
-
git clone https://github.com/yourusername/codesys-mcp-toolkit.git
|
|
46
|
-
cd codesys-mcp-toolkit
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
2. Install dependencies
|
|
50
|
-
```bash
|
|
51
|
-
npm install
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
3. Build the project
|
|
55
|
-
```bash
|
|
56
|
-
npm run build
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Style Guidelines
|
|
60
|
-
|
|
61
|
-
- Follow existing code formatting patterns
|
|
62
|
-
- Use meaningful variable and function names
|
|
63
|
-
- Add comments where necessary to explain complex logic
|
|
64
|
-
- Update documentation when changing functionality
|
|
65
|
-
|
|
66
|
-
## Testing
|
|
67
|
-
|
|
68
|
-
- Add tests for new features
|
|
69
|
-
- Ensure all tests pass before submitting a PR
|
|
70
|
-
- Consider edge cases in your tests
|
|
71
|
-
|
|
72
|
-
Thank you for contributing!
|
|
1
|
+
# Contributing to @codesys/mcp-toolkit
|
|
2
|
+
|
|
3
|
+
Thank you for considering contributing to the CODESYS MCP Toolkit! This document provides guidelines and steps for contributing.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
Please be respectful and considerate of others when contributing to this project. We aim to foster an inclusive and welcoming community.
|
|
8
|
+
|
|
9
|
+
## How Can I Contribute?
|
|
10
|
+
|
|
11
|
+
### Reporting Bugs
|
|
12
|
+
|
|
13
|
+
Bug reports help improve the project! When reporting bugs:
|
|
14
|
+
|
|
15
|
+
1. Check if the bug has already been reported
|
|
16
|
+
2. Use the bug report template
|
|
17
|
+
3. Include detailed steps to reproduce the issue
|
|
18
|
+
4. Describe the expected vs. actual behavior
|
|
19
|
+
5. Include screenshots if applicable
|
|
20
|
+
6. Provide environment details (OS, Node.js version, etc.)
|
|
21
|
+
|
|
22
|
+
### Suggesting Features
|
|
23
|
+
|
|
24
|
+
We welcome feature suggestions! When suggesting features:
|
|
25
|
+
|
|
26
|
+
1. Describe the problem your feature would solve
|
|
27
|
+
2. Explain how your feature would work
|
|
28
|
+
3. Consider potential alternatives
|
|
29
|
+
4. Provide examples of similar features in other projects (if applicable)
|
|
30
|
+
|
|
31
|
+
### Pull Requests
|
|
32
|
+
|
|
33
|
+
1. Fork the repository
|
|
34
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
35
|
+
3. Make your changes
|
|
36
|
+
4. Run tests and ensure they pass
|
|
37
|
+
5. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
38
|
+
6. Push to your branch (`git push origin feature/amazing-feature`)
|
|
39
|
+
7. Open a Pull Request
|
|
40
|
+
|
|
41
|
+
## Development Setup
|
|
42
|
+
|
|
43
|
+
1. Clone the repository
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/yourusername/codesys-mcp-toolkit.git
|
|
46
|
+
cd codesys-mcp-toolkit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. Install dependencies
|
|
50
|
+
```bash
|
|
51
|
+
npm install
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. Build the project
|
|
55
|
+
```bash
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Style Guidelines
|
|
60
|
+
|
|
61
|
+
- Follow existing code formatting patterns
|
|
62
|
+
- Use meaningful variable and function names
|
|
63
|
+
- Add comments where necessary to explain complex logic
|
|
64
|
+
- Update documentation when changing functionality
|
|
65
|
+
|
|
66
|
+
## Testing
|
|
67
|
+
|
|
68
|
+
- Add tests for new features
|
|
69
|
+
- Ensure all tests pass before submitting a PR
|
|
70
|
+
- Consider edge cases in your tests
|
|
71
|
+
|
|
72
|
+
Thank you for contributing!
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 CODESYS MCP Server Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 CODESYS MCP Server Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,79 +1,254 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
# @codesys/mcp-toolkit
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
A Model Context Protocol (MCP) server for CODESYS V3 programming environments. This toolkit enables seamless interaction between MCP clients (like Claude Desktop) and CODESYS, allowing automation of project management, POU creation, code editing, and compilation tasks.
|
|
7
|
+
|
|
8
|
+
## 🌟 Features
|
|
9
|
+
|
|
10
|
+
- **Project Management**
|
|
11
|
+
- Open existing CODESYS projects
|
|
12
|
+
- Create new projects from templates
|
|
13
|
+
- Save project changes
|
|
14
|
+
|
|
15
|
+
- **POU Management**
|
|
16
|
+
- Create Programs, Function Blocks, and Functions
|
|
17
|
+
- Set declaration and implementation code
|
|
18
|
+
- Create properties and methods for Function Blocks
|
|
19
|
+
- Compile projects
|
|
20
|
+
|
|
21
|
+
- **MCP Resources**
|
|
22
|
+
- `codesys://project/status`: Check scripting status and project state
|
|
23
|
+
- `codesys://project/{+project_path}/structure`: Retrieve project structure
|
|
24
|
+
- `codesys://project/{+project_path}/pou/{+pou_path}/code`: Read POU code
|
|
25
|
+
|
|
26
|
+
- **MCP Tools**
|
|
27
|
+
- `open_project`: Open specified CODESYS project
|
|
28
|
+
- `create_project`: Create new CODESYS project
|
|
29
|
+
- `save_project`: Save currently open project
|
|
30
|
+
- `create_pou`: Create new Program, Function Block, or Function
|
|
31
|
+
- `set_pou_code`: Update code for a specified POU
|
|
32
|
+
- `create_property`: Create property in a Function Block
|
|
33
|
+
- `create_method`: Create method in a Function Block
|
|
34
|
+
- `compile_project`: Compile the open project
|
|
35
|
+
|
|
36
|
+
## 📋 Prerequisites
|
|
37
|
+
|
|
38
|
+
- **CODESYS V3**: A working CODESYS V3 installation (tested with 3.5 SP21) with **Scripting Engine** component enabled
|
|
39
|
+
- **Node.js**: Version 18 or later required
|
|
40
|
+
- **MCP Client**: An MCP-enabled application (e.g., Claude Desktop)
|
|
41
|
+
|
|
42
|
+
## 🚀 Installation
|
|
43
|
+
|
|
44
|
+
### Option 1: Install from npm (Recommended)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install -g @codesys/mcp-toolkit
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This installs the package globally, making the `codesys-mcp-toolkit` command available in your terminal.
|
|
51
|
+
|
|
52
|
+
### Option 2: Install from Source
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Clone the repository
|
|
56
|
+
git clone https://github.com/johannesPettersson80/codesys-mcp-toolkit.git
|
|
57
|
+
cd codesys-mcp-toolkit
|
|
58
|
+
|
|
59
|
+
# Install dependencies
|
|
60
|
+
npm install
|
|
61
|
+
|
|
62
|
+
# Build the project
|
|
63
|
+
npm run build
|
|
64
|
+
|
|
65
|
+
# Install globally
|
|
66
|
+
npm install -g .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🔧 Configuration
|
|
70
|
+
|
|
71
|
+
### Claude Desktop Configuration
|
|
72
|
+
|
|
73
|
+
1. Locate your Claude Desktop configuration file:
|
|
74
|
+
- Windows: `C:\Users\<YourUsername>\AppData\Roaming\Claude\claude_desktop_config.json`
|
|
75
|
+
|
|
76
|
+
2. Add the CODESYS MCP server entry:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"codesys_local": {
|
|
82
|
+
"command": "npx",
|
|
83
|
+
"args": [
|
|
84
|
+
"-y",
|
|
85
|
+
"@codesys/mcp-toolkit",
|
|
86
|
+
"--codesys-path", "C:\\Program Files\\CODESYS 3.5.21.0\\CODESYS\\Common\\CODESYS.exe",
|
|
87
|
+
"--codesys-profile", "CODESYS V3.5 SP21"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
3. Customize the paths to match your CODESYS installation:
|
|
95
|
+
- `--codesys-path`: Path to your CODESYS.exe
|
|
96
|
+
- `--codesys-profile`: Your CODESYS profile name
|
|
97
|
+
|
|
98
|
+
4. Restart Claude Desktop to apply the changes
|
|
99
|
+
|
|
100
|
+
## 🛠️ Usage Examples
|
|
101
|
+
|
|
102
|
+
### Creating a Function Block with Properties
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Ask Claude: "Using the CODESYS Local server, please create a Motor Controller function block with Start and Stop methods, plus CurrentSpeed property."
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Claude will execute these MCP tool calls:
|
|
109
|
+
1. `create_pou` to create the MotorController Function Block
|
|
110
|
+
2. `create_property` to add the CurrentSpeed property
|
|
111
|
+
3. `create_method` to add Start and Stop methods
|
|
112
|
+
4. `set_pou_code` to implement each method and property
|
|
113
|
+
|
|
114
|
+
### Opening and Compiling a Project
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
Ask Claude: "Can you open the project at C:/MyProjects/TestProject.project using CODESYS Local and compile it?"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Claude will:
|
|
121
|
+
1. Use `open_project` to open the specified file
|
|
122
|
+
2. Use `compile_project` to build the application
|
|
123
|
+
|
|
124
|
+
## 🔍 Troubleshooting
|
|
125
|
+
|
|
126
|
+
### Common Issues
|
|
127
|
+
|
|
128
|
+
- **Connection Failures**: Check Claude Desktop logs for error messages
|
|
129
|
+
- **Path Issues**: Ensure CODESYS executable path is correct
|
|
130
|
+
- **Profile Mismatch**: Verify profile name matches exactly
|
|
131
|
+
- **Permission Problems**: Ensure Claude has appropriate permissions
|
|
132
|
+
- **CODESYS Already Running**: Close other CODESYS instances
|
|
133
|
+
|
|
134
|
+
### Debug Logs
|
|
135
|
+
|
|
136
|
+
Check logs at:
|
|
137
|
+
- Windows: `C:\Users\<YourUsername>\AppData\Roaming\Claude\logs\`
|
|
138
|
+
|
|
139
|
+
## 📖 Detailed OOP Workflow Guide
|
|
140
|
+
|
|
141
|
+
When creating object-oriented structures with this toolkit, follow this step-by-step workflow for best results:
|
|
142
|
+
|
|
143
|
+
### Creating Function Blocks with Properties and Methods
|
|
144
|
+
|
|
145
|
+
1. **Create the Function Block**
|
|
146
|
+
```
|
|
147
|
+
create_pou(
|
|
148
|
+
projectFilePath: "path/to/project.project",
|
|
149
|
+
name: "PumpController",
|
|
150
|
+
type: "FunctionBlock",
|
|
151
|
+
language: "ST",
|
|
152
|
+
parentPath: "Application"
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
2. **Create Properties**
|
|
157
|
+
```
|
|
158
|
+
create_property(
|
|
159
|
+
projectFilePath: "path/to/project.project",
|
|
160
|
+
parentPouPath: "Application/PumpController",
|
|
161
|
+
propertyName: "SpeedSetpoint",
|
|
162
|
+
propertyType: "INT"
|
|
163
|
+
)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
3. **Create Methods**
|
|
167
|
+
```
|
|
168
|
+
create_method(
|
|
169
|
+
projectFilePath: "path/to/project.project",
|
|
170
|
+
parentPouPath: "Application/PumpController",
|
|
171
|
+
methodName: "Start",
|
|
172
|
+
returnType: "" // Empty for no return value
|
|
173
|
+
)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
4. **Implement Methods**
|
|
177
|
+
```
|
|
178
|
+
set_pou_code(
|
|
179
|
+
projectFilePath: "path/to/project.project",
|
|
180
|
+
pouPath: "Application/PumpController/Start",
|
|
181
|
+
implementationCode: "isRunning := TRUE;"
|
|
182
|
+
)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
5. **Declare Backing Variables**
|
|
186
|
+
```
|
|
187
|
+
set_pou_code(
|
|
188
|
+
projectFilePath: "path/to/project.project",
|
|
189
|
+
pouPath: "Application/PumpController",
|
|
190
|
+
declarationCode: "VAR PRIVATE\n _speedSetpoint : INT;\n _isRunning : BOOL;\nEND_VAR"
|
|
191
|
+
)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
6. **Implement Property Accessors**
|
|
195
|
+
- For GET accessor:
|
|
196
|
+
```
|
|
197
|
+
set_pou_code(
|
|
198
|
+
projectFilePath: "path/to/project.project",
|
|
199
|
+
pouPath: "Application/PumpController/SpeedSetpoint/Get",
|
|
200
|
+
implementationCode: "SpeedSetpoint := _speedSetpoint;"
|
|
201
|
+
)
|
|
202
|
+
```
|
|
203
|
+
- For SET accessor:
|
|
204
|
+
```
|
|
205
|
+
set_pou_code(
|
|
206
|
+
projectFilePath: "path/to/project.project",
|
|
207
|
+
pouPath: "Application/PumpController/SpeedSetpoint/Set",
|
|
208
|
+
implementationCode: "_speedSetpoint := SpeedSetpoint;"
|
|
209
|
+
)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
7. **Save Project**
|
|
213
|
+
```
|
|
214
|
+
save_project(
|
|
215
|
+
projectFilePath: "path/to/project.project"
|
|
216
|
+
)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Important Path Usage Notes
|
|
220
|
+
|
|
221
|
+
- Use forward slashes (`/`) in all object paths
|
|
222
|
+
- Ensure paths are precise and target the specific object
|
|
223
|
+
- For property accessors, always specify the full path including `/Get` or `/Set`
|
|
224
|
+
|
|
225
|
+
### CODESYS Naming Conventions
|
|
226
|
+
|
|
227
|
+
- **POUs** (Programs, FBs, Functions): PascalCase (e.g., `MotorControl`)
|
|
228
|
+
- **Interfaces**: PascalCase with I_ prefix (e.g., `I_AxisCommands`)
|
|
229
|
+
- **DUTs** (Structs, Enums): PascalCase (e.g., `MachineState`, `E_OperationMode`)
|
|
230
|
+
- **Variables**: camelCase (e.g., `motorSpeed`)
|
|
231
|
+
- **Backing variables**: camelCase with _ prefix (e.g., `_speedSetpoint`)
|
|
232
|
+
- **Constants**: UPPER_SNAKE_CASE (e.g., `MAX_RPM`)
|
|
233
|
+
- **Properties & Methods**: PascalCase with descriptive names
|
|
234
|
+
|
|
235
|
+
### Recommended Property Naming
|
|
236
|
+
|
|
237
|
+
- Control values: Add `Setpoint` suffix (e.g., `SpeedSetpoint`)
|
|
238
|
+
- Measured values: Add `Actual` suffix (e.g., `TemperatureActual`)
|
|
239
|
+
- Status indicators: Use `Is` or `Has` prefix (e.g., `IsRunning`, `HasError`)
|
|
240
|
+
- Configuration: Use descriptive prefixes (e.g., `MaxSpeed`, `MinPressure`)
|
|
241
|
+
|
|
242
|
+
## 🤝 Contributing
|
|
243
|
+
|
|
244
|
+
Contributions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
|
245
|
+
|
|
246
|
+
## 📝 License
|
|
247
|
+
|
|
248
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
249
|
+
|
|
250
|
+
## 🙏 Acknowledgements
|
|
251
|
+
|
|
252
|
+
- The [CODESYS](https://www.codesys.com/) team for their scripting engine
|
|
253
|
+
- [Model Context Protocol](https://github.com/m-ld/model-context-protocol) project
|
|
254
|
+
- All contributors who have helped improve this toolkit
|