如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
OpenPLC Runtime v4 是一款无头工业可编程逻辑控制器(PLC)运行时,可在标准计算硬件上运行 IEC 61131-3 程序。它设计为可通过 REST API 由 https://github.com/Autonomy-Logic/openplc-editor 桌面应用程序控制,或通过 Autonomy Edge Cloud 控制。
OpenPLC Runtime v4 包含两个主要组件:
运行时执行在 OpenPLC Editor 中创建的程序,支持 IEC 61131-3 编程语言(梯形图、结构化文本、功能块图等)。
最快的入门方式:
docker pull ghcr.io/autonomy-logic/openplc-runtime:latest
docker run -d \
--name openplc-runtime \
-p 8443:8443 \
--cap-add=SYS_NICE \
--cap-add=SYS_RESOURCE \
-v openplc-runtime-data:/var/run/runtime \
ghcr.io/autonomy-logic/openplc-runtime:latest
运行时将启动并在端口 8443 上监听来自 OpenPLC Editor 的连接。**不要在浏览器中打开 https://localhost:8443**——与 v3 运行时不同,此处没有 Web 界面。相反,请打开 OpenPLC Editor 桌面应用程序,配置运行时 IP 地址和凭据以进行连接。
预构建二进制文件: amd64、arm64、armv7
对于原生 Linux 安装:
# Clone repository
git clone https://github.com/Autonomy-Logic/openplc-runtime.git
cd openplc-runtime
git checkout development
# Install dependencies and compile
sudo ./install.sh
# Start the runtime
sudo ./start_openplc.sh
运行时将启动并在端口 8443 上监听。通过在 OpenPLC Editor 桌面应用程序中配置运行时 IP 地址并从编辑器登录来连接到它。
支持的发行版: Ubuntu、Debian、Fedora、CentOS、RHEL
要求:
/api/upload-file 接口/api/compilation-status 获取进度)/api/start-plc 和 /api/stop-plc 端点控制 PLC 执行/api/debug 处的 WebSocket 调试接口以进行实时变量监控运行时将上传的程序编译为共享库并动态加载。PLC 核心以实时优先级(SCHED_FIFO)执行,以实现确定性时序。
有关编辑器-运行时集成的详细信息,请参见 docs/EDITOR_INTEGRATION.md。
# 拉取镜像
docker pull ghcr.io/autonomy-logic/openplc-runtime:latest
# 使用持久化存储运行
docker run -d \
--name openplc-runtime \
-p 8443:8443 \
-v openplc-runtime-data:/var/run/runtime \
ghcr.io/autonomy-logic/openplc-runtime:latest
# 查看日志
docker logs -f openplc-runtime
# 停止容器
docker stop openplc-runtime
创建 docker-compose.yml 文件:
version: '3.8'
services:
openplc-runtime:
image: ghcr.io/autonomy-logic/openplc-runtime:latest
container_name: openplc-runtime
ports:
- "8443:8443"
volumes:
- openplc-runtime-data:/var/run/runtime
restart: unless-stopped
volumes:
openplc-runtime-data:
启动命令:docker-compose up -d
完整的 Docker 文档请参见 docs/DOCKER.md。
安装依赖项:
# Ubuntu/Debian
sudo apt-get install build-essential gcc make cmake \
python3-dev python3-pip python3-venv
# Fedora/RHEL/CentOS
sudo dnf install gcc gcc-c++ make cmake \
python3 python3-devel python3-pip python3-venv
# 克隆仓库
git clone https://github.com/Autonomy-Logic/openplc-runtime.git
cd openplc-runtime
git checkout development
# 运行安装脚本
sudo ./install.sh
安装脚本将执行以下操作:
venvs/runtime/ 创建 Python 虚拟环境手动编译步骤:
# 创建 Python 虚拟环境
python3 -m venv venvs/runtime
source venvs/runtime/bin/activate
pip install -r requirements.txt
pip install -e .
# 编译运行时核心
mkdir -p build
cd build
cmake ..
make -j$(nproc)
cd ..
sudo ./start_openplc.sh
启动脚本将执行以下操作:
注意: 需要 root 权限以执行以下操作:
/run/runtime/ 创建 Unix 域套接字openplc-runtime/
├── webserver/ # Flask Web应用程序(Python)
│ ├── app.py # 主应用入口
│ ├── restapi.py # REST API 蓝图
│ ├── debug_websocket.py # WebSocket 调试接口
│ └── ...
├── core/
│ ├── src/plc_app/ # PLC 运行时源代码(C/C++)
│ │ ├── plc_main.c # 主入口点
│ │ ├── plc_state_manager.c/h # 状态管理
│ │ ├── unix_socket.c/h # IPC 服务器
│ │ └── utils/ # 工具(日志、看门狗、定时)
│ └── src/drivers/ # 插件驱动系统
├── scripts/ # 构建和管理脚本
│ ├── compile.sh # 编译 PLC 程序
│ ├── compile-clean.sh # 清理并重命名库
│ └── manage_plugin_venvs.sh # 插件虚拟环境管理
├── build/ # 编译输出
│ ├── plc_main # 编译后的运行时可执行文件
│ └── libplc_*.so # 编译后的 PLC 程序库
├── docs/ # 文档
├── CMakeLists.txt # CMake 构建配置
├── Dockerfile # 容器定义
├── install.sh # 安装脚本
└── start_openplc.sh # 启动脚本
为实现确定性实时性能:
详情参见 LICENSE 文件。
docs/ 目录OpenPLC Runtime v4 由 Autonomy Logic 开发和维护。
来自真实用户的反馈,见证轩辕镜像的优质服务