slowpy 0.4.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 (114) hide show
  1. slowpy-0.4.0/PKG-INFO +27 -0
  2. slowpy-0.4.0/pyproject.toml +55 -0
  3. slowpy-0.4.0/setup.cfg +4 -0
  4. slowpy-0.4.0/slowpy/__init__.py +11 -0
  5. slowpy-0.4.0/slowpy/basetypes.py +118 -0
  6. slowpy-0.4.0/slowpy/control/__init__.py +13 -0
  7. slowpy-0.4.0/slowpy/control/control_AsyncDripline.py +492 -0
  8. slowpy-0.4.0/slowpy/control/control_AsyncHTTP.py +153 -0
  9. slowpy-0.4.0/slowpy/control/control_AsyncLocalPubsub.py +213 -0
  10. slowpy-0.4.0/slowpy/control/control_AsyncMQTT.py +370 -0
  11. slowpy-0.4.0/slowpy/control/control_AsyncModbus.py +208 -0
  12. slowpy-0.4.0/slowpy/control/control_AsyncNATS.py +275 -0
  13. slowpy-0.4.0/slowpy/control/control_AsyncRabbitMQ.py +594 -0
  14. slowpy-0.4.0/slowpy/control/control_AsyncRedis.py +500 -0
  15. slowpy-0.4.0/slowpy/control/control_AsyncSlowMQ.py +321 -0
  16. slowpy-0.4.0/slowpy/control/control_AsyncSlowdash.py +43 -0
  17. slowpy-0.4.0/slowpy/control/control_CAMAC.py +497 -0
  18. slowpy-0.4.0/slowpy/control/control_DataStore.py +53 -0
  19. slowpy-0.4.0/slowpy/control/control_Dripline.py +229 -0
  20. slowpy-0.4.0/slowpy/control/control_DriplineInterface.py +61 -0
  21. slowpy-0.4.0/slowpy/control/control_DummyDevice.py +178 -0
  22. slowpy-0.4.0/slowpy/control/control_Ethernet.py +398 -0
  23. slowpy-0.4.0/slowpy/control/control_HTTP.py +156 -0
  24. slowpy-0.4.0/slowpy/control/control_LabJackU.py +466 -0
  25. slowpy-0.4.0/slowpy/control/control_MQTT.py +246 -0
  26. slowpy-0.4.0/slowpy/control/control_Microphone.py +198 -0
  27. slowpy-0.4.0/slowpy/control/control_Modbus.py +172 -0
  28. slowpy-0.4.0/slowpy/control/control_NanotechMotor.py +528 -0
  29. slowpy-0.4.0/slowpy/control/control_RabbitMQ.py +596 -0
  30. slowpy-0.4.0/slowpy/control/control_Redis.py +499 -0
  31. slowpy-0.4.0/slowpy/control/control_Serial.py +104 -0
  32. slowpy-0.4.0/slowpy/control/control_Shell.py +95 -0
  33. slowpy-0.4.0/slowpy/control/control_Slowdash.py +42 -0
  34. slowpy-0.4.0/slowpy/control/control_UDP.py +119 -0
  35. slowpy-0.4.0/slowpy/control/control_VISA.py +108 -0
  36. slowpy-0.4.0/slowpy/control/dummy_device.py +132 -0
  37. slowpy-0.4.0/slowpy/control/hdl/__init__.py +3 -0
  38. slowpy-0.4.0/slowpy/control/hdl/hdl.py +177 -0
  39. slowpy-0.4.0/slowpy/control/netutils.py +127 -0
  40. slowpy-0.4.0/slowpy/control/node.py +819 -0
  41. slowpy-0.4.0/slowpy/control/scpi_server.py +344 -0
  42. slowpy-0.4.0/slowpy/control/system.py +372 -0
  43. slowpy-0.4.0/slowpy/graphs.py +121 -0
  44. slowpy-0.4.0/slowpy/histograms.py +316 -0
  45. slowpy-0.4.0/slowpy/mesh/__init__.py +5 -0
  46. slowpy-0.4.0/slowpy/mesh/dash.py +81 -0
  47. slowpy-0.4.0/slowpy/mesh/mesh.py +645 -0
  48. slowpy-0.4.0/slowpy/mesh/packet.py +107 -0
  49. slowpy-0.4.0/slowpy/mesh/stdio.py +403 -0
  50. slowpy-0.4.0/slowpy/mesh/tasklet.py +755 -0
  51. slowpy-0.4.0/slowpy/mpldata.py +348 -0
  52. slowpy-0.4.0/slowpy/slowfetch.py +184 -0
  53. slowpy-0.4.0/slowpy/slowplot.py +540 -0
  54. slowpy-0.4.0/slowpy/store/__init__.py +9 -0
  55. slowpy-0.4.0/slowpy/store/blob_storage.py +155 -0
  56. slowpy-0.4.0/slowpy/store/factory.py +32 -0
  57. slowpy-0.4.0/slowpy/store/store.py +156 -0
  58. slowpy-0.4.0/slowpy/store/store_CSV.py +95 -0
  59. slowpy-0.4.0/slowpy/store/store_HDF5.py +239 -0
  60. slowpy-0.4.0/slowpy/store/store_InfluxDB2.py +143 -0
  61. slowpy-0.4.0/slowpy/store/store_Redis.py +163 -0
  62. slowpy-0.4.0/slowpy/store/store_SQL.py +489 -0
  63. slowpy-0.4.0/slowpy/treetable.py +71 -0
  64. slowpy-0.4.0/slowpy/trend.py +200 -0
  65. slowpy-0.4.0/slowpy.egg-info/PKG-INFO +27 -0
  66. slowpy-0.4.0/slowpy.egg-info/SOURCES.txt +112 -0
  67. slowpy-0.4.0/slowpy.egg-info/dependency_links.txt +1 -0
  68. slowpy-0.4.0/slowpy.egg-info/requires.txt +28 -0
  69. slowpy-0.4.0/slowpy.egg-info/top_level.txt +1 -0
  70. slowpy-0.4.0/test/test-control-async-modbus.py +32 -0
  71. slowpy-0.4.0/test/test-control-async-mqtt.py +40 -0
  72. slowpy-0.4.0/test/test-control-async-nats.py +40 -0
  73. slowpy-0.4.0/test/test-control-async-rabbitmq.py +42 -0
  74. slowpy-0.4.0/test/test-control-async-redis-pubsub.py +40 -0
  75. slowpy-0.4.0/test/test-control-async-redis.py +34 -0
  76. slowpy-0.4.0/test/test-control-async-slowdash.py +28 -0
  77. slowpy-0.4.0/test/test-control-async-slowmq.py +40 -0
  78. slowpy-0.4.0/test/test-control-dripline.py +10 -0
  79. slowpy-0.4.0/test/test-control-dummydevice.py +24 -0
  80. slowpy-0.4.0/test/test-control-dummyevents.py +10 -0
  81. slowpy-0.4.0/test/test-control-ethernet-scpi.py +27 -0
  82. slowpy-0.4.0/test/test-control-labjack.py +20 -0
  83. slowpy-0.4.0/test/test-control-modbus.py +27 -0
  84. slowpy-0.4.0/test/test-control-mqtt-callback.py +20 -0
  85. slowpy-0.4.0/test/test-control-mqtt.py +34 -0
  86. slowpy-0.4.0/test/test-control-rabbitmq.py +35 -0
  87. slowpy-0.4.0/test/test-control-redis-pubsub.py +32 -0
  88. slowpy-0.4.0/test/test-control-redis.py +29 -0
  89. slowpy-0.4.0/test/test-control-shell.py +14 -0
  90. slowpy-0.4.0/test/test-control-slowdash.py +23 -0
  91. slowpy-0.4.0/test/test-data-hist-graph.py +28 -0
  92. slowpy-0.4.0/test/test-data-trend.py +29 -0
  93. slowpy-0.4.0/test/test-hdl-dummy-store.py +27 -0
  94. slowpy-0.4.0/test/test-hdl-simple.py +25 -0
  95. slowpy-0.4.0/test/test-hdl.py +80 -0
  96. slowpy-0.4.0/test/test-mesh-node.py +54 -0
  97. slowpy-0.4.0/test/test-mesh-pubsub.py +40 -0
  98. slowpy-0.4.0/test/test-mesh-rpc.py +41 -0
  99. slowpy-0.4.0/test/test-mesh-slowtask.py +59 -0
  100. slowpy-0.4.0/test/test-mesh-tasklet.py +70 -0
  101. slowpy-0.4.0/test/test-scpi-server.py +46 -0
  102. slowpy-0.4.0/test/test-scpize-dummydevice-nodes.py +28 -0
  103. slowpy-0.4.0/test/test-slowfetch-obj.py +28 -0
  104. slowpy-0.4.0/test/test-slowfetch.py +28 -0
  105. slowpy-0.4.0/test/test-slowplot-hist-graph.py +48 -0
  106. slowpy-0.4.0/test/test-slowplot-plt.py +34 -0
  107. slowpy-0.4.0/test/test-store-csv.py +22 -0
  108. slowpy-0.4.0/test/test-store-hdf5.py +23 -0
  109. slowpy-0.4.0/test/test-store-influxdb.py +22 -0
  110. slowpy-0.4.0/test/test-store-mysql.py +22 -0
  111. slowpy-0.4.0/test/test-store-postgresql.py +22 -0
  112. slowpy-0.4.0/test/test-store-redis.py +22 -0
  113. slowpy-0.4.0/test/test-store-sqlite-blob.py +20 -0
  114. slowpy-0.4.0/test/test-store-sqlite.py +22 -0
slowpy-0.4.0/PKG-INFO ADDED
@@ -0,0 +1,27 @@
1
+ Metadata-Version: 2.4
2
+ Name: slowpy
3
+ Version: 0.4.0
4
+ Summary: SlowDash Python Library
5
+ Author: Sanshiro Enomoto
6
+ License-Expression: MIT
7
+ Requires-Dist: numpy
8
+ Requires-Dist: matplotlib
9
+ Provides-Extra: pandas
10
+ Requires-Dist: pandas; extra == "pandas"
11
+ Provides-Extra: postgres
12
+ Requires-Dist: psycopg2-binary; extra == "postgres"
13
+ Provides-Extra: mysql
14
+ Requires-Dist: mysql-connector-python; extra == "mysql"
15
+ Provides-Extra: influxdb
16
+ Requires-Dist: influxdb-client; extra == "influxdb"
17
+ Provides-Extra: redis
18
+ Requires-Dist: redis; extra == "redis"
19
+ Provides-Extra: hdf5
20
+ Requires-Dist: h5py; extra == "hdf5"
21
+ Provides-Extra: all
22
+ Requires-Dist: pandas; extra == "all"
23
+ Requires-Dist: psycopg2-binary; extra == "all"
24
+ Requires-Dist: mysql-connector-python; extra == "all"
25
+ Requires-Dist: influxdb-client; extra == "all"
26
+ Requires-Dist: redis; extra == "all"
27
+ Requires-Dist: h5py; extra == "all"
@@ -0,0 +1,55 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "slowpy"
7
+ version = "0.4.0"
8
+ description = "SlowDash Python Library"
9
+ authors = [
10
+ { name = "Sanshiro Enomoto" }
11
+ ]
12
+ license = "MIT"
13
+
14
+ dependencies = [
15
+ "numpy",
16
+ "matplotlib",
17
+ ]
18
+
19
+ [project.optional-dependencies]
20
+ pandas = [
21
+ "pandas",
22
+ ]
23
+
24
+ postgres = [
25
+ "psycopg2-binary",
26
+ ]
27
+
28
+ mysql = [
29
+ "mysql-connector-python",
30
+ ]
31
+
32
+ influxdb = [
33
+ "influxdb-client",
34
+ ]
35
+
36
+ redis = [
37
+ "redis",
38
+ ]
39
+
40
+ hdf5 = [
41
+ "h5py",
42
+ ]
43
+
44
+ all = [
45
+ "pandas",
46
+ "psycopg2-binary",
47
+ "mysql-connector-python",
48
+ "influxdb-client",
49
+ "redis",
50
+ "h5py",
51
+ ]
52
+
53
+ [tool.setuptools.packages.find]
54
+ where = ["."]
55
+ include = ["slowpy*"]
slowpy-0.4.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,11 @@
1
+
2
+ from .basetypes import DataElement, TimeSeries
3
+ from .histograms import Histogram, Histogram2d, HistogramBasicStat, HistogramCountStat, Histogram2dBasicStat
4
+ from .graphs import Graph, GraphYStat
5
+ from .trend import Trend, RateTrend
6
+ from .treetable import Tree, Table
7
+
8
+ from .slowfetch import SlowFetch
9
+
10
+ from .mpldata import slowdashify
11
+ from .slowplot import slowplot
@@ -0,0 +1,118 @@
1
+ # Created by Sanshiro Enomoto on 17 July 2024 #
2
+
3
+
4
+ import time, json
5
+
6
+
7
+ class DataElement:
8
+ def __init__(self):
9
+ self.attr_values = {}
10
+ self.stat_values = {}
11
+ self.stat_functors = []
12
+
13
+
14
+ def add_attr(self, name, value):
15
+ self.attr_values[name] = value
16
+
17
+
18
+ def add_stat(self, arg0, arg1=None):
19
+ # add_stat(key, value) or add_stat(functor) where functor takes an DataElement and returns a dict
20
+ if callable(arg0):
21
+ self.stat_functors.append(arg0)
22
+ else:
23
+ self.stat_values[arg0] = arg1
24
+
25
+
26
+ def clear(self):
27
+ self.stat_values = {}
28
+
29
+
30
+ def to_json(self):
31
+ for f in self.stat_functors:
32
+ self.stat_values.update(f(self))
33
+
34
+ record = {}
35
+ if any(self.attr_values):
36
+ record.update({ '_attr': self.attr_values })
37
+ if any(self.stat_values):
38
+ record.update({ '_stat': self.stat_values })
39
+ return record
40
+
41
+
42
+ @staticmethod
43
+ def from_json(obj):
44
+ if type(obj) is not dict:
45
+ return obj
46
+
47
+ from .graphs import Graph
48
+ from .histograms import Histogram, Histogram2d
49
+
50
+ if 'bins' in obj:
51
+ return Histogram.from_json(obj)
52
+ elif 'ybins' in obj:
53
+ return Histogram2d.from_json(obj)
54
+ elif 'y' in obj:
55
+ return Graph.from_json(obj)
56
+ return None
57
+
58
+
59
+ def __str__(self):
60
+ return json.dumps(self.to_json())
61
+
62
+
63
+
64
+ class TimeSeries:
65
+ def __init__(self, *, fields:list[str]|None=None, start:float=0, length:float|None=None):
66
+ self.start = start
67
+ self.length = length
68
+ self.fields = fields if fields is not None and len(fields) > 0 else ['x']
69
+ self.t = []
70
+ self.values = [ [] for _ in self.fields ] # self.values[field] is a time-series (array) for the field
71
+
72
+
73
+ def write(self, values, t=None):
74
+ '''
75
+ # add one point to the time-series #
76
+ - values: dict for field name-value pairs, or list for field values, or a value
77
+ where a value can be a number, string, or data-element.
78
+ - time: UNIX time-stamp, if None if given, the current time will be used.
79
+ '''
80
+ if t is None:
81
+ t = time.time()
82
+
83
+ record = [None] * len(self.fields)
84
+ if isinstance(values, dict):
85
+ for i in range(len(record)):
86
+ record[i] = values.get(self.fields[i], None)
87
+ elif isinstance(values, list):
88
+ for i in range(min(len(values), len(record))):
89
+ record[i] = values[i]
90
+ else:
91
+ record[0] = values
92
+
93
+ self.t.append(t - self.start)
94
+ for k in range(len(self.fields)):
95
+ self.values[k].append(record[k])
96
+
97
+
98
+ def to_json(self):
99
+ length = self.length
100
+ if length is None:
101
+ if len(self.t) < 1:
102
+ length = 1
103
+ else:
104
+ length = self.t[-1] + 1
105
+
106
+ data = {
107
+ 'start': self.start,
108
+ 'length': length,
109
+ 't': self.t,
110
+ }
111
+ for k in range(len(self.fields)):
112
+ data[self.fields[k]] = self.values[k]
113
+
114
+ return data
115
+
116
+
117
+ def __str__(self):
118
+ return json.dumps(self.to_json())
@@ -0,0 +1,13 @@
1
+
2
+ from .node import ControlNode, ControlVariableNode, ControlThreadNode, ControlException
3
+ from .system import ControlSystem, ValueNode, control_system
4
+ from .control_Ethernet import EthernetNode, ScpiNode, ScpiCommandNode
5
+ from .control_UDP import UdpSocketNode
6
+ from .control_HTTP import HttpNode
7
+ from .control_Shell import ShellNode
8
+ from .control_DataStore import DataStoreNode
9
+
10
+ from .scpi_server import ScpiServer, ScpiAdapter
11
+ from .netutils import find_ip
12
+
13
+ from .dummy_device import RandomWalkDevice, RandomHitDevice, RandomChargeDevice, RandomTimeDevice