PyAutomationIO 0.0.0__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.
- automation/__init__.py +46 -0
- automation/alarms/__init__.py +563 -0
- automation/alarms/states.py +192 -0
- automation/alarms/trigger.py +64 -0
- automation/buffer.py +132 -0
- automation/core.py +1775 -0
- automation/dbmodels/__init__.py +23 -0
- automation/dbmodels/alarms.py +524 -0
- automation/dbmodels/core.py +86 -0
- automation/dbmodels/events.py +153 -0
- automation/dbmodels/logs.py +155 -0
- automation/dbmodels/machines.py +181 -0
- automation/dbmodels/opcua.py +81 -0
- automation/dbmodels/opcua_server.py +174 -0
- automation/dbmodels/tags.py +921 -0
- automation/dbmodels/users.py +259 -0
- automation/extensions/__init__.py +15 -0
- automation/extensions/api.py +149 -0
- automation/extensions/cors.py +18 -0
- automation/filter/__init__.py +19 -0
- automation/iad/__init__.py +3 -0
- automation/iad/frozen_data.py +54 -0
- automation/iad/out_of_range.py +51 -0
- automation/iad/outliers.py +51 -0
- automation/logger/__init__.py +0 -0
- automation/logger/alarms.py +426 -0
- automation/logger/core.py +265 -0
- automation/logger/datalogger.py +646 -0
- automation/logger/events.py +194 -0
- automation/logger/logdict.py +53 -0
- automation/logger/logs.py +203 -0
- automation/logger/machines.py +248 -0
- automation/logger/opcua_server.py +130 -0
- automation/logger/users.py +96 -0
- automation/managers/__init__.py +4 -0
- automation/managers/alarms.py +455 -0
- automation/managers/db.py +328 -0
- automation/managers/opcua_client.py +186 -0
- automation/managers/state_machine.py +183 -0
- automation/models.py +174 -0
- automation/modules/__init__.py +14 -0
- automation/modules/alarms/__init__.py +0 -0
- automation/modules/alarms/resources/__init__.py +10 -0
- automation/modules/alarms/resources/alarms.py +280 -0
- automation/modules/alarms/resources/summary.py +79 -0
- automation/modules/events/__init__.py +0 -0
- automation/modules/events/resources/__init__.py +10 -0
- automation/modules/events/resources/events.py +83 -0
- automation/modules/events/resources/logs.py +109 -0
- automation/modules/tags/__init__.py +0 -0
- automation/modules/tags/resources/__init__.py +8 -0
- automation/modules/tags/resources/tags.py +201 -0
- automation/modules/users/__init__.py +2 -0
- automation/modules/users/resources/__init__.py +10 -0
- automation/modules/users/resources/models/__init__.py +2 -0
- automation/modules/users/resources/models/roles.py +5 -0
- automation/modules/users/resources/models/users.py +14 -0
- automation/modules/users/resources/roles.py +38 -0
- automation/modules/users/resources/users.py +113 -0
- automation/modules/users/roles.py +121 -0
- automation/modules/users/users.py +335 -0
- automation/opcua/__init__.py +1 -0
- automation/opcua/models.py +541 -0
- automation/opcua/subscription.py +259 -0
- automation/pages/__init__.py +0 -0
- automation/pages/alarms.py +34 -0
- automation/pages/alarms_history.py +21 -0
- automation/pages/assets/styles.css +7 -0
- automation/pages/callbacks/__init__.py +28 -0
- automation/pages/callbacks/alarms.py +218 -0
- automation/pages/callbacks/alarms_summary.py +20 -0
- automation/pages/callbacks/db.py +222 -0
- automation/pages/callbacks/filter.py +238 -0
- automation/pages/callbacks/machines.py +29 -0
- automation/pages/callbacks/machines_detailed.py +581 -0
- automation/pages/callbacks/opcua.py +266 -0
- automation/pages/callbacks/opcua_server.py +244 -0
- automation/pages/callbacks/tags.py +495 -0
- automation/pages/callbacks/trends.py +119 -0
- automation/pages/communications.py +129 -0
- automation/pages/components/__init__.py +123 -0
- automation/pages/components/alarms.py +151 -0
- automation/pages/components/alarms_summary.py +45 -0
- automation/pages/components/database.py +128 -0
- automation/pages/components/gaussian_filter.py +69 -0
- automation/pages/components/machines.py +396 -0
- automation/pages/components/opcua.py +384 -0
- automation/pages/components/opcua_server.py +53 -0
- automation/pages/components/tags.py +253 -0
- automation/pages/components/trends.py +66 -0
- automation/pages/database.py +26 -0
- automation/pages/filter.py +55 -0
- automation/pages/machines.py +20 -0
- automation/pages/machines_detailed.py +41 -0
- automation/pages/main.py +63 -0
- automation/pages/opcua_server.py +28 -0
- automation/pages/tags.py +40 -0
- automation/pages/trends.py +35 -0
- automation/singleton.py +30 -0
- automation/state_machine.py +1672 -0
- automation/tags/__init__.py +2 -0
- automation/tags/cvt.py +1198 -0
- automation/tags/filter.py +55 -0
- automation/tags/tag.py +418 -0
- automation/tests/__init__.py +10 -0
- automation/tests/test_alarms.py +110 -0
- automation/tests/test_core.py +257 -0
- automation/tests/test_unit.py +21 -0
- automation/tests/test_user.py +155 -0
- automation/utils/__init__.py +164 -0
- automation/utils/decorators.py +222 -0
- automation/utils/npw.py +294 -0
- automation/utils/observer.py +21 -0
- automation/utils/units.py +118 -0
- automation/variables/__init__.py +55 -0
- automation/variables/adimentional.py +30 -0
- automation/variables/current.py +71 -0
- automation/variables/density.py +115 -0
- automation/variables/eng_time.py +68 -0
- automation/variables/force.py +90 -0
- automation/variables/length.py +104 -0
- automation/variables/mass.py +80 -0
- automation/variables/mass_flow.py +101 -0
- automation/variables/percentage.py +30 -0
- automation/variables/power.py +113 -0
- automation/variables/pressure.py +93 -0
- automation/variables/temperature.py +168 -0
- automation/variables/volume.py +70 -0
- automation/variables/volumetric_flow.py +100 -0
- automation/workers/__init__.py +2 -0
- automation/workers/logger.py +164 -0
- automation/workers/state_machine.py +207 -0
- automation/workers/worker.py +36 -0
- pyautomationio-0.0.0.dist-info/METADATA +198 -0
- pyautomationio-0.0.0.dist-info/RECORD +138 -0
- pyautomationio-0.0.0.dist-info/WHEEL +5 -0
- pyautomationio-0.0.0.dist-info/licenses/LICENSE +21 -0
- pyautomationio-0.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
from peewee import CharField, ForeignKeyField
|
|
2
|
+
from ..dbmodels.core import BaseModel
|
|
3
|
+
|
|
4
|
+
class AccessType(BaseModel):
|
|
5
|
+
|
|
6
|
+
name = CharField(unique=True)
|
|
7
|
+
|
|
8
|
+
@classmethod
|
|
9
|
+
def create(cls, name:str="Read")-> dict:
|
|
10
|
+
r"""Documentation here
|
|
11
|
+
"""
|
|
12
|
+
if name.lower()=="read" or name.lower()=="write" or name.lower()=="readwrite":
|
|
13
|
+
|
|
14
|
+
access_type_obj = cls.read_by_name(name=name)
|
|
15
|
+
|
|
16
|
+
if not access_type_obj:
|
|
17
|
+
query = cls(name=name)
|
|
18
|
+
query.save()
|
|
19
|
+
return query
|
|
20
|
+
|
|
21
|
+
return cls.read_by_name(name=name)
|
|
22
|
+
|
|
23
|
+
@classmethod
|
|
24
|
+
def read_by_name(cls, name:str)->bool:
|
|
25
|
+
r"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
query = cls.get_or_none(name=name)
|
|
29
|
+
|
|
30
|
+
if query is not None:
|
|
31
|
+
|
|
32
|
+
return query
|
|
33
|
+
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def name_exist(cls, name:str)->bool:
|
|
38
|
+
r"""
|
|
39
|
+
|
|
40
|
+
"""
|
|
41
|
+
query = cls.get_or_none(name=name)
|
|
42
|
+
|
|
43
|
+
if query is not None:
|
|
44
|
+
|
|
45
|
+
return True
|
|
46
|
+
|
|
47
|
+
return False
|
|
48
|
+
|
|
49
|
+
def serialize(self)-> dict:
|
|
50
|
+
r"""
|
|
51
|
+
Serialize database record to a jsonable object
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
"id": self.id,
|
|
56
|
+
"name": self.name
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class OPCUAServer(BaseModel):
|
|
61
|
+
|
|
62
|
+
name = CharField(unique=True)
|
|
63
|
+
namespace = CharField(unique=True)
|
|
64
|
+
access_type = ForeignKeyField(AccessType, null=True)
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def create(cls, name:str, namespace:str, access_type:str)-> dict:
|
|
68
|
+
r"""Documentation here
|
|
69
|
+
"""
|
|
70
|
+
if not cls.name_exist(name=name):
|
|
71
|
+
|
|
72
|
+
if not cls.namespace_exist(namespace=namespace):
|
|
73
|
+
|
|
74
|
+
if AccessType.name_exist(name=access_type):
|
|
75
|
+
access_type_obj = AccessType.read_by_name(name=access_type)
|
|
76
|
+
else:
|
|
77
|
+
access_type_obj = AccessType.create(name=access_type)
|
|
78
|
+
|
|
79
|
+
if access_type_obj:
|
|
80
|
+
|
|
81
|
+
query = cls(
|
|
82
|
+
name=name,
|
|
83
|
+
namespace=namespace,
|
|
84
|
+
access_type=access_type_obj
|
|
85
|
+
)
|
|
86
|
+
query.save()
|
|
87
|
+
|
|
88
|
+
return query
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def read_by_name(cls, name:str)->bool:
|
|
92
|
+
r"""
|
|
93
|
+
|
|
94
|
+
"""
|
|
95
|
+
query = cls.get_or_none(name=name)
|
|
96
|
+
|
|
97
|
+
if query is not None:
|
|
98
|
+
|
|
99
|
+
return query
|
|
100
|
+
|
|
101
|
+
return None
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def read_by_namespace(cls, namespace:str)->bool:
|
|
105
|
+
r"""
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
query = cls.get_or_none(namespace=namespace)
|
|
109
|
+
|
|
110
|
+
if query is not None:
|
|
111
|
+
|
|
112
|
+
return query
|
|
113
|
+
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
@classmethod
|
|
117
|
+
def name_exist(cls, name:str)->bool:
|
|
118
|
+
r"""
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
query = cls.get_or_none(name=name)
|
|
122
|
+
|
|
123
|
+
if query is not None:
|
|
124
|
+
|
|
125
|
+
return True
|
|
126
|
+
|
|
127
|
+
return False
|
|
128
|
+
|
|
129
|
+
@classmethod
|
|
130
|
+
def namespace_exist(cls, namespace:str)->bool:
|
|
131
|
+
r"""
|
|
132
|
+
|
|
133
|
+
"""
|
|
134
|
+
query = cls.get_or_none(namespace=namespace)
|
|
135
|
+
|
|
136
|
+
if query is not None:
|
|
137
|
+
|
|
138
|
+
return True
|
|
139
|
+
|
|
140
|
+
return False
|
|
141
|
+
|
|
142
|
+
@classmethod
|
|
143
|
+
def update_access_type(cls, namespace:str, access_type:str)-> dict:
|
|
144
|
+
r""""
|
|
145
|
+
Update a single record
|
|
146
|
+
|
|
147
|
+
Once a model instance has a primary key, you UPDATE a field by its id.
|
|
148
|
+
The model's primary key will not change:
|
|
149
|
+
"""
|
|
150
|
+
obj = cls.get_or_none(namespace=namespace)
|
|
151
|
+
|
|
152
|
+
if obj:
|
|
153
|
+
|
|
154
|
+
if AccessType.name_exist(name=access_type):
|
|
155
|
+
access_type_obj = AccessType.read_by_name(name=access_type)
|
|
156
|
+
else:
|
|
157
|
+
access_type_obj = AccessType.create(name=access_type)
|
|
158
|
+
|
|
159
|
+
if access_type_obj:
|
|
160
|
+
|
|
161
|
+
query = cls.update(access_type=access_type_obj).where(cls.id == obj.id)
|
|
162
|
+
query.execute()
|
|
163
|
+
return query
|
|
164
|
+
|
|
165
|
+
def serialize(self)-> dict:
|
|
166
|
+
r"""
|
|
167
|
+
Serialize database record to a jsonable object
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
"id": self.id,
|
|
172
|
+
"name": self.name,
|
|
173
|
+
"access_type": self.access_type.serialize()
|
|
174
|
+
}
|