ubuntu平台安装OpenPLC详细教程

安装OpenPLC

OpenPLC项目由两个子项目组成:
Runtime运行时
Programming editor逻辑编辑器

Runtime运行时、OpenPLC Runtime version 3

在Ubuntu上安装

git clone https://github.com/thiagoralves/OpenPLC_v3.git
cd OpenPLC_v3
./install.sh [platform]

安装 OpenPLC 后,只需重新启动您的设备,它将在启动后自动启动。

OpenPLC编辑器

在 Ubuntu上 安装 OpenPLC 编辑器

  1. 克隆代码

    # PY3 这是旧命令,此时仓库已经没有了 dev-python3分支
    git clone –-branch dev-python3 https://github.com/thiagoralves/OpenPLC_Editor
    # 主分支即是 py3,请执行此行
    git clone https://github.com/thiagoralves/OpenPLC_Editor
    
  2. 安装依赖

    • GCC and G++ (or any other C / C++ compiler)
    • Bison
    • Flex
    • Autoconf
    • Automake
    • Make
    • Python 3 (including pip)
  3. 安装Py库

    pip3 install wxPython lxml future matplotlib zeroconf pyserial
    

    记录错误:wxPython 安装出错。

    checking for GTK+ - version >= 3.0.0... Package gtk+-3.0 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gtk+-3.0.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gtk+-3.0' found
    

    解决 wxPython 安装出错

    # No package ‘gtk+-3.0‘ found
    sudo apt install -y libgtk-3-dev
    # 在 Ubuntu 上,`libgtk-3-dev` 是一个开发库,包含了 GTK+ 3 的头文件和开发工具。安装这个库可以让你编译和开发基于 GTK+ 3 的应用程序。
    # 验证安装
    pkg-config --modversion gtk+-3.0
    
  4. 编译 matiec

    cd matiec
    autoreconf -i
    ./configure
    make -s
    # keeps a copy of the iec2c compiler inside the arduino folder
    cp ./iec2c ../editor/arduino/bin/
    

启动 OpenPLC EDITOR

python3 ./editor/Beremiz.py

记录错误:jinja2 ModuleNotFoundError
解决jinja2 ModuleNotFoundError

pip3 install jinja2

附录

ubuntu安装 OpenPLC Runtime version3 命令历史

# 安装OpenPLC Runtime version3
mkdir OpenPLC
cd OpenPLC/
mkdir OpenPLCRuntimeV3
cd OpenPLCRuntimeV3/
git clone https://github.com/thiagoralves/OpenPLC_v3.git
sudo apt install git
git clone https://github.com/thiagoralves/OpenPLC_v3.git
cd OpenPLC_v3/
./install.sh linux

ubuntu 安装 OpenPLC Editor 命令历史

# 安装 OpenPLC Editor
mkdir OpenPLCEditor
cd OpenPLCEditor/
git clone https://github.com/thiagoralves/OpenPLC_Editor
sudo apt update
sudo apt install gcc g++ bison flex autoconf automake make python3 python3-pip
pip3 install wxPython lxml future matplotlib zeroconf pyserial
cat ~/.pip
mkdir -p  ~/.pip
nano ~/.pip/pip.conf
pip3 install wxPython lxml future matplotlib zeroconf pyserial # wxPython 安装出错。
# 解决wxPython 安装出错
sudo apt-get install -y libgtk-3-dev
# 验证 gtk+-3.0 成功安装
pkg-config --modversion gtk+-3.0
pip3 install wxPython
pip3 install lxml future matplotlib zeroconf pyserial
cd OpenPLC_Editor/
cd matiec
# matiec 目录为空,需要递归克隆
git submodule update --init --recursive matiec
# editor 目录为空,同样递归克隆
git submodule update --init --recursive editor
cd matiec/
autoreconf -i
./configure 
make -s
cp ./iec2c ../editor/arduino/bin/
cd ..
python3 ./editor/Beremiz.py 
# 启动报错缺少模块jinja2
# 解决报错
pip3 install jinja2
# 能够启动

配置 pip3 镜像的 pip.conf 文件

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
posted @ 2024-09-04 10:20  生产队的扛把子  阅读(787)  评论(2)    收藏  举报