From 5b5d6ca578e5382be4910dc699e430cf27ff26a3 Mon Sep 17 00:00:00 2001 From: Adam Rodwell Date: Fri, 20 Mar 2026 15:41:12 +1100 Subject: [PATCH 1/5] claude added --- .devcontainer/devcontainer.json | 3 +- CLAUDE.md | 121 ++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 CLAUDE.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ae4f3ad..74774aa 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -34,7 +34,8 @@ "aaron-bond.better-comments", "ms-azuretools.vscode-docker", "dillonkearns.vscode-gtest-adapter", - "GitHub.vscode-pull-request-github" + "GitHub.vscode-pull-request-github", + "anthropic.claude-code" ] } }, diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..ea8ee68 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,121 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Environment + +This project runs inside a Docker dev container (`ghcr.io/cyberflaneurx/plc-next-ghcr:latest`) using VSCode Dev Containers. All PLCnext CLI tools (`plcncli`) and the cross-compilation SDK are pre-installed in the container. The remote user is `plc`. + +The PLCnext SDK targets the **AXCF2152** controller (ARM Cortex-A9, `arm-pxc-linux-gnueabi`) with SDK at `/opt/plcnext_axcf2152_sdk_2023/`. C++ standard is **C++14**. + +## Build Commands + +All commands are run from within a project directory (e.g., `src/projects/StarterKit`): + +```bash +# Generate code and config (required when port definitions change) +export BUILD_TYPE=Release +plcncli generate code --verbose +plcncli generate config --verbose + +# Build (cross-compiles for ARM target) +plcncli build --verbose + +# Deploy (creates .pcwlx library file in bin/) +plcncli deploy + +# Full generate + build + deploy (equivalent to plcnext_gen_build task) +export BUILD_TYPE=Release && plcncli generate code --verbose && plcncli generate config --verbose && plcncli build --verbose && plcncli deploy +``` + +**Use `plcnext_build` (no generate)** when only `.cpp`/`.hpp` logic changed. +**Use `plcnext_gen_build` (with generate)** when port definitions, component/program metadata annotations, or project structure changed. + +## Static Analysis + +```bash +# Run cppcheck on all projects +cppcheck --quiet --enable=warning --force --error-exitcode=2 src/projects + +# With unusedFunction suppressed (as used in CI) +cppcheck --quiet --enable=warning --force --error-exitcode=2 --suppress=unusedFunction src/projects/StarterKit +``` + +## Scaffolding New Projects/Components/Programs + +```bash +# New project (sets target to AXCF2152 automatically) +cd src/projects && plcncli new project -n --force +cd && plcncli set target --add -n AXCF2152 + +# New component within a project +cd src/projects/ && plcncli new component -n + +# New program within a component +cd src/projects/ && plcncli new program -n -c + +# After scaffolding, always regenerate +plcncli generate all +``` + +## Architecture + +### PLCnext Component Model (ARP Framework) + +Each PLCnext project compiles to a shared library (`.so`) packaged as a `.pcwlx` file for use in PLCnext Engineer. + +The ARP (Automation Runtime Platform) framework structures code into three layers: + +- **Library** (`*Library.hpp/.cpp`) — auto-generated; registers the library with the runtime. Do not edit manually. +- **Component** (`*Component.hpp/.cpp`) — manages lifecycle (`Initialize`, `LoadConfig`, `SetupConfig`, `ResetConfig`, `PowerDown`) and owns a `ProgramProvider`. Inherits `ComponentBase` and `ProgramComponentBase`. +- **Program** (`*Program.hpp/.cpp`) — contains the cyclic execution logic in `Execute()`. Inherits `ProgramBase`. + +The `intermediate/` directory contains auto-generated files (code and config metadata). **Do not manually edit files in `intermediate/`** — they are regenerated by `plcncli generate`. + +### Port Annotation System + +Ports (I/O variables exposed to the PLCnext GDS/OPC-UA) are declared using comment annotations in header files: + +```cpp +//#port +//#attributes(Input|Opc) +//#name(MyPortName) +Arp::boolean myField_; +``` + +Port attributes: `Input`, `Output`, `Retain`, `Opc`. After changing any port annotations, `plcncli generate code` and `plcncli generate config` must be re-run. + +### Project Structure + +``` +src/projects// +├── plcnext.proj # Project metadata (target: AXCF2152) +├── CMakeLists.txt # CMake build; links ArpDevice and ArpProgramming +├── src/ # Hand-written source files (Component, Program headers/impls) +├── intermediate/ +│ ├── code/ # Auto-generated: Library, ProgramProvider, *.meta.cpp +│ └── config/ # Auto-generated: .libmeta, .typemeta, .compmeta, .progmeta +└── external/ # Place dependent libraries here +``` + +### Output Artifact + +The built `.pcwlx` file is copied to `/home/plc/Windows_PLCNextEngineer_Libraries` (accessible from the Windows host) for import into PLCnext Engineer. + +## Code Style + +Formatting is enforced by clang-format-14 with `.clang-format` at the repo root: +- Allman brace style, 4-space indent, 100-column limit +- Pointer alignment: right (`int *ptr`) +- Includes sorted, trailing comments aligned + +Format-on-save is configured in the dev container. To format manually: `clang-format-14 -i `. + +## CI + +GitHub Actions (`.github/workflows/static-code-analysis.yml`) runs on push/PR to `main`: +1. Pulls the dev container image +2. Runs `cppcheck` +3. Runs `plcncli generate code`, `generate config`, `build`, `deploy` + +Requires `GH_PAT` secret for authenticating with `ghcr.io`. From 4d031f936a526eb58a316388811c1e98937763b8 Mon Sep 17 00:00:00 2001 From: Adam Rodwell Date: Sun, 22 Mar 2026 09:50:04 +1100 Subject: [PATCH 2/5] update to the dev env, claude logic might be over done --- .devcontainer/Dockerfile | 1 - .devcontainer/devcontainer.json | 13 ++++++++++--- docker-compose.yml | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) delete mode 100644 .devcontainer/Dockerfile create mode 100644 docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index b2576e7..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM ghcr.io/adamrodwell/plc-next-ghcr:2024 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 74774aa..1d76b95 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,12 @@ { "name": "PLCNext Dev Container", - "image": "ghcr.io/cyberflaneurx/plc-next-ghcr:latest", + "image": "ghcr.io/adamrodwell/plc-next-ghcr:2024", + "mounts": [ + "source=${localEnv:HOME}/.claude,target=/home/plc/.claude,type=bind,consistency=cached" + ], + "containerEnv": { + "ANTHROPIC_API_KEY": "${localEnv:ANTHROPIC_API_KEY}" + }, "customizations": { "vscode": { "settings": { @@ -39,6 +45,7 @@ ] } }, + "postCreateCommand": "curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash - && sudo apt-get install -y nodejs && sudo npm install -g @anthropic-ai/claude-code", "remoteUser": "plc", - "workspaceFolder": "/workspace" -} \ No newline at end of file + "workspaceFolder": "/workspaces/PLCnext" +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..8c7e151 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + dev: + image: ghcr.io/adamrodwell/plc-next-ghcr:2024 + volumes: + - .:/workspace:cached + - ~/.claude:/home/plc/.claude + command: sleep infinity + environment: + - SHELL=/bin/zsh + - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-} From fb0665d6e1aec2d25df6b1d64ea01b16813bedd5 Mon Sep 17 00:00:00 2001 From: Adam Rodwell Date: Sun, 22 Mar 2026 09:59:10 +1100 Subject: [PATCH 3/5] update to pipelines --- .github/workflows/static-code-analysis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml index b00c903..a48ddc2 100644 --- a/.github/workflows/static-code-analysis.yml +++ b/.github/workflows/static-code-analysis.yml @@ -14,17 +14,21 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Authenticate Docker with GitHub Container Registry - run: docker login --username cyberflaneurx --password ${{ secrets.GH_PAT }} ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GH_PAT }} - name: Pull Docker image - run: docker pull ghcr.io/cyberflaneurx/plc-next-ghcr:latest + run: docker pull ghcr.io/adamrodwell/plc-next-ghcr:2024 - name: Start Docker Container run: | - docker run -d --name plcnext_container -v $(pwd):/code -w /code ghcr.io/cyberflaneurx/plc-next-ghcr:latest sleep infinity + docker run -d --name plcnext_container -v $(pwd):/code -w /code ghcr.io/adamrodwell/plc-next-ghcr:2024 sleep infinity - name: Ensure Permissions Inside Container run: | From 5490b73c4448cd09e3c8b9c5a7de1c92789eee29 Mon Sep 17 00:00:00 2001 From: Adam Rodwell Date: Sun, 22 Mar 2026 10:12:25 +1100 Subject: [PATCH 4/5] lets see if this fixes pipelines --- .github/workflows/static-code-analysis.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/static-code-analysis.yml b/.github/workflows/static-code-analysis.yml index a48ddc2..d5af0e3 100644 --- a/.github/workflows/static-code-analysis.yml +++ b/.github/workflows/static-code-analysis.yml @@ -16,13 +16,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Authenticate Docker with GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GH_PAT }} - - name: Pull Docker image run: docker pull ghcr.io/adamrodwell/plc-next-ghcr:2024 From 276a4e3ca365bbbcd979a5f5a61dc70924fca760 Mon Sep 17 00:00:00 2001 From: Adam Rodwell Date: Sun, 22 Mar 2026 10:35:01 +1100 Subject: [PATCH 5/5] build update --- src/projects/StarterKit/plcnext.proj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/projects/StarterKit/plcnext.proj b/src/projects/StarterKit/plcnext.proj index 0490244..8ef605f 100644 --- a/src/projects/StarterKit/plcnext.proj +++ b/src/projects/StarterKit/plcnext.proj @@ -5,5 +5,5 @@ StarterKit true true - AXCF2152,2023.0.0 LTS (23.0.0.65) + AXCF2152,24.0.9.199 \ No newline at end of file