Skip to content

Commit

Permalink
- adds device name replacement {4} substituted by current temperatu…
Browse files Browse the repository at this point in the history
…re mode (`C` or `F`)

- adds support for Phidget motor controllers DCC1020 and DCC1120
  • Loading branch information
MAKOMO committed Dec 19, 2024
1 parent c69c3f7 commit d9e440e
Show file tree
Hide file tree
Showing 17 changed files with 121 additions and 168 deletions.
8 changes: 4 additions & 4 deletions src/artisanlib/alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,10 +799,10 @@ def savealarms(self) -> None:
def buildAlarmSourceList(self) -> List[str]:
extra_names = []
for i in range(len(self.aw.qmc.extradevices)):
extra_names.append(self.aw.qmc.extraname1[i].format(self.aw.qmc.etypesf(0),self.aw.qmc.etypesf(1),self.aw.qmc.etypesf(2),self.aw.qmc.etypesf(3)))
extra_names.append(self.aw.qmc.extraname2[i].format(self.aw.qmc.etypesf(0),self.aw.qmc.etypesf(1),self.aw.qmc.etypesf(2),self.aw.qmc.etypesf(3)))
et_name = self.aw.ETname.format(self.aw.qmc.etypesf(0),self.aw.qmc.etypesf(1),self.aw.qmc.etypesf(2),self.aw.qmc.etypesf(3))
bt_name = self.aw.BTname.format(self.aw.qmc.etypesf(0),self.aw.qmc.etypesf(1),self.aw.qmc.etypesf(2),self.aw.qmc.etypesf(3))
extra_names.append(self.aw.qmc.device_name_subst(self.aw.qmc.extraname1[i]))
extra_names.append(self.aw.qmc.device_name_subst(self.aw.qmc.extraname2[i]))
et_name = self.aw.qmc.device_name_subst(self.aw.ETname)
bt_name = self.aw.qmc.device_name_subst(self.aw.BTname)
return ['',
deltaLabelUTF8 + et_name,
deltaLabelUTF8 + bt_name,
Expand Down
29 changes: 17 additions & 12 deletions src/artisanlib/background.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->
super().__init__(parent, aw)
self.activeTab = activeTab

self.ETname = self.aw.qmc.device_name_subst(self.aw.ETname)
self.BTname = self.aw.qmc.device_name_subst(self.aw.BTname)

self.setWindowTitle(QApplication.translate('Form Caption','Profile Background'))
self.setModal(True)

Expand All @@ -65,11 +68,11 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->
self.backgroundDetails = QCheckBox(QApplication.translate('CheckBox','Annotations'))
self.backgroundeventsflag = QCheckBox(QApplication.translate('CheckBox','Events'))
self.backgroundDeltaETflag = QCheckBox()
backgroundDeltaETflagLabel = QLabel(deltaLabelPrefix + QApplication.translate('Label','ET'))
backgroundDeltaETflagLabel = QLabel(deltaLabelPrefix + self.ETname)
self.backgroundDeltaBTflag = QCheckBox()
backgroundDeltaBTflagLabel = QLabel(deltaLabelPrefix + QApplication.translate('Label','BT'))
self.backgroundETflag = QCheckBox(QApplication.translate('CheckBox','ET'))
self.backgroundBTflag = QCheckBox(QApplication.translate('CheckBox','BT'))
backgroundDeltaBTflagLabel = QLabel(deltaLabelPrefix + self.BTname)
self.backgroundETflag = QCheckBox(self.ETname)
self.backgroundBTflag = QCheckBox(self.BTname)
self.backgroundFullflag = QCheckBox(QApplication.translate('CheckBox','Show Full'))
self.keyboardControlflag = QCheckBox(QApplication.translate('CheckBox','Keyboard Control'))
self.keyboardControlflag.setToolTip(QApplication.translate('Tooltip', 'Move the background profile using the cursor keys'))
Expand Down Expand Up @@ -118,8 +121,10 @@ def __init__(self, parent:QWidget, aw:'ApplicationWindow', activeTab:int = 0) ->

curvenames = [''] # first entry is the empty one, no extra curve displayed
for i in range(min(len(self.aw.qmc.extraname1B),len(self.aw.qmc.extraname2B),len(self.aw.qmc.extratimexB))):
curvenames.append('B' + str(2*i+3) + ': ' + self.aw.qmc.extraname1B[i].format(self.aw.qmc.Betypesf(0),self.aw.qmc.Betypesf(1),self.aw.qmc.Betypesf(2),self.aw.qmc.Betypesf(3)))
curvenames.append('B' + str(2*i+4) + ': ' + self.aw.qmc.extraname2B[i].format(self.aw.qmc.Betypesf(0),self.aw.qmc.Betypesf(1),self.aw.qmc.Betypesf(2),self.aw.qmc.Betypesf(3)))
curvenames.append('B' + str(2*i+3) + ': ' + self.aw.qmc.extraname1B[i].format(
self.aw.qmc.Betypesf(0),self.aw.qmc.Betypesf(1),self.aw.qmc.Betypesf(2),self.aw.qmc.Betypesf(3),self.aw.qmc.mode))
curvenames.append('B' + str(2*i+4) + ': ' + self.aw.qmc.extraname2B[i].format(
self.aw.qmc.Betypesf(0),self.aw.qmc.Betypesf(1),self.aw.qmc.Betypesf(2),self.aw.qmc.Betypesf(3),self.aw.qmc.mode))

self.xtcurvelabel = QLabel(QApplication.translate('Label', 'Extra 1'))
self.xtcurveComboBox = QComboBox()
Expand Down Expand Up @@ -770,8 +775,8 @@ def createEventTable(self) -> None:
self.eventtable.setRowCount(ndata)
self.eventtable.setColumnCount(6)
self.eventtable.setHorizontalHeaderLabels([QApplication.translate('Table','Time'),
QApplication.translate('Table', 'ET'),
QApplication.translate('Table', 'BT'),
self.ETname,
self.BTname,
QApplication.translate('Table','Description'),
QApplication.translate('Table','Type'),
QApplication.translate('Table','Value')])
Expand Down Expand Up @@ -844,10 +849,10 @@ def createDataTable(self) -> None:
start = 0
self.datatable.setRowCount(ndata)
headers = [QApplication.translate('Table','Time'),
QApplication.translate('Table','ET'),
QApplication.translate('Table','BT'),
deltaLabelUTF8 + QApplication.translate('Table','ET'),
deltaLabelUTF8 + QApplication.translate('Table','BT')]
self.ETname,
self.BTname,
deltaLabelUTF8 + self.ETname,
deltaLabelUTF8 + self.BTname]
xtcurve = False # no XT curve
n3:int = 0
n4:int = 0
Expand Down
85 changes: 26 additions & 59 deletions src/artisanlib/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,13 @@ def doUpdate(self) -> None:

self.block_update = False

def device_name_subst(self, device_name:str) -> str:
try:
return device_name.format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3],self.mode)
except Exception: # pylint: disable=broad-except
# substitution might fail if the label contains brackets like in "t{FCS}"
return device_name

def get_etype_default(self, i:int, default_etypes_set:Optional[List[int]] = None) -> str:
etypes_set = (self.default_etypes_set if default_etypes_set is None else default_etypes_set)
return (self.alt_etypesdefault[i] if etypes_set[i] else self.etypesdefault[i])
Expand Down Expand Up @@ -3399,56 +3406,22 @@ def intChannel(self, n:int, c:int) -> bool:
no_math_formula_defined = bool(self.extramathexpression1[n] == '')
if c == 1:
no_math_formula_defined = bool(self.extramathexpression2[n] == '')
if self.extradevices[n] == 29: # MODBUS
if c == 0:
return ((self.aw.modbus.inputFloatsAsInt[0] or self.aw.modbus.inputBCDsAsInt[0] or not self.aw.modbus.inputFloats[0]) and
self.aw.modbus.inputDivs[0] == 0 and
self.aw.modbus.inputModes[0] == '' and
no_math_formula_defined)
return ((self.aw.modbus.inputFloatsAsInt[1] or self.aw.modbus.inputBCDsAsInt[1] or not self.aw.modbus.inputFloats[1]) and
self.aw.modbus.inputDivs[1] == 0 and
self.aw.modbus.inputModes[1] == '' and
no_math_formula_defined)
if self.extradevices[n] == 33: # MODBUS_34
if c == 0:
return ((self.aw.modbus.inputFloatsAsInt[2] or self.aw.modbus.inputBCDsAsInt[2] or not self.aw.modbus.inputFloats[2]) and
self.aw.modbus.inputDivs[2] == 0 and
self.aw.modbus.inputModes[2] == '' and
no_math_formula_defined)
return ((self.aw.modbus.inputFloatsAsInt[3] or self.aw.modbus.inputBCDsAsInt[3] or not self.aw.modbus.inputFloats[3]) and
self.aw.modbus.inputDivs[3] == 0 and
self.aw.modbus.inputModes[3] == '' and
no_math_formula_defined)
if self.extradevices[n] == 55: # MODBUS_56
if c == 0:
return ((self.aw.modbus.inputFloatsAsInt[4] or self.aw.modbus.inputBCDsAsInt[4] or not self.aw.modbus.inputFloats[4]) and
self.aw.modbus.inputDivs[4] == 0 and
self.aw.modbus.inputModes[4] == '' and
no_math_formula_defined)
return ((self.aw.modbus.inputFloatsAsInt[5] or self.aw.modbus.inputBCDsAsInt[5] or not self.aw.modbus.inputFloats[5]) and
self.aw.modbus.inputDivs[5] == 0 and
self.aw.modbus.inputModes[5] == '' and
no_math_formula_defined)
if self.extradevices[n] == 109: # MODBUS_78
if c == 0:
return ((self.aw.modbus.inputFloatsAsInt[6] or self.aw.modbus.inputBCDsAsInt[6] or not self.aw.modbus.inputFloats[6]) and
self.aw.modbus.inputDivs[6] == 0 and
self.aw.modbus.inputModes[6] == '' and
# MODBUS channels
for idx, dev_type in enumerate([29,33,55,109,150]): # MODBUS, MODBUS_34, MODBUS_56, MODBUS_78, MODBUS_910
if self.extradevices[n] == dev_type:
return ((self.aw.modbus.inputFloatsAsInt[idx*2 + c] or self.aw.modbus.inputBCDsAsInt[idx*2 + c] or not self.aw.modbus.inputFloats[idx*2 + c]) and
self.aw.modbus.inputDivs[idx*2 + c] == 0 and
(self.aw.modbus.inputModes[idx*2 + c] == '' or self.aw.modbus.inputModes[idx*2 + c] == self.aw.qmc.mode) and
no_math_formula_defined)
return ((self.aw.modbus.inputFloatsAsInt[7] or self.aw.modbus.inputBCDsAsInt[7] or not self.aw.modbus.inputFloats[7]) and
self.aw.modbus.inputDivs[7] == 0 and
self.aw.modbus.inputModes[7] == '' and
no_math_formula_defined)
if self.extradevices[n] == 70: # S7
return self.aw.s7.type[0+c] != 1 and self.aw.s7.mode[0+c] == 0 and (self.aw.s7.div[0+c] == 0 or self.aw.s7.type[0+c] == 2) and no_math_formula_defined
if self.extradevices[n] == 80: # S7_34
return self.aw.s7.type[2+c] != 1 and self.aw.s7.mode[2+c] == 0 and (self.aw.s7.div[2+c] == 0 or self.aw.s7.type[2+c] == 2) and no_math_formula_defined
if self.extradevices[n] == 81: # S7_56
return self.aw.s7.type[4+c] != 1 and self.aw.s7.mode[4+c] == 0 and (self.aw.s7.div[4+c] == 0 or self.aw.s7.type[4+c] == 2) and no_math_formula_defined
if self.extradevices[n] == 82: # S7_78
return self.aw.s7.type[6+c] != 1 and self.aw.s7.mode[6+c] == 0 and (self.aw.s7.div[6+c] == 0 or self.aw.s7.type[6+c] == 2) and no_math_formula_defined
if self.extradevices[n] == 110: # S7_910
return self.aw.s7.type[8+c] != 1 and self.aw.s7.mode[8+c] == 0 and (self.aw.s7.div[8+c] == 0 or self.aw.s7.type[8+c] == 2) and no_math_formula_defined
# S7 channels
for idx, dev_type in enumerate([70,80,81,82,110,151]): # S7, S7_34, S7_56, S7_78, S7_910, S7_1112
if self.extradevices[n] == dev_type:
return (self.aw.s7.type[idx*2 + c] != 1 and
(self.aw.s7.mode[idx*2 + c] == 0 or (self.aw.s7.mode[idx*2 + c] == 1 and
self.aw.qmc.mode == 'C') or (self.aw.s7.mode[idx*2 + c] == 2 and self.aw.qmc.mode == 'F')) and
(self.aw.s7.div[idx*2 + c] == 0 or self.aw.s7.type[idx*2 + c] == 2) and
no_math_formula_defined)
# others
if self.extradevices[n] in {54, 90, 91, 135, 136, 140, 141, 165}: # Hottop Heater/Fan, Slider 12, Slider 34, Santoker Power / Fan, Kaleido Fan/Drum, Kaleido Heater/AH, Mugma Heater/Fan
return True
if self.extradevices[n] == 136 and c == 0: # Santoker Drum
Expand Down Expand Up @@ -8236,14 +8209,8 @@ def redraw(self, recomputeAllDeltas:bool = True, re_smooth_foreground:bool = Tru
extraname1_subst = self.extraname1[:]
extraname2_subst = self.extraname2[:]
for i in range(len(self.extratimex)):
try:
extraname1_subst[i] = extraname1_subst[i].format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3])
except Exception: # pylint: disable=broad-except
pass
try:
extraname2_subst[i] = extraname2_subst[i].format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3])
except Exception: # pylint: disable=broad-except
pass
extraname1_subst[i] = self.device_name_subst(extraname1_subst[i])
extraname2_subst[i] = self.device_name_subst(extraname2_subst[i])

if self.flagstart or self.ygrid == 0:
y_label = self.ax.set_ylabel('')
Expand Down Expand Up @@ -10000,7 +9967,7 @@ def redraw(self, recomputeAllDeltas:bool = True, re_smooth_foreground:bool = Tru
if not l1.startswith('_'):
self.handles.append(self.extratemp1lines[idx1])
try:
self.labels.append(self.aw.arabicReshape(l1.format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3])))
self.labels.append(self.aw.arabicReshape(l1.format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3],self.mode)))
except Exception: # pylint: disable=broad-except
# a key error can occur triggered by the format if curley braces are used without reference
self.labels.append(self.aw.arabicReshape(l1))
Expand All @@ -10011,7 +9978,7 @@ def redraw(self, recomputeAllDeltas:bool = True, re_smooth_foreground:bool = Tru
if not l2.startswith('_'):
self.handles.append(self.extratemp2lines[idx2])
try:
self.labels.append(self.aw.arabicReshape(l2.format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3])))
self.labels.append(self.aw.arabicReshape(l2.format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3],self.mode)))
except Exception: # pylint: disable=broad-except
# a key error can occur triggered by the format if curley braces are used without reference
self.labels.append(self.aw.arabicReshape(l2))
Expand Down
11 changes: 11 additions & 0 deletions src/artisanlib/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4725,7 +4725,9 @@ def phidgetVOUTclose(self) -> None:
# only supporting
# 1 channel VINT DCC1000 and DCC1002
# 2 channel VINT DCC1003
# 1 channel VINT DCC1020
# 1 channel VINT DCC1100 (brushless DC motor controller)
# 1 channel VINT DCC1120 (brushless DC motor controller)
# commands:
# accel(c,v[,sn]) with c channel number and v acceleration as a float, and sn serial the optional serial/port number of the addressed module
# vel(c,v[,sn]) with c channel number and v target velocity as a float, and sn serial the optional serial/port number of the addressed module
Expand All @@ -4751,11 +4753,20 @@ def phidgetDCMotorAttach(self, channel:int, serial:Optional[str] = None) -> None
ser,port = self.aw.qmc.phidgetManager.getFirstMatchingPhidget('PhidgetDCMotor',DeviceID.PHIDID_DCC1003,
remote=self.aw.qmc.phidgetRemoteFlag,remoteOnly=self.aw.qmc.phidgetRemoteOnlyFlag,serial=s,hubport=p)
ports = 2
if ser is None:
ser,port = self.aw.qmc.phidgetManager.getFirstMatchingPhidget('PhidgetDCMotor',DeviceID.PHIDID_DCC1020,
remote=self.aw.qmc.phidgetRemoteFlag,remoteOnly=self.aw.qmc.phidgetRemoteOnlyFlag,serial=s,hubport=p)
ports = 1
if ser is None:
ser,port = self.aw.qmc.phidgetManager.getFirstMatchingPhidget('PhidgetBLDCMotor',DeviceID.PHIDID_DCC1100,
remote=self.aw.qmc.phidgetRemoteFlag,remoteOnly=self.aw.qmc.phidgetRemoteOnlyFlag,serial=s,hubport=p)
ports = 1
brushless = True
if ser is None:
ser,port = self.aw.qmc.phidgetManager.getFirstMatchingPhidget('PhidgetBLDCMotor',DeviceID.PHIDID_DCC1120,
remote=self.aw.qmc.phidgetRemoteFlag,remoteOnly=self.aw.qmc.phidgetRemoteOnlyFlag,serial=s,hubport=p)
ports = 1
brushless = True
if ser is not None:
self.aw.ser.PhidgetDCMotor[serial] = []
for i in range(ports):
Expand Down
4 changes: 2 additions & 2 deletions src/artisanlib/comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ def __init__(self, aw:'ApplicationWindow', profile:'ProfileData', filepath:str,
self.extratemp2.append(fill_gaps(xtemp2[i]) if self.aw.qmc.interpolateDropsflag else xtemp2[i])
else:
self.extratemp2.append([-1.]*len(self.timex))
self.extraname1 = [decodeLocalStrict(n).format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3]) for n in xname1] # we apply event name substitutions
self.extraname2 = [decodeLocalStrict(n).format(self.etypes[0],self.etypes[1],self.etypes[2],self.etypes[3]) for n in xname2] # we apply event name substitutions
self.extraname1 = [self.aw.qmc.device_name_subst(decodeLocalStrict(n)) for n in xname1] # we apply event name substitutions
self.extraname2 = [self.aw.qmc.device_name_subst(decodeLocalStrict(n)) for n in xname2] # we apply event name substitutions
self.extraDelta1 = delta1
self.extraDelta2 = delta2
# temperature conversion
Expand Down
10 changes: 6 additions & 4 deletions src/artisanlib/curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,16 +1527,18 @@ def renameBT(self) -> None:
self.aw.BTname = str(self.renameBTLine.text()).strip()
if self.aw.BTname == '':
self.aw.BTname = QApplication.translate('Label', 'BT')
self.aw.label3.setText(f'<big><b>{self.aw.BTname}</b></big>'.format(self.aw.qmc.etypes[0],self.aw.qmc.etypes[1],self.aw.qmc.etypes[2],self.aw.qmc.etypes[3]))
self.aw.label5.setText(f'{deltaLabelBigPrefix}{self.aw.BTname}</b></big>'.format(self.aw.qmc.etypes[0],self.aw.qmc.etypes[1],self.aw.qmc.etypes[2],self.aw.qmc.etypes[3]))
BTname_subst = self.aw.qmc.device_name_subst(self.aw.BTname)
self.aw.label3.setText(f'<big><b>{BTname_subst}</b></big>')
self.aw.label5.setText(f'{deltaLabelBigPrefix}{BTname_subst}</b></big>')

@pyqtSlot()
def renameET(self) -> None:
self.aw.ETname = str(self.renameETLine.text()).strip()
if self.aw.ETname == '':
self.aw.ETname = QApplication.translate('Label', 'ET')
self.aw.label2.setText(f'<big><b>{self.aw.ETname}</b></big>'.format(self.aw.qmc.etypes[0],self.aw.qmc.etypes[1],self.aw.qmc.etypes[2],self.aw.qmc.etypes[3]))
self.aw.label4.setText(f'{deltaLabelBigPrefix}{self.aw.ETname}</b></big>'.format(self.aw.qmc.etypes[0],self.aw.qmc.etypes[1],self.aw.qmc.etypes[2],self.aw.qmc.etypes[3]))
ETname_subst = self.aw.qmc.device_name_subst(self.aw.ETname)
self.aw.label2.setText(f'<big><b>{ETname_subst}</b></big>')
self.aw.label4.setText(f'{deltaLabelBigPrefix}{ETname_subst}</b></big>')

@pyqtSlot(int)
def toggleWebLCDsAlerts(self, _:int) -> None:
Expand Down
Loading

0 comments on commit d9e440e

Please sign in to comment.