slm-open-api-package 0.2.2__tar.gz → 0.2.3__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.
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/PKG-INFO +1 -1
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/pyproject.toml +1 -1
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/pyproject.toml.orig +1 -1
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/example_multi.py +1 -1
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/https_requests.py +10 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/stream_handler.py +6 -2
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/websocket_handler.py +3 -1
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/webxi_helper_functions.py +5 -1
- slm_open_api_package-0.2.3/src/slm_api/multi_instrument_example.py +83 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/README.md +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/CPB_example.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/__init__.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/enums/fast_log_intervals_enum.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/enums/sequence_id_enum.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/fast_log_example.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/flac_example.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/FigureHandler.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/Leq.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/__init__.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/buffer.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/data_handler.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/fft.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/flac_stream_2_samples.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/measurment_handler.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/sequence_handler.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/stream_handlers.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/tmpFileStateMachine.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/webxi_root.pem +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/mp3_example.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/screen_record_example.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/README.md +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/__init__.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/webxi-header.ksy +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/webxi-stream.ksy +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/webxi_header.py +0 -0
- {slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/webxi_stream.py +0 -0
|
@@ -22,7 +22,7 @@ from slm_api.helpers import stream_handlers as sh
|
|
|
22
22
|
from slm_api.helpers.data_handler import DataHandler
|
|
23
23
|
from slm_api.helpers.https_requests import UseHttps
|
|
24
24
|
|
|
25
|
-
UseHttps(use_https=False)
|
|
25
|
+
# UseHttps(use_https=False)
|
|
26
26
|
|
|
27
27
|
host, ip = webxi_helper.set_host_ip(__file__)
|
|
28
28
|
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/https_requests.py
RENAMED
|
@@ -18,6 +18,14 @@ class WebxiAdapter(HTTPAdapter):
|
|
|
18
18
|
kwargs["assert_hostname"] = False # urllib3 does its own SAN check independent of ssl_context.check_hostname
|
|
19
19
|
return super().init_poolmanager(*args, **kwargs)
|
|
20
20
|
|
|
21
|
+
def build_ssl_context():
|
|
22
|
+
"""SSLContext trusting only webxi_root.pem, with hostname checking disabled."""
|
|
23
|
+
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
|
|
24
|
+
ctx.load_verify_locations(cafile=str(_CERT_FILE))
|
|
25
|
+
ctx.check_hostname = False
|
|
26
|
+
ctx.verify_mode = ssl.CERT_REQUIRED
|
|
27
|
+
return ctx
|
|
28
|
+
|
|
21
29
|
|
|
22
30
|
_session = requests.Session()
|
|
23
31
|
if _CERT_FILE.is_file():
|
|
@@ -26,6 +34,8 @@ if _CERT_FILE.is_file():
|
|
|
26
34
|
class UseHttps:
|
|
27
35
|
use_https = True # class attribute: shared, module-wide default
|
|
28
36
|
|
|
37
|
+
|
|
38
|
+
|
|
29
39
|
def __init__(self, use_https=None):
|
|
30
40
|
if use_https is not None:
|
|
31
41
|
UseHttps.use_https = use_https
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/stream_handler.py
RENAMED
|
@@ -20,8 +20,12 @@ def setup_stream(host,ip,sequenceID,StreamName):
|
|
|
20
20
|
if not (response.status_code == 201):
|
|
21
21
|
print(response.text)
|
|
22
22
|
raise Exception("Cannot start stream, could be bacause of to many streams open on the device")
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
https = https_requests.UseHttps.use_https
|
|
24
|
+
if https:
|
|
25
|
+
return 'wss://' + ip + response.json()["URI"][0]
|
|
26
|
+
else:
|
|
27
|
+
return 'ws://' + ip + response.json()["URI"][0]
|
|
28
|
+
|
|
25
29
|
def get_stream_ID(host, streamName):
|
|
26
30
|
"""This function shows how to find the ID of a specific stream with specific name"""
|
|
27
31
|
streams = https_requests.get(host, "/WebXi/Streams?recursive").json()
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/websocket_handler.py
RENAMED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import websockets
|
|
2
2
|
import asyncio
|
|
3
|
+
from . import https_requests
|
|
3
4
|
|
|
4
5
|
async def next_async_websocket(uri, packetHandler):
|
|
5
6
|
"""Function which awaits response from the websocket and calls the packetHandler"""
|
|
6
|
-
|
|
7
|
+
ssl_context = https_requests.build_ssl_context() if uri.startswith("wss://") else None
|
|
8
|
+
async with websockets.connect(uri, ping_interval=None, ssl=ssl_context) as websocket:
|
|
7
9
|
async for message in websocket:
|
|
8
10
|
packetHandler(message)
|
|
@@ -7,13 +7,17 @@ from slm_api.helpers.https_requests import get, put
|
|
|
7
7
|
|
|
8
8
|
# Functions to turn on/off BB freq weights and sequences. These are used in the examples to make sure the wanted sequences are enabled on the SLM.
|
|
9
9
|
def turn_off_bb_freq_weight(host):
|
|
10
|
+
|
|
10
11
|
for endpoint in (
|
|
11
12
|
"/webxi/Applications/SLM/Setup/BBFreqWeightB",
|
|
12
13
|
"/webxi/Applications/SLM/Setup/BBFreqWeightZ",
|
|
13
14
|
"/webxi/Applications/SLM/Setup/BBFreqWeightA",
|
|
14
15
|
"/webxi/Applications/SLM/Setup/BBFreqWeightC",
|
|
15
16
|
):
|
|
16
|
-
|
|
17
|
+
try:
|
|
18
|
+
put(host , endpoint, json=False, timeout=10)
|
|
19
|
+
except requests.exceptions.HTTPError as exc:
|
|
20
|
+
print(f"Skipping {endpoint}: {exc}")
|
|
17
21
|
|
|
18
22
|
def turn_on_bb_freq_weight(host, weights, fast=False):
|
|
19
23
|
weights = [weights] if isinstance(weights, str) else weights
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""
|
|
2
|
+
18. Stream FastLAF (Sequence 115)
|
|
3
|
+
-----------------------------------
|
|
4
|
+
Streams the FastLAF (LAeq) broadband Leq value from sequence 115
|
|
5
|
+
and pretty-prints each received value to the terminal.
|
|
6
|
+
|
|
7
|
+
Sequence 115 properties:
|
|
8
|
+
Name: FastLAF
|
|
9
|
+
LocalName: LAeq
|
|
10
|
+
FunctionType: BroadbandLeq
|
|
11
|
+
DataType: Int16
|
|
12
|
+
Scale: 0.01
|
|
13
|
+
Weighting: A
|
|
14
|
+
AveragingMode: Linear
|
|
15
|
+
Unit: dB re 20uPa
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import time
|
|
19
|
+
import threading
|
|
20
|
+
|
|
21
|
+
# Reuse existing help functions
|
|
22
|
+
import slm_api.helpers.stream_handler as stream
|
|
23
|
+
import slm_api.helpers.measurment_handler as meas
|
|
24
|
+
from slm_api.helpers.stream_handlers import WebXiStreamHandler
|
|
25
|
+
from slm_api.helpers.data_handler import DataHandler
|
|
26
|
+
|
|
27
|
+
# enums
|
|
28
|
+
from slm_api.enums.sequence_id_enum import SequenceIdEnums
|
|
29
|
+
from slm_api.enums.fast_log_intervals_enum import FastLogInterval
|
|
30
|
+
from slm_api.helpers import webxi_helper_functions as webxi_helper
|
|
31
|
+
|
|
32
|
+
SCALE = 0.01 # Raw Int16 value * SCALE = dB
|
|
33
|
+
|
|
34
|
+
# WebXi header timestamps are 64-bit fixed-point seconds since the Unix epoch
|
|
35
|
+
# (Q32.32): upper 32 bits = whole seconds, lower 32 bits = fraction of a second.
|
|
36
|
+
WEBXI_TICKS_PER_SECOND = 2 ** 32
|
|
37
|
+
|
|
38
|
+
FAST_LOGGING_INTERVAL_MS = FastLogInterval.interval_1000ms.value
|
|
39
|
+
SEQUENCE_ID = SequenceIdEnums.LAeq.value
|
|
40
|
+
sequenceNames = ["FastLAF"]
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class PrintDataHandler(DataHandler):
|
|
44
|
+
def handle(self, timestamp, name, local, value, unit, **_ignored):
|
|
45
|
+
print(f"{timestamp}{name} ({local}): {value:7.2f} {unit}")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
|
|
50
|
+
streams = []
|
|
51
|
+
devices = [
|
|
52
|
+
("http://192.168.1.216", "192.168.1.216"),
|
|
53
|
+
("http://192.168.1.191", "192.168.1.191"),
|
|
54
|
+
("http://192.168.1.183", "192.168.1.183"),
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
for dev_host, dev_ip in devices:
|
|
58
|
+
webxi_helper.turn_off_bb_freq_weight(dev_host)
|
|
59
|
+
webxi_helper.turn_on_bb_freq_weight(dev_host, "A")
|
|
60
|
+
|
|
61
|
+
s = WebXiStreamHandler(
|
|
62
|
+
host=dev_host,
|
|
63
|
+
ip=dev_ip,
|
|
64
|
+
sequenceID=SEQUENCE_ID,
|
|
65
|
+
fast_logging_interval=FAST_LOGGING_INTERVAL_MS,
|
|
66
|
+
streamName=f"Stream_{dev_ip}",
|
|
67
|
+
)
|
|
68
|
+
s.setDataHandler(PrintDataHandler())
|
|
69
|
+
streams.append(s)
|
|
70
|
+
|
|
71
|
+
for s in streams:
|
|
72
|
+
threading.Thread(target=s.startStream, daemon=True).start()
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
while True:
|
|
76
|
+
time.sleep(1)
|
|
77
|
+
except KeyboardInterrupt:
|
|
78
|
+
for s in streams:
|
|
79
|
+
if s.data_handler is not None:
|
|
80
|
+
s.data_handler.close()
|
|
81
|
+
stream.delete_stream(s.host, s.streamName)
|
|
82
|
+
meas.stop_measurement(s.host)
|
|
83
|
+
print("\nStreams stopped by user.")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/enums/sequence_id_enum.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/FigureHandler.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/data_handler.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/measurment_handler.py
RENAMED
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/sequence_handler.py
RENAMED
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/stream_handlers.py
RENAMED
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/tmpFileStateMachine.py
RENAMED
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/helpers/webxi_root.pem
RENAMED
|
File without changes
|
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/screen_record_example.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/webxi-header.ksy
RENAMED
|
File without changes
|
{slm_open_api_package-0.2.2 → slm_open_api_package-0.2.3}/src/slm_api/webxi/webxi-stream.ksy
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|