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,192 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
ACTIONS = {
|
|
5
|
+
"Normal": ['shelve', 'suppress by design', 'out of service', 'disable'],
|
|
6
|
+
"Unacknowledged": ['acknowledge', 'shelve', 'suppress by design', 'out of service', 'silence', 'disable'],
|
|
7
|
+
"Acknowledged": ['shelve', 'suppress by design', 'out of service', 'disable'],
|
|
8
|
+
"RTN Unacknowledged": ['shelve', 'suppress by design', 'out of service', 'disable'],
|
|
9
|
+
"Shelved": ["reset"],
|
|
10
|
+
"Suppressed By Design": ["unsuppress by design"],
|
|
11
|
+
"Out Of Service": ["return to service"]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class States(Enum):
|
|
16
|
+
|
|
17
|
+
NORM = "Normal"
|
|
18
|
+
UNACK = "Unacknowledged"
|
|
19
|
+
ACKED = "Acknowledged"
|
|
20
|
+
RTNUN = "RTN Unacknowledged"
|
|
21
|
+
SHLVD = "Shelved"
|
|
22
|
+
DSUPR = "Suppressed By Design"
|
|
23
|
+
OOSRV = "Out Of Service"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Status(Enum):
|
|
27
|
+
|
|
28
|
+
ACTV = "Active"
|
|
29
|
+
NACTV = "Not Active"
|
|
30
|
+
ANNCTD = "Annunciated"
|
|
31
|
+
NANNCTD = "Not Annunciated"
|
|
32
|
+
OR = "Not Active or Active"
|
|
33
|
+
SUPR = "Suppressed"
|
|
34
|
+
NA = "Not Applicable"
|
|
35
|
+
NORM = "Normal"
|
|
36
|
+
ABNORM = "Abnormal"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class AlarmAttrs:
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
mnemonic: str,
|
|
44
|
+
state: str,
|
|
45
|
+
process_condition: str,
|
|
46
|
+
alarm_status: str,
|
|
47
|
+
annunciate_status: str,
|
|
48
|
+
acknowledge_status: str,
|
|
49
|
+
):
|
|
50
|
+
self.__mnemonic = mnemonic
|
|
51
|
+
self.__state = state
|
|
52
|
+
self.__process_condition = process_condition
|
|
53
|
+
self.__alarm_status = alarm_status
|
|
54
|
+
self.__annunciate_status = annunciate_status
|
|
55
|
+
self.__acknowledge_status = acknowledge_status
|
|
56
|
+
|
|
57
|
+
@property
|
|
58
|
+
def mnemonic(self):
|
|
59
|
+
r"""
|
|
60
|
+
Documentation here
|
|
61
|
+
"""
|
|
62
|
+
return self.__mnemonic
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def state(self):
|
|
66
|
+
r"""
|
|
67
|
+
Documentation here
|
|
68
|
+
"""
|
|
69
|
+
return self.__state
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def process_condition(self):
|
|
73
|
+
r"""
|
|
74
|
+
Documentation here
|
|
75
|
+
"""
|
|
76
|
+
return self.__process_condition
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def alarm_status(self):
|
|
80
|
+
r"""
|
|
81
|
+
Documentation here
|
|
82
|
+
"""
|
|
83
|
+
return self.__alarm_status
|
|
84
|
+
|
|
85
|
+
@property
|
|
86
|
+
def annunciate_status(self):
|
|
87
|
+
r"""
|
|
88
|
+
Documentation here
|
|
89
|
+
"""
|
|
90
|
+
return self.__annunciate_status
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def acknowledge_status(self):
|
|
94
|
+
r"""
|
|
95
|
+
Documentation here
|
|
96
|
+
"""
|
|
97
|
+
return self.__acknowledge_status
|
|
98
|
+
|
|
99
|
+
def is_acknowledged(self):
|
|
100
|
+
r"""
|
|
101
|
+
Documentation here
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
return self.acknowledge_status == States.ACKED.value
|
|
105
|
+
|
|
106
|
+
def serialize(self):
|
|
107
|
+
r"""
|
|
108
|
+
Documentation here
|
|
109
|
+
"""
|
|
110
|
+
return {
|
|
111
|
+
'mnemonic': self.mnemonic,
|
|
112
|
+
'state': self.state,
|
|
113
|
+
'process_condition': self.process_condition,
|
|
114
|
+
'alarm_status': self.alarm_status,
|
|
115
|
+
'annunciate_status': self.annunciate_status,
|
|
116
|
+
'acknowledge_status': self.acknowledge_status
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class AlarmState:
|
|
121
|
+
|
|
122
|
+
NORM = AlarmAttrs(
|
|
123
|
+
mnemonic=States.NORM.name,
|
|
124
|
+
state=States.NORM.value,
|
|
125
|
+
process_condition=Status.NORM.value,
|
|
126
|
+
alarm_status=Status.NACTV.value,
|
|
127
|
+
annunciate_status=Status.NANNCTD.value,
|
|
128
|
+
acknowledge_status=States.ACKED.value
|
|
129
|
+
)
|
|
130
|
+
UNACK = AlarmAttrs(
|
|
131
|
+
mnemonic=States.UNACK.name,
|
|
132
|
+
state=States.UNACK.value,
|
|
133
|
+
process_condition=Status.ABNORM.value,
|
|
134
|
+
alarm_status=Status.ACTV.value,
|
|
135
|
+
annunciate_status=Status.ANNCTD.value,
|
|
136
|
+
acknowledge_status=States.UNACK.value
|
|
137
|
+
)
|
|
138
|
+
ACKED = AlarmAttrs(
|
|
139
|
+
mnemonic=States.ACKED.name,
|
|
140
|
+
state=States.ACKED.value,
|
|
141
|
+
process_condition=Status.ABNORM.value,
|
|
142
|
+
alarm_status=Status.ACTV.value,
|
|
143
|
+
annunciate_status=Status.ANNCTD.value,
|
|
144
|
+
acknowledge_status=States.ACKED.value
|
|
145
|
+
)
|
|
146
|
+
RTNUN = AlarmAttrs(
|
|
147
|
+
mnemonic=States.RTNUN.name,
|
|
148
|
+
state=States.RTNUN.value,
|
|
149
|
+
process_condition=Status.NORM.value,
|
|
150
|
+
alarm_status=Status.NACTV.value,
|
|
151
|
+
annunciate_status=Status.ANNCTD.value,
|
|
152
|
+
acknowledge_status=States.UNACK.value
|
|
153
|
+
)
|
|
154
|
+
SHLVD = AlarmAttrs(
|
|
155
|
+
mnemonic=States.SHLVD.name,
|
|
156
|
+
state=States.SHLVD.value,
|
|
157
|
+
process_condition=Status.NORM.value,
|
|
158
|
+
alarm_status=Status.OR.value,
|
|
159
|
+
annunciate_status=Status.SUPR.value,
|
|
160
|
+
acknowledge_status=Status.NA.value
|
|
161
|
+
)
|
|
162
|
+
DSUPR = AlarmAttrs(
|
|
163
|
+
mnemonic=States.DSUPR.name,
|
|
164
|
+
state=States.DSUPR.value,
|
|
165
|
+
process_condition=Status.NORM.value,
|
|
166
|
+
alarm_status=Status.OR.value,
|
|
167
|
+
annunciate_status=Status.SUPR.value,
|
|
168
|
+
acknowledge_status=Status.NA.value
|
|
169
|
+
)
|
|
170
|
+
OOSRV = AlarmAttrs(
|
|
171
|
+
mnemonic=States.OOSRV.name,
|
|
172
|
+
state=States.OOSRV.value,
|
|
173
|
+
process_condition=Status.NORM.value,
|
|
174
|
+
alarm_status=Status.OR.value,
|
|
175
|
+
annunciate_status=Status.SUPR.value,
|
|
176
|
+
acknowledge_status=Status.NA.value
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
_states = [NORM, UNACK, ACKED, RTNUN, SHLVD, DSUPR, OOSRV]
|
|
180
|
+
|
|
181
|
+
@classmethod
|
|
182
|
+
def get_state_by_name(cls, state:str):
|
|
183
|
+
r"""
|
|
184
|
+
Documentation here
|
|
185
|
+
"""
|
|
186
|
+
_state = States(state)
|
|
187
|
+
for alarm_state in cls._states:
|
|
188
|
+
|
|
189
|
+
if _state==alarm_state:
|
|
190
|
+
|
|
191
|
+
return alarm_state
|
|
192
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
class TriggerType(Enum):
|
|
4
|
+
|
|
5
|
+
HH = "HIGH-HIGH"
|
|
6
|
+
H = "HIGH"
|
|
7
|
+
L = "LOW"
|
|
8
|
+
LL = "LOW-LOW"
|
|
9
|
+
B = "BOOL"
|
|
10
|
+
NONE = "NOT DEFINED"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Trigger:
|
|
14
|
+
|
|
15
|
+
def __init__(self):
|
|
16
|
+
|
|
17
|
+
self.__type = TriggerType.NONE
|
|
18
|
+
self.__value = None
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def type(self):
|
|
22
|
+
r"""
|
|
23
|
+
Documentation here
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
return self.__type
|
|
27
|
+
|
|
28
|
+
@type.setter
|
|
29
|
+
def type(self, _type:str):
|
|
30
|
+
|
|
31
|
+
self.__type = TriggerType(_type)
|
|
32
|
+
|
|
33
|
+
@property
|
|
34
|
+
def value(self):
|
|
35
|
+
r"""
|
|
36
|
+
Documentation here
|
|
37
|
+
"""
|
|
38
|
+
return self.__value
|
|
39
|
+
|
|
40
|
+
@value.setter
|
|
41
|
+
def value(self, value):
|
|
42
|
+
|
|
43
|
+
if self.type==TriggerType.B:
|
|
44
|
+
|
|
45
|
+
if isinstance(value, bool):
|
|
46
|
+
|
|
47
|
+
self.__value = value
|
|
48
|
+
|
|
49
|
+
else:
|
|
50
|
+
|
|
51
|
+
self.__value = bool(value)
|
|
52
|
+
|
|
53
|
+
else:
|
|
54
|
+
|
|
55
|
+
if isinstance(value, (float, int)):
|
|
56
|
+
|
|
57
|
+
self.__value = value
|
|
58
|
+
|
|
59
|
+
def serialize(self):
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
"type": self.type.value,
|
|
63
|
+
"value": self.value
|
|
64
|
+
}
|
automation/buffer.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
class Buffer(list):
|
|
2
|
+
r"""
|
|
3
|
+
Documentation here
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
def __init__(self, size:int=10, roll:str='forward'):
|
|
7
|
+
r"""
|
|
8
|
+
Documentation here
|
|
9
|
+
"""
|
|
10
|
+
self._roll_type_allowed = ['forward', 'backward']
|
|
11
|
+
self._size = size
|
|
12
|
+
self.roll = roll
|
|
13
|
+
|
|
14
|
+
@property
|
|
15
|
+
def size(self):
|
|
16
|
+
r"""
|
|
17
|
+
Documentation here
|
|
18
|
+
"""
|
|
19
|
+
return self._size
|
|
20
|
+
|
|
21
|
+
@size.setter
|
|
22
|
+
def size(self, value:int):
|
|
23
|
+
r"""
|
|
24
|
+
Documentation here
|
|
25
|
+
"""
|
|
26
|
+
if not isinstance(value, int):
|
|
27
|
+
|
|
28
|
+
raise TypeError("Only integers are allowed")
|
|
29
|
+
|
|
30
|
+
if value <= 1:
|
|
31
|
+
|
|
32
|
+
raise ValueError(f"{value} must be greater than one (1)")
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
self.__init__(value, roll=self.roll)
|
|
36
|
+
|
|
37
|
+
def last(self):
|
|
38
|
+
r"""
|
|
39
|
+
Returns last registered value of the buffer
|
|
40
|
+
"""
|
|
41
|
+
if self:
|
|
42
|
+
if self.roll == 'forward':
|
|
43
|
+
|
|
44
|
+
return self[-1]
|
|
45
|
+
|
|
46
|
+
return self[0]
|
|
47
|
+
|
|
48
|
+
def current(self):
|
|
49
|
+
r"""
|
|
50
|
+
Returns lastest registered value of the buffer
|
|
51
|
+
"""
|
|
52
|
+
if self:
|
|
53
|
+
if self.roll == 'forward':
|
|
54
|
+
|
|
55
|
+
return self[0]
|
|
56
|
+
|
|
57
|
+
return self[-1]
|
|
58
|
+
|
|
59
|
+
def previous_current(self):
|
|
60
|
+
r"""
|
|
61
|
+
Returns lastest registered value of the buffer
|
|
62
|
+
"""
|
|
63
|
+
if self:
|
|
64
|
+
if self.roll == 'forward':
|
|
65
|
+
|
|
66
|
+
return self[1]
|
|
67
|
+
|
|
68
|
+
return self[-2]
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def roll(self):
|
|
72
|
+
r"""
|
|
73
|
+
Documentation here
|
|
74
|
+
"""
|
|
75
|
+
return self.roll_type
|
|
76
|
+
|
|
77
|
+
@roll.setter
|
|
78
|
+
def roll(self, value:str):
|
|
79
|
+
r"""
|
|
80
|
+
Documentation here
|
|
81
|
+
"""
|
|
82
|
+
if not isinstance(value, str):
|
|
83
|
+
|
|
84
|
+
raise TypeError("Only strings are allowed")
|
|
85
|
+
|
|
86
|
+
if value not in self._roll_type_allowed:
|
|
87
|
+
|
|
88
|
+
raise ValueError(f"{value} is not allowed, you can only use: {self._roll_type_allowed}")
|
|
89
|
+
|
|
90
|
+
self.roll_type = value
|
|
91
|
+
|
|
92
|
+
def __call__(self, value):
|
|
93
|
+
r"""
|
|
94
|
+
Documentation here
|
|
95
|
+
"""
|
|
96
|
+
if self.roll.lower()=='forward':
|
|
97
|
+
|
|
98
|
+
_len = len(self)
|
|
99
|
+
|
|
100
|
+
if _len >= self.size:
|
|
101
|
+
|
|
102
|
+
if _len == self.size:
|
|
103
|
+
|
|
104
|
+
self.pop()
|
|
105
|
+
|
|
106
|
+
else:
|
|
107
|
+
|
|
108
|
+
for _ in range(_len - self.size):
|
|
109
|
+
|
|
110
|
+
self.pop()
|
|
111
|
+
|
|
112
|
+
super(Buffer, self).insert(0, value)
|
|
113
|
+
|
|
114
|
+
else:
|
|
115
|
+
|
|
116
|
+
_len = len(self)
|
|
117
|
+
|
|
118
|
+
if _len >= self.size:
|
|
119
|
+
|
|
120
|
+
if _len == self.size:
|
|
121
|
+
|
|
122
|
+
self.pop(0)
|
|
123
|
+
|
|
124
|
+
else:
|
|
125
|
+
|
|
126
|
+
for _ in range(_len - self.size):
|
|
127
|
+
|
|
128
|
+
self.pop(0)
|
|
129
|
+
|
|
130
|
+
super(Buffer, self).append(value)
|
|
131
|
+
|
|
132
|
+
return self
|