修复多处的Result结果未return的问题

This commit is contained in:
2025-06-03 23:23:26 +08:00
parent 454d068626
commit 7197994019
7 changed files with 44 additions and 35 deletions

View File

@ -1230,7 +1230,6 @@ class Data:
tho_bias_list.append(tho_seg_pos // temp_freq)
abd_bias_list.append(abd_seg_pos // temp_freq)
result = {
"tho_bias_list": tho_bias_list,
"abd_bias_list": abd_bias_list,
@ -1238,7 +1237,6 @@ class Data:
"epoch_max": epoch_max
}
except Exception as e:
return Result().failure(
info=Constants.APPROXIMATELY_EPOCH_GET_FAILURE + Constants.FAILURE_REASON[

View File

@ -1338,7 +1338,7 @@ class Data:
def resample(self):
if self.orgBcg is None:
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["InputConfig"]["orgBcgFreq"] != Config["InputConfig"]["UseFreq"]:
@ -1348,7 +1348,7 @@ class Data:
else:
return Result().success(info=Constants.RESAMPLE_NO_NEED)
except Exception as e:
Result().failure(info=Constants.RESAMPLE_FAILURE +
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)

View File

@ -1072,7 +1072,7 @@ class Data():
def resample(self):
if self.BCG is None:
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["InputConfig"]["BCGFreq"] != Config["InputConfig"]["UseFreq"]:
@ -1082,7 +1082,7 @@ class Data():
else:
return Result().success(info=Constants.RESAMPLE_NO_NEED)
except Exception as e:
Result().failure(info=Constants.RESAMPLE_FAILURE +
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)

View File

@ -1559,7 +1559,7 @@ class Data:
def resample(self):
if self.raw_orgBcg is None or self.raw_BCG is None or self.raw_ECG is None:
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["InputConfig"]["orgBcgFreq"] != Config["InputConfig"]["UseFreq"]:
@ -1569,7 +1569,7 @@ class Data:
else:
return Result().success(info=Constants.RESAMPLE_NO_NEED)
except Exception as e:
Result().failure(info=Constants.RESAMPLE_FAILURE +
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)

View File

@ -432,7 +432,7 @@ class Data:
def resample(self):
if self.raw_data is None:
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["InputConfig"]["Freq"] != Config["OutputConfig"]["Freq"]:
@ -442,24 +442,35 @@ class Data:
else:
return Result().success(info=Constants.RESAMPLE_NO_NEED)
except Exception as e:
Result().failure(info=Constants.RESAMPLE_FAILURE +
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)
def preprocess(self):
if self.raw_data is None:
Result().failure(info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["Mode"] == "BCG":
if Config["Filter"]["BCGBandPassOrder"] == 0:
self.processed_data = self.raw_data
else:
if Config["Filter"]["BCGBandPassLow"] >= Config["Filter"]["BCGBandPassHigh"]:
return Result().failure(
info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"])
self.processed_data = Butterworth_for_BCG_PreProcess(self.raw_data, type='bandpass',
low_cut=Config["Filter"]["BCGBandPassLow"],
high_cut=Config["Filter"]["BCGBandPassHigh"],
order=Config["Filter"]["BCGBandPassOrder"],
sample_rate=Config["OutputConfig"]["Freq"])
elif Config["Mode"] == "ECG":
if Config["Filter"]["ECGBandPassOrder"] == 0:
self.processed_data = self.raw_data
else:
if Config["Filter"]["ECGBandPassLow"] >= Config["Filter"]["ECGBandPassHigh"]:
return Result().failure(
info=Constants.PREPROCESS_FAILURE + Constants.FAILURE_REASON["Filter_Args_Not_Correct"])
self.processed_data = Butterworth_for_ECG_PreProcess(self.raw_data, type='bandpass',
low_cut=Config["Filter"]["ECGBandPassLow"],
high_cut=Config["Filter"]["ECGBandPassHigh"],
@ -468,7 +479,7 @@ class Data:
else:
raise ValueError("模式不存在")
except Exception as e:
Result().failure(info=Constants.PREPROCESS_FAILURE +
return Result().failure(info=Constants.PREPROCESS_FAILURE +
Constants.FAILURE_REASON["Preprocess_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.PREPROCESS_FINISHED)

View File

@ -806,8 +806,7 @@ class MainWindow_resp_quality_label(QMainWindow):
def __slot_btn_refilter_orgBcg__(self):
PublicFunc.__disableAllButton__(self, ButtonState)
if len(self.data.OrgBCG_Processed) == 0:
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
if self.ui.radioButton_orgBcg_fillterMode_custom.isChecked():
if self.check_filter_args() is False:
@ -1301,7 +1300,7 @@ class Data():
def resample_tho(self):
if self.Tho is None:
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if Config["InputConfig"]["ThoFreq"] != Config["InputConfig"]["ThoUseFreq"]:
@ -1311,7 +1310,7 @@ class Data():
else:
return Result().success(info=Constants.RESAMPLE_NO_NEED)
except Exception as e:
Result().failure(info=Constants.RESAMPLE_FAILURE +
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)
@ -1477,7 +1476,7 @@ class Data():
def resample_tho_and_OrgBCG(self):
if (self.OrgBCG is None) or (self.Tho is None):
Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
return Result().failure(info=Constants.RESAMPLE_FAILURE + Constants.FAILURE_REASON["Data_Not_Exist"])
try:
if ((Config["InputConfig"]["OrgBCGFreq"] != Config["InputConfig"]["OrgBCGUseFreq"])
@ -1494,7 +1493,7 @@ class Data():
else:
return Result().success(info=Constants.RESAMPLE_NO_NEED)
except Exception as e:
Result().failure(info=Constants.RESAMPLE_FAILURE +
return Result().failure(info=Constants.RESAMPLE_FAILURE +
Constants.FAILURE_REASON["Resample_Exception"] + "\n" + format_exc())
return Result().success(info=Constants.RESAMPLE_FINISHED)

View File

@ -106,6 +106,7 @@ class Constants:
"Data_Length_not_Correct": "orgBcg和BCG长度不匹配",
"Artifact_Format_Not_Correct": "(体动长度或格式不正确)",
"Data_Length_Not_Correct": "(信号长度不正确)",
"Filter_Args_Not_Correct": "(滤波器参数输入不正确)",
"Open_Data_Exception": "(打开数据异常)",
"Process_Exception": "(处理异常)",