pyxcp 0.22.24__cp311-cp311-win_amd64.whl → 0.22.26__cp311-cp311-win_amd64.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.
Potentially problematic release.
This version of pyxcp might be problematic. Click here for more details.
- pyxcp/__init__.py +1 -1
- pyxcp/config/__init__.py +3 -1
- pyxcp/cpp_ext/cpp_ext.cp310-win_amd64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp311-win_amd64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp38-win_amd64.pyd +0 -0
- pyxcp/cpp_ext/cpp_ext.cp39-win_amd64.pyd +0 -0
- pyxcp/daq_stim/__init__.py +1 -1
- pyxcp/daq_stim/stim.cp310-win_amd64.pyd +0 -0
- pyxcp/daq_stim/stim.cp311-win_amd64.pyd +0 -0
- pyxcp/daq_stim/stim.cp38-win_amd64.pyd +0 -0
- pyxcp/daq_stim/stim.cp39-win_amd64.pyd +0 -0
- pyxcp/daq_stim/stim_wrapper.cpp +3 -1
- pyxcp/examples/run_daq.py +0 -2
- pyxcp/master/errorhandler.py +7 -1
- pyxcp/master/master.py +41 -40
- pyxcp/recorder/__init__.py +7 -8
- pyxcp/recorder/converter/__init__.py +416 -2
- pyxcp/recorder/rekorder.cp310-win_amd64.pyd +0 -0
- pyxcp/recorder/rekorder.cp311-win_amd64.pyd +0 -0
- pyxcp/recorder/rekorder.cp38-win_amd64.pyd +0 -0
- pyxcp/recorder/rekorder.cp39-win_amd64.pyd +0 -0
- pyxcp/types.py +7 -1
- {pyxcp-0.22.24.dist-info → pyxcp-0.22.26.dist-info}/METADATA +1 -1
- {pyxcp-0.22.24.dist-info → pyxcp-0.22.26.dist-info}/RECORD +27 -32
- pyxcp/examples/ex_arrow.py +0 -109
- pyxcp/examples/ex_csv.py +0 -85
- pyxcp/examples/ex_excel.py +0 -95
- pyxcp/examples/ex_mdf.py +0 -124
- pyxcp/examples/ex_sqlite.py +0 -128
- {pyxcp-0.22.24.dist-info → pyxcp-0.22.26.dist-info}/LICENSE +0 -0
- {pyxcp-0.22.24.dist-info → pyxcp-0.22.26.dist-info}/WHEEL +0 -0
- {pyxcp-0.22.24.dist-info → pyxcp-0.22.26.dist-info}/entry_points.txt +0 -0
pyxcp/examples/ex_sqlite.py
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import logging
|
|
3
|
-
import os
|
|
4
|
-
import sqlite3
|
|
5
|
-
from array import array
|
|
6
|
-
from dataclasses import dataclass, field
|
|
7
|
-
from mmap import PAGESIZE
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
from typing import Any, List
|
|
10
|
-
|
|
11
|
-
from pyxcp.recorder import XcpLogFileDecoder
|
|
12
|
-
from pyxcp.recorder.converter import MAP_TO_ARRAY
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
MAP_TO_SQL = {
|
|
16
|
-
"U8": "INTEGER",
|
|
17
|
-
"I8": "INTEGER",
|
|
18
|
-
"U16": "INTEGER",
|
|
19
|
-
"I16": "INTEGER",
|
|
20
|
-
"U32": "INTEGER",
|
|
21
|
-
"I32": "INTEGER",
|
|
22
|
-
"U64": "INTEGER",
|
|
23
|
-
"I64": "INTEGER",
|
|
24
|
-
"F32": "FLOAT",
|
|
25
|
-
"F64": "FLOAT",
|
|
26
|
-
"F16": "FLOAT",
|
|
27
|
-
"BF16": "FLOAT",
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
logger = logging.getLogger("PyXCP")
|
|
31
|
-
|
|
32
|
-
parser = argparse.ArgumentParser(description="Use .xmraw files in an Apache Arrow application.")
|
|
33
|
-
parser.add_argument("xmraw_file", help=".xmraw file")
|
|
34
|
-
args = parser.parse_args()
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
@dataclass
|
|
38
|
-
class Storage:
|
|
39
|
-
name: str
|
|
40
|
-
arrow_type: Any
|
|
41
|
-
arr: array
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
@dataclass
|
|
45
|
-
class StorageContainer:
|
|
46
|
-
name: str
|
|
47
|
-
arr: List[Storage] = field(default_factory=[])
|
|
48
|
-
ts0: List[int] = field(default_factory=lambda: array("Q"))
|
|
49
|
-
ts1: List[int] = field(default_factory=lambda: array("Q"))
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
class Decoder(XcpLogFileDecoder):
|
|
53
|
-
|
|
54
|
-
def __init__(self, recording_file_name: str):
|
|
55
|
-
super().__init__(recording_file_name)
|
|
56
|
-
self.sq3_file_name = Path(recording_file_name).with_suffix(".sq3")
|
|
57
|
-
try:
|
|
58
|
-
os.unlink(self.sq3_file_name)
|
|
59
|
-
except Exception as e:
|
|
60
|
-
print(e)
|
|
61
|
-
|
|
62
|
-
def initialize(self) -> None:
|
|
63
|
-
self.create_database(self.sq3_file_name)
|
|
64
|
-
self.arrow_tables = []
|
|
65
|
-
self.insert_stmt = {}
|
|
66
|
-
for dl in self.daq_lists:
|
|
67
|
-
result = []
|
|
68
|
-
for name, type_str in dl.headers:
|
|
69
|
-
array_txpe = MAP_TO_ARRAY[type_str]
|
|
70
|
-
sql_type = MAP_TO_SQL[type_str]
|
|
71
|
-
sd = Storage(name, sql_type, array(array_txpe))
|
|
72
|
-
result.append(sd)
|
|
73
|
-
sc = StorageContainer(dl.name, result)
|
|
74
|
-
print(f"Creating table {sc.name!r}.")
|
|
75
|
-
self.create_table(sc)
|
|
76
|
-
self.insert_stmt[sc.name] = (
|
|
77
|
-
f"""INSERT INTO {sc.name}({', '.join(['ts0', 'ts1'] + [r.name for r in sc.arr])}) VALUES({', '.join(["?" for _ in range(len(sc.arr) + 2)])})"""
|
|
78
|
-
)
|
|
79
|
-
self.arrow_tables.append(sc)
|
|
80
|
-
print("\nInserting data...")
|
|
81
|
-
|
|
82
|
-
def create_database(self, db_name: str) -> None:
|
|
83
|
-
self.conn = sqlite3.Connection(db_name)
|
|
84
|
-
self.cursor = self.conn.cursor()
|
|
85
|
-
self.execute("PRAGMA FOREIGN_KEYS=ON")
|
|
86
|
-
self.execute(f"PRAGMA PAGE_SIZE={PAGESIZE}")
|
|
87
|
-
self.execute("PRAGMA SYNCHRONOUS=OFF")
|
|
88
|
-
self.execute("PRAGMA LOCKING_MODE=EXCLUSIVE")
|
|
89
|
-
self.execute("PRAGMA TEMP_STORE=MEMORY")
|
|
90
|
-
|
|
91
|
-
timestamp_info = self.parameters.timestamp_info
|
|
92
|
-
self.execute(
|
|
93
|
-
"CREATE TABLE timestamp_info(timestamp_ns INTEGER, utc_offset INTEGER, dst_offset INTEGER, timezone VARCHAR(255))"
|
|
94
|
-
)
|
|
95
|
-
self.execute("CREATE TABLE table_names(name VARCHAR(255))")
|
|
96
|
-
self.execute(
|
|
97
|
-
"INSERT INTO timestamp_info VALUES(?, ?, ?, ?)",
|
|
98
|
-
[timestamp_info.timestamp_ns, timestamp_info.utc_offset, timestamp_info.dst_offset, timestamp_info.timezone],
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
def create_table(self, sc: StorageContainer) -> None:
|
|
102
|
-
columns = ["ts0 INTEGER", "ts1 INTEGER"]
|
|
103
|
-
for elem in sc.arr:
|
|
104
|
-
columns.append(f"{elem.name} {elem.arrow_type}")
|
|
105
|
-
ddl = f"CREATE TABLE {sc.name}({', '.join(columns)})"
|
|
106
|
-
self.execute(ddl)
|
|
107
|
-
self.execute("INSERT INTO table_names VALUES(?)", [sc.name])
|
|
108
|
-
|
|
109
|
-
def execute(self, *args: List[str]) -> None:
|
|
110
|
-
try:
|
|
111
|
-
self.cursor.execute(*args)
|
|
112
|
-
except Exception as e:
|
|
113
|
-
print(e)
|
|
114
|
-
|
|
115
|
-
def finalize(self) -> None:
|
|
116
|
-
self.conn.commit()
|
|
117
|
-
self.conn.close()
|
|
118
|
-
print("Done.")
|
|
119
|
-
|
|
120
|
-
def on_daq_list(self, daq_list_num: int, timestamp0: int, timestamp1: int, measurements: list) -> None:
|
|
121
|
-
sc = self.arrow_tables[daq_list_num]
|
|
122
|
-
insert_stmt = self.insert_stmt[sc.name]
|
|
123
|
-
data = [timestamp0, timestamp1, *measurements]
|
|
124
|
-
self.execute(insert_stmt, data)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
decoder = Decoder(args.xmraw_file)
|
|
128
|
-
decoder.run()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|