local_contact_panel.py: added config for autoamtion, currently just the sleep between mount and wait.
This commit is contained in:
1 parent
ce1f939e63
commit
6a90a01dbe
5 files changed
+200
-2
No files matched your search
@@ -86,6 +86,8 @@ class DAQWorker(QObject):
|
||||
local_contact_simulation_state_loaded = Signal(dict)
|
||||
local_contact_device_state_loaded = Signal(dict)
|
||||
local_contact_links_loaded = Signal(dict)
|
||||
local_contact_config_loaded = Signal(dict)
|
||||
local_contact_config_saved = Signal(dict)
|
||||
local_contact_transfer_error = Signal(str)
|
||||
|
||||
polled_devices_status = Signal(str, bool) # (message, is_error)
|
||||
@@ -1543,6 +1545,62 @@ class DAQWorker(QObject):
|
||||
)
|
||||
self._disable_local_contact_metadata_polling(message)
|
||||
|
||||
@Slot()
|
||||
def load_local_contact_config(self):
|
||||
if self.__base_url is None:
|
||||
self.local_contact_config_loaded.emit({"mount_to_center_sleep_s": 0.0})
|
||||
return
|
||||
|
||||
request = QNetworkRequest(QUrl(f"{self.__base_url}/local_contact/config"))
|
||||
request.setRawHeader(b"Authorization", f"Bearer {self.__token}".encode("utf-8"))
|
||||
reply = self.__net_manager.get(request)
|
||||
reply.finished.connect(lambda: self._handle_local_contact_config_response(reply))
|
||||
|
||||
def _handle_local_contact_config_response(self, reply: QNetworkReply):
|
||||
try:
|
||||
response_data = self.handle_response(reply)
|
||||
payload = json.loads(response_data) if response_data else {}
|
||||
if not isinstance(payload, dict):
|
||||
raise RuntimeError("Invalid local contact config payload")
|
||||
self.local_contact_config_loaded.emit(payload)
|
||||
except Exception as e:
|
||||
message = (
|
||||
"Error transferring information from DAQ while loading Local Contact config.\n\n"
|
||||
f"{e}"
|
||||
)
|
||||
logger.error(message)
|
||||
self.local_contact_transfer_error.emit(message)
|
||||
|
||||
@Slot(dict)
|
||||
def set_local_contact_config(self, payload: dict):
|
||||
if self.__base_url is None:
|
||||
self.local_contact_config_saved.emit(payload)
|
||||
return
|
||||
|
||||
request = QNetworkRequest(QUrl(f"{self.__base_url}/local_contact/config"))
|
||||
request.setRawHeader(b"Authorization", f"Bearer {self.__token}".encode("utf-8"))
|
||||
request.setRawHeader(b"Content-Type", b"application/json")
|
||||
body = QByteArray(json.dumps(payload).encode("utf-8"))
|
||||
reply = self.__net_manager.put(request, body)
|
||||
reply.finished.connect(lambda: self._handle_set_local_contact_config_response(reply))
|
||||
|
||||
def _handle_set_local_contact_config_response(self, reply: QNetworkReply):
|
||||
try:
|
||||
response_data = self.handle_response(reply)
|
||||
payload = json.loads(response_data) if response_data else {}
|
||||
if not isinstance(payload, dict):
|
||||
raise RuntimeError("Invalid local contact config response")
|
||||
self.local_contact_config_saved.emit(payload)
|
||||
self.local_contact_config_loaded.emit(payload)
|
||||
self.status_message.emit("Local Contact config saved.", False)
|
||||
except Exception as e:
|
||||
message = (
|
||||
"Error transferring information from DAQ while saving Local Contact config.\n\n"
|
||||
f"{e}"
|
||||
)
|
||||
logger.error(message)
|
||||
self.local_contact_transfer_error.emit(message)
|
||||
|
||||
@Slot(str, bool)
|
||||
def set_local_contact_simulation(self, device: str, enabled: bool):
|
||||
self.generic_post(f"local_contact/simulate/{device}?enabled={str(enabled).lower()}")
|
||||
|
||||
Reference in new issue
Block a user