修复AI,DI在模拟值时不能强制值问题

main
ZHANGXUXU\95193 2 months ago
parent 3ea5f0d2b6
commit 57b755f1e6

@ -193,60 +193,61 @@ class AnalogButtonDelegate(TcRtdButtonDelegate):
# 获取强制值(从视图)和其他数据(从源模型)
value = self._get_view_data(view_row, 1) # 强制值列
varType = model.datas[source_row][6]
min = model.datas[source_row][7]
max = model.datas[source_row][8]
minValue = model.datas[source_row][7]
maxValue = model.datas[source_row][8]
# print(model.datas[source_row][9])
pattern = re.compile(r'[^0-9\.-]+')
if varType in ['AI', 'DI'] and model.datas[source_row][9] != '模拟值':
if varType in ['AI', 'DI'] and model.datas[source_row][10] != '模拟值':
reply = QMessageBox.question(self.parent(),
'警告',
"AI,DI类型变量不允许强制值",
QMessageBox.Yes)
return
if varType in ['DO'] and int(value) not in [0, 1]:
if not value or re.findall(pattern, str(value)):
reply = QMessageBox.question(self.parent(),
'警告',
"DO类型变量强制值只能为0或1",
"请输入强制值或数字",
QMessageBox.Yes)
return
if not value or re.findall(pattern, str(value)):
if varType in ['DO'] and int(value) not in [0, 1]:
reply = QMessageBox.question(self.parent(),
'警告',
"请输入强制值或数字",
"DO类型变量强制值只能为0或1",
QMessageBox.Yes)
return
if source_row > 15:
if not value.isdigit:
if not str(value).isdigit:
reply = QMessageBox.question(self.parent(),
'警告',
"请输入0或1",
QMessageBox.Yes)
return
if min and max and source_row < 16:
if float(value) < float(min) or float(value) > float(max):
if minValue and maxValue:
if float(value) < float(minValue) or float(value) > float(maxValue):
reply = QMessageBox.question(self.parent(),
'警告',
"超出量程范围",
QMessageBox.Yes)
return
else:
min = None
max = None
# print(value, source_row)
if (float(value) > 20 or float(value)) < 4 and source_row < 8:
reply = QMessageBox.question(self.parent(),
'警告',
"超出量程范围1",
QMessageBox.Yes)
return
if float(value) > 10000 or float(value) < 0.1 and 8 < source_row < 16:
reply = QMessageBox.question(self.parent(),
'警告',
"超出量程范围2",
QMessageBox.Yes)
return
# else:
# minValue = None
# maxValue = None
# # print(value, source_row)
# if (float(value) > 20 or float(value)) < 4 and source_row < 8:
# reply = QMessageBox.question(self.parent(),
# '警告',
# "超出量程范围1",
# QMessageBox.Yes)
# return
# if float(value) > 10000 or float(value) < 0.1 and 8 < source_row < 16:
# reply = QMessageBox.question(self.parent(),
# '警告',
# "超出量程范围2",
# QMessageBox.Yes)
# return
# if source_row < 8:
# model.table.realList[source_row] = getRealAO(float(value), max, min)
# model.table.valueList[source_row] = float(value)

Loading…
Cancel
Save