basically done again
This commit is contained in:
@ -159,13 +159,12 @@ class DoBrakeTest(QThread):
|
||||
prj_name = ".".join(prj_file.split("/")[-1].split(".")[:-1])
|
||||
wb = openpyxl.load_workbook(config_file, read_only=True)
|
||||
ws = wb["Target"]
|
||||
write_diagnosis = float(ws.cell(row=2, column=2).value)
|
||||
get_init_speed = float(ws.cell(row=3, column=2).value)
|
||||
single_brake = str(ws.cell(row=4, column=2).value)
|
||||
pon = ws.cell(row=5, column=2).value
|
||||
io_name = ws.cell(row=6, column=2).value.upper().strip()
|
||||
get_init_speed = float(ws.cell(row=2, column=2).value)
|
||||
single_brake = str(ws.cell(row=3, column=2).value).strip()
|
||||
pon = ws.cell(row=4, column=2).value
|
||||
io_name = ws.cell(row=5, column=2).value.upper().strip()
|
||||
wb.close()
|
||||
msg = f"基本参数配置:write_diagnosis(废弃) = {write_diagnosis}, get_init_speed = {get_init_speed}, single_brake = {single_brake}, pon = {pon}"
|
||||
msg = f"基本参数配置:get_init_speed = {get_init_speed}, single_brake = {single_brake}, pon = {pon}, IO = {io_name}"
|
||||
self.logger("INFO", "do_brake", msg)
|
||||
|
||||
if pon == "positive":
|
||||
@ -195,7 +194,7 @@ class DoBrakeTest(QThread):
|
||||
continue
|
||||
|
||||
clibs.c_md.write_axis(axis)
|
||||
self.logger("INFO", "brake-processing", "-" * 90, "purple", flag="signal")
|
||||
self.logger("INFO", "brake", "-" * 90, "purple", flag="signal")
|
||||
speed_max = 0
|
||||
for rounds in range(1, 4):
|
||||
count += 1
|
||||
@ -309,9 +308,9 @@ class DoBrakeTest(QThread):
|
||||
if clibs.c_md.w_program_state == 1:
|
||||
break
|
||||
else:
|
||||
time.sleep(5)
|
||||
time.sleep(2)
|
||||
if time.time() - t_start > 60:
|
||||
self.logger("ERROR", "do_brake","60s 内程序未能正常执行,需检查...", "red", "RlProgramStartTimeout")
|
||||
self.logger("ERROR", "do_brake", "60s 内程序未能正常执行,需检查...", "red", "RlProgramStartTimeout")
|
||||
|
||||
for i in range(16):
|
||||
if clibs.c_md.read_ready_to_go() == 1:
|
||||
@ -360,7 +359,7 @@ class DoBrakeTest(QThread):
|
||||
break
|
||||
|
||||
else:
|
||||
time.sleep(50) # why?
|
||||
time.sleep(clibs.INTERVAL*2)
|
||||
self.change_curve_state(False)
|
||||
msg = f"<br>{self.tool.removeprefix('tool')}%负载的制动性能测试执行完毕,如需采集其他负载,须切换负载类型,并更换其他负载,重新执行"
|
||||
self.logger("INFO", "do_brake", msg, "green")
|
||||
|
@ -81,23 +81,18 @@ def handle_exception(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
log_path = f"assets/logs"
|
||||
PREFIX = "resources/assets" # for pyinstaller
|
||||
# PREFIX = "assets" # for local testing
|
||||
log_path = f"{PREFIX}/logs"
|
||||
lock = threading.Lock()
|
||||
running = [0, 0, 0, 0, 0, 0, 0] # 制动数据/转矩数据/激光数据/精度数据/制动自动化/转矩自动化/耐久数据采集
|
||||
functions = ["制动数据处理", "转矩数据处理", "激光数据处理", "精度数据处理", "制动自动化测试", "转矩自动化测试", "耐久数据采集"]
|
||||
levels = ["DEBUG", "INFO", "WARNING", "ERROR"]
|
||||
ip_addr, ssh_port, socket_port, xService_port, external_port, modbus_port, upgrade_port = "", 22, 5050, 6666, 8080, 502, 4567
|
||||
username, password = "luoshi", "luoshi2019"
|
||||
INTERVAL, RADIAN, MAX_FRAME_SIZE, MAX_LOG_NUMBER = 1, 57.3, 1024, 10
|
||||
INTERVAL, RADIAN, MAX_FRAME_SIZE, MAX_LOG_NUMBER, CYCLE = 1, 57.3, 1024, 10, 300
|
||||
c_md, c_hr, c_ec, c_pd, conn, cursor, search_records = None, None, None, None, None, None, None
|
||||
status = {"mysql": 0, "hmi": 0, "md": 0, "ec": 0}
|
||||
c_joint_vel, c_servo_trq, c_sensor_trq, c_estimate_trans_trq, c_safety_estop = 1, 2, 3, 4, 3 # 各个指标所在列
|
||||
|
||||
init_logdb()
|
||||
|
||||
# ============== ↓↓↓DEBUG CODE↓↓↓ ==============
|
||||
for i in range(100):
|
||||
logger("DEBUG", "clibs", 'running123', flag="cursor")
|
||||
logger("INFO", "aio", 'running234', flag="cursor")
|
||||
logger("WARNING", "openapi", 'running345', flag="cursor")
|
||||
logger("ERROR", "brake", 'running456', flag="cursor")
|
||||
|
@ -745,7 +745,7 @@ class HmiRequest(QThread):
|
||||
def execution(self, command, **kwargs):
|
||||
req = None
|
||||
try:
|
||||
with open(f"assets/files/protocols/hmi/{command}.json", encoding="utf-8", mode="r") as f_json:
|
||||
with open(f"{clibs.PREFIX}/files/protocols/hmi/{command}.json", encoding="utf-8", mode="r") as f_json:
|
||||
req = json.load(f_json)
|
||||
t = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")
|
||||
req["id"] = f"{command}@{t}"
|
||||
@ -768,12 +768,14 @@ class HmiRequest(QThread):
|
||||
cmd = json.dumps(req, separators=(",", ":"))
|
||||
try:
|
||||
self.c.send(self.package(cmd))
|
||||
time.sleep(clibs.INTERVAL/4)
|
||||
self.logger("DEBUG", "openapi", f"hmi: 老协议请求发送成功 {cmd}")
|
||||
except Exception as err:
|
||||
self.logger("ERROR", "openapi", f"hmi: 老协议请求发送失败 {cmd},报错信息 {err}", "red", "CommandSendFailed")
|
||||
elif flag == 1:
|
||||
try:
|
||||
self.c_xs.send(self.package_xs(req))
|
||||
time.sleep(clibs.INTERVAL/4)
|
||||
self.logger("DEBUG", "openapi", f"hmi: xService请求发送成功 {req}")
|
||||
except Exception as Err:
|
||||
self.logger("ERROR", "openapi", f"hr: xService请求发送失败 {req} 报错信息 {Err}", "red", "CommandSendFailed")
|
||||
@ -1804,9 +1806,9 @@ class ExternalCommunication(QThread):
|
||||
if clibs.status["ec"]:
|
||||
try:
|
||||
self.c.close()
|
||||
self.logger("INFO", "openapi", f"ec: 关闭 EC 连接成功", "green")
|
||||
self.logger("INFO", "openapi", f"ec: 关闭外部通信连接成功", "green")
|
||||
except Exception as err:
|
||||
self.logger("ERROR", "openapi", f"ec: 关闭 EC 连接失败:{err}", "red", "EcCloseFailed")
|
||||
self.logger("ERROR", "openapi", f"ec: 关闭外部通信连接失败:{err}", "red", "EcCloseFailed")
|
||||
|
||||
def s_string(self, directive):
|
||||
order = "".join([directive, self.suffix])
|
||||
@ -2057,7 +2059,7 @@ class ExternalCommunication(QThread):
|
||||
self.s_string(directive)
|
||||
time.sleep(clibs.INTERVAL)
|
||||
result = self.r_string(directive).strip()
|
||||
self.logger("INFO", "openapi", f"ec: 执行{description}指令是 {directive},返回值为 {result}{more_desc}")
|
||||
self.logger("DEBUG", "openapi", f"ec: 执行{description}指令是 {directive},返回值为 {result}{more_desc}")
|
||||
return result
|
||||
|
||||
|
||||
@ -2167,9 +2169,9 @@ class RobotInit(object):
|
||||
interactive_data = f"/home/luoshi/bin/controller/interactive_data/{robot_type}"
|
||||
|
||||
config_files = [
|
||||
f"assets/files/projects/fieldbus_device.json",
|
||||
f"assets/files/projects/registers.json",
|
||||
f"assets/files/projects/registers.xml"
|
||||
f"{clibs.PREFIX}/files/projects/fieldbus_device.json",
|
||||
f"{clibs.PREFIX}/files/projects/registers.json",
|
||||
f"{clibs.PREFIX}/files/projects/registers.xml"
|
||||
]
|
||||
for config_file in config_files:
|
||||
filename = config_file.split("/")[-1]
|
||||
@ -2197,10 +2199,10 @@ class RobotInit(object):
|
||||
os.remove(io_device_file_local_tmp)
|
||||
except:
|
||||
...
|
||||
clibs.c_hr.execution("io_device.load_cfg")
|
||||
clibs.c_hr.execution("modbus.load_cfg")
|
||||
clibs.c_hr.execution("fieldbus_device.load_cfg")
|
||||
clibs.c_hr.execution("fieldbus_device.set_params", device_name="autotest", enable=True)
|
||||
clibs.c_hr.execution("io_device.load_cfg")
|
||||
clibs.c_hr.execution("modbus.load_cfg")
|
||||
|
||||
def robot_init(self):
|
||||
pd = PreDos(clibs.ip_addr, clibs.ssh_port, clibs.username, clibs.password)
|
||||
|
@ -19,7 +19,7 @@ class DoFactoryTest(QThread):
|
||||
def __init__(self, dir_path, interval, procs, /):
|
||||
super().__init__()
|
||||
self.dir_path = dir_path
|
||||
self.interval = int(interval) if interval != "" else 300
|
||||
self.interval = int(interval) if interval != "" else clibs.CYCLE
|
||||
self.procs = procs
|
||||
self.idx = 6
|
||||
self.curves = []
|
||||
@ -99,6 +99,7 @@ class DoFactoryTest(QThread):
|
||||
self.change_curve_state(False)
|
||||
clibs.c_md.r_soft_estop(0)
|
||||
clibs.c_md.r_soft_estop(1)
|
||||
clibs.c_md.r_reset_estop()
|
||||
clibs.c_md.r_clear_alarm()
|
||||
clibs.c_md.write_act(False)
|
||||
time.sleep(1) # 让曲线彻底关闭
|
||||
|
@ -38,9 +38,6 @@ class Ui_MainWindow(QMainWindow):
|
||||
font.setFamilies([u"Consolas"])
|
||||
font.setPointSize(14)
|
||||
MainWindow.setFont(font)
|
||||
icon = QIcon()
|
||||
icon.addFile(u"../assets/media/icon.ico", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
MainWindow.setWindowIcon(icon)
|
||||
MainWindow.setStyleSheet(u"background-color: rgb(233, 233, 233);")
|
||||
MainWindow.setDocumentMode(False)
|
||||
self.centralwidget = QWidget(MainWindow)
|
||||
@ -290,7 +287,7 @@ class Ui_MainWindow(QMainWindow):
|
||||
self.sa_durable.setWidgetResizable(True)
|
||||
self.scrollAreaWidgetContents = QWidget()
|
||||
self.scrollAreaWidgetContents.setObjectName(u"scrollAreaWidgetContents")
|
||||
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 212, 78))
|
||||
self.scrollAreaWidgetContents.setGeometry(QRect(0, 0, 158, 78))
|
||||
self.horizontalLayout_9 = QHBoxLayout(self.scrollAreaWidgetContents)
|
||||
self.horizontalLayout_9.setObjectName(u"horizontalLayout_9")
|
||||
self.verticalLayout_5 = QVBoxLayout()
|
||||
@ -652,6 +649,7 @@ class Ui_MainWindow(QMainWindow):
|
||||
self.cb_ec_cmd.addItem("")
|
||||
self.cb_ec_cmd.addItem("")
|
||||
self.cb_ec_cmd.addItem("")
|
||||
self.cb_ec_cmd.addItem("")
|
||||
self.cb_ec_cmd.setObjectName(u"cb_ec_cmd")
|
||||
self.cb_ec_cmd.setMinimumSize(QSize(240, 0))
|
||||
self.cb_ec_cmd.setFont(font4)
|
||||
@ -881,7 +879,7 @@ class Ui_MainWindow(QMainWindow):
|
||||
self.label.setText(QCoreApplication.translate("MainWindow", u"Rokae AIO", None))
|
||||
self.btn_start.setText(QCoreApplication.translate("MainWindow", u"\u5f00\u59cb\u6267\u884c", None))
|
||||
self.btn_stop.setText(QCoreApplication.translate("MainWindow", u"\u505c\u6b62\u6267\u884c", None))
|
||||
self.btn_reset.setText(QCoreApplication.translate("MainWindow", u"\u72b6\u6001\u91cd\u7f6e", None))
|
||||
self.btn_reset.setText(QCoreApplication.translate("MainWindow", u"\u8f93\u51fa\u91cd\u7f6e", None))
|
||||
self.cb_data_func.setItemText(0, QCoreApplication.translate("MainWindow", u"\u5236\u52a8", None))
|
||||
self.cb_data_func.setItemText(1, QCoreApplication.translate("MainWindow", u"\u8f6c\u77e9", None))
|
||||
self.cb_data_func.setItemText(2, QCoreApplication.translate("MainWindow", u"\u6fc0\u5149", None))
|
||||
@ -951,12 +949,13 @@ class Ui_MainWindow(QMainWindow):
|
||||
self.label_18.setText("")
|
||||
self.cb_ec_cmd.setItemText(0, QCoreApplication.translate("MainWindow", u"motor_on", None))
|
||||
self.cb_ec_cmd.setItemText(1, QCoreApplication.translate("MainWindow", u"motor_off", None))
|
||||
self.cb_ec_cmd.setItemText(2, QCoreApplication.translate("MainWindow", u"set_do", None))
|
||||
self.cb_ec_cmd.setItemText(2, QCoreApplication.translate("MainWindow", u"setdo", None))
|
||||
self.cb_ec_cmd.setItemText(3, QCoreApplication.translate("MainWindow", u"switch_mode_auto", None))
|
||||
self.cb_ec_cmd.setItemText(4, QCoreApplication.translate("MainWindow", u"switch_mode_manual", None))
|
||||
self.cb_ec_cmd.setItemText(5, QCoreApplication.translate("MainWindow", u"operating_mode", None))
|
||||
self.cb_ec_cmd.setItemText(6, QCoreApplication.translate("MainWindow", u"motor_on_state", None))
|
||||
self.cb_ec_cmd.setItemText(7, QCoreApplication.translate("MainWindow", u"robot_running_state", None))
|
||||
self.cb_ec_cmd.setItemText(6, QCoreApplication.translate("MainWindow", u"io_state", None))
|
||||
self.cb_ec_cmd.setItemText(7, QCoreApplication.translate("MainWindow", u"motor_on_state", None))
|
||||
self.cb_ec_cmd.setItemText(8, QCoreApplication.translate("MainWindow", u"robot_running_state", None))
|
||||
|
||||
self.btn_ec_send.setText(QCoreApplication.translate("MainWindow", u"\u53d1\u9001", None))
|
||||
self.pushButton.setText(QCoreApplication.translate("MainWindow", u"HMI", None))
|
||||
|
Reference in New Issue
Block a user