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.
Files changed (138) hide show
  1. automation/__init__.py +46 -0
  2. automation/alarms/__init__.py +563 -0
  3. automation/alarms/states.py +192 -0
  4. automation/alarms/trigger.py +64 -0
  5. automation/buffer.py +132 -0
  6. automation/core.py +1775 -0
  7. automation/dbmodels/__init__.py +23 -0
  8. automation/dbmodels/alarms.py +524 -0
  9. automation/dbmodels/core.py +86 -0
  10. automation/dbmodels/events.py +153 -0
  11. automation/dbmodels/logs.py +155 -0
  12. automation/dbmodels/machines.py +181 -0
  13. automation/dbmodels/opcua.py +81 -0
  14. automation/dbmodels/opcua_server.py +174 -0
  15. automation/dbmodels/tags.py +921 -0
  16. automation/dbmodels/users.py +259 -0
  17. automation/extensions/__init__.py +15 -0
  18. automation/extensions/api.py +149 -0
  19. automation/extensions/cors.py +18 -0
  20. automation/filter/__init__.py +19 -0
  21. automation/iad/__init__.py +3 -0
  22. automation/iad/frozen_data.py +54 -0
  23. automation/iad/out_of_range.py +51 -0
  24. automation/iad/outliers.py +51 -0
  25. automation/logger/__init__.py +0 -0
  26. automation/logger/alarms.py +426 -0
  27. automation/logger/core.py +265 -0
  28. automation/logger/datalogger.py +646 -0
  29. automation/logger/events.py +194 -0
  30. automation/logger/logdict.py +53 -0
  31. automation/logger/logs.py +203 -0
  32. automation/logger/machines.py +248 -0
  33. automation/logger/opcua_server.py +130 -0
  34. automation/logger/users.py +96 -0
  35. automation/managers/__init__.py +4 -0
  36. automation/managers/alarms.py +455 -0
  37. automation/managers/db.py +328 -0
  38. automation/managers/opcua_client.py +186 -0
  39. automation/managers/state_machine.py +183 -0
  40. automation/models.py +174 -0
  41. automation/modules/__init__.py +14 -0
  42. automation/modules/alarms/__init__.py +0 -0
  43. automation/modules/alarms/resources/__init__.py +10 -0
  44. automation/modules/alarms/resources/alarms.py +280 -0
  45. automation/modules/alarms/resources/summary.py +79 -0
  46. automation/modules/events/__init__.py +0 -0
  47. automation/modules/events/resources/__init__.py +10 -0
  48. automation/modules/events/resources/events.py +83 -0
  49. automation/modules/events/resources/logs.py +109 -0
  50. automation/modules/tags/__init__.py +0 -0
  51. automation/modules/tags/resources/__init__.py +8 -0
  52. automation/modules/tags/resources/tags.py +201 -0
  53. automation/modules/users/__init__.py +2 -0
  54. automation/modules/users/resources/__init__.py +10 -0
  55. automation/modules/users/resources/models/__init__.py +2 -0
  56. automation/modules/users/resources/models/roles.py +5 -0
  57. automation/modules/users/resources/models/users.py +14 -0
  58. automation/modules/users/resources/roles.py +38 -0
  59. automation/modules/users/resources/users.py +113 -0
  60. automation/modules/users/roles.py +121 -0
  61. automation/modules/users/users.py +335 -0
  62. automation/opcua/__init__.py +1 -0
  63. automation/opcua/models.py +541 -0
  64. automation/opcua/subscription.py +259 -0
  65. automation/pages/__init__.py +0 -0
  66. automation/pages/alarms.py +34 -0
  67. automation/pages/alarms_history.py +21 -0
  68. automation/pages/assets/styles.css +7 -0
  69. automation/pages/callbacks/__init__.py +28 -0
  70. automation/pages/callbacks/alarms.py +218 -0
  71. automation/pages/callbacks/alarms_summary.py +20 -0
  72. automation/pages/callbacks/db.py +222 -0
  73. automation/pages/callbacks/filter.py +238 -0
  74. automation/pages/callbacks/machines.py +29 -0
  75. automation/pages/callbacks/machines_detailed.py +581 -0
  76. automation/pages/callbacks/opcua.py +266 -0
  77. automation/pages/callbacks/opcua_server.py +244 -0
  78. automation/pages/callbacks/tags.py +495 -0
  79. automation/pages/callbacks/trends.py +119 -0
  80. automation/pages/communications.py +129 -0
  81. automation/pages/components/__init__.py +123 -0
  82. automation/pages/components/alarms.py +151 -0
  83. automation/pages/components/alarms_summary.py +45 -0
  84. automation/pages/components/database.py +128 -0
  85. automation/pages/components/gaussian_filter.py +69 -0
  86. automation/pages/components/machines.py +396 -0
  87. automation/pages/components/opcua.py +384 -0
  88. automation/pages/components/opcua_server.py +53 -0
  89. automation/pages/components/tags.py +253 -0
  90. automation/pages/components/trends.py +66 -0
  91. automation/pages/database.py +26 -0
  92. automation/pages/filter.py +55 -0
  93. automation/pages/machines.py +20 -0
  94. automation/pages/machines_detailed.py +41 -0
  95. automation/pages/main.py +63 -0
  96. automation/pages/opcua_server.py +28 -0
  97. automation/pages/tags.py +40 -0
  98. automation/pages/trends.py +35 -0
  99. automation/singleton.py +30 -0
  100. automation/state_machine.py +1672 -0
  101. automation/tags/__init__.py +2 -0
  102. automation/tags/cvt.py +1198 -0
  103. automation/tags/filter.py +55 -0
  104. automation/tags/tag.py +418 -0
  105. automation/tests/__init__.py +10 -0
  106. automation/tests/test_alarms.py +110 -0
  107. automation/tests/test_core.py +257 -0
  108. automation/tests/test_unit.py +21 -0
  109. automation/tests/test_user.py +155 -0
  110. automation/utils/__init__.py +164 -0
  111. automation/utils/decorators.py +222 -0
  112. automation/utils/npw.py +294 -0
  113. automation/utils/observer.py +21 -0
  114. automation/utils/units.py +118 -0
  115. automation/variables/__init__.py +55 -0
  116. automation/variables/adimentional.py +30 -0
  117. automation/variables/current.py +71 -0
  118. automation/variables/density.py +115 -0
  119. automation/variables/eng_time.py +68 -0
  120. automation/variables/force.py +90 -0
  121. automation/variables/length.py +104 -0
  122. automation/variables/mass.py +80 -0
  123. automation/variables/mass_flow.py +101 -0
  124. automation/variables/percentage.py +30 -0
  125. automation/variables/power.py +113 -0
  126. automation/variables/pressure.py +93 -0
  127. automation/variables/temperature.py +168 -0
  128. automation/variables/volume.py +70 -0
  129. automation/variables/volumetric_flow.py +100 -0
  130. automation/workers/__init__.py +2 -0
  131. automation/workers/logger.py +164 -0
  132. automation/workers/state_machine.py +207 -0
  133. automation/workers/worker.py +36 -0
  134. pyautomationio-0.0.0.dist-info/METADATA +198 -0
  135. pyautomationio-0.0.0.dist-info/RECORD +138 -0
  136. pyautomationio-0.0.0.dist-info/WHEEL +5 -0
  137. pyautomationio-0.0.0.dist-info/licenses/LICENSE +21 -0
  138. pyautomationio-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,396 @@
1
+ import dash
2
+ import dash_bootstrap_components as dbc
3
+ from automation.models import StringType
4
+
5
+
6
+ class MachinesComponents:
7
+
8
+ @classmethod
9
+ def machine_actions(cls):
10
+ r"""
11
+ Documentation here
12
+ """
13
+
14
+ return dash.html.Div([
15
+ dash.dcc.Location(id='machine_actions_page', refresh=False),
16
+ dbc.Row([
17
+ dbc.Col([
18
+ dbc.InputGroup(
19
+ [
20
+ dbc.InputGroupText(id="machine_state_input"),
21
+ dbc.Select(
22
+ options=[],
23
+ id="machine_actions_input"
24
+ ),
25
+ ],
26
+ size="md"
27
+ )
28
+ ],
29
+ width=12,
30
+ className="col-sm-12 col-md-12")
31
+ ])
32
+ ])
33
+
34
+ @classmethod
35
+ def machine_attributes(cls, app, machine_name:str):
36
+ r"""
37
+ Documentation here
38
+ """
39
+ machine = app.get_machine(name=StringType(machine_name))
40
+ machine_interval = machine.get_interval()
41
+ threshold = machine.threshold
42
+ on_delay = machine.on_delay
43
+ disable = True
44
+ if hasattr(machine, "buffer_size"):
45
+ disable = False
46
+ if "pfm" in machine_name.lower():
47
+ disable = True
48
+ elif "observer" in machine_name.lower():
49
+ disable = True
50
+ return dash.html.Div([
51
+ dash.dcc.Location(id='machine_attributes_page', refresh=False),
52
+ dbc.Accordion(
53
+ [
54
+ dbc.AccordionItem(
55
+ [
56
+ dbc.Row([
57
+ dbc.Col(
58
+ [
59
+ dbc.InputGroup(
60
+ [
61
+ dbc.Input(placeholder=f"{machine_name} Current threshold {threshold.value}", type="number", step=0.1, min=0.0, max=600000, id="machine_threshold_input", disabled=disable, n_submit=0),
62
+ dbc.InputGroupText(threshold.unit, id="threshold_input_text")
63
+ ],
64
+ size="md",
65
+ className="mb-1"
66
+ )
67
+ ],
68
+ width=12,
69
+ className="col-sm-12 col-md-12 col-lg-12"
70
+ ),
71
+ dbc.Col(
72
+ [
73
+ dbc.InputGroup(
74
+ [
75
+ dbc.Input(placeholder=f"Current Machine Interval {machine_interval}", type="number", step=0.5, min=0.5, max=600000, id="machine_interval_input", disabled=False, n_submit=0),
76
+ dbc.InputGroupText('s')
77
+ ],
78
+ size="md",
79
+ className="mb-1"
80
+ )
81
+ ],
82
+ width=12,
83
+ className="col-sm-12 col-md-12 col-lg-12"
84
+ ),
85
+ dbc.Col(
86
+ [
87
+ dbc.InputGroup(
88
+ [
89
+ dbc.Input(placeholder="Buffer Size", type="number", step=1, min=2, max=600000, id="buffer_size_input", disabled=disable, n_submit=0),
90
+ ],
91
+ size="md",
92
+ className="mb-1"
93
+ )
94
+ ],
95
+ width=12,
96
+ className="col-sm-12 col-md-12 col-lg-12"
97
+ ),
98
+ dbc.Col(
99
+ [
100
+ dbc.InputGroup(
101
+ [
102
+ dbc.Input(placeholder=f"Current On Delay: {on_delay.value}", type="number", step=1, min=1, max=600000, id="on_delay_input", disabled=False, n_submit=0),
103
+ dbc.InputGroupText('s')
104
+ ],
105
+ size="md",
106
+ className="mb-1"
107
+ )
108
+ ],
109
+ width=12,
110
+ className="col-sm-12 col-md-12 col-lg-12"
111
+ ),
112
+ ])
113
+ ],
114
+ title="Machine Attributes",
115
+ className="my-3"
116
+ )
117
+ ],
118
+ start_collapsed=False,
119
+ )
120
+ ])
121
+
122
+ @classmethod
123
+ def subscription_tag_form(cls, app, machine_name:str):
124
+ r"""
125
+ Documentation here
126
+ """
127
+ machine = app.get_machine(name=StringType(machine_name))
128
+ internal_variables = machine.get_read_only_process_type_variables()
129
+ subscribed_tags_machine = [{"label": "", "value": ""}]
130
+ not_subscribed = [{"label": "", "value": ""}]
131
+ available_tags = [{"label": "", "value": ""}]
132
+ tags = app.cvt._cvt.get_field_tags_names()
133
+ for _tag_name, value in internal_variables.items():
134
+
135
+ if value.tag:
136
+ subscribed_tags_machine.append({
137
+ "label": f"{value.tag.name}->{_tag_name}", "value": value.tag.name
138
+ })
139
+
140
+ if value.tag.name in tags:
141
+
142
+ tags.remove(value.tag.name)
143
+
144
+ else:
145
+
146
+ not_subscribed.append({
147
+ "label": _tag_name, "value": _tag_name
148
+ })
149
+
150
+ for tag in tags:
151
+
152
+ available_tags.append({
153
+ "label": tag, "value": tag
154
+ })
155
+
156
+ return dash.html.Div(
157
+ [
158
+ dash.dcc.Location(id='tags_machine_subscription_page', refresh=False),
159
+ dbc.Accordion(
160
+ [
161
+ dbc.AccordionItem(
162
+ [
163
+ dbc.Row(
164
+ [
165
+ dbc.Col(
166
+ [
167
+ dbc.InputGroup(
168
+ [
169
+ dbc.InputGroupText("Subscribed"),
170
+ dbc.Select(
171
+ options=subscribed_tags_machine,
172
+ id="subscribed_tag_machine_input"
173
+ ),
174
+ ],
175
+ size="md"
176
+ )
177
+ ],
178
+ width=12,
179
+ className="col-sm-12 col-md-12"
180
+ )
181
+ ],
182
+ className="form g-3"
183
+ ),
184
+ dbc.Row([
185
+ dbc.Col(
186
+ [
187
+ dbc.InputGroup(
188
+ [
189
+ dbc.InputGroupText("Field"), dbc.Select(options=available_tags, id="field_tag_input" )
190
+ ],
191
+ size="md",
192
+ className="mb-6"
193
+ )
194
+
195
+ ],
196
+ width=12,
197
+ className="col-sm-12 col-md-6"
198
+ ),
199
+
200
+ dbc.Col(
201
+ [
202
+ dbc.InputGroup(
203
+ [
204
+ dbc.InputGroupText("Tag"),
205
+ dbc.Select(options=not_subscribed, id="internal_tag_input")
206
+ ],
207
+ size="md",
208
+ className="mb-6"
209
+ )
210
+ ],
211
+ width=12,
212
+ className="col-sm-12 col-md-6"
213
+ ),
214
+ ]),
215
+ dbc.Row([
216
+ dbc.Col(
217
+ dbc.Button(
218
+ "Subscribe",
219
+ color="primary",
220
+ outline=True,
221
+ disabled=True,
222
+ id="subscribe_tag_machine_button",
223
+ className="w-100"
224
+ ),
225
+ width="auto",
226
+ className="d-flex justify-content-center align-items-center"
227
+ ),
228
+ dbc.Col(
229
+ dbc.Button(
230
+ "Unsubscribe",
231
+ color="danger",
232
+ outline=True,
233
+ disabled=True,
234
+ id="unsubscribe_tag_machine_button",
235
+ className="w-100"
236
+ ),
237
+ width="auto",
238
+ className="d-flex justify-content-center align-items-center"
239
+ ),
240
+ ])
241
+ ],
242
+ title="Tags - Machine Subscription",
243
+ className="my-3"
244
+ )
245
+ ],
246
+ start_collapsed=False,
247
+ )
248
+ ]
249
+ )
250
+
251
+ @classmethod
252
+ def machines_table(cls)->dash.dash_table.DataTable:
253
+ r"""
254
+ Documentation here
255
+ """
256
+ return dbc.Container(
257
+ dbc.Row(
258
+ dbc.Col(
259
+ dash.dash_table.DataTable(
260
+ data=[],
261
+ columns=[
262
+ {'name': 'name', 'id': 'name', 'editable': False},
263
+ {'name': 'sampling_time', 'id': 'sampling_time', 'editable': False},
264
+ {'name': 'description', 'id': 'description', 'editable': False},
265
+ {'name': 'state', 'id': 'state', 'editable': False},
266
+ {'name': 'criticity', 'id': 'criticity', 'editable': False},
267
+ {'name': 'priority', 'id': 'priority', 'editable': False},
268
+ {'name': 'classification', 'id': 'classification', 'editable': False},
269
+ ],
270
+ id="machines_datatable",
271
+ filter_action="native",
272
+ sort_action="native",
273
+ sort_mode="multi",
274
+ selected_columns=[],
275
+ page_action="native",
276
+ page_current= 0,
277
+ page_size= 10,
278
+ persistence=True,
279
+ editable=True,
280
+ persisted_props=['data'],
281
+ export_format='xlsx',
282
+ export_headers='display',
283
+ style_table={'overflowX': 'auto'},
284
+ ),
285
+ width=12,
286
+ )
287
+ ),
288
+ fluid=True,
289
+ className="mx-0 px-0"
290
+ )
291
+
292
+ @classmethod
293
+ def machines_tabs(cls):
294
+
295
+ return dash.html.Div(
296
+ [
297
+ dbc.Tabs(
298
+ [
299
+ dbc.Tab(label="No Advanced Machine", tab_id="tab-1"),
300
+ ],
301
+ id="machines_detailed_tabs",
302
+ active_tab="tab-1",
303
+ ),
304
+ dash.html.Div(id="machine_detailed_content"),
305
+ ]
306
+ )
307
+
308
+ @classmethod
309
+ def machine_tab_datatable_content(cls, app, machine_name:str)->dash.dash_table.DataTable:
310
+ r"""
311
+ Documentation here
312
+ """
313
+ def flatten_dict(d, parent_key='', sep='.'):
314
+ items = []
315
+ for k, v in d.items():
316
+
317
+ new_key = f"{parent_key}{sep}{k}" if parent_key else k
318
+ if isinstance(v, dict):
319
+ items.extend(flatten_dict(v, new_key, sep=sep).items())
320
+ else:
321
+ items.append((new_key, v))
322
+
323
+ return dict(items)
324
+
325
+ machine = app.get_machine(name=StringType(machine_name))
326
+ data = list()
327
+ serialized_data = machine.serialize()
328
+ flattened_data = flatten_dict(serialized_data)
329
+ for key, value in flattened_data.items():
330
+
331
+ if isinstance(value, (bool, int, str, float)):
332
+
333
+ data.append({"name": key, "value": value})
334
+
335
+ return dash.dash_table.DataTable(
336
+ data=data,
337
+ columns=[
338
+ {'name': 'name', 'id': 'name', 'editable': False},
339
+ {'name': 'value', 'id': 'value', 'editable': False},
340
+ ],
341
+ id="machines_detailed_datatable",
342
+ filter_action="native",
343
+ sort_action="native",
344
+ sort_mode="multi",
345
+ row_deletable=False,
346
+ selected_columns=[],
347
+ page_action="native",
348
+ page_size=10,
349
+ persistence=True,
350
+ editable=False,
351
+ persisted_props=['data'],
352
+ export_format='xlsx',
353
+ export_headers='display',
354
+ style_table={'overflowX': 'auto'},
355
+ )
356
+
357
+ @classmethod
358
+ def machine_tab_content(cls, app, machine_name:str):
359
+
360
+ return dash.html.Div(
361
+ [
362
+ dbc.Row([
363
+ dbc.Col(
364
+ [
365
+ dbc.Container(
366
+ dbc.Row(
367
+ dbc.Col(
368
+ cls.machine_tab_datatable_content(app=app, machine_name=machine_name),
369
+ width=12,
370
+ )
371
+ ),
372
+ fluid=True,
373
+ className="mx-0 px-0"
374
+ )
375
+ ],
376
+ width=6,
377
+ className="col-sm-12 col-md-6"
378
+ ),
379
+ dbc.Col(
380
+ [
381
+ dbc.Row([
382
+ cls.subscription_tag_form(app=app, machine_name=machine_name)
383
+ ]),
384
+ dbc.Row([
385
+ cls.machine_actions()
386
+ ]),
387
+ dbc.Row([
388
+ cls.machine_attributes(app=app, machine_name=machine_name)
389
+ ]),
390
+ ],
391
+ width=6,
392
+ className="col-sm-12 col-md-6"
393
+ )
394
+ ])
395
+ ]
396
+ )