Skip to content

Commit 614690e

Browse files
authored
Merge pull request #85 from introlab/dev
Main merge for 1.1.3 release
2 parents bbd2d0e + de38adb commit 614690e

20 files changed

+191
-114
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ python-3.10
2020
*.dmg
2121
python-3.11
2222
build
23+
python-3.12

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PROJECT (OpenIMU)
33
set(CMAKE_VERBOSE_MAKEFILE ON)
44

55
#Look for minimum cmake version
6-
cmake_minimum_required(VERSION 3.0.2)
6+
cmake_minimum_required(VERSION 3.21)
77

88
#Python
99
add_subdirectory(python)

python/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#TODO MAKE THIS GENERIC
2-
set (PYTHON_VERSION 3.11)
2+
set (PYTHON_VERSION 3.12)
33
add_subdirectory(env)
44

55
set(PYTHON_ENV_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env/python-${PYTHON_VERSION})
@@ -113,6 +113,7 @@ message(STATUS ${python_files})
113113
# PyInstaller
114114
set (installer_args
115115
--hidden-import logging.config
116+
--hidden-import scipy._lib.array_api_compat.numpy.fft
116117
--clean
117118
-y
118119
--windowed # If windowed, no console is displayed

python/OpenIMU.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def except_hook(cls, exception, traceback):
4242
app = OpenIMUApp()
4343

4444
# Route errors to error dialog
45-
sys.excepthook = except_hook
45+
# sys.excepthook = except_hook
4646

4747
# Set current directory to home path
4848
QDir.setCurrent(QDir.homePath())

python/env/requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pypiwin32==223; sys_platform == 'win32'
2-
PySide6==6.6.3
3-
cython==3.0.10
4-
numpy==1.26.4
5-
scipy==1.11.4
6-
sqlalchemy==2.0.29
7-
alembic==1.13.1
2+
PySide6==6.8.1.1
3+
cython==3.0.11
4+
numpy==2.2.2
5+
scipy==1.15.1
6+
sqlalchemy==2.0.37
7+
alembic==1.14.1
88
pyinstaller==5.13.2

python/libopenimu/db/DBManager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,16 @@ def delete_participant(self, part):
255255

256256
#
257257
def add_sensor(self, _id_sensor_type, _name, _hw_name, _location, _sampling_rate, _data_rate,
258-
_settings: str | None = None):
258+
_settings: str | None = None, _hw_id: str | None = None):
259259
# Check if that sensor is already present in the database
260260
query = self.session.query(Sensor).filter((Sensor.id_sensor_type == _id_sensor_type) &
261261
(Sensor.location == _location) &
262262
(Sensor.name == _name) &
263263
(Sensor.hw_name == _hw_name) &
264264
(Sensor.sampling_rate == _sampling_rate) &
265265
(Sensor.data_rate == _data_rate) &
266-
(Sensor.settings == _settings))
266+
(Sensor.settings == _settings) &
267+
(Sensor.hw_id == _hw_id))
267268

268269
if query.first():
269270
# print("Sensor " + _name + " already present in DB!")
@@ -274,6 +275,7 @@ def add_sensor(self, _id_sensor_type, _name, _hw_name, _location, _sampling_rate
274275
id_sensor_type=_id_sensor_type,
275276
name=_name,
276277
hw_name=_hw_name,
278+
hw_id=_hw_id,
277279
location=_location,
278280
sampling_rate=_sampling_rate,
279281
data_rate=_data_rate,

python/libopenimu/importers/AppleWatchImporter.py

Lines changed: 51 additions & 37 deletions
Large diffs are not rendered by default.

python/libopenimu/importers/BaseImporter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def add_recordset_to_db(self, name, start_timestamp, stop_timestamp):
8787
return recordset
8888

8989
def add_sensor_to_db(self, sensor_type, name, hw_name, location, sampling_rate, data_rate,
90-
settings: str | None = None):
91-
sensor = self.db.add_sensor(sensor_type, name, hw_name, location, sampling_rate, data_rate, settings)
90+
settings: str | None = None, hw_id: str | None = None):
91+
sensor = self.db.add_sensor(sensor_type, name, hw_name, location, sampling_rate, data_rate, settings, hw_id)
9292
return sensor
9393

9494
def add_channel_to_db(self, sensor, unit, data_format, label):

python/libopenimu/importers/wimu.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ class GPSGeodetic:
3030
magnetic_variation = np.int16(0)
3131
climb_rate = np.int16(0)
3232
heading_rate = np.int16(0)
33+
accuracy = np.uint16(0)
34+
altitude_accuracy = np.int16(0)
3335
original_data = bytes()
3436
valid = False
3537

3638
def from_bytes(self, data, offset=0):
37-
if len(data) != 91:
39+
if len(data) != 91 and len(data) != 54:
3840
print('Error GPSGeo len:', len(data))
3941
self.valid = False
4042
return False
@@ -63,8 +65,9 @@ def from_bytes(self, data, offset=0):
6365
[self.magnetic_variation] = struct.unpack_from('>h', data, offset=44)
6466
[self.climb_rate] = struct.unpack_from('>h', data, offset=46)
6567
[self.heading_rate] = struct.unpack_from('>h', data, offset=48)
66-
67-
# TODO continue other fields
68+
if len(data) == 54:
69+
[self.accuracy] = struct.unpack_from('>H', data, offset=50)
70+
[self.altitude_accuracy] = struct.unpack_from('>H', data, offset=52)
6871

6972
# print('latitude', self.latitude / 1e7, 'longitude', self.longitude / 1e7)
7073

@@ -84,10 +87,32 @@ def tobytes(self):
8487
if len(self.original_data) > 0:
8588
return self.original_data
8689
else:
87-
# TODO Write all fields
88-
data = np.zeros(91, dtype=np.uint8)
89-
struct.pack_into('>i', data, 23, int(self.latitude))
90-
struct.pack_into('>i', data, 27, int(self.longitude))
90+
data = np.zeros(54, dtype=np.uint8)
91+
struct.pack_into('>B', data, 0, self.message_id)
92+
struct.pack_into('>H', data, 1, self.nav_valid)
93+
struct.pack_into('>H', data, 3, self.nav_type)
94+
struct.pack_into('>H', data, 5, self.extended_week_number)
95+
struct.pack_into('>I', data, 7, self.tow)
96+
struct.pack_into('>H', data, 11, self.year)
97+
struct.pack_into('>B', data, 13, self.month)
98+
struct.pack_into('>B', data, 14, self.day)
99+
struct.pack_into('>B', data, 15, self.hour)
100+
struct.pack_into('>B', data, 16, self.minute)
101+
struct.pack_into('>H', data, 17, self.second)
102+
struct.pack_into('>I', data, 19, self.satellite_id_list)
103+
struct.pack_into('>i', data, 23, self.latitude)
104+
struct.pack_into('>i', data, 27, self.longitude)
105+
struct.pack_into('>i', data, 31, self.altitude_ellipsoid)
106+
struct.pack_into('>i', data, 35, self.altitude_mls)
107+
struct.pack_into('>b', data, 39, self.map_datum)
108+
struct.pack_into('>H', data, 40, self.speed_over_ground)
109+
struct.pack_into('>H', data, 42, self.course_over_ground)
110+
struct.pack_into('>h', data, 44, self.magnetic_variation)
111+
struct.pack_into('>h', data, 46, self.climb_rate)
112+
struct.pack_into('>h', data, 48, self.heading_rate)
113+
struct.pack_into('>H', data, 50, self.accuracy)
114+
struct.pack_into('>H', data, 52, self.altitude_accuracy)
115+
91116
return data
92117

93118

python/libopenimu/qt/BackgroundProcess.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def __init__(self, bg_process: BackgroundProcess, job_title: string, parent=None
157157
self.UI = Ui_ProgressDialog()
158158
self.UI.setupUi(self)
159159
self.setWindowFlags(Qt.SplashScreen)
160+
self.setWindowModality(Qt.WindowModality.ApplicationModal)
161+
self.setModal(True)
160162

161163
# self.UI.frameCancel.hide() # Hide cancel frame
162164

python/libopenimu/qt/ExportDialog.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from PySide6.QtWidgets import QDialog, QFileDialog, QMessageBox
2-
from PySide6.QtCore import Slot, Signal
2+
from PySide6.QtCore import Qt, Slot, Signal, QCoreApplication
33

44
from resources.ui.python.ExportDialog_ui import Ui_ExportDialog
55

@@ -100,7 +100,8 @@ def export(self):
100100
shutil.rmtree(export_path, ignore_errors=True)
101101

102102
if not os.path.exists(export_path):
103-
os.mkdir(export_path)
103+
#os.mkdir(export_path)
104+
os.makedirs(export_path)
104105

105106
# print('Should export in : ', directory)
106107

@@ -189,7 +190,9 @@ def process(self):
189190

190191
# Show dialog
191192
self.hide()
192-
dialog.exec()
193+
dialog.show()
194+
while process.isRunning():
195+
QCoreApplication.processEvents()
193196

194197
# Show warning if errors
195198
if self.has_export_errors:

python/libopenimu/qt/ImportBrowser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from PySide6.QtCore import Slot, Qt, Signal, QObject, QEvent, QFileInfo, QDirIterator, QDir
1+
from PySide6.QtCore import Slot, Qt, Signal, QObject, QEvent, QFileInfo, QDirIterator, QDir, QCoreApplication
22
from PySide6.QtWidgets import QDialog, QTableWidgetItem, QComboBox, QApplication, QHBoxLayout, QFileDialog, QMessageBox
33
from PySide6.QtGui import QDropEvent, QDragEnterEvent, QDragMoveEvent, QDragLeaveEvent, QIcon, QKeyEvent
44

@@ -189,7 +189,9 @@ def process(self):
189189

190190
# Show progress dialog
191191
# self.showMinimized()
192-
dialog.exec()
192+
dialog.show()
193+
while process.isRunning():
194+
QCoreApplication.processEvents()
193195

194196
if self.has_error:
195197
# Error occured while importing

python/libopenimu/qt/MainWindow.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from PySide6.QtWidgets import QMessageBox
44
from PySide6.QtGui import QKeyEvent, QMouseEvent, QKeySequence
55

6-
from PySide6.QtCore import Slot, Signal, QObject, QEvent, Qt
6+
from PySide6.QtCore import Slot, Signal, QObject, QEvent, Qt, QCoreApplication
77
import gc
88

99
# UI
@@ -267,7 +267,7 @@ def toggle_log(self, visibility):
267267

268268
@Slot()
269269
def import_requested(self):
270-
importer = ImportBrowser(data_manager=self.dbMan)
270+
importer = ImportBrowser(data_manager=self.dbMan, parent=self)
271271
importer.participant_added.connect(self.load_data_from_dataset)
272272
current_part_id = self.UI.treeDataSet.get_current_participant_id()
273273
if current_part_id >= 0:
@@ -276,7 +276,7 @@ def import_requested(self):
276276
# importer.setStyleSheet(self.styleSheet())
277277
if importer.exec() == QDialog.Accepted:
278278
self.load_data_from_dataset()
279-
gc.collect()
279+
# gc.collect()
280280

281281
@Slot()
282282
def export_requested(self):
@@ -348,7 +348,9 @@ def db_compact_requested(self):
348348
process = BackgroundProcess([task])
349349
dialog = ProgressDialog(process, self.tr('Cleanup'), self)
350350
process.start()
351-
dialog.exec()
351+
dialog.show()
352+
while process.isRunning():
353+
QCoreApplication.processEvents()
352354

353355
@Slot()
354356
def new_group_requested(self):
@@ -641,7 +643,9 @@ def delete_requested(self):
641643
dialog = ProgressDialog(process, self.tr('Deleting'), self)
642644
# Start tasks
643645
process.start()
644-
dialog.exec()
646+
dialog.show()
647+
while process.isRunning():
648+
QCoreApplication.processEvents()
645649
# self.dbMan.clean_db()
646650

647651
self.add_to_log(item_name + ' ' + self.tr('was deleted.'), LogTypes.LOGTYPE_DONE)

python/libopenimu/qt/ProcessSelectWindow.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from PySide6.QtWidgets import QDialog, QListWidgetItem, QVBoxLayout, QWidget
2-
from PySide6.QtCore import Slot
2+
from PySide6.QtCore import Qt, Slot, QCoreApplication
33
from PySide6.QtGui import QIcon
44
from resources.ui.python.ProcessSelectDialog_ui import Ui_dlgProcessSelect
55

@@ -130,7 +130,10 @@ def get_results(self):
130130
# process.trigger.connect(dialog.trigger)
131131
process.start()
132132

133-
dialog.exec()
133+
# dialog.exec()
134+
dialog.show()
135+
while process.isRunning():
136+
QCoreApplication.processEvents()
134137

135138
results = processor.get_results()
136139

python/libopenimu/qt/RecordsetWindow.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from PySide6.QtWidgets import QGraphicsScene, QApplication, QGraphicsRectItem, QGraphicsLineItem, QGraphicsItem
33
from PySide6.QtWidgets import QMenu, QMessageBox, QMdiSubWindow
44
from PySide6.QtGui import QBrush, QPen, QColor, QFont, QGuiApplication, QAction
5-
from PySide6.QtCore import Qt, Slot, Signal, QPoint, QRect, QObject, QRectF, QFile
5+
from PySide6.QtCore import Qt, Slot, Signal, QPoint, QRect, QObject, QRectF, QFile, QCoreApplication
66

77
from resources.ui.python.RecordsetWidget_ui import Ui_frmRecordsets
88
from libopenimu.qt.GraphWindow import GraphType, GraphWindow
@@ -509,7 +509,9 @@ def load_sensors_blocks(self):
509509
dialog = ProgressDialog(process, self.tr('Loading'), self)
510510

511511
process.start()
512-
dialog.exec()
512+
dialog.show()
513+
while process.isRunning():
514+
QCoreApplication.processEvents()
513515
QGuiApplication.restoreOverrideCursor()
514516

515517
# Combine tasks results
@@ -744,11 +746,14 @@ def get_sensor_data(self, sensor, start_time=None, end_time=None):
744746
process = BackgroundProcess([task], self)
745747
dialog = ProgressDialog(process, self.tr('Processing'), self)
746748
process.start()
747-
dialog.exec()
749+
dialog.show()
750+
while process.isRunning():
751+
QCoreApplication.processEvents()
748752
QGuiApplication.restoreOverrideCursor()
749753

750754
return task.results['timeseries'], task.results['channel_data']
751755

756+
752757
def update_tile_buttons_state(self):
753758
if self.sensors_graphs.keys().__len__() > 1:
754759
self.UI.btnTileAuto.setEnabled(True)

python/resources/stylesheet.qss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ QLineEdit, QPlainTextEdit, QComboBox, QDateEdit{
124124
border-radius: 5px;
125125
min-height: 24px;
126126
padding-left: 10px;
127+
color: black;
127128
}
128129

129130
QLineEdit:!enabled, QPlainTextEdit:!enabled, QComboBox:!enabled, QDateEdit:!enabled{
@@ -217,6 +218,7 @@ QToolButton#btnAddGroup, QToolButton#btnAddParticipant, QToolButton#btnDelete, Q
217218
QTreeWidget{
218219
background-color:rgba(200,200,200,75%);
219220
show-decoration-selected: 0;
221+
color: black;
220222
}
221223

222224
QTreeWidget::item:hover#treeDataSet,QTreeWidget::item:hover:selected#treeDataSet {
@@ -324,6 +326,10 @@ QTableWidget{
324326
text-align: center;
325327
}
326328

329+
QTableWidget::item{
330+
color: black;
331+
}
332+
327333
QTableWidget QTableCornerButton::section {
328334
background: rgb(50,50,50);
329335
border: 2px outset grey;
@@ -404,6 +410,9 @@ QCheckBox:!checked{color:red;background-color:rgba(0,0,0,0%);}
404410
QComboBox QAbstractItemView {
405411
selection-color: blue;
406412
}
413+
QComboBox{
414+
color: black;
415+
}
407416

408417
/************************/
409418
/* QSpinBox */
@@ -434,6 +443,12 @@ QScrollArea {
434443
border: 0px solid transparent;
435444
}
436445

446+
/************************/
447+
/* QTextEdit */
448+
/************************/
449+
QTextEdit{
450+
background-color:rgba(200,200,200,75%);
451+
}
437452

438453
/*QPushButton:hover,QToolButton:hover{border-radius: 5px; color:black;background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 grey, stop: 0.2 rgb(200,200, 200), stop:1 grey);border: 2px solid rgb(186, 186, 186);}
439454
QPushButton,QToolButton{border-radius: 5px; color:white; background-color: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 black, stop: 0.2 rgb(200,200, 200), stop:1 black);border: 2px solid rgb(96, 96, 96);}

0 commit comments

Comments
 (0)