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,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
+ }