PyAutomationIO 1.1.1__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 +1792 -0
- automation/dbmodels/__init__.py +23 -0
- automation/dbmodels/alarms.py +549 -0
- automation/dbmodels/core.py +86 -0
- automation/dbmodels/events.py +178 -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 +434 -0
- automation/logger/core.py +265 -0
- automation/logger/datalogger.py +877 -0
- automation/logger/events.py +202 -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 +81 -0
- automation/modules/events/__init__.py +0 -0
- automation/modules/events/resources/__init__.py +10 -0
- automation/modules/events/resources/events.py +85 -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 +254 -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 +1674 -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-1.1.1.dist-info/METADATA +199 -0
- pyautomationio-1.1.1.dist-info/RECORD +138 -0
- pyautomationio-1.1.1.dist-info/WHEEL +5 -0
- pyautomationio-1.1.1.dist-info/licenses/LICENSE +21 -0
- pyautomationio-1.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from .temperature import Temperature
|
|
2
|
+
from .length import Length
|
|
3
|
+
from .current import Current
|
|
4
|
+
from .eng_time import Time
|
|
5
|
+
from .pressure import Pressure
|
|
6
|
+
from .mass import Mass
|
|
7
|
+
from .force import Force
|
|
8
|
+
from .power import Power
|
|
9
|
+
from .volumetric_flow import VolumetricFlow
|
|
10
|
+
from .mass_flow import MassFlow
|
|
11
|
+
from .density import Density
|
|
12
|
+
from .percentage import Percentage
|
|
13
|
+
from .adimentional import Adimentional
|
|
14
|
+
from .volume import Volume
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
temperature_base = Temperature(value=1, unit='K')
|
|
18
|
+
length_base = Length(value=1, unit="m")
|
|
19
|
+
current_base = Current(value=1, unit="A")
|
|
20
|
+
time_base = Time(value=1, unit="s")
|
|
21
|
+
pressure_base = Pressure(value=1, unit="bar")
|
|
22
|
+
mass_base = Mass(value=1, unit="kg")
|
|
23
|
+
force_base = Force(value=1, unit="J/m")
|
|
24
|
+
power_base = Power(value=1, unit="kW")
|
|
25
|
+
volumetric_flow_base = VolumetricFlow(value=1, unit="bbl/sec")
|
|
26
|
+
mass_flow_base = MassFlow(value=1.0, unit="kg/day")
|
|
27
|
+
density_base = Density(value=1.0, unit="kg/bbl")
|
|
28
|
+
percentage_base = Percentage(value=0.0, unit="%")
|
|
29
|
+
adimentional_base = Adimentional(value=0.0, unit="adim")
|
|
30
|
+
volume_base = Volume(value=0.0, unit="m3")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
VARIABLES = {
|
|
34
|
+
f"{temperature_base.__class__.__name__}": temperature_base.Units.serialize(),
|
|
35
|
+
f"{length_base.__class__.__name__}": length_base.Units.serialize(),
|
|
36
|
+
f"{current_base.__class__.__name__}": current_base.Units.serialize(),
|
|
37
|
+
f"{time_base.__class__.__name__}": time_base.Units.serialize(),
|
|
38
|
+
f"{pressure_base.__class__.__name__}": pressure_base.Units.serialize(),
|
|
39
|
+
f"{mass_base.__class__.__name__}": mass_base.Units.serialize(),
|
|
40
|
+
f"{force_base.__class__.__name__}": force_base.Units.serialize(),
|
|
41
|
+
f"{power_base.__class__.__name__}": power_base.Units.serialize(),
|
|
42
|
+
f"{volumetric_flow_base.__class__.__name__}": volumetric_flow_base.Units.serialize(),
|
|
43
|
+
f"{mass_flow_base.__class__.__name__}": mass_flow_base.Units.serialize(),
|
|
44
|
+
f"{density_base.__class__.__name__}": density_base.Units.serialize(),
|
|
45
|
+
f"{percentage_base.__class__.__name__}": percentage_base.Units.serialize(),
|
|
46
|
+
f"{adimentional_base.__class__.__name__}": adimentional_base.Units.serialize(),
|
|
47
|
+
f"{volume_base.__class__.__name__}": volume_base.Units.serialize()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
DATATYPES = [
|
|
51
|
+
{'label': 'Float', 'value': 'float'},
|
|
52
|
+
{'label': 'Integer', 'value': 'integer'},
|
|
53
|
+
{'label': 'Boolean', 'value': 'boolean'},
|
|
54
|
+
{'label': 'String', 'value': 'string'}
|
|
55
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from ..utils.units import EngUnit, UnitSerializer, UnitError
|
|
2
|
+
|
|
3
|
+
class Adimentional(EngUnit):
|
|
4
|
+
"""Creates an adimentional object that can store an adimentional value and
|
|
5
|
+
convert between units of adimentional.
|
|
6
|
+
|
|
7
|
+
:param value: [int|float] Engineering value\n
|
|
8
|
+
:param unit: [str] Engineering unit\n
|
|
9
|
+
:return: [Length Object]\n
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
class Units(UnitSerializer):
|
|
16
|
+
adim = 'adim'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
conversions = {
|
|
20
|
+
|
|
21
|
+
'adim' : 1.0
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
def __init__(self, value, unit):
|
|
25
|
+
|
|
26
|
+
if unit not in Adimentional.Units.list():
|
|
27
|
+
|
|
28
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Adimentional.Units.list()}")
|
|
29
|
+
|
|
30
|
+
super(Adimentional, self).__init__(value=value, unit=unit)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from ..utils.units import EngUnit, UnitError, UnitSerializer
|
|
2
|
+
|
|
3
|
+
class Current(EngUnit):
|
|
4
|
+
r"""
|
|
5
|
+
Creates a current object pruebaaaaa that can store a current value and
|
|
6
|
+
convert between units of current.
|
|
7
|
+
|
|
8
|
+
:param value: The current value (engineering value)
|
|
9
|
+
:type value: int | float
|
|
10
|
+
:param unit: The unit of the current (e.g., "A", "mA", "kA")
|
|
11
|
+
:type unit: str
|
|
12
|
+
:return: A new Current object
|
|
13
|
+
:rtype: Current
|
|
14
|
+
|
|
15
|
+
Example usage:
|
|
16
|
+
|
|
17
|
+
.. code-block:: python
|
|
18
|
+
|
|
19
|
+
>>> from automation.variables.current import Current
|
|
20
|
+
>>> current = Current(value=1.0, unit="A")
|
|
21
|
+
>>> current.value
|
|
22
|
+
1.0
|
|
23
|
+
>>> current.unit
|
|
24
|
+
'A'
|
|
25
|
+
>>> current.convert(to_unit="kA")
|
|
26
|
+
0.001
|
|
27
|
+
>>> Current.convert_value(value=1.0, from_unit="A", to_unit="mA")
|
|
28
|
+
1000.0
|
|
29
|
+
>>> Current.convert_values(values=[1.0, 10.0], from_unit="A", to_unit="mA")
|
|
30
|
+
[1000.0, 10000.0]
|
|
31
|
+
>>> current.change_unit(unit="kA")
|
|
32
|
+
0.001
|
|
33
|
+
>>> current.unit
|
|
34
|
+
'kA'
|
|
35
|
+
>>> current.get_value()
|
|
36
|
+
[0.001, 'kA']
|
|
37
|
+
>>> print(current)
|
|
38
|
+
0.001 kA
|
|
39
|
+
>>> current2 = Current(value=3.0, unit="mA")
|
|
40
|
+
>>> current_result = current + current2
|
|
41
|
+
>>> print(current_result)
|
|
42
|
+
0.001003 kA
|
|
43
|
+
>>> current_result = current * current2
|
|
44
|
+
>>> print(current_result)
|
|
45
|
+
3e-09 kA
|
|
46
|
+
>>> current_result = current / current2
|
|
47
|
+
>>> print(current_result)
|
|
48
|
+
333.3333333333333 kA
|
|
49
|
+
>>> current_result = current ** current2
|
|
50
|
+
>>> print(current_result)
|
|
51
|
+
0.9999792769488884 kA
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
class Units(UnitSerializer):
|
|
55
|
+
A = 'A'
|
|
56
|
+
mA = 'mA'
|
|
57
|
+
kA = 'kA'
|
|
58
|
+
|
|
59
|
+
conversions = {
|
|
60
|
+
'A' : 1,
|
|
61
|
+
'mA' : 1000,
|
|
62
|
+
'kA' : 0.001
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
def __init__(self, value, unit):
|
|
66
|
+
|
|
67
|
+
if unit not in Current.Units.list():
|
|
68
|
+
|
|
69
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Current.Units.list()}")
|
|
70
|
+
|
|
71
|
+
super(Current, self).__init__(value=value, unit=unit)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
from ..utils.units import *
|
|
2
|
+
|
|
3
|
+
class Density(EngUnit):
|
|
4
|
+
"""Creates a density object that can store a density value and
|
|
5
|
+
convert between units of density.
|
|
6
|
+
|
|
7
|
+
:param value: [int|float] Engineering value\n
|
|
8
|
+
:param unit: [str] Engineering unit\n
|
|
9
|
+
:return: [Density Object]\n
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
>>> from automation.variables.density import Density
|
|
13
|
+
>>> density = Density(value=1.0, unit="kg/m3")
|
|
14
|
+
>>> density.value
|
|
15
|
+
1.0
|
|
16
|
+
>>> density.unit
|
|
17
|
+
'kg/m3'
|
|
18
|
+
>>> density.convert(to_unit="lb/ml")
|
|
19
|
+
2.2046226218000004e-06
|
|
20
|
+
>>> Density.convert_value(value=1.0, from_unit="kg/m3", to_unit="g/ml")
|
|
21
|
+
0.0010000000000000002
|
|
22
|
+
>>> Density.convert_values(values=[1.0, 10.0], from_unit="kg/m3", to_unit="g/ml")
|
|
23
|
+
[0.0010000000000000002, 0.010000000000000002]
|
|
24
|
+
>>> density.change_unit(unit="lb/ml")
|
|
25
|
+
2.2046226218000004e-06
|
|
26
|
+
>>> density.unit
|
|
27
|
+
'lb/ml'
|
|
28
|
+
>>> density.get_value()
|
|
29
|
+
[2.2046226218000004e-06, 'lb/ml']
|
|
30
|
+
>>> print(density)
|
|
31
|
+
2.2046226218000004e-06 lb/ml
|
|
32
|
+
>>> density2 = Density(value=3.0, unit="g/ml")
|
|
33
|
+
>>> density_result = density + density2
|
|
34
|
+
>>> print(density_result)
|
|
35
|
+
0.0066160724880218 lb/ml
|
|
36
|
+
>>> density_result = density * density2
|
|
37
|
+
>>> print(density_result)
|
|
38
|
+
1.458108271365692e-08 lb/ml
|
|
39
|
+
>>> density_result = density / density2
|
|
40
|
+
>>> print(density_result)
|
|
41
|
+
0.00033333333333333343 lb/ml
|
|
42
|
+
>>> density_result = density ** density2
|
|
43
|
+
>>> print(density_result)
|
|
44
|
+
0.9174608905185654 lb/ml
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
class Units(UnitSerializer):
|
|
51
|
+
kg_bbl = 'kg/bbl'
|
|
52
|
+
kg_gal = 'kg/gal'
|
|
53
|
+
kg_m3 = 'kg/m3'
|
|
54
|
+
kg_lt = 'kg/lt'
|
|
55
|
+
kg_ml = 'kg/ml'
|
|
56
|
+
g_bbl = 'g/bbl'
|
|
57
|
+
g_gal = 'g/gal'
|
|
58
|
+
g_m3 = 'g/m3'
|
|
59
|
+
g_lt = 'g/lt'
|
|
60
|
+
g_ml = 'g/ml'
|
|
61
|
+
mg_bbl = 'mg/bbl'
|
|
62
|
+
mg_gal = 'mg/gal'
|
|
63
|
+
mg_m3 = 'kmg/m3'
|
|
64
|
+
mg_lt = 'mg/lt'
|
|
65
|
+
mg_ml = 'mg/ml'
|
|
66
|
+
lb_bbl = 'lb/bbl'
|
|
67
|
+
lb_gal = 'lb/gal'
|
|
68
|
+
lb_m3 = 'lb/m3'
|
|
69
|
+
lb_lt = 'lb/lt'
|
|
70
|
+
lb_ml = 'lb/ml'
|
|
71
|
+
metricTon_bbl = 'metricTon/bbl'
|
|
72
|
+
metricTon_gal = 'metricTon/gal'
|
|
73
|
+
metricTon_m3 = 'metricTon/m3'
|
|
74
|
+
metricTon_lt = 'metricTon/lt'
|
|
75
|
+
metricTon_ml = 'metricTon/ml'
|
|
76
|
+
|
|
77
|
+
conversions = {
|
|
78
|
+
'kg/bbl' : 1.0,
|
|
79
|
+
'g/bbl' : 1.0 * 1000,
|
|
80
|
+
'mg/bbl' : 1.0 * 1000 * 1000,
|
|
81
|
+
'metricTon/bbl' : 1.0 / 1000.0,
|
|
82
|
+
'lb/bbl' : 2.2046226218,
|
|
83
|
+
|
|
84
|
+
'kg/gal' : 1.0 / 42.0,
|
|
85
|
+
'g/gal' : 1.0 * 1000 / 42.0,
|
|
86
|
+
'mg/gal' : 1.0 * 1000 * 1000 / 42.0,
|
|
87
|
+
'metricTon/gal' : 1.0 / 1000.0 / 42.0,
|
|
88
|
+
'lb/gal' : 2.2046226218 / 42.0,
|
|
89
|
+
|
|
90
|
+
'kg/m3' : 1.0 / 0.158987294928,
|
|
91
|
+
'g/m3' : 1.0 * 1000 / 0.158987294928,
|
|
92
|
+
'mg/m3' : 1.0 * 1000 * 1000 / 0.158987294928,
|
|
93
|
+
'metricTon/m3' : 1.0 / 1000.0 / 0.158987294928,
|
|
94
|
+
'lb/m3' : 2.2046226218 / 0.158987294928,
|
|
95
|
+
|
|
96
|
+
'kg/lt' : 1.0 / 158.987294928,
|
|
97
|
+
'g/lt' : 1.0 * 1000 / 158.987294928,
|
|
98
|
+
'mg/lt' : 1.0 * 1000 * 1000 / 158.987294928,
|
|
99
|
+
'metricTon/lt' : 1.0 / 1000.0 / 158.987294928,
|
|
100
|
+
'lb/lt' : 2.2046226218 / 158.987294928,
|
|
101
|
+
|
|
102
|
+
'kg/ml' : 1.0 / 158987.294928,
|
|
103
|
+
'g/ml' : 1.0 * 1000 / 158987.294928,
|
|
104
|
+
'mg/ml' : 1.0 * 1000 * 1000 / 158987.294928,
|
|
105
|
+
'metricTon/ml' : 1.0 / 1000.0 / 158987.294928,
|
|
106
|
+
'lb/ml' : 2.2046226218 / 158987.294928,
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
def __init__(self, value, unit):
|
|
110
|
+
|
|
111
|
+
if unit not in Density.Units.list():
|
|
112
|
+
|
|
113
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Density.Units.list()}")
|
|
114
|
+
|
|
115
|
+
super(Density, self).__init__(value=value, unit=unit)
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from ..utils.units import *
|
|
2
|
+
|
|
3
|
+
class Time(EngUnit):
|
|
4
|
+
"""Creates a eng_time object that can store a eng_time value and
|
|
5
|
+
convert between units of eng_time.
|
|
6
|
+
|
|
7
|
+
:param value: [int|float] Engineering value\n
|
|
8
|
+
:param unit: [str] Engineering unit\n
|
|
9
|
+
:return: [Time Object]\n
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
>>> from automation.variables.eng_time import Time
|
|
13
|
+
>>> eng_time = Time(value=1.0, unit="hr")
|
|
14
|
+
>>> eng_time.value
|
|
15
|
+
1.0
|
|
16
|
+
>>> eng_time.unit
|
|
17
|
+
'hr'
|
|
18
|
+
>>> eng_time.convert(to_unit="minute")
|
|
19
|
+
60.0
|
|
20
|
+
>>> Time.convert_value(value=1.0, from_unit="hr", to_unit="s")
|
|
21
|
+
3600.0
|
|
22
|
+
>>> Time.convert_values(values=[1.0, 10.0], from_unit="hr", to_unit="s")
|
|
23
|
+
[3600.0, 36000.0]
|
|
24
|
+
>>> eng_time.change_unit(unit="minute")
|
|
25
|
+
60.0
|
|
26
|
+
>>> eng_time.unit
|
|
27
|
+
'minute'
|
|
28
|
+
>>> eng_time.get_value()
|
|
29
|
+
[60.0, 'minute']
|
|
30
|
+
>>> print(eng_time)
|
|
31
|
+
60.0 minute
|
|
32
|
+
>>> eng_time2 = Time(value=3.0, unit="s")
|
|
33
|
+
>>> eng_time_result = eng_time + eng_time2
|
|
34
|
+
>>> print(eng_time_result)
|
|
35
|
+
60.05 minute
|
|
36
|
+
>>> eng_time_result = eng_time * eng_time2
|
|
37
|
+
>>> print(eng_time_result)
|
|
38
|
+
3.0 minute
|
|
39
|
+
>>> eng_time_result = eng_time / eng_time2
|
|
40
|
+
>>> print(eng_time_result)
|
|
41
|
+
1200.0 minute
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
class Units(UnitSerializer):
|
|
48
|
+
ms = 'ms'
|
|
49
|
+
s = 's'
|
|
50
|
+
minute = 'minute'
|
|
51
|
+
hr = 'hr'
|
|
52
|
+
day = 'day'
|
|
53
|
+
|
|
54
|
+
conversions = {
|
|
55
|
+
'ms' : 1000.0,
|
|
56
|
+
's' : 1.0,
|
|
57
|
+
'minute' : 1.0 / 60.0,
|
|
58
|
+
'hr' : 1.0 / 60.0 / 60.0,
|
|
59
|
+
'day' : 1.0 / 60.0 / 60.0 / 24.0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
def __init__(self, value, unit):
|
|
63
|
+
|
|
64
|
+
if unit not in Time.Units.list():
|
|
65
|
+
|
|
66
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Time.Units.list()}")
|
|
67
|
+
|
|
68
|
+
super(Time, self).__init__(value=value, unit=unit)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from ..utils.units import *
|
|
2
|
+
|
|
3
|
+
class Force(EngUnit):
|
|
4
|
+
"""Creates a force object that can store a force value and
|
|
5
|
+
convert between units of force.
|
|
6
|
+
|
|
7
|
+
:param value: [int|float] Engineering value\n
|
|
8
|
+
:param unit: [str] Engineering unit\n
|
|
9
|
+
:return: [Force Object]\n
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
>>> from automation.variables.force import Force
|
|
13
|
+
>>> force = Force(value=1.0, unit="N")
|
|
14
|
+
>>> force.value
|
|
15
|
+
1.0
|
|
16
|
+
>>> force.unit
|
|
17
|
+
'N'
|
|
18
|
+
>>> force.convert(to_unit="kgf")
|
|
19
|
+
0.1019716213
|
|
20
|
+
>>> Force.convert_value(value=1.0, from_unit="N", to_unit="lbf")
|
|
21
|
+
0.2248089431
|
|
22
|
+
>>> Force.convert_values(values=[1.0, 10.0], from_unit="N", to_unit="lbf")
|
|
23
|
+
[0.2248089431, 2.248089431]
|
|
24
|
+
>>> force.change_unit(unit="kgf")
|
|
25
|
+
0.1019716213
|
|
26
|
+
>>> force.unit
|
|
27
|
+
'kgf'
|
|
28
|
+
>>> force.get_value()
|
|
29
|
+
[0.1019716213, 'kgf']
|
|
30
|
+
>>> print(force)
|
|
31
|
+
0.1019716213 kgf
|
|
32
|
+
>>> force2 = Force(value=3.0, unit="lbf")
|
|
33
|
+
>>> force_result = force + force2
|
|
34
|
+
>>> print(force_result)
|
|
35
|
+
1.4627487313277014 kgf
|
|
36
|
+
>>> force_result = force * force2
|
|
37
|
+
>>> print(force_result)
|
|
38
|
+
0.1387606481374532 kgf
|
|
39
|
+
>>> force_result = force / force2
|
|
40
|
+
>>> print(force_result)
|
|
41
|
+
0.07493631436666666 kgf
|
|
42
|
+
>>> force_result = force ** force2
|
|
43
|
+
>>> print(force_result)
|
|
44
|
+
0.04474673588461198 kgf
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
class Units(UnitSerializer):
|
|
50
|
+
N = 'N'
|
|
51
|
+
kN = 'kN'
|
|
52
|
+
MN = 'MN'
|
|
53
|
+
GN = 'GN'
|
|
54
|
+
gf = 'gf'
|
|
55
|
+
kgf = 'kgf'
|
|
56
|
+
dyn = 'dyn'
|
|
57
|
+
Jm = 'J/m'
|
|
58
|
+
Jcm = 'J/cm'
|
|
59
|
+
shortTonF = 'shortTonF'
|
|
60
|
+
longTonF = 'longTonF'
|
|
61
|
+
kipf = 'kipf'
|
|
62
|
+
lbf = 'lbf'
|
|
63
|
+
ozf = 'ozf'
|
|
64
|
+
pdl = 'pdl'
|
|
65
|
+
|
|
66
|
+
conversions = {
|
|
67
|
+
'N' : 1.0,
|
|
68
|
+
'kN' : 1.0 / 1000.0,
|
|
69
|
+
'MN' : 1.0 / 1000000.0,
|
|
70
|
+
'GN' : 1.0 / 1000000000.0,
|
|
71
|
+
'gf' : 1.019716213e+2,
|
|
72
|
+
'kgf' : 1.019716213e-1,
|
|
73
|
+
'dyn' : 1e+5,
|
|
74
|
+
'J/m' : 1.0,
|
|
75
|
+
'J/cm' : 100.0,
|
|
76
|
+
'shortTonF' : 1.124045e-4,
|
|
77
|
+
'longTonF' : 1.003611e-4,
|
|
78
|
+
'kipf' : 2.248089e-4,
|
|
79
|
+
'lbf' : 2.248089431e-1,
|
|
80
|
+
'ozf' : 3.5969430896,
|
|
81
|
+
'pdf' : 7.2330138512
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
def __init__(self, value, unit):
|
|
85
|
+
|
|
86
|
+
if unit not in Force.Units.list():
|
|
87
|
+
|
|
88
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Force.Units.list()}")
|
|
89
|
+
|
|
90
|
+
super(Force, self).__init__(value=value, unit=unit)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from ..utils.units import EngUnit, UnitSerializer, UnitError
|
|
2
|
+
|
|
3
|
+
class Length(EngUnit):
|
|
4
|
+
"""Creates a length object that can store a length value and
|
|
5
|
+
convert between units of length.
|
|
6
|
+
|
|
7
|
+
:param value: [int|float] Engineering value\n
|
|
8
|
+
:param unit: [str] Engineering unit\n
|
|
9
|
+
:return: [Length Object]\n
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
>>> from automation.variables.length import Length
|
|
13
|
+
>>> length = Length(value=1.0, unit="m")
|
|
14
|
+
>>> length.value
|
|
15
|
+
1.0
|
|
16
|
+
>>> length.unit
|
|
17
|
+
'm'
|
|
18
|
+
>>> length.convert(to_unit="inch")
|
|
19
|
+
39.3701
|
|
20
|
+
>>> Length.convert_value(value=1.0, from_unit="m", to_unit="cm")
|
|
21
|
+
100.0
|
|
22
|
+
>>> Length.convert_values(values=[1.0, 10.0], from_unit="m", to_unit="cm")
|
|
23
|
+
[100.0, 1000.0]
|
|
24
|
+
>>> length.change_unit(unit="inch")
|
|
25
|
+
39.3701
|
|
26
|
+
>>> length.unit
|
|
27
|
+
'inch'
|
|
28
|
+
>>> length.get_value()
|
|
29
|
+
[39.3701, 'inch']
|
|
30
|
+
>>> print(length)
|
|
31
|
+
39.3701 inch
|
|
32
|
+
>>> length2 = Length(value=3.0, unit="cm")
|
|
33
|
+
>>> length_result = length + length2
|
|
34
|
+
>>> print(length_result)
|
|
35
|
+
40.551203 inch
|
|
36
|
+
>>> length_result = length * length2
|
|
37
|
+
>>> print(length_result)
|
|
38
|
+
46.500143220300004 inch
|
|
39
|
+
>>> length_result = length / length2
|
|
40
|
+
>>> print(length_result)
|
|
41
|
+
33.333333333333336 inch
|
|
42
|
+
>>> length_result = length ** length2
|
|
43
|
+
>>> print(length_result)
|
|
44
|
+
76.56952620577046 inch
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
class Units(UnitSerializer):
|
|
50
|
+
fm = 'fm'
|
|
51
|
+
pm = 'pm'
|
|
52
|
+
nm = 'nm'
|
|
53
|
+
um = 'um'
|
|
54
|
+
mm = 'mm'
|
|
55
|
+
cm = 'cm'
|
|
56
|
+
m = 'm'
|
|
57
|
+
dam = 'dam'
|
|
58
|
+
hm = 'hm'
|
|
59
|
+
km = 'km'
|
|
60
|
+
Mm = 'Mm'
|
|
61
|
+
Gm = 'Gm'
|
|
62
|
+
Tm = 'Tm'
|
|
63
|
+
Pm = 'Pm'
|
|
64
|
+
|
|
65
|
+
inch = 'inch'
|
|
66
|
+
ft = 'ft'
|
|
67
|
+
yd = 'yd'
|
|
68
|
+
mi = 'mi'
|
|
69
|
+
|
|
70
|
+
nautMi = 'nautMi'
|
|
71
|
+
lightYear = 'lightYear'
|
|
72
|
+
|
|
73
|
+
conversions = {
|
|
74
|
+
'fm' : 1000000000000000,
|
|
75
|
+
'pm' : 1000000000000,
|
|
76
|
+
'nm' : 1000000000,
|
|
77
|
+
'um' : 1000000,
|
|
78
|
+
'mm' : 1000,
|
|
79
|
+
'cm' : 100,
|
|
80
|
+
'm' : 1.0,
|
|
81
|
+
'dam' : 0.1,
|
|
82
|
+
'hm' : 0.01,
|
|
83
|
+
'km' : 0.001,
|
|
84
|
+
'Mm' : 0.000001,
|
|
85
|
+
'Gm' : 0.000000001,
|
|
86
|
+
'Tm' : 0.000000000001,
|
|
87
|
+
'Pm' : 0.000000000000001,
|
|
88
|
+
|
|
89
|
+
'inch' : 39.3701,
|
|
90
|
+
'ft' : 3.28084,
|
|
91
|
+
'yd' : 1.09361,
|
|
92
|
+
'mi' : 0.000621371,
|
|
93
|
+
|
|
94
|
+
'nautMi' : 1.0 / 1852.0,
|
|
95
|
+
'lightYear' : 1.0 / (9.4607304725808 * (10**15))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
def __init__(self, value, unit):
|
|
99
|
+
|
|
100
|
+
if unit not in Length.Units.list():
|
|
101
|
+
|
|
102
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Length.Units.list()}")
|
|
103
|
+
|
|
104
|
+
super(Length, self).__init__(value=value, unit=unit)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from ..utils.units import *
|
|
2
|
+
|
|
3
|
+
class Mass(EngUnit):
|
|
4
|
+
"""Creates a mass object that can store a mass value and
|
|
5
|
+
convert between units of mass.
|
|
6
|
+
|
|
7
|
+
:param value: [int|float] Engineering value\n
|
|
8
|
+
:param unit: [str] Engineering unit\n
|
|
9
|
+
:return: [Mass Object]\n
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
>>> from automation.variables.mass import Mass
|
|
13
|
+
>>> mass = Mass(value=1.0, unit="kg")
|
|
14
|
+
>>> mass.value
|
|
15
|
+
1.0
|
|
16
|
+
>>> mass.unit
|
|
17
|
+
'kg'
|
|
18
|
+
>>> mass.convert(to_unit="lb")
|
|
19
|
+
2.2046226218
|
|
20
|
+
>>> Mass.convert_value(value=1.0, from_unit="kg", to_unit="g")
|
|
21
|
+
1000.0
|
|
22
|
+
>>> Mass.convert_values(values=[1.0, 10.0], from_unit="kg", to_unit="g")
|
|
23
|
+
[1000.0, 10000.0]
|
|
24
|
+
>>> mass.change_unit(unit="lb")
|
|
25
|
+
2.2046226218
|
|
26
|
+
>>> mass.unit
|
|
27
|
+
'lb'
|
|
28
|
+
>>> mass.get_value()
|
|
29
|
+
[2.2046226218, 'lb']
|
|
30
|
+
>>> print(mass)
|
|
31
|
+
2.2046226218 lb
|
|
32
|
+
>>> mass2 = Mass(value=3.0, unit="g")
|
|
33
|
+
>>> mass_result = mass + mass2
|
|
34
|
+
>>> print(mass_result)
|
|
35
|
+
2.2112364896654 lb
|
|
36
|
+
>>> mass_result = mass * mass2
|
|
37
|
+
>>> print(mass_result)
|
|
38
|
+
0.014581082713656917 lb
|
|
39
|
+
>>> mass_result = mass / mass2
|
|
40
|
+
>>> print(mass_result)
|
|
41
|
+
333.33333333333337 lb
|
|
42
|
+
>>> mass_result = mass ** mass2
|
|
43
|
+
>>> print(mass_result)
|
|
44
|
+
1.0052423283919558 lb
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
class Units(UnitSerializer):
|
|
50
|
+
kg = 'kg'
|
|
51
|
+
g = 'g'
|
|
52
|
+
mg = 'mg'
|
|
53
|
+
lb = 'lb'
|
|
54
|
+
metricTon = 'metricTon'
|
|
55
|
+
oz = 'oz'
|
|
56
|
+
grain = 'grain'
|
|
57
|
+
shortTon = 'shortTon'
|
|
58
|
+
longTon = 'longTon'
|
|
59
|
+
slug = 'slug'
|
|
60
|
+
|
|
61
|
+
conversions = {
|
|
62
|
+
'kg' : 1.0,
|
|
63
|
+
'g' : 1000.0,
|
|
64
|
+
'mg' : 1000000.0,
|
|
65
|
+
'metricTon' : 1.0 / 1000.0,
|
|
66
|
+
'lb' : 2.2046226218,
|
|
67
|
+
'oz' : 35.274,
|
|
68
|
+
'grain' : 2.2046226218 * 7000.0,
|
|
69
|
+
'shortTon' : 1.0 / 907.185,
|
|
70
|
+
'longTon' : 1.0 / 1016.047,
|
|
71
|
+
'slug' : 1.0 / 14.5939029
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
def __init__(self, value, unit):
|
|
75
|
+
|
|
76
|
+
if unit not in Mass.Units.list():
|
|
77
|
+
|
|
78
|
+
raise UnitError(f"{unit} value is not allowed for {self.__class__.__name__} object - you can use: {Mass.Units.list()}")
|
|
79
|
+
|
|
80
|
+
super(Mass, self).__init__(value=value, unit=unit)
|