gravity-controller-operator 2.0.2__py3-none-any.whl → 2.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gravity_controller_operator/controllers_super.py +9 -5
- {gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info}/METADATA +124 -115
- {gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info}/RECORD +6 -6
- {gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info}/WHEEL +1 -1
- {gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info/licenses}/LICENSE +0 -0
- {gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info}/top_level.txt +0 -0
|
@@ -11,9 +11,13 @@ class SoftStateMixin:
|
|
|
11
11
|
map_keys_amount = 0
|
|
12
12
|
starts_with = 0
|
|
13
13
|
|
|
14
|
-
def __init__(self):
|
|
14
|
+
def __init__(self, map_keys_amount=None, starts_with=None, spec_addr=None):
|
|
15
|
+
self.map_keys_amount = map_keys_amount if map_keys_amount is not None else getattr(self.__class__, 'map_keys_amount', 0)
|
|
16
|
+
self.starts_with = starts_with if starts_with is not None else getattr(self.__class__, 'starts_with', 0)
|
|
17
|
+
self.spec_addr = spec_addr if spec_addr is not None else getattr(self.__class__, 'spec_addr', {})
|
|
15
18
|
self.state = self._init_state()
|
|
16
19
|
|
|
20
|
+
|
|
17
21
|
def _init_state(self):
|
|
18
22
|
points = {}
|
|
19
23
|
for i in range(self.map_keys_amount):
|
|
@@ -58,8 +62,8 @@ class RelayPhysInterface(BasePhysInterface):
|
|
|
58
62
|
pass
|
|
59
63
|
|
|
60
64
|
class DIInterface(SoftStateMixin, BasePhysInterface):
|
|
61
|
-
def __init__(self):
|
|
62
|
-
super().__init__()
|
|
65
|
+
def __init__(self, map_keys_amount=None, starts_with=None, spec_addr=None):
|
|
66
|
+
super().__init__(map_keys_amount, starts_with, spec_addr)
|
|
63
67
|
self.update_from_device()
|
|
64
68
|
|
|
65
69
|
def update_from_device(self):
|
|
@@ -69,8 +73,8 @@ class DIInterface(SoftStateMixin, BasePhysInterface):
|
|
|
69
73
|
|
|
70
74
|
|
|
71
75
|
class RelayInterface(SoftStateMixin, RelayPhysInterface):
|
|
72
|
-
def __init__(self):
|
|
73
|
-
super().__init__()
|
|
76
|
+
def __init__(self, map_keys_amount=None, starts_with=None, spec_addr=None):
|
|
77
|
+
super().__init__(map_keys_amount, starts_with, spec_addr)
|
|
74
78
|
self.update_from_device()
|
|
75
79
|
|
|
76
80
|
def update_from_device(self):
|
{gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info}/METADATA
RENAMED
|
@@ -1,115 +1,124 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name: gravity_controller_operator
|
|
3
|
-
Version: 2.0.
|
|
4
|
-
Summary: SDK предоставляющий универсальный интерфейс для работы со многими промышленными контроллерами ввода-вывода (количество расширяемо)
|
|
5
|
-
Author: PunchyArchy
|
|
6
|
-
Author-email: ksmdrmvscthny@gmail.com
|
|
7
|
-
Classifier: Programming Language :: Python :: 3
|
|
8
|
-
Classifier: Operating System :: OS Independent
|
|
9
|
-
Requires-Python: >=3.7
|
|
10
|
-
Description-Content-Type: text/markdown
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
Requires-Dist: pyModbusTCP
|
|
13
|
-
Requires-Dist: pymodbus
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gravity_controller_operator
|
|
3
|
+
Version: 2.0.4
|
|
4
|
+
Summary: SDK предоставляющий универсальный интерфейс для работы со многими промышленными контроллерами ввода-вывода (количество расширяемо)
|
|
5
|
+
Author: PunchyArchy
|
|
6
|
+
Author-email: ksmdrmvscthny@gmail.com
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Operating System :: OS Independent
|
|
9
|
+
Requires-Python: >=3.7
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: pyModbusTCP
|
|
13
|
+
Requires-Dist: pymodbus==3.6.9
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: author-email
|
|
16
|
+
Dynamic: classifier
|
|
17
|
+
Dynamic: description
|
|
18
|
+
Dynamic: description-content-type
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
Dynamic: requires-dist
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
Dynamic: summary
|
|
23
|
+
|
|
24
|
+
# Gravity Controller Operator
|
|
25
|
+
|
|
26
|
+
Модуль для унифицированной работы с промышленными контроллерами (реле, дискретные входы и т.д.). Позволяет взаимодействовать с различными устройствами через единый интерфейс.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🚀 Поддерживаемые контроллеры
|
|
31
|
+
|
|
32
|
+
- **EmulatorController** — заглушка для тестов
|
|
33
|
+
- **ARMK210Controller** — Modbus TCP
|
|
34
|
+
- **WBMR6LV** — Modbus RTU
|
|
35
|
+
- **NetPing2Controller** — HTTP API
|
|
36
|
+
- **Sigur** — доступ через TCP (СКУД)
|
|
37
|
+
- **MoxaE1214** — REST API (vdn.dac.v1)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🧩 Архитектура
|
|
42
|
+
|
|
43
|
+
### 🧠 Интерфейсы:
|
|
44
|
+
|
|
45
|
+
- `DIInterface`: чтение дискретных входов
|
|
46
|
+
- `RelayInterface`: чтение/управление релейными выходами
|
|
47
|
+
- `ControllerInterface`: объединяет оба
|
|
48
|
+
|
|
49
|
+
Все интерфейсы наследуют `SoftStateMixin`, в котором реализовано хранение состояния точек (`state`, `changed`, `addr`).
|
|
50
|
+
|
|
51
|
+
### 🛠 Контроллер
|
|
52
|
+
Каждый контроллер реализует:
|
|
53
|
+
```python
|
|
54
|
+
self.interface = ControllerInterface(di_interface=..., relay_interface=...)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 🧪 Обёртки:
|
|
58
|
+
|
|
59
|
+
- `ControllerOperator` — отвечает за автоматическое обновление, mutex-безопасность и удобный API
|
|
60
|
+
- `ControllerCreator` — фабрика создания контроллеров по имени модели (см. `controller_factory.py`)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🧪 Как использовать
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from gravity_controller_operator.controllers.moxa import MoxaE1214
|
|
68
|
+
from gravity_controller_operator.controller_operator import ControllerOperator
|
|
69
|
+
|
|
70
|
+
moxa = MoxaE1214("192.168.60.103")
|
|
71
|
+
operator = ControllerOperator(moxa)
|
|
72
|
+
|
|
73
|
+
print(operator.get_points())
|
|
74
|
+
operator.change_relay_state(0, 1) # включить реле 0
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🔬 Тестирование
|
|
80
|
+
|
|
81
|
+
Установка:
|
|
82
|
+
```bash
|
|
83
|
+
pip install pytest
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Запуск:
|
|
87
|
+
```bash
|
|
88
|
+
pytest gravity_controller_operator/tests/
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 📦 Добавление нового контроллера
|
|
94
|
+
|
|
95
|
+
1. Реализуй `YourControllerDI` и `YourControllerRelay`, наследуя `DIInterface`, `RelayInterface`
|
|
96
|
+
2. Создай `YourController`, в котором:
|
|
97
|
+
```python
|
|
98
|
+
self.interface = ControllerInterface(di_interface=..., relay_interface=...)
|
|
99
|
+
```
|
|
100
|
+
3. Добавь контроллер в `AVAILABLE_CONTROLLERS` в `controller_factory.py`
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 📁 Структура
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
controllers_super.py # Базовые интерфейсы
|
|
108
|
+
controllers/ # Реализации контроллеров
|
|
109
|
+
controller_operator.py # Обёртка ControllerOperator ✅
|
|
110
|
+
controller_factory.py # AVAILABLE_CONTROLLERS + фабрика ✅
|
|
111
|
+
exceptions.py # Кастомные исключения ✅
|
|
112
|
+
tests/ # Тесты
|
|
113
|
+
README.md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 🤝 Контакты
|
|
119
|
+
|
|
120
|
+
- 📧 Email: ksmdrmvstchny@gmail.com
|
|
121
|
+
- 💬 Telegram: [@PunchyArchy](https://t.me/PunchyArchy)
|
|
122
|
+
- 📞 Phone: +7 996 294-75-95
|
|
123
|
+
|
|
124
|
+
Проект поддерживается Артуром (PunchyArchy, Qodex)
|
{gravity_controller_operator-2.0.2.dist-info → gravity_controller_operator-2.0.4.dist-info}/RECORD
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
gravity_controller_operator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
gravity_controller_operator/controller_factory.py,sha256=QQHym-fPhWCBCOFUp7MHrecjXcRy9dXVnUbg6LvwvDo,1111
|
|
3
|
-
gravity_controller_operator/controllers_super.py,sha256=
|
|
3
|
+
gravity_controller_operator/controllers_super.py,sha256=ITcJhxZRAu4dMLyHthAOxuMntb4VQIdq7VMTAJV5h-k,4211
|
|
4
4
|
gravity_controller_operator/exceptions.py,sha256=tAuviQbnrZh_T5E31RBeEnagwbvdi7x23uQJ8v4XRtM,647
|
|
5
5
|
gravity_controller_operator/main.py,sha256=_7qdTj4bHwUR4YsRScSr5eSEcMoxOqBHNfnxNY8D2J0,1492
|
|
6
6
|
gravity_controller_operator/controllers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -15,8 +15,8 @@ gravity_controller_operator/controllers/tests/test_moxa_controller.py,sha256=RKw
|
|
|
15
15
|
gravity_controller_operator/docs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
gravity_controller_operator/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
gravity_controller_operator/tests/main_tests.py,sha256=BkgWDKUXVmK4WIYY_5CAHazYmqkKumYPtfbnyxcm_UU,575
|
|
18
|
-
gravity_controller_operator-2.0.
|
|
19
|
-
gravity_controller_operator-2.0.
|
|
20
|
-
gravity_controller_operator-2.0.
|
|
21
|
-
gravity_controller_operator-2.0.
|
|
22
|
-
gravity_controller_operator-2.0.
|
|
18
|
+
gravity_controller_operator-2.0.4.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
|
|
19
|
+
gravity_controller_operator-2.0.4.dist-info/METADATA,sha256=8d9JhGRV1y5991g0EoYf_ZAQfsRx2eLw-z9E98v5k44,4124
|
|
20
|
+
gravity_controller_operator-2.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
21
|
+
gravity_controller_operator-2.0.4.dist-info/top_level.txt,sha256=krapbz1cEDGquDJf0DnoTbnybUwi7J_8OgoIumEc0OM,28
|
|
22
|
+
gravity_controller_operator-2.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|