Skip to content

Commit

Permalink
Merge pull request #85 from introlab/dev
Browse files Browse the repository at this point in the history
Main merge for 1.1.3 release
  • Loading branch information
SBriere authored Jan 31, 2025
2 parents bbd2d0e + de38adb commit 614690e
Show file tree
Hide file tree
Showing 20 changed files with 191 additions and 114 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ python-3.10
*.dmg
python-3.11
build
python-3.12
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PROJECT (OpenIMU)
set(CMAKE_VERBOSE_MAKEFILE ON)

#Look for minimum cmake version
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.21)

#Python
add_subdirectory(python)
3 changes: 2 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#TODO MAKE THIS GENERIC
set (PYTHON_VERSION 3.11)
set (PYTHON_VERSION 3.12)
add_subdirectory(env)

set(PYTHON_ENV_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env/python-${PYTHON_VERSION})
Expand Down Expand Up @@ -113,6 +113,7 @@ message(STATUS ${python_files})
# PyInstaller
set (installer_args
--hidden-import logging.config
--hidden-import scipy._lib.array_api_compat.numpy.fft
--clean
-y
--windowed # If windowed, no console is displayed
Expand Down
2 changes: 1 addition & 1 deletion python/OpenIMU.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def except_hook(cls, exception, traceback):
app = OpenIMUApp()

# Route errors to error dialog
sys.excepthook = except_hook
# sys.excepthook = except_hook

# Set current directory to home path
QDir.setCurrent(QDir.homePath())
Expand Down
12 changes: 6 additions & 6 deletions python/env/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pypiwin32==223; sys_platform == 'win32'
PySide6==6.6.3
cython==3.0.10
numpy==1.26.4
scipy==1.11.4
sqlalchemy==2.0.29
alembic==1.13.1
PySide6==6.8.1.1
cython==3.0.11
numpy==2.2.2
scipy==1.15.1
sqlalchemy==2.0.37
alembic==1.14.1
pyinstaller==5.13.2
6 changes: 4 additions & 2 deletions python/libopenimu/db/DBManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,16 @@ def delete_participant(self, part):

#
def add_sensor(self, _id_sensor_type, _name, _hw_name, _location, _sampling_rate, _data_rate,
_settings: str | None = None):
_settings: str | None = None, _hw_id: str | None = None):
# Check if that sensor is already present in the database
query = self.session.query(Sensor).filter((Sensor.id_sensor_type == _id_sensor_type) &
(Sensor.location == _location) &
(Sensor.name == _name) &
(Sensor.hw_name == _hw_name) &
(Sensor.sampling_rate == _sampling_rate) &
(Sensor.data_rate == _data_rate) &
(Sensor.settings == _settings))
(Sensor.settings == _settings) &
(Sensor.hw_id == _hw_id))

if query.first():
# print("Sensor " + _name + " already present in DB!")
Expand All @@ -274,6 +275,7 @@ def add_sensor(self, _id_sensor_type, _name, _hw_name, _location, _sampling_rate
id_sensor_type=_id_sensor_type,
name=_name,
hw_name=_hw_name,
hw_id=_hw_id,
location=_location,
sampling_rate=_sampling_rate,
data_rate=_data_rate,
Expand Down
88 changes: 51 additions & 37 deletions python/libopenimu/importers/AppleWatchImporter.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions python/libopenimu/importers/BaseImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def add_recordset_to_db(self, name, start_timestamp, stop_timestamp):
return recordset

def add_sensor_to_db(self, sensor_type, name, hw_name, location, sampling_rate, data_rate,
settings: str | None = None):
sensor = self.db.add_sensor(sensor_type, name, hw_name, location, sampling_rate, data_rate, settings)
settings: str | None = None, hw_id: str | None = None):
sensor = self.db.add_sensor(sensor_type, name, hw_name, location, sampling_rate, data_rate, settings, hw_id)
return sensor

def add_channel_to_db(self, sensor, unit, data_format, label):
Expand Down
39 changes: 32 additions & 7 deletions python/libopenimu/importers/wimu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ class GPSGeodetic:
magnetic_variation = np.int16(0)
climb_rate = np.int16(0)
heading_rate = np.int16(0)
accuracy = np.uint16(0)
altitude_accuracy = np.int16(0)
original_data = bytes()
valid = False

def from_bytes(self, data, offset=0):
if len(data) != 91:
if len(data) != 91 and len(data) != 54:
print('Error GPSGeo len:', len(data))
self.valid = False
return False
Expand Down Expand Up @@ -63,8 +65,9 @@ def from_bytes(self, data, offset=0):
[self.magnetic_variation] = struct.unpack_from('>h', data, offset=44)
[self.climb_rate] = struct.unpack_from('>h', data, offset=46)
[self.heading_rate] = struct.unpack_from('>h', data, offset=48)

# TODO continue other fields
if len(data) == 54:
[self.accuracy] = struct.unpack_from('>H', data, offset=50)
[self.altitude_accuracy] = struct.unpack_from('>H', data, offset=52)

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

Expand All @@ -84,10 +87,32 @@ def tobytes(self):
if len(self.original_data) > 0:
return self.original_data
else:
# TODO Write all fields
data = np.zeros(91, dtype=np.uint8)
struct.pack_into('>i', data, 23, int(self.latitude))
struct.pack_into('>i', data, 27, int(self.longitude))
data = np.zeros(54, dtype=np.uint8)
struct.pack_into('>B', data, 0, self.message_id)
struct.pack_into('>H', data, 1, self.nav_valid)
struct.pack_into('>H', data, 3, self.nav_type)
struct.pack_into('>H', data, 5, self.extended_week_number)
struct.pack_into('>I', data, 7, self.tow)
struct.pack_into('>H', data, 11, self.year)
struct.pack_into('>B', data, 13, self.month)
struct.pack_into('>B', data, 14, self.day)
struct.pack_into('>B', data, 15, self.hour)
struct.pack_into('>B', data, 16, self.minute)
struct.pack_into('>H', data, 17, self.second)
struct.pack_into('>I', data, 19, self.satellite_id_list)
struct.pack_into('>i', data, 23, self.latitude)
struct.pack_into('>i', data, 27, self.longitude)
struct.pack_into('>i', data, 31, self.altitude_ellipsoid)
struct.pack_into('>i', data, 35, self.altitude_mls)
struct.pack_into('>b', data, 39, self.map_datum)
struct.pack_into('>H', data, 40, self.speed_over_ground)
struct.pack_into('>H', data, 42, self.course_over_ground)
struct.pack_into('>h', data, 44, self.magnetic_variation)
struct.pack_into('>h', data, 46, self.climb_rate)
struct.pack_into('>h', data, 48, self.heading_rate)
struct.pack_into('>H', data, 50, self.accuracy)
struct.pack_into('>H', data, 52, self.altitude_accuracy)

return data


Expand Down
2 changes: 2 additions & 0 deletions python/libopenimu/qt/BackgroundProcess.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def __init__(self, bg_process: BackgroundProcess, job_title: string, parent=None
self.UI = Ui_ProgressDialog()
self.UI.setupUi(self)
self.setWindowFlags(Qt.SplashScreen)
self.setWindowModality(Qt.WindowModality.ApplicationModal)
self.setModal(True)

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

Expand Down
9 changes: 6 additions & 3 deletions python/libopenimu/qt/ExportDialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PySide6.QtWidgets import QDialog, QFileDialog, QMessageBox
from PySide6.QtCore import Slot, Signal
from PySide6.QtCore import Qt, Slot, Signal, QCoreApplication

from resources.ui.python.ExportDialog_ui import Ui_ExportDialog

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

if not os.path.exists(export_path):
os.mkdir(export_path)
#os.mkdir(export_path)
os.makedirs(export_path)

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

Expand Down Expand Up @@ -189,7 +190,9 @@ def process(self):

# Show dialog
self.hide()
dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()

# Show warning if errors
if self.has_export_errors:
Expand Down
6 changes: 4 additions & 2 deletions python/libopenimu/qt/ImportBrowser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PySide6.QtCore import Slot, Qt, Signal, QObject, QEvent, QFileInfo, QDirIterator, QDir
from PySide6.QtCore import Slot, Qt, Signal, QObject, QEvent, QFileInfo, QDirIterator, QDir, QCoreApplication
from PySide6.QtWidgets import QDialog, QTableWidgetItem, QComboBox, QApplication, QHBoxLayout, QFileDialog, QMessageBox
from PySide6.QtGui import QDropEvent, QDragEnterEvent, QDragMoveEvent, QDragLeaveEvent, QIcon, QKeyEvent

Expand Down Expand Up @@ -189,7 +189,9 @@ def process(self):

# Show progress dialog
# self.showMinimized()
dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()

if self.has_error:
# Error occured while importing
Expand Down
14 changes: 9 additions & 5 deletions python/libopenimu/qt/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PySide6.QtWidgets import QMessageBox
from PySide6.QtGui import QKeyEvent, QMouseEvent, QKeySequence

from PySide6.QtCore import Slot, Signal, QObject, QEvent, Qt
from PySide6.QtCore import Slot, Signal, QObject, QEvent, Qt, QCoreApplication
import gc

# UI
Expand Down Expand Up @@ -267,7 +267,7 @@ def toggle_log(self, visibility):

@Slot()
def import_requested(self):
importer = ImportBrowser(data_manager=self.dbMan)
importer = ImportBrowser(data_manager=self.dbMan, parent=self)
importer.participant_added.connect(self.load_data_from_dataset)
current_part_id = self.UI.treeDataSet.get_current_participant_id()
if current_part_id >= 0:
Expand All @@ -276,7 +276,7 @@ def import_requested(self):
# importer.setStyleSheet(self.styleSheet())
if importer.exec() == QDialog.Accepted:
self.load_data_from_dataset()
gc.collect()
# gc.collect()

@Slot()
def export_requested(self):
Expand Down Expand Up @@ -348,7 +348,9 @@ def db_compact_requested(self):
process = BackgroundProcess([task])
dialog = ProgressDialog(process, self.tr('Cleanup'), self)
process.start()
dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()

@Slot()
def new_group_requested(self):
Expand Down Expand Up @@ -641,7 +643,9 @@ def delete_requested(self):
dialog = ProgressDialog(process, self.tr('Deleting'), self)
# Start tasks
process.start()
dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()
# self.dbMan.clean_db()

self.add_to_log(item_name + ' ' + self.tr('was deleted.'), LogTypes.LOGTYPE_DONE)
Expand Down
7 changes: 5 additions & 2 deletions python/libopenimu/qt/ProcessSelectWindow.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PySide6.QtWidgets import QDialog, QListWidgetItem, QVBoxLayout, QWidget
from PySide6.QtCore import Slot
from PySide6.QtCore import Qt, Slot, QCoreApplication
from PySide6.QtGui import QIcon
from resources.ui.python.ProcessSelectDialog_ui import Ui_dlgProcessSelect

Expand Down Expand Up @@ -130,7 +130,10 @@ def get_results(self):
# process.trigger.connect(dialog.trigger)
process.start()

dialog.exec()
# dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()

results = processor.get_results()

Expand Down
11 changes: 8 additions & 3 deletions python/libopenimu/qt/RecordsetWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from PySide6.QtWidgets import QGraphicsScene, QApplication, QGraphicsRectItem, QGraphicsLineItem, QGraphicsItem
from PySide6.QtWidgets import QMenu, QMessageBox, QMdiSubWindow
from PySide6.QtGui import QBrush, QPen, QColor, QFont, QGuiApplication, QAction
from PySide6.QtCore import Qt, Slot, Signal, QPoint, QRect, QObject, QRectF, QFile
from PySide6.QtCore import Qt, Slot, Signal, QPoint, QRect, QObject, QRectF, QFile, QCoreApplication

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

process.start()
dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()
QGuiApplication.restoreOverrideCursor()

# Combine tasks results
Expand Down Expand Up @@ -744,11 +746,14 @@ def get_sensor_data(self, sensor, start_time=None, end_time=None):
process = BackgroundProcess([task], self)
dialog = ProgressDialog(process, self.tr('Processing'), self)
process.start()
dialog.exec()
dialog.show()
while process.isRunning():
QCoreApplication.processEvents()
QGuiApplication.restoreOverrideCursor()

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


def update_tile_buttons_state(self):
if self.sensors_graphs.keys().__len__() > 1:
self.UI.btnTileAuto.setEnabled(True)
Expand Down
15 changes: 15 additions & 0 deletions python/resources/stylesheet.qss
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ QLineEdit, QPlainTextEdit, QComboBox, QDateEdit{
border-radius: 5px;
min-height: 24px;
padding-left: 10px;
color: black;
}

QLineEdit:!enabled, QPlainTextEdit:!enabled, QComboBox:!enabled, QDateEdit:!enabled{
Expand Down Expand Up @@ -217,6 +218,7 @@ QToolButton#btnAddGroup, QToolButton#btnAddParticipant, QToolButton#btnDelete, Q
QTreeWidget{
background-color:rgba(200,200,200,75%);
show-decoration-selected: 0;
color: black;
}

QTreeWidget::item:hover#treeDataSet,QTreeWidget::item:hover:selected#treeDataSet {
Expand Down Expand Up @@ -324,6 +326,10 @@ QTableWidget{
text-align: center;
}

QTableWidget::item{
color: black;
}

QTableWidget QTableCornerButton::section {
background: rgb(50,50,50);
border: 2px outset grey;
Expand Down Expand Up @@ -404,6 +410,9 @@ QCheckBox:!checked{color:red;background-color:rgba(0,0,0,0%);}
QComboBox QAbstractItemView {
selection-color: blue;
}
QComboBox{
color: black;
}

/************************/
/* QSpinBox */
Expand Down Expand Up @@ -434,6 +443,12 @@ QScrollArea {
border: 0px solid transparent;
}

/************************/
/* QTextEdit */
/************************/
QTextEdit{
background-color:rgba(200,200,200,75%);
}

/*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);}
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);}
Expand Down
Loading

0 comments on commit 614690e

Please sign in to comment.