Skip to main content

SDK предоставляющий универсальный интерфейс для работы со многими промышленными контроллерами ввода-вывода (количество расширяемо)

Project description

Gravity Controller Operator

Модуль для унифицированной работы с промышленными контроллерами (реле, дискретные входы и т.д.). Позволяет взаимодействовать с различными устройствами через единый интерфейс.


🚀 Поддерживаемые контроллеры

  • EmulatorController — заглушка для тестов
  • ARMK210Controller — Modbus TCP
  • WBMR6LV — Modbus RTU
  • NetPing2Controller — HTTP API
  • Sigur — доступ через TCP (СКУД)
  • MoxaE1214 — REST API (vdn.dac.v1)

🧩 Архитектура

🧠 Интерфейсы:

  • DIInterface: чтение дискретных входов
  • RelayInterface: чтение/управление релейными выходами
  • ControllerInterface: объединяет оба

Все интерфейсы наследуют SoftStateMixin, в котором реализовано хранение состояния точек (state, changed, addr).

🛠 Контроллер

Каждый контроллер реализует:

self.interface = ControllerInterface(di_interface=..., relay_interface=...)

🧪 Обёртки:

  • ControllerOperator — отвечает за автоматическое обновление, mutex-безопасность и удобный API
  • ControllerCreator — фабрика создания контроллеров по имени модели (см. controller_factory.py)

🧪 Как использовать

from gravity_controller_operator.controllers.moxa import MoxaE1214
from gravity_controller_operator.controller_operator import ControllerOperator

moxa = MoxaE1214("192.168.60.103")
operator = ControllerOperator(moxa)

print(operator.get_points())
operator.change_relay_state(0, 1)  # включить реле 0

🔬 Тестирование

Установка:

pip install pytest

Запуск:

pytest gravity_controller_operator/tests/

📦 Добавление нового контроллера

  1. Реализуй YourControllerDI и YourControllerRelay, наследуя DIInterface, RelayInterface
  2. Создай YourController, в котором:
self.interface = ControllerInterface(di_interface=..., relay_interface=...)
  1. Добавь контроллер в AVAILABLE_CONTROLLERS в controller_factory.py

📁 Структура

controllers_super.py          # Базовые интерфейсы
controllers/                  # Реализации контроллеров
controller_operator.py        # Обёртка ControllerOperator ✅
controller_factory.py         # AVAILABLE_CONTROLLERS + фабрика ✅
exceptions.py                 # Кастомные исключения ✅
tests/                        # Тесты
README.md

🤝 Контакты

Проект поддерживается Артуром (PunchyArchy, Qodex)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gravity_controller_operator-2.0.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gravity_controller_operator-2.0.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file gravity_controller_operator-2.0.0.tar.gz.

File metadata

File hashes

Hashes for gravity_controller_operator-2.0.0.tar.gz
Algorithm Hash digest
SHA256 82e1665ab9b5350f4f396da96efe2a7e4ed73d88a9e29d8bbf9b331f1a1e6d49
MD5 790e156beb05bcf6522649a612b20076
BLAKE2b-256 c7c157f5c67eb825b34cfb18761904146a9418c3f30b53f7a97092bebf885b4e

See more details on using hashes here.

File details

Details for the file gravity_controller_operator-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for gravity_controller_operator-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80509f0942976386d3ffddcc08c3b78be8a7b2fed45209b9e9d2efaf50cf5e3e
MD5 a0bbf9b3ee40dacef25609212fa80b3b
BLAKE2b-256 608b27efa63e6af40bfd3f29b113c01596afb2d95e81618ecc0b06131eeccbf2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page