Commit 682991b8 authored by Benjamin Mummery's avatar Benjamin Mummery 💻

Merge branch 'ui_dev' of ssh://ohwr.org:7999/project/hev into ui_dev

parents c7e30913 fe941517
Pipeline #1857 failed with stages
......@@ -29,7 +29,7 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
manualChanged = QtCore.Signal()
programmaticallyChanged = QtCore.Signal()
def __init__(self, NativeUI, popup, label_text, min, max, initVal, step, decPlaces):
def __init__(self, NativeUI, typeval_popup, label_text, min, max, initVal, step, decPlaces):
super().__init__()
self.lineEdit().installEventFilter(self)
self.editable = True
......@@ -47,35 +47,33 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
self.setValue(initVal)
self.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)
self.NativeUI = NativeUI
# self.populateVals = [label_text, min, max, initVal, step, decPlaces]
self.popUp = (
popup
self.typeval_popup = (
typeval_popup
) # TypeValuePopup(NativeUI, label_text, min, max, initVal, step, decPlaces)
# self.popUp.okButton.clicked.connect(self.okButtonPressed)
# self.popUp.cancelButton.clicked.connect(self.cancelButtonPressed)
def setEditability(self, setBool):
self.editable = setBool
def okButtonPressed(self):
"""Ok button press applies changes in popup to the spin box, closes the popup, and emits a signal"""
val = float(self.popUp.lineEdit.text())
val = float(self.typeval_popup.lineEdit.text())
self.setValue(val)
self.popUp.close()
self.typeval_popup.close()
self.manualChanged.emit()
def cancelButtonPressed(self):
"""Cancel button press reverts changes and closes popup"""
self.popUp.lineEdit.setText(self.popUp.lineEdit.saveVal)
self.popUp.close()
self.typeval_popup.lineEdit.setText(self.typeval_popup.lineEdit.saveVal)
self.typeval_popup.close()
def stepBy(self, step):
"""Overrides stepBy to store previous value and emit a signal when called"""
"""Overrides stepBy to emit a signal when called"""
value = self.value()
self.prevValue = value
#self.prevValue = value
super(signallingSpinBox, self).stepBy(step)
if self.value() != value:
self.manualChanged.emit()
self.manualChanged.emit() # only emitted if value actually changes
def set_value(self, value):
self.setValue(value)
......@@ -89,12 +87,8 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
):
if not self.editable:
return
# self.popUp.lineEdit.setText(str(self.value()))
# self.popUp.lineEdit.setFocus()
self.popUp.populatePopup(self, self.NativeUI.display_stack.currentWidget())
self.NativeUI.display_stack.setCurrentWidget(self.popUp)
# self.popUp.show()
self.typeval_popup.populatePopup(self, self.NativeUI.display_stack.currentWidget())
self.NativeUI.display_stack.setCurrentWidget(self.typeval_popup)
return True
return False
......@@ -104,12 +98,12 @@ class labelledSpin(QtWidgets.QWidget):
It is created by an information array which indicates labels, units, command type and code for value setting,
and the range of permitted values"""
def __init__(self, NativeUI, popup, infoArray, *args, **kwargs):
def __init__(self, NativeUI, typeval_popup, infoArray, *args, **kwargs):
super(labelledSpin, self).__init__(*args, **kwargs)
self.NativeUI = NativeUI
self.cmd_type, self.cmd_code = "", ""
self.min, self.max, self.step = 0, 10000, 0.3
self.min, self.max, self.step = 0, 10000, 1
self.initVal = 1
self.currentDbValue = self.initVal
self.decPlaces = 2
......@@ -123,8 +117,12 @@ class labelledSpin(QtWidgets.QWidget):
infoArray
)
elif len(infoArray) == 5:
print('creating with 5')
print(infoArray)
self.label, self.units, self.tag, self.cmd_type, self.cmd_code = infoArray
elif len(infoArray) == 3:
print('creating with 3')
print(infoArray)
self.label, self.units, self.tag = infoArray
self.manuallyUpdated = False
......@@ -139,7 +137,7 @@ class labelledSpin(QtWidgets.QWidget):
self.simpleSpin = signallingSpinBox(
NativeUI,
popup,
typeval_popup,
self.label,
self.min,
self.max,
......@@ -147,10 +145,7 @@ class labelledSpin(QtWidgets.QWidget):
self.step,
self.decPlaces,
)
# self.simpleSpin.setRange(self.min, self.max)
# self.simpleSpin.setSingleStep(self.step)
# self.simpleSpin.setDecimals(self.decPlaces)
# self.simpleSpin.setValue(self.initVal)
self.simpleSpin.setStyleSheet(
"QDoubleSpinBox{"
"border:none;"
......@@ -166,18 +161,12 @@ class labelledSpin(QtWidgets.QWidget):
"QDoubleSpinBox[textColour='0']{"
" color:" + NativeUI.colors["page_background"].name() + ";"
"}"
"QDoubleSpinBox[textColour='2']{"
" color:" + NativeUI.colors["red"].name() + ";"
"}"
"QDoubleSpinBox[textColour='1']{"
" color:" + NativeUI.colors["page_foreground"].name() + ";"
"}"
"QDoubleSpinBox::up-button{"
# "width:20; "
"}"
"QDoubleSpinBox::down-button{"
# "width:20px;"
# "height:20px; "
"QDoubleSpinBox[textColour='2']{"
" color:" + NativeUI.colors[
"red"].name() + ";"
"}"
)
self.simpleSpin.setFont(NativeUI.text_font)
......@@ -185,6 +174,8 @@ class labelledSpin(QtWidgets.QWidget):
self.simpleSpin.setProperty("bgColour", "0")
self.simpleSpin.setAlignment(QtCore.Qt.AlignCenter)
if self.cmd_type == "":
print('cmd_type is empty')
print(self.label)
self.simpleSpin.setReadOnly(True)
self.simpleSpin.setEditability(False)
self.simpleSpin.style().polish(self.simpleSpin)
......@@ -244,7 +235,7 @@ class labelledSpin(QtWidgets.QWidget):
return 0
try:
if 'SET_TARGET' in self.cmd_type and self.NativeUI.currentMode.replace("/", "_").replace("-", "_") not in self.cmd_type: # only update value if spin w idget corresponds to current mode
if 'SET_TARGET' in self.cmd_type and self.NativeUI.currentMode.replace("/", "_").replace("-", "_") not in self.cmd_type: # only update value if spin widget corresponds to current mode
return 0
else:
newVal = db[self.tag]
......
......@@ -852,8 +852,8 @@ class Layout:
widg = self.NativeUI.widgets.get_widget(attrName)
if setting[0] in modeDict["radioSettings"]:
stack.addWidget(widg)
widg.simpleSpin.setFont(self.NativeUI.value_font)
widg.label.setFont(self.NativeUI.text_font)
#widg.simpleSpin.setFont(self.NativeUI.value_font)
#widg.label.setFont(self.NativeUI.text_font)
if "IE Ratio" in widg.label_text:
stack.setCurrentWidget(widg)
else:
......@@ -889,12 +889,12 @@ class Layout:
self.NativeUI.widgets.get_widget(attrName).simpleSpin.setFixedSize(
x_spin, 0.7 * y_spin
)
self.NativeUI.widgets.get_widget(attrName).simpleSpin.setFont(
self.NativeUI.value_font
)
self.NativeUI.widgets.get_widget(attrName).label.setFont(
self.NativeUI.text_font
)
# self.NativeUI.widgets.get_widget(attrName).simpleSpin.setFont(
# self.NativeUI.value_font
# )
# self.NativeUI.widgets.get_widget(attrName).label.setFont(
# self.NativeUI.text_font
# )
stack.setFixedSize(x_spin, y_spin)
......
......@@ -54,6 +54,7 @@ class SpinButton(QtWidgets.QFrame):
# create and style label
self.label = QtWidgets.QLabel()
self.label.setText(NativeUI.text[self.label_text])
self.label.setFont(self.NativeUI.text_font)
labelBgColour = "rgb(60,58,60)"
self.label.setStyleSheet(
......@@ -110,6 +111,7 @@ class SpinButton(QtWidgets.QFrame):
self.simpleSpin.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed
)
self.simpleSpin.setFont(self.NativeUI.value_font)
self.layout.addWidget(self.simpleSpin)
self.setLayout(self.layout)
self.setFixedWidth(300)
......
......@@ -77,9 +77,9 @@ class StartupHandler(
def carryout_calibration(self) -> int:
assert self.activeWidget is not None
calibrationWidget = self.activeWidget
if "calibration" in calibrationWidget.infoDict["label"]:
self.NativeUI.q_send_cmd("DO_CALIBRATION", "DO_CALIBRATION")
elif "Leak_Test" in calibrationWidget.infoDict["label"]:
if 'calibration' in calibrationWidget.infoDict['label']:
self.NativeUI.q_send_cmd("DO_CALIBRATION", "DO_CALIBRATIONING")
elif 'Leak_Test' in calibrationWidget.infoDict['label']:
self.NativeUI.q_send_cmd()
else:
logging.debug("ERROR: label does not mach any calibration procedure")
......
......@@ -31,7 +31,7 @@ import time
import json
import threading
from typing import List, Dict, Union
from CommsCommon import PayloadFormat, PAYLOAD_TYPE
#from CommsCommon import PayloadFormat, PAYLOAD_TYPE
import logging
logging.basicConfig(
......
......@@ -157,9 +157,18 @@ class HEVServer(object):
try:
reqtype = request["type"]
if reqtype == "CMD":
print('reqtype is cmd')
reqcmd = request["cmd"] if request["cmd"] is not None else 0
print('reqcmd is ' + str(reqcmd))
reqcmdtype = request["cmdtype"]
print('reqcmdtpye is ' + str(reqcmdtype))
reqparam = request["param"] if request["param"] is not None else 0
print('reqparam is ' + str(reqparam))
print('cmd_type is ')
print(CMD_TYPE[reqcmdtype].value)
print('cmd code is ')
print('cmd code is ')
print(CMD_MAP[reqcmdtype].value[reqcmd].value)
command = CommandFormat(
cmd_type=CMD_TYPE[reqcmdtype].value,
cmd_code=CMD_MAP[reqcmdtype].value[reqcmd].value,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment