Opc hda client python

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

squidmoron/Read-OPC-DA-from-Python3

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

If you want to Read variable data from OPC DA used python3 and Windows 10

You can follow these instructions below:

  1. Install Python3.9 32bit i used Python3.9.5 32bit Download Here
  2. Add Path of Python3.9 and pip in folder /Script
  3. INSTALL PYWIN32 : Download Here
  4. DOWNLOAD AND REGISTER THE DLL: Download Here or you can Download from my repository Here Then Write a Command: regsvr32 gbda_aut.dll From OPC DA Auto Wrapper
  5. INSTALL OPENOPC: pip3 install OpenOPC-Python3x if pip need to upgrade : pip install —upgrade pip Install Matrikon OPC Simulator Download Here Install Matrikon OPC Explorer Download Here

If you wanna try to read an OPC DA variables with python, you can use a Matrikon OPC Simulator and try with «opcsimulation.py» script Here

To communication from python to SQL Server you need to install PyODBC library

  1. copy file «pyodbc-4.0.30-cp39-cp39-win32.whl» you can find on repo Python odbc library
  2. open shell and run : pip install \pyodbc-4.0.30-cp39-cp39-win32.whl
  3. After shell shown : Installing collected packages: pyodbc Successfully installed pyodbc-4.0.30
  4. You got your library for pyodbc

For python script to Insert, Update, and Select Database from MS SQL, you can find script Here

Читайте также:  Css селектор класс содержит

Источник

openopc2 0.1.11

OPC library with a Windows gateway enabling non-Windows clients to access OPC-DA calls.

Ссылки проекта

Статистика

Метаданные

Лицензия: GNU General Public License v2 or later (GPLv2+) (GPL-2.0-or-later)

Метки opc, openopc, opc-da, opc classic

Требует: Python >=3.8,

Сопровождающие

Классификаторы

  • Development Status
    • 4 — Beta
    • Manufacturing
    • OSI Approved :: GNU General Public License v2 or later (GPLv2+)
    • Python :: 3
    • Python :: 3.8
    • Python :: 3.9
    • Python :: 3.10
    • Python :: 3.11
    • Scientific/Engineering :: Human Machine Interfaces
    • Scientific/Engineering :: Interface Engine/Protocol Translator

    Описание проекта

    OpenOPC 2 is a Python Library for OPC DA. It is Open source and free for everyone. It allows you to use OPC Classic (OPC Data Access) in modern Python environments. OPC Classic is a pure Windows technology by design, but this library includes a Gateway Server that lets you use OPC Classic on any architecture (Linux, MacOS, Windows, Docker). So this Library creates a gateway between 2022 and the late 90ties. Like cruising into the sunset with Marty McFly in a Tesla.

    OpenOPC 2 is based on the OpenOPC Library that was initially created by Barry Barnleitner and hosted on Source Forge, but It was completely refactorerd and migrated to Python 3.8+

    🔥 Features

    • An OpenOPC Gateway Service (a Windows service providing remote access to the OpenOPC library, which is useful to avoid DCOM issues).
    • Command Line Interface (CLI)
    • Enables you to use OPC Classic with any Platform
    • CLI and Gateway are independent Executables that do not require Python
    • A system check module (allows you to check the health of your system)
    • A free OPC automation wrapper (required DLL file).
    • General documentation with updated procedures (this file).

    🐍 OpenOPC vs OpenOPC 2

    Open OPC 2 is based on OpenOPC and should be seen as a successor. If you already have an application that is based on OpenOPC, you can migrate with a minimal effort. Our main motivation to build this new version was to improve the developer experience and create a base for other developers that is easier to maintain, test and work with.

    • Simpler installation
    • Mostly the same api (but we take the freedom to not be compatible)
    • No memory leak in the OpenOpcService 🎉
    • Python 3.8+ (tested with 3.10)
    • Typings
    • Pyro5, increased security
    • We added tests 😎
    • Refactoring for increased readablity
    • Nicer CLI
    • Pipy Package

    🚀 Getting started

    Windows local installation

    The quickest way to start is the cli application. Start your OPC server and use the openopc2.exe cli application for test (no python installation required).

    Now you know that your OPC server is talking to OpenOPC 2. Then lets get started with python. If you use OpenOPC 2 with Python in windows directly you are limited to a 32bit Python installation. This is because the dlls of OPC are 32bit. If you prefere working with a 64bit Python version you can simply use the With OpenOPC Gateway.

    You must install the gbda_aut.dll (in /lib) which is the GrayboxOpcDa wrapper.

    Multi plattform installation

    One of the main benefits of OpenOPC 2 ist the OpenOPC gateway. This enables you to use any modern platform for developting your application. Start the OpenOPC service in the Windows environment where the OPC server is running. The Service starts a server (Pyro5) that lets you use the OpenOPC2 OpcDaClient on another machine. Due to the magic of Pyro (Python Remote Objects) the developer experience and usage of the Library remains the same as if you worke int the local Windows setup.

    On the Windows Machine open the console as administrator.

    openopcservice install openopcservice start
    pip install openopc2 openopc2 --install` 

    The configuration of the OpenOpc 2 libray and the OpenOpcGateway is done via environment variables. To initiate them, simply run:

    OPC_CLASS=Matrikon.OPC.Automation;Graybox.OPC.DAWrapper;HSCOPC.Automation;RSI.OPCAutomation;OPC.Automation OPC_CLIENT=OpenOPC OPC_GATE_HOST=192.168.1.96 # IMPORTANT: Replace with your IP address OPC_GATE_PORT=7766 OPC_HOST=localhost OPC_MODE=dcom OPC_SERVER=Hci.TPNServer;HwHsc.OPCServer;opc.deltav.1;AIM.OPC.1;Yokogawa.ExaopcDAEXQ.1;OSI.DA.1;OPC.PHDServerDA.1;Aspen.Infoplus21_DA.1;National Instruments.OPCLabVIEW;RSLinx OPC Server;KEPware.KEPServerEx.V4;Matrikon.OPC.Simulation;Prosys.OPC.Simulation 
    C:\>set ENV_VAR=VALUE C:\>set OPC_GATE_HOST=172.16.4.22 # this is an example 
    • Make sure the firewall is allowed to keep the port 7766 open. If in doubt, and you’re doing a quick test, just turn off your firewall completely.
    • For easy testing, make sure an OPC server is installed in your Windows box (i.e. Matrikon OPC Simulation Server).
    • The work environment for testing these changes was a remote MacOs with Window10 64bit host and the Matrikon simulation server.
    • Register the OPC automation wrapper ( gbda_aut.dll ) by typing this in the command line:
    • If, for any reason, you want to uninstall this file and remove it from your system registry later, type this in the command line:

    The CLI (Command Line Interface) lets you use OpenOPC2 in the shell and offers you a quick way to explore your opc server and the OpenOPC DA client without the need of writing Python code.

    The documentation of the CLI can be found here

    OpenOPC Gateway

    This task can be completed from one of two ways (make sure to have it installed first):

    • By clicking the Start link on the «OpenOPC Gateway Service» from the «Services» window (Start -> Control Panel -> System and Security -> Administrative Tools).
    • By running the net start SERVICE command like this:

    Configure the way the OpenOPC Gateway Service starts

    If you are going to use this service frequently, it would be better to configure it to start in «automatic» mode. To do this:

    • Select the «OpenOPC Gateway Service» from the «Services» window (Start -> Control Panel -> System and Security -> Administrative Tools).
    • Right-click and choose «Properties».
    • Change the startup mode to «Automatic». Click «Apply» and «OK» buttons.
    • Start the service (if not already started).

    🙏 Credits

    OpenOPC 2 is based on the OpenOPC python library that was originally created by Barry Barnleitner and its many Forks on Github. Without the great work of all the contributors, this would not be possible. Contribution is open for everyone.

    The authors of the var package are:

    Years Name User
    2008-2012 🇺🇸 Barry Barnreiter barry_b@users.sourceforge.net
    2014 🇷🇺 Anton D. Kachalov barry_b@users.sourceforge.net
    2017 🇻🇪 José A. Maita jose.a.maita@gmail.com
    2022 🇨🇭 Lorenz Padberg renzop
    2022 🇨🇭 Elia Bieri eliabieri

    📜 License

    This software is licensed under the terms of the GNU GPL v2 license plus a special linking exception for portions of the package. This license is available in the LICENSE.txt file.

    Источник

    Русские Блоги

    Проект компании включает в себя сбор машинных данных из серии Karmier в Германии, поэтому он изучал протокол и методы сбора данных на основе OPC-DA. На рынке уже есть почти много коллекции OPC, которые уже сформировались, и, наконец, выберите структуру Python OpenOPC (Хотя код Python прост, среда установки действительно напряжена, пожалуйста, следуйте среде автора, чтобы использовать платформу OpenOPC)。

    Во -вторых, окружающая среда

    1. Версия Python: Python2.7 32 -bit (64 -bit и python3 почти не могут успешно установить и использовать OpenOPC. Я лично тестируюсь
    2. Сервер OPC: программное обеспечение Kepserverex 6
    4. Сторона обслуживания клиентов OPC: OPC Quick Client (сторона обслуживания клиентов OPC, которая поставляется с Kepserverex 6)
    3. OpenOPC пакет
    Сетевой диск Baidu:
    Ссылка: https://pan.baidu.com/s/1tqq8worlxbsnpjukswvvq
    Извлечение кода: CIA1

    3. Установка OpenOPC

    1. Скачать OpenOPC-1.3.1.Win32-PY2.7.exe и Install
    2. Скопируйте OpenOpc.py в папке SRC в каталоге установки OpenOPC (остальные 3 файла PY являются повседневными) для страницы Python2.7 или вашего каталога установки Python2.7 или вашего Справочник проекта (может быть импортирован. (Лучше всего использовать Anaconda для создания независимой среды Python2.7_32)
    3. Изменить переменную компьютерной среды
    OPC_MODE = open

    В -четвертых, установите пакет PIP

    pip install Pywin32
    pip install Pyro

    5. Используйте учебник

    1. Используйте kepserverex6 для моделирования канала и элемента машин -сервера.

    2、Реализация программного обеспечения для обслуживания клиентов OPC
    Используйте OpcClient для чтения канала на сервере OPC (канал, созданный на сервере)
    Сначала подключитесь к локальному серверу OPC

    Затем нажмите Tools-Sever-Auto Creat Tags и найдите созданный канал, который вы создаете

    Вы можете увидеть элемент, созданный на стороне сервера, и значение случайным образом изменяется
    3、Реализация кода Python

     import OpenOPC opc = OpenOPC.client() print opc.servers() #Print Сервер OPC считывается локально, то есть kepware.kepserverex.v6 opc.connect('Kepware.KEPServerEX.V6') #соединять print opc['test.PLC1.T'] #Опция вашего элемента taglist = ['test.PLC1.T', 'test.PLC1.V'] #Overall вывод всех opc_datas = opc.read(taglist) print opc_datas opc.close() 

    6. Резюме

    Хотя код Python прост, среда действительно озадачивает. Помимо уязвимостей в Интернете, почти не может быть успешным. Автор урегулировал окружающую среду почти 2 дня. На данный момент сбор данных OPC-DA на основе Python завершена. Я надеюсь, что читатели могут взять меньше обхода!

    Источник

Оцените статью