aboutsummaryrefslogtreecommitdiffstats
path: root/extras/FeedKuksa.py
diff options
context:
space:
mode:
authorsuchinton2001 <suchinton.2001@gmail.com>2023-10-15 23:30:36 +0530
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2023-10-19 16:19:32 +0000
commit20fe2d131df0041e121eccaf4fc58d4ac88dfbbc (patch)
treed555cd863e644014e9eb7a3fb9b759de246b6c2e /extras/FeedKuksa.py
parente875973f63fc9a9582e957eb7264a4a589b78a97 (diff)
agl-demo-control-panel: Refactor Settings, Config and UI scaling
V1: - Add template to specify new configs in config.ini - Add drop-down to load all configurations specified in config.ini - Add new assets and refine UI elements (Scaling issue fixed) - Add size grip to main window - Add options in settings to configure port and AGL's CA.pem file - Removed unused or redundant files V2: - Check for user configs agl-demo-control-panel.ini & config.ini before resorting to default config.ini - Check for CA.pem and jwt tokens in default paths - Add new fields in settings for CA.pem file, jwt token path, TLS Server name - Fix crash in dashboard.py module due to icon.availableSizes() V3: Add Start/Stop states for the client V4: Block subscription event updates to the UI when values are changed on the control panel Bug-AGL: SPEC-4905 Signed-off-by: suchinton2001 <suchinton.2001@gmail.com> Change-Id: Id7883ba3bc88248dabb58d54e6e931f6d365fd54
Diffstat (limited to 'extras/FeedKuksa.py')
-rw-r--r--extras/FeedKuksa.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/extras/FeedKuksa.py b/extras/FeedKuksa.py
index 56e902e..cda2a30 100644
--- a/extras/FeedKuksa.py
+++ b/extras/FeedKuksa.py
@@ -14,12 +14,15 @@
limitations under the License.
"""
-import time
import logging
from PyQt5.QtCore import QThread
+from PyQt5.QtCore import pyqtSignal
from . import Kuksa_Instance as kuksa_instance
+import threading
class FeedKuksa(QThread):
+ sending_values = pyqtSignal()
+ finished_sending_values = pyqtSignal()
"""
A class to handle sending values to Kuksa.
@@ -85,20 +88,25 @@ class FeedKuksa(QThread):
Exception
If there is an error sending values to Kuksa.
"""
- if self.client is not None:
- if self.client.checkConnection():
- try:
- if attribute is not None:
- self.client.setValue(path, str(value), attribute)
- else:
- self.client.setValue(path, str(value))
- except Exception as e:
- logging.error(f"Error sending values to kuksa {e}")
- self.set_instance()
- else:
- logging.error("Kuksa client is not connected, try reconnecting")
- self.set_instance()
- else:
+
+ if self.client is None:
logging.error("Kuksa client is None, try reconnecting")
- time.sleep(2)
- self.set_instance() \ No newline at end of file
+ return
+
+ if not self.client.checkConnection():
+ logging.error("Kuksa client is not connected, try reconnecting")
+ threading.Thread(target=self.set_instance).start()
+ return
+
+ try:
+ if attribute is not None:
+ self.sending_values.emit()
+ self.client.setValue(path, value, attribute)
+ else:
+ self.sending_values.emit()
+ self.client.setValue(path, value)
+
+ self.finished_sending_values.emit()
+ except Exception as e:
+ logging.error(f"Error sending values to kuksa {e}")
+ threading.Thread(target=self.set_instance).start() \ No newline at end of file