PyAutomationIO 1.1.13__tar.gz → 2.0.0__tar.gz

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 (161) hide show
  1. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/PKG-INFO +3 -5
  2. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/PyAutomationIO.egg-info/PKG-INFO +3 -5
  3. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/PyAutomationIO.egg-info/SOURCES.txt +10 -0
  4. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/PyAutomationIO.egg-info/requires.txt +2 -4
  5. pyautomationio-2.0.0/automation/__init__.py +96 -0
  6. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/core.py +485 -44
  7. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/alarms.py +83 -18
  8. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/events.py +77 -6
  9. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/logs.py +109 -12
  10. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/users.py +28 -0
  11. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/alarms.py +10 -7
  12. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/logs.py +27 -8
  13. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/users.py +27 -0
  14. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/managers/db.py +7 -0
  15. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/managers/opcua_client.py +6 -4
  16. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/__init__.py +9 -1
  17. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/alarms/resources/alarms.py +228 -3
  18. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/alarms/resources/summary.py +39 -6
  19. pyautomationio-2.0.0/automation/modules/database/resources/__init__.py +9 -0
  20. pyautomationio-2.0.0/automation/modules/database/resources/database.py +150 -0
  21. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/events/resources/events.py +40 -7
  22. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/events/resources/logs.py +74 -8
  23. pyautomationio-2.0.0/automation/modules/machines/__init__.py +2 -0
  24. pyautomationio-2.0.0/automation/modules/machines/resources/__init__.py +9 -0
  25. pyautomationio-2.0.0/automation/modules/machines/resources/machines.py +290 -0
  26. pyautomationio-2.0.0/automation/modules/opcua/resources/__init__.py +11 -0
  27. pyautomationio-2.0.0/automation/modules/opcua/resources/clients.py +425 -0
  28. pyautomationio-2.0.0/automation/modules/opcua/resources/server.py +116 -0
  29. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/settings/resources/settings.py +19 -22
  30. pyautomationio-2.0.0/automation/modules/tags/__init__.py +0 -0
  31. pyautomationio-2.0.0/automation/modules/tags/resources/tags.py +603 -0
  32. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/resources/models/users.py +4 -0
  33. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/resources/users.py +116 -5
  34. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/users.py +26 -0
  35. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/opcua/models.py +1 -1
  36. pyautomationio-2.0.0/automation/pages/__init__.py +0 -0
  37. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/requirements.txt +3 -7
  38. pyautomationio-2.0.0/version.py +2 -0
  39. pyautomationio-1.1.13/automation/__init__.py +0 -50
  40. pyautomationio-1.1.13/automation/modules/tags/resources/tags.py +0 -290
  41. pyautomationio-1.1.13/version.py +0 -2
  42. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/LICENSE +0 -0
  43. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/MANIFEST.in +0 -0
  44. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/PyAutomationIO.egg-info/dependency_links.txt +0 -0
  45. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/PyAutomationIO.egg-info/top_level.txt +0 -0
  46. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/README.md +0 -0
  47. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/alarms/__init__.py +0 -0
  48. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/alarms/states.py +0 -0
  49. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/alarms/trigger.py +0 -0
  50. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/buffer.py +0 -0
  51. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/__init__.py +0 -0
  52. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/core.py +0 -0
  53. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/machines.py +0 -0
  54. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/opcua.py +0 -0
  55. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/opcua_server.py +0 -0
  56. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/dbmodels/tags.py +0 -0
  57. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/extensions/__init__.py +0 -0
  58. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/extensions/api.py +0 -0
  59. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/extensions/cors.py +0 -0
  60. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/filter/__init__.py +0 -0
  61. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/iad/__init__.py +0 -0
  62. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/iad/frozen_data.py +0 -0
  63. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/iad/out_of_range.py +0 -0
  64. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/iad/outliers.py +0 -0
  65. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/__init__.py +0 -0
  66. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/core.py +0 -0
  67. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/datalogger.py +0 -0
  68. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/events.py +0 -0
  69. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/logdict.py +0 -0
  70. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/machines.py +0 -0
  71. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/logger/opcua_server.py +0 -0
  72. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/managers/__init__.py +0 -0
  73. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/managers/alarms.py +0 -0
  74. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/managers/state_machine.py +0 -0
  75. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/models.py +0 -0
  76. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/alarms/__init__.py +0 -0
  77. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/alarms/resources/__init__.py +0 -0
  78. {pyautomationio-1.1.13/automation/modules/events → pyautomationio-2.0.0/automation/modules/database}/__init__.py +0 -0
  79. {pyautomationio-1.1.13/automation/modules/tags → pyautomationio-2.0.0/automation/modules/events}/__init__.py +0 -0
  80. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/events/resources/__init__.py +0 -0
  81. {pyautomationio-1.1.13/automation/pages → pyautomationio-2.0.0/automation/modules/opcua}/__init__.py +0 -0
  82. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/settings/__init__.py +0 -0
  83. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/settings/resources/__init__.py +0 -0
  84. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/tags/resources/__init__.py +0 -0
  85. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/__init__.py +0 -0
  86. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/resources/__init__.py +0 -0
  87. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/resources/models/__init__.py +0 -0
  88. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/resources/models/roles.py +0 -0
  89. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/resources/roles.py +0 -0
  90. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/modules/users/roles.py +0 -0
  91. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/opcua/__init__.py +0 -0
  92. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/opcua/subscription.py +0 -0
  93. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/alarms.py +0 -0
  94. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/alarms_history.py +0 -0
  95. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/assets/styles.css +0 -0
  96. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/__init__.py +0 -0
  97. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/alarms.py +0 -0
  98. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/alarms_summary.py +0 -0
  99. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/db.py +0 -0
  100. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/filter.py +0 -0
  101. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/machines.py +0 -0
  102. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/machines_detailed.py +0 -0
  103. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/opcua.py +0 -0
  104. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/opcua_server.py +0 -0
  105. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/tags.py +0 -0
  106. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/callbacks/trends.py +0 -0
  107. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/communications.py +0 -0
  108. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/__init__.py +0 -0
  109. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/alarms.py +0 -0
  110. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/alarms_summary.py +0 -0
  111. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/database.py +0 -0
  112. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/gaussian_filter.py +0 -0
  113. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/machines.py +0 -0
  114. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/opcua.py +0 -0
  115. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/opcua_server.py +0 -0
  116. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/tags.py +0 -0
  117. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/components/trends.py +0 -0
  118. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/database.py +0 -0
  119. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/filter.py +0 -0
  120. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/machines.py +0 -0
  121. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/machines_detailed.py +0 -0
  122. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/main.py +0 -0
  123. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/opcua_server.py +0 -0
  124. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/tags.py +0 -0
  125. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/pages/trends.py +0 -0
  126. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/singleton.py +0 -0
  127. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/state_machine.py +0 -0
  128. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tags/__init__.py +0 -0
  129. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tags/cvt.py +0 -0
  130. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tags/filter.py +0 -0
  131. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tags/tag.py +0 -0
  132. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tests/__init__.py +0 -0
  133. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tests/test_alarms.py +0 -0
  134. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tests/test_core.py +0 -0
  135. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tests/test_unit.py +0 -0
  136. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/tests/test_user.py +0 -0
  137. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/utils/__init__.py +0 -0
  138. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/utils/decorators.py +0 -0
  139. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/utils/observer.py +0 -0
  140. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/utils/units.py +0 -0
  141. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/__init__.py +0 -0
  142. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/adimentional.py +0 -0
  143. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/current.py +0 -0
  144. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/density.py +0 -0
  145. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/eng_time.py +0 -0
  146. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/force.py +0 -0
  147. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/length.py +0 -0
  148. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/mass.py +0 -0
  149. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/mass_flow.py +0 -0
  150. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/percentage.py +0 -0
  151. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/power.py +0 -0
  152. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/pressure.py +0 -0
  153. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/temperature.py +0 -0
  154. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/volume.py +0 -0
  155. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/variables/volumetric_flow.py +0 -0
  156. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/workers/__init__.py +0 -0
  157. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/workers/logger.py +0 -0
  158. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/workers/state_machine.py +0 -0
  159. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/automation/workers/worker.py +0 -0
  160. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/setup.cfg +0 -0
  161. {pyautomationio-1.1.13 → pyautomationio-2.0.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyAutomationIO
3
- Version: 1.1.13
3
+ Version: 2.0.0
4
4
  Summary: A python framework to develop automation industrial processes applications and Artificial Intelligence applications for the industrial field
5
5
  Home-page: https://github.com/know-ai/PyAutomation
6
6
  Author: KnowAI
@@ -30,13 +30,11 @@ Requires-Dist: numpy==2.1.0; python_version >= "3.14"
30
30
  Requires-Dist: PyWavelets==1.6.0; python_version == "3.9"
31
31
  Requires-Dist: PyWavelets==1.7.0; python_version >= "3.10" and python_version <= "3.11"
32
32
  Requires-Dist: PyWavelets==1.9.0; python_version >= "3.12" and python_version <= "3.14"
33
- Requires-Dist: dash==3.3.0
34
- Requires-Dist: dash-bootstrap-components==2.0.4
35
- Requires-Dist: dash-mantine-components==2.4.0
36
- Requires-Dist: dash-iconify==0.1.2
37
33
  Requires-Dist: opcua==0.98.13
38
34
  Requires-Dist: python-dotenv==1.2.1
39
35
  Requires-Dist: cryptography==43.0.3
36
+ Requires-Dist: Flask==3.1.2
37
+ Requires-Dist: requests==2.32.5
40
38
  Requires-Dist: Flask-Cors==6.0.1
41
39
  Requires-Dist: flask-restx==1.3.2
42
40
  Requires-Dist: Flask-SocketIO==5.5.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyAutomationIO
3
- Version: 1.1.13
3
+ Version: 2.0.0
4
4
  Summary: A python framework to develop automation industrial processes applications and Artificial Intelligence applications for the industrial field
5
5
  Home-page: https://github.com/know-ai/PyAutomation
6
6
  Author: KnowAI
@@ -30,13 +30,11 @@ Requires-Dist: numpy==2.1.0; python_version >= "3.14"
30
30
  Requires-Dist: PyWavelets==1.6.0; python_version == "3.9"
31
31
  Requires-Dist: PyWavelets==1.7.0; python_version >= "3.10" and python_version <= "3.11"
32
32
  Requires-Dist: PyWavelets==1.9.0; python_version >= "3.12" and python_version <= "3.14"
33
- Requires-Dist: dash==3.3.0
34
- Requires-Dist: dash-bootstrap-components==2.0.4
35
- Requires-Dist: dash-mantine-components==2.4.0
36
- Requires-Dist: dash-iconify==0.1.2
37
33
  Requires-Dist: opcua==0.98.13
38
34
  Requires-Dist: python-dotenv==1.2.1
39
35
  Requires-Dist: cryptography==43.0.3
36
+ Requires-Dist: Flask==3.1.2
37
+ Requires-Dist: requests==2.32.5
40
38
  Requires-Dist: Flask-Cors==6.0.1
41
39
  Requires-Dist: flask-restx==1.3.2
42
40
  Requires-Dist: Flask-SocketIO==5.5.1
@@ -56,10 +56,20 @@ automation/modules/alarms/__init__.py
56
56
  automation/modules/alarms/resources/__init__.py
57
57
  automation/modules/alarms/resources/alarms.py
58
58
  automation/modules/alarms/resources/summary.py
59
+ automation/modules/database/__init__.py
60
+ automation/modules/database/resources/__init__.py
61
+ automation/modules/database/resources/database.py
59
62
  automation/modules/events/__init__.py
60
63
  automation/modules/events/resources/__init__.py
61
64
  automation/modules/events/resources/events.py
62
65
  automation/modules/events/resources/logs.py
66
+ automation/modules/machines/__init__.py
67
+ automation/modules/machines/resources/__init__.py
68
+ automation/modules/machines/resources/machines.py
69
+ automation/modules/opcua/__init__.py
70
+ automation/modules/opcua/resources/__init__.py
71
+ automation/modules/opcua/resources/clients.py
72
+ automation/modules/opcua/resources/server.py
63
73
  automation/modules/settings/__init__.py
64
74
  automation/modules/settings/resources/__init__.py
65
75
  automation/modules/settings/resources/settings.py
@@ -1,13 +1,11 @@
1
1
  python-statemachine==2.4.0
2
2
  python-statemachine[diagrams]
3
3
  peewee==3.18.3
4
- dash==3.3.0
5
- dash-bootstrap-components==2.0.4
6
- dash-mantine-components==2.4.0
7
- dash-iconify==0.1.2
8
4
  opcua==0.98.13
9
5
  python-dotenv==1.2.1
10
6
  cryptography==43.0.3
7
+ Flask==3.1.2
8
+ requests==2.32.5
11
9
  Flask-Cors==6.0.1
12
10
  flask-restx==1.3.2
13
11
  Flask-SocketIO==5.5.1
@@ -0,0 +1,96 @@
1
+ import os, pytz
2
+ from flask import Flask, send_from_directory, send_file
3
+ from .core import PyAutomation
4
+ from .state_machine import OPCUAServer
5
+
6
+ app = Flask(__name__, instance_relative_config=False)
7
+
8
+ MANUFACTURER = os.environ.get('AUTOMATION_MANUFACTURER')
9
+ SEGMENT = os.environ.get('AUTOMATION_SEGMENT')
10
+ _TIMEZONE = os.environ.get('AUTOMATION_TIMEZONE') or "America/Caracas"
11
+ TIMEZONE = pytz.timezone(_TIMEZONE)
12
+ CERT_FILE = os.path.join(".", "ssl", os.environ.get('AUTOMATION_CERT_FILE') or "")
13
+ KEY_FILE = os.path.join(".", "ssl", os.environ.get('AUTOMATION_KEY_FILE') or "")
14
+ if not os.path.isfile(CERT_FILE):
15
+ CERT_FILE = None
16
+
17
+ if not os.path.isfile(KEY_FILE):
18
+ KEY_FILE = None
19
+ AUTOMATION_OPCUA_SERVER_PORT = os.environ.get('AUTOMATION_OPCUA_SERVER_PORT') or "53530"
20
+ AUTOMATION_LOGGER_PERIOD = os.environ.get('AUTOMATION_LOGGER_PERIOD') or 10.0
21
+ AUTOMATION_APP_SECRET_KEY = os.environ.get('AUTOMATION_APP_SECRET_KEY') or "073821603fcc483f9afee3f1500782a4"
22
+ AUTOMATION_SUPERUSER_PASSWORD = os.environ.get('AUTOMATION_SUPERUSER_PASSWORD') or "super_ultra_secret_password"
23
+
24
+ # Ruta del frontend React construido
25
+ HMI_DIST_PATH = os.path.join(".", "hmi", "dist")
26
+
27
+
28
+ class CreateApp():
29
+ """Initialize the core application."""
30
+
31
+ def __call__(self):
32
+ """
33
+ Documentation here
34
+ """
35
+ app.client = None
36
+ self.application = app
37
+
38
+ with app.app_context():
39
+
40
+ from . import extensions
41
+ extensions.init_app(app)
42
+
43
+ from . import modules
44
+ modules.init_app(app)
45
+
46
+ # Configurar rutas para servir el frontend React
47
+ self._setup_frontend_routes(app)
48
+
49
+ return app
50
+
51
+ def _setup_frontend_routes(self, app):
52
+ """
53
+ Configura las rutas para servir el frontend React construido en /hmi.
54
+ Sirve archivos estáticos y redirige todas las rutas bajo /hmi al index.html (SPA routing).
55
+ Estas rutas se registran con baja prioridad para no interferir con Dash y la API.
56
+ """
57
+ # Verificar si existe el directorio del frontend construido
58
+ if not os.path.exists(HMI_DIST_PATH):
59
+ return # Si no existe, no configuramos las rutas (modo desarrollo o sin frontend)
60
+
61
+ # Servir archivos estáticos del frontend (JS, CSS, assets, etc.) bajo /hmi
62
+ @app.route('/hmi/assets/<path:filename>')
63
+ def serve_frontend_assets(filename):
64
+ """Sirve archivos estáticos del frontend (JS, CSS, imágenes, etc.)"""
65
+ assets_dir = os.path.join(HMI_DIST_PATH, 'assets')
66
+ if os.path.exists(assets_dir):
67
+ return send_from_directory(assets_dir, filename)
68
+ return None
69
+
70
+ # Ruta catch-all para SPA bajo /hmi: todas las rutas /hmi/* sirven el index.html
71
+ @app.route('/hmi/', defaults={'path': ''})
72
+ @app.route('/hmi/<path:path>')
73
+ def serve_frontend_hmi(path):
74
+ """
75
+ Sirve el frontend React bajo /hmi.
76
+ Para rutas que no sean archivos estáticos, sirve index.html (SPA routing).
77
+ """
78
+ # Intentar servir el archivo estático si existe
79
+ if path:
80
+ file_path = os.path.join(HMI_DIST_PATH, path)
81
+ if os.path.exists(file_path) and os.path.isfile(file_path):
82
+ return send_from_directory(HMI_DIST_PATH, path)
83
+
84
+ # Para todas las demás rutas bajo /hmi, servir index.html (SPA routing)
85
+ index_path = os.path.join(HMI_DIST_PATH, 'index.html')
86
+ if os.path.exists(index_path):
87
+ return send_file(index_path)
88
+
89
+ return None
90
+
91
+ __application = CreateApp()
92
+ server = __application()
93
+ server.config['AUTOMATION_APP_SECRET_KEY'] = AUTOMATION_APP_SECRET_KEY
94
+ server.config['AUTOMATION_SUPERUSER_PASSWORD'] = AUTOMATION_SUPERUSER_PASSWORD
95
+ server.config['BUNDLE_ERRORS'] = True
96
+ opcua_server = OPCUAServer()