fix module path
@ -0,0 +1,5 @@
|
||||
from pathlib import Path
|
||||
|
||||
MODULE_FOLDER = Path(__file__)
|
||||
ASSETS = MODULE_FOLDER / 'assets'
|
||||
DEV_PROJECT_FOLDER = MODULE_FOLDER.parent.parent
|
||||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
@ -3,12 +3,16 @@ import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import platformdirs
|
||||
|
||||
from flandre import DEV_PROJECT_FOLDER
|
||||
|
||||
ISDEV = False
|
||||
if '--dev' in sys.argv:
|
||||
ISDEV = True
|
||||
|
||||
PLAYBACK_SOCKET_PORT = 5003
|
||||
PLAYBACK_SOCKET = f'127.0.0.1:{PLAYBACK_SOCKET_PORT}'
|
||||
LIVE_SOCKET_IP = '11.6.1.71'
|
||||
LIVE_REP_SOCKET_PORT = 5556
|
||||
LIVE_SOCKET = f'{LIVE_SOCKET_IP}:5555'
|
||||
LIVE_REP_SOCKET = f'{LIVE_SOCKET_IP}:{LIVE_REP_SOCKET_PORT}'
|
||||
MI_REP_SOCKET_PORT = 5557
|
||||
DEVICE_PY_REP_SOCKET_PORT = 5558
|
||||
|
||||
@ -17,32 +21,41 @@ SWITCH1_TOKEN = '7ad51e0016e7a9d22f753d5110f76c7d'
|
||||
SWITCH2_IP = 'c2'
|
||||
SWITCH2_TOKEN = 'bf5a7b77a1ba3761ea63fafd8427b7d6'
|
||||
|
||||
BASE = Path(__file__).parent.parent
|
||||
DS = BASE / '@DS'
|
||||
DOC = BASE / 'doc'
|
||||
CONFIG = BASE / 'config'
|
||||
ASSETS = BASE / 'assets'
|
||||
if ISDEV:
|
||||
CONFIG_FOLDER = platformdirs.user_config_path('Flandre', 'Scarlet')
|
||||
else:
|
||||
CONFIG_FOLDER = DEV_PROJECT_FOLDER / 'config'
|
||||
|
||||
DS = DEV_PROJECT_FOLDER / '@DS'
|
||||
DS.mkdir(exist_ok=True, parents=True)
|
||||
DOC.mkdir(exist_ok=True, parents=True)
|
||||
DEVICE_CONFIG = CONFIG / 'device'
|
||||
IMAGING_CONFIG = CONFIG / 'imaging'
|
||||
DEVICE_CONFIG.mkdir(exist_ok=True, parents=True)
|
||||
IMAGING_CONFIG.mkdir(exist_ok=True, parents=True)
|
||||
# CONFIG.mkdir(exist_ok=True, parents=True)
|
||||
|
||||
CONFIG_FOLDER = BASE / 'config'
|
||||
LAST_CONFIG = BASE / 'config' / 'last_imaging_config.json'
|
||||
|
||||
CONFIG_FOLDER.mkdir(exist_ok=True)
|
||||
|
||||
SOFTWARE_CONFIG_PATH = BASE / 'software.json'
|
||||
SOFTWARE_CONFIG_PATH = CONFIG_FOLDER / 'software.json'
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class SoftwareConfig:
|
||||
base_dir: Path = DS
|
||||
video_height = 1920
|
||||
video_width = 1080
|
||||
data_folder: Path = DS
|
||||
|
||||
@property
|
||||
def imaging_config_folder(self):
|
||||
p = CONFIG_FOLDER / 'imaging'
|
||||
p.mkdir(exist_ok=True, parents=True)
|
||||
return p
|
||||
|
||||
video_height: int = 1920
|
||||
video_width: int = 1080
|
||||
|
||||
live_ip: str = '11.6.1.71'
|
||||
live_push_port: int = 5555
|
||||
live_rep_port: int = 5556
|
||||
|
||||
@property
|
||||
def live_push_socket(self):
|
||||
return f'tcp://{self.live_ip}:{self.live_push_port}'
|
||||
|
||||
@property
|
||||
def live_rep_socket(self):
|
||||
return f'tcp://{self.live_ip}:{self.live_rep_port}'
|
||||
|
||||
@staticmethod
|
||||
def read_config(path: Path):
|
||||
@ -70,7 +83,7 @@ class SoftwareConfig:
|
||||
|
||||
C = SoftwareConfig()
|
||||
|
||||
if SOFTWARE_CONFIG_PATH.exists() and '--debug' not in sys.argv:
|
||||
if SOFTWARE_CONFIG_PATH.exists() and not ISDEV:
|
||||
C = SoftwareConfig.read_config(SOFTWARE_CONFIG_PATH)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@ -48,7 +48,7 @@ class Loader(Node):
|
||||
if not seq_list:
|
||||
logger.warning(f'No sequences found in {base}')
|
||||
else:
|
||||
C.base_dir = base
|
||||
C.data_folder = base
|
||||
C.write_config()
|
||||
self.send(SeqListMsg(seq_list))
|
||||
elif isinstance(msg, KillMsg):
|
||||
|
||||
@ -11,9 +11,10 @@ from PyQt6 import QtCore, QtWidgets, QtGui
|
||||
from PyQt6.QtCore import QByteArray
|
||||
from PyQt6.QtWidgets import QMainWindow, QApplication, QFrame, QMessageBox, QFileDialog, QLineEdit
|
||||
|
||||
from flandre import ASSETS
|
||||
from flandre.pyqt.Main import Ui_MainWindow
|
||||
from flandre.pyqt.ZMQReceiver import ZMQReceiver
|
||||
from flandre.config import DS, C, IMAGING_CONFIG, ASSETS, MI_REP_SOCKET_PORT
|
||||
from flandre.config import DS, C, MI_REP_SOCKET_PORT
|
||||
from flandre.nodes.Node import Node
|
||||
from flandre.utils.Msg import KillMsg, Msg, ImageArgMsg, SeqIdMinMax, MoveAxisMsg, SeqListMsg, SetBaseMsg, \
|
||||
SetSeqMetaMsg, SetPlayMode, DeviceConnectedMsg, DeviceEnabledMsg, DeviceOnlineMsg, SetDeviceEnabledMsg, \
|
||||
@ -99,7 +100,7 @@ class Adv(QMainWindow, Ui_MainWindow):
|
||||
# self.b_device_connected.clicked.connect(lambda: self.p.send(SetDeviceConnectedMsg(not self.device_connected)))
|
||||
# self.c_live_seq_name.currentIndexChanged.connect(self.on_seq_meta)
|
||||
self.b_live_seq_apply.clicked.connect(self.on_seq_meta)
|
||||
self.l_base.setText(C.base_dir.__str__())
|
||||
self.l_base.setText(C.data_folder.__str__())
|
||||
self.l_base.textChanged.connect(lambda e:
|
||||
self.l_base.setStyleSheet("")
|
||||
if Path(e).exists() else
|
||||
@ -182,7 +183,7 @@ class Adv(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def on_imaging_config(self, i):
|
||||
name = self.c_imaging_config.itemText(i)
|
||||
self.p.send(ImageArgMsg.from_path(IMAGING_CONFIG / f'{name}.json'))
|
||||
self.p.send(ImageArgMsg.from_path(C.imaging_config_folder / f'{name}.json'))
|
||||
|
||||
def on_new_imaging_config(self):
|
||||
text, okPressed = QtWidgets.QInputDialog.getText(None,
|
||||
@ -191,7 +192,7 @@ class Adv(QMainWindow, Ui_MainWindow):
|
||||
QLineEdit.EchoMode.Normal,
|
||||
"")
|
||||
if okPressed and text != '':
|
||||
(IMAGING_CONFIG / f'{text}.json').write_text(self.arg.json())
|
||||
(C.imaging_config_folder / f'{text}.json').write_text(self.arg.json())
|
||||
|
||||
def on_select_base(self):
|
||||
base = QFileDialog.getExistingDirectory(self, 'Select Base Folder', DS.__str__())
|
||||
|
||||
@ -1,17 +1,10 @@
|
||||
import logging
|
||||
import struct
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import zmq
|
||||
|
||||
from flandre.BusClient import BusClient
|
||||
from flandre.config import LIVE_REP_SOCKET, CONFIG, DEVICE_CONFIG
|
||||
from flandre.config import C
|
||||
from flandre.nodes.Node import Node
|
||||
from flandre.utils.Msg import ImageArgMsg, KillMsg, SetDeviceConnectedMsg, SetDeviceEnabledMsg, DeviceEnabledMsg, \
|
||||
DeviceConnectedMsg, SetDeviceConfigMsg, DeviceOnlineMsg, DeviceConfigListMsg, RequestRfFrameMsg, RfFrameMsg, \
|
||||
RfFrameWithMetaMsg
|
||||
from flandre.utils.RfMeta import RfFrameMeta
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -24,7 +17,7 @@ class Monitor(Node):
|
||||
def custom_setup(self):
|
||||
self.c2 = BusClient()
|
||||
self.device_rep_socket = self.context.socket(zmq.REQ)
|
||||
self.device_rep_socket.connect(f"tcp://{LIVE_REP_SOCKET}")
|
||||
self.device_rep_socket.connect(C.live_rep_socket)
|
||||
|
||||
def loop(self):
|
||||
while True:
|
||||
|
||||
@ -6,7 +6,7 @@ from pathlib import Path
|
||||
import numpy as np
|
||||
import zmq
|
||||
|
||||
from flandre.config import LIVE_SOCKET
|
||||
from flandre.config import LIVE_SOCKET,C
|
||||
from flandre.nodes.Node import Node
|
||||
from flandre.utils.Msg import ImageArgMsg, KillMsg, SetSeqMetaMsg, SetPlayMode, SetDeviceConfigMsg, SetRecordMsg, \
|
||||
RfFrameWithMetaMsg, RequestRfFrameMsg, RecordFrameMsg, RobotRtsiMsg
|
||||
@ -79,8 +79,8 @@ class Recorder(Node):
|
||||
p = Path(msg.base) / seq_meta.name
|
||||
p.mkdir(parents=True, exist_ok=True)
|
||||
self.record_path = p
|
||||
device_socket.connect(f"tcp://{LIVE_SOCKET}")
|
||||
device_socket.connect(C.live_push_socket)
|
||||
else:
|
||||
device_socket.disconnect(f"tcp://{LIVE_SOCKET}")
|
||||
device_socket.disconnect(C.live_push_socket)
|
||||
elif isinstance(msg, RobotRtsiMsg):
|
||||
self.rtsi = msg
|
||||
|
||||
@ -16,4 +16,5 @@ dependencies = [
|
||||
"click>=8.1.8",
|
||||
"mido[ports-rtmidi]>=1.3.3",
|
||||
"pyjoystick>=1.2.4",
|
||||
"platformdirs>=4.3.6",
|
||||
]
|
||||
|
||||
@ -8,6 +8,7 @@ class ASD:
|
||||
bbb: int = 1
|
||||
ccc: int = 1
|
||||
|
||||
@property
|
||||
def b(self):
|
||||
return self.aaa
|
||||
|
||||
|
||||
2
uv.lock
@ -384,6 +384,7 @@ dependencies = [
|
||||
{ name = "jupyter" },
|
||||
{ name = "mido", extra = ["ports-rtmidi"] },
|
||||
{ name = "opencv-python" },
|
||||
{ name = "platformdirs" },
|
||||
{ name = "pyjoystick" },
|
||||
{ name = "pyqt6" },
|
||||
{ name = "python-miio" },
|
||||
@ -399,6 +400,7 @@ requires-dist = [
|
||||
{ name = "jupyter", specifier = ">=1.1.1" },
|
||||
{ name = "mido", extras = ["ports-rtmidi"], specifier = ">=1.3.3" },
|
||||
{ name = "opencv-python", specifier = ">=4.10.0.84" },
|
||||
{ name = "platformdirs", specifier = ">=4.3.6" },
|
||||
{ name = "pyjoystick", specifier = ">=1.2.4" },
|
||||
{ name = "pyqt6", specifier = ">=6.8.0" },
|
||||
{ name = "python-miio", specifier = ">=0.5.12" },
|
||||
|
||||