def test_CheckToolSet(self): th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "参数") th.msleep(1000) dlg = th.assertActiveWindow(ParamsDialog) th.msleep(500) P[4006] = 1 th.msleep(500) dlg.close() th.msleep(500) for i in range(basic.spindleCount()): R[31, i] = 0 th.msleep(1000) basic.start() th.msleep(2000) self.assertTrue(F[3]) th.msleep(500) P[4006] = 0 th.msleep(1000) basic.start() th.msleep(2000) self.assertFalse(F[3]) th.msleep(500) basic.stop() th.msleep(2000) self.assertTrue(F[3])
def test_forbidden_halt2(self): P[4143] = 1 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "其他功能") th.msleep(1000) # self.win = th.assertActiveWindow(basic.otherDialog) # 登录操作员 self.win = QtWidgets.QApplication.activeWindow() if self.win.windowTitle() == "其他功能": th.clickButton(self.win, "用户管理") self.win = th.assertActiveWindow(basic.UserManagementDialog) th.clickButton(self.win, "操作员登录") th.msleep(500) th.close(self.win) th.msleep(1000) assert basic.Auth_Level() == 20 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "坐标设定") th.msleep(1000) th.assertActiveWindow(basic.mainWindow) P[4143] = 0 th.clickButton(basic.mainWindow, "坐标设定") th.msleep(1000) win = th.assertActiveWindow(CoordinateDialog) th.close(win)
def test_CoordinateZero(self): P[2506] = 1 th.msleep(500) th.findButtons(self.win, "清零") buttons = th.findButtons(self.win, "清零") for i in buttons: th.click(widget=i) th.msleep(1500) msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.clickButton(msg, "确定") th.msleep(1000) th.click(widget=i) th.msleep(1500) msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.clickButton(msg, "取消") th.msleep(500) P[2506] = 0 th.msleep(500) th.findButtons(self.win, "清零") buttons = th.findButtons(self.win, "清零") for i in buttons: th.click(widget=i) th.msleep(1500) th.assertActiveWindow(CoordinateDialog) th.msleep(1000)
def setUp(self): th.msleep(1000) # 获取寻原点方向初始值 self.origin_dir = [] for i in range(basic.axisCount()): self.origin_dir.append(P[1701 + i]) # 打开Home对话框 th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "Home") th.msleep(1000) # 判断当前窗口是否为Home对话框 self.homewindow = th.assertActiveWindow(basic.HomeDialog)
def test_stopspindle2(self): P[4100] = 1 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(6000) # 判断主轴已启动且同步 for i in range(basic.spindleCount()): assert F[71 + i] and F[81 + i] th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") th.msleep(5000) assert F[3] # 判断主轴未启动且同步 for i in range(basic.spindleCount()): assert not F[71 + i] and F[81 + i] # 判断主轴转速为0 for i in range(basic.spindleCount()): assert R[191 + i] == 0 P[4100] = 0 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(6000) # 判断主轴已启动且同步 for i in range(basic.spindleCount()): assert F[71 + i] and F[81 + i] th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") th.msleep(5000) assert F[3] # 判断主轴已启动且同步 for i in range(basic.spindleCount()): assert F[71 + i] and F[81 + i]
def test_UseMultiCoordinate(self): th.msleep(500) # 勾选“使用多坐标系” P[4305] = 1 th.msleep(1000) # # 设置每个坐标系的工件坐标和材料厚度 lineEdit_x = self.win.ui.offset_x lineEdit_y = self.win.ui.offset_y thickness = self.win.ui.groupBox_4.findChildren(QtWidgets.QLineEdit) th.msleep(1000) offsetx = 160 offsety = -160 for wcs in ["G54", "G55", "G56", "G57", "G58", "G59"]: offsetx = offsetx - 10 offsety = offsety + 10 th.clickButton(self.win, wcs) th.lineEditTypewrite(str(offsetx), lineEdit_x) th.lineEditTypewrite(str(offsety), lineEdit_y) for i in thickness: th.lineEditTypewrite("-50", i) th.msleep(1000) th.close(self.win) th.msleep(1000) self.win = th.assertActiveWindow(basic.mainWindow) # 加载NC程序 th.loadProgram("E:/NC/自动测试程序/多坐标系.NC") th.msleep(2000) # 进行仿真 th.clickButton(basic.mainWindow, "仿真") th.msleep(1000) self.win = th.assertActiveWindow(Simu3dDialog) th.moveTo(widget=self.win.ui.widget) th.msleep(1000) th.rightClick() th.msleep(1000) th.assertActiveMenu() th.clickMenu("俯视图") th.msleep(1000) th.rightClick() th.msleep(1000) th.assertActiveMenu() th.clickMenu("标尺") self.win = th.assertActiveWindow(Simu3dDialog) th.clickButton(self.win, "连续仿真") th.msleep(1000) # 输出仿真图形 th.screenshot() th.msleep(1000) # 关闭仿真对话框 th.close(self.win) # # 取消勾选“使用多坐标系” P[4305] = 0 th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "坐标设定") th.msleep(1000) self.win = th.assertActiveWindow(CoordinateDialog) self.assertTrue(self.win.ui.G54.isEnabled()) self.assertFalse(self.win.ui.G55.isEnabled())
def setUp(self): th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.msleep(500) # 打开刀具页面 th.clickButton(basic.mainWindow, "刀具") self.tool = th.assertActiveWindow(basic.ToolDialog) th.msleep(500) # 创建空刀具名称列表,保存刀具列表原始值 self.list_name = [] self.table = self.tool.findChildren(QtWidgets.QTableWidget) for i in range(self.table[0].rowCount()): self.list_name.append(self.table[0].item(i, 2).text()) # 点击刀具全选,完成测试初始化设置 th.clickButton(self.tool, "全选") th.msleep(500)
def test_AfterProcess(self): # 加工结束后回固定点 P[4001] = 0 th.msleep(500) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(35000) # 判断机床坐标等于固定点参数值 for i in range(basic.axisCount()): assert (round(R[101 + i] * BLU) == P[1601 + i] * mm) th.msleep(500) # 加工结束后回工件原点 P[4001] = 1 th.msleep(500) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(35000) # 判断X,Y工件坐标等于0,Z轴机床坐标等于固定点参数值 assert (R[121] == R[122] == 0) for a in range(basic.spindleCount()): assert round(R[103 + a] * BLU) == P[1603 + a] * mm # 加工结束后无附件动作 P[4001] = 2 th.msleep(500) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(35000) # 判断X,Y,Z工件坐标等于NC程序最后的X,Y,Z走的值 assert round(R[121] * BLU) == 0 * mm and round(R[122] * BLU, 3) == -62.375 * mm for b in range(basic.spindleCount()): assert round(R[123 + b] * BLU) == 5 * mm
def test_add(self): th.msleep(500) # self.assertTrue(self.win.isVisible()) # add点击手动按钮 button_list = self.win.buttons th.msleep(500) for i in ["0.01", "0.1", "1"]: th.clickButton(self.win, i) th.msleep(500) for btn in button_list: if btn == 0: continue else: th.click(widget=btn) th.msleep(1000) _logger.warning( str( tuple( round(R[341 + x] * BLU, 3) for x in range(basic.axisCount())))) th.msleep(500) # 自定义模式点击手动按钮 th.clickButton(ManualOpDialog, "自定义") th.msleep(500) lineEdit = self.win.ui.customstep th.lineEditTypewrite( str(random.randint(1, 20) + round(random.uniform(0.001, 1), 3)), lineEdit) th.msleep(500) for btn in button_list: th.click(widget=btn) th.msleep(1000) _logger.warning( str( tuple( round(R[341 + x] * BLU, 3) for x in range(basic.axisCount())))) th.msleep(500) # 连续模式点击手动按钮 th.clickButton(ManualOpDialog, "连续") for btn in button_list: if btn == 0: continue else: th.click(widget=btn) th.msleep(1000) # 开启快动按钮点击手动按钮 for btn in button_list: th.click(widget=btn) th.msleep(1000) _logger.warning( str( tuple( round(R[341 + x] * BLU, 3) for x in range(basic.axisCount())))) th.msleep(500)
def test_up_tool(self): P[4008] = 1 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(3000) # 判断Z轴机床坐标不为0 for i in range(basic.spindleCount()): assert round(R[103 + i] * BLU) != 0 * mm th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "暂停") th.msleep(200) assert F[1] # 判断Z轴进给速度不为0 for i in range(basic.spindleCount()): R[173 + i] != 0 th.msleep(6000) # 判断Z轴机床坐标为0 for i in range(basic.spindleCount()): assert round(R[103 + i] * BLU) == 0 * mm th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") th.msleep(1000) P[4008] = 0 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(5000) # 判断Z轴机床坐标不为0 for i in range(basic.spindleCount()): assert round(R[103 + i] * BLU) != 0 * mm th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "暂停") th.msleep(500) assert F[1] # 判断Z轴进给速度为0且机床坐标不为0 for i in range(basic.spindleCount()): assert R[173 + i] == 0 and round(R[103 + i] * BLU) != 0 * mm
def test_BackWPHome(self): # 设置xyz运动的距离为行程的一半 move_x = round((P[1501] + P[1521]) / 2) move_y = round((P[1502] + P[1522]) / 2) move_z = round((P[1503] + P[1523]) / 2) # XY轴先运动,Z轴再运动 basic.mdi("G90 G00 X{:.3f} Y{:.3f}".format(move_x / mm, move_y / mm)) th.msleep(8000) basic.mdi("G90 G53 G00 Z{:.3f}".format(move_z / mm)) th.msleep(3000) # 点击BackWPHome th.clickButton(basic.mainWindow, "BackWPHome") th.msleep(500) # Z工件坐标 wcs_z = round(move_z / BLU - R[143]) # 判断BackWPHome时“Z轴先抬高,XY轴不动 assert (R[121] == round(move_x / BLU)) and (R[122] == round( move_y / BLU)) for i in range(basic.spindleCount()): assert R[123 + i] != wcs_z th.msleep(3000) # Z工件坐标原点 wcs_origin_z = round(R[103] - R[143]) # 判断BackWPHome时“Z轴回到工件原点后,XY回再工件原点” assert (R[121] != round(move_x / BLU)) and (R[122] != round( move_y / BLU)) for i in range(basic.spindleCount()): assert R[123 + i] == wcs_origin_z th.msleep(6000) # 判断XYZ轴是否都回到工件原点 assert (R[121] == 0) and (R[121] == 0) for i in range(basic.spindleCount()): assert R[123 + i] == wcs_origin_z
def test_BackFixesPt(self): # 设置xyz运动的距离为行程的一半 move_x = round((P[1501] + P[1521]) / 2) move_y = round((P[1502] + P[1522]) / 2) move_z = round((P[1503] + P[1523]) / 2) # XY轴先运动,Z轴再运动 basic.mdi("G90 G53 G01 X{:.3f} Y{:.3f}".format(move_x / mm, move_y / mm)) th.msleep(2000) basic.mdi("G90 G53 G01 Z{:.3f}".format(move_z / mm)) th.msleep(3000) # 点击BackFixesPt th.clickButton(basic.mainWindow, "BackFixesPt") th.msleep(500) # 判断BackFixesPt时“Z轴先抬高,XY轴不动 assert (R[101] == round(move_x / BLU)) and (R[102] == round( move_y / BLU)) for i in range(basic.spindleCount()): assert R[103 + i] != round(move_z / BLU) th.msleep(3000) # 判断BackFixesPt时“Z轴回到固定点后,XY回再固定点” assert (R[101] != round(move_x / BLU)) and (R[102] != round( move_y / BLU)) for i in range(basic.spindleCount()): assert R[103 + i] == round(-0.001 * mm / BLU) th.msleep(5000) # 判断XYZ轴是否都回到固定点 assert (R[101] == round(-0.001 * mm / BLU)) and (R[102] == round( -0.001 * mm / BLU)) for i in range(basic.spindleCount()): assert R[103 + i] == round(-0.001 * mm / BLU)
def test_Tool(self): # 加载测试程序 basic.loadProgram("E:/NC/自动测试程序/分别外形尺寸补偿功能测试程序.NC") th.msleep(500) th.close(self.tool) th.msleep(500) # 判断刀具全部勾选 th.clickButton(basic.mainWindow, "F11开始") th.msleep(1000) assert basic.GetMainToolNo() == 1 th.msleep(8000) assert basic.GetMainToolNo() == 2 th.msleep(3000) assert basic.GetMainToolNo() == 3 th.msleep(3000) assert F[3] # 判断未勾选任何刀具 th.clickButton(basic.mainWindow, "刀具") tool = th.assertActiveWindow(basic.ToolDialog) th.msleep(500) th.clickButton(tool, "反选") th.msleep(500) th.close(tool) th.msleep(500) th.clickButton(basic.mainWindow, "F11开始") th.msleep(1000) # 如果弹出Qmessagebox则没有勾选任何刀具 msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.clickButton(msg, "取消") # 在刀具名称那一栏输入值 th.clickButton(basic.mainWindow, "刀具") th.msleep(500) # print(table[0].item(0, 2).text()) th.clickButton(self.tool, "全选") th.msleep(500) # 定义包含所有数字,字母和特殊字符的字符串 s1 = string.digits + string.ascii_letters + '~{}!@#$%^&*()><?-+=' # 随机给刀具名称列表输入值 for i in range(self.table[0].rowCount()): text = "".join(random.choice(s1) for j in range(10, 30)) self.table[0].item(i, 2).setText(text) th.msleep(1000) # 判断输入的字符串有没有保存 # assert self.list_name[i] != table[0].item(i,2).text() th.msleep(500) # 卸载NC程序 basic.unloadProgram() th.msleep(1000) basic.loadProgram("E:/NC/自动测试程序/2013样条曲线圆弧拟合.NC") th.msleep(1000) basic.unloadProgram() th.msleep(1000) basic.loadProgram("E:/NC/自动测试程序/分别外形尺寸补偿功能测试程序.NC") # 刀具半径只可输入数字不可输入字符串 for i in range(self.table[0].rowCount()): num = str(round(random.uniform(0, 1000), 3)) self.table[0].item(i, 4).setText(num) th.msleep(1000) for i in range(self.table[0].rowCount()): text = "".join(random.choice(s1) for j in range(5, 15)) self.table[0].item(i, 5).setText(text) th.msleep(1000) # 刀具寿命 th.msleep(500) th.lineEditTypewrite( "10", tool.findChild(QtWidgets.QLineEdit, "toolmaxlife")) th.msleep(500) th.lineEditTypewrite("5", tool.body.currentWidget().ui.toolcurrentlifez)
def tearDown(self): th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止")
def test_AutoToolSet(self): # 获取键盘 F[400] = True # 单头机 if basic.spindleCount() == 1: th.clickButton(basic.mainWindow, "AutoToolSet") th.msleep(1000) msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.msleep(500) th.clickButton(msg, "确定") th.msleep(500) # 点击完AutoToolSet,判断输出端口对刀吹气是否为ture assert Y[7] th.msleep(1500) # 判断XY是否到达对刀起始高度 assert R[101] == round(P[1621] / BLU, 1) and R[102] == round( P[1622] / BLU, 1) # 判断XYZ是否到达对刀起始高度后,关闭吹气 self.assertFalse(Y[7]) th.msleep(1000) F[590] = True # 判断对刀时,第一次触碰对刀信号后,Z轴抬高 th.msleep(200) v1 = R[103] th.msleep(200) v2 = R[103] assert v1 < v2 th.msleep(1000) F[590] = False th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(2000) # 判断 取消AutoToolSet后 XYZ轴不动 v1_x = R[101] v1_y = R[102] v1_z = R[103] th.clickButton(basic.mainWindow, "AutoToolSet") th.msleep(1000) msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.msleep(1000) th.clickButton(msg, "取消") v2_x = R[101] v2_y = R[102] v2_z = R[103] assert v1_x == v2_x and v1_y == v2_y and v1_z == v2_z else: # 多头机对刀 th.clickButton(basic.mainWindow, "AutoToolSet") th.msleep(1000) msg = th.assertActiveWindow(basic.AutomaticToolDialog) th.msleep(1000) th.clickButton(msg, "对刀开始") th.msleep(2000) # 判断XYZ是否到达对刀起始高度 assert R[101] == round(P[1621] / BLU, 1) and R[102] == round( P[1622] / BLU, 1) th.msleep(1000) F[590] = True # 判断对刀时,第一次触碰对刀信号后,Z轴抬高 th.msleep(200) v1 = R[103] th.msleep(200) v2 = R[103] assert v1 < v2 th.msleep(1000) F[590] = False th.msleep(500) F[590] = True th.msleep(1000) F[590] = False th.msleep(3000) # 不勾选所有Z轴 th.clickButton(basic.mainWindow, "AutoToolSet") th.msleep(1000) R[1007, random.randint(0, basic.spindleCount() - 1)] = 0 th.msleep(1000) msg = th.assertActiveWindow(basic.AutomaticToolDialog) th.clickButton(msg, "对刀开始") th.msleep(2000) F[590] = True th.msleep(1000) F[590] = False th.msleep(500) F[590] = True th.msleep(1000) F[590] = False th.msleep(3000)
def test_Manul_Home(self): # 获取键盘 F[400] = True # 将X寻原点方向设为1,YZ寻原点方向设为0 P[1701] = 1 for i in range(basic.axisCount() - 1): P[1702 + i] = 0 if P[4138] == 0: # 点击所有轴Home按钮 th.clickButton(self.homewindow, "所有轴Home") th.msleep(1000) # 判断是否是Z轴先Home assert R[41] == 1 and R[42] == 1 for i in range(basic.spindleCount()): R[43 + i] == 0 self.push_key() # 判断是否ZHome完成后,xy开始Home assert R[41] == 0 and R[42] == 0 for i in range(basic.spindleCount()): R[43 + i] == 1 self.push_key() # 判断xyZ是否都Home成功 assert R[41] == 1 and R[42] == 1 for i in range(basic.spindleCount()): R[43 + i] == 1 # 单轴Home # X轴Home th.clickButton(self.homewindow, "X 轴Home") th.msleep(1000) # 判断X轴Home方向 th.msleep(200) v1 = R[101] th.msleep(500) v2 = R[101] assert v1 > v2 th.msleep(500) F[588] = True th.msleep(500) F[588] = False # 判断粗定位完成后,X轴Home方向 th.msleep(200) v3 = R[101] th.msleep(200) v4 = R[101] assert v3 < v4 th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(500) # Y轴Home th.clickButton(self.homewindow, "Y 轴Home") th.msleep(1000) # 判断Y轴Home方向 th.msleep(200) v1 = R[102] th.msleep(500) v2 = R[102] assert v1 < v2 th.msleep(500) F[588] = True th.msleep(500) F[588] = False # 判断粗定位完成后,Y轴Home方向 th.msleep(200) v3 = R[102] th.msleep(200) v4 = R[102] assert v3 > v4 th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(500) # Z轴Home i = random.randint(1, basic.spindleCount()) th.clickButton(self.homewindow, "Z{} 轴Home".format(i)) th.msleep(1000) # 判断Z轴Home方向 th.msleep(200) v1 = R[102 + i] th.msleep(500) v2 = R[102 + i] assert v1 < v2 th.msleep(500) F[588] = True th.msleep(500) F[588] = False # 判断粗定位完成后,Z轴Home方向 th.msleep(200) v3 = R[102 + i] th.msleep(200) v4 = R[102 + i] assert v3 > v4 th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(500) F[590] = True th.msleep(500) F[590] = False th.msleep(500) # 选择任意一个Z轴Home th.msleep(1000) th.clickButton( self.homewindow, "Z{} 轴Home".format(random.randint(1, basic.spindleCount()))) th.msleep(500) # 停止Home th.clickButton(basic.mainWindow, "F12 停止") # Z轴未Home的情况下,XHome th.msleep(500) th.clickButton(self.homewindow, "X 轴Home") th.msleep(500) msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.clickButton(msg, "是(&Y)") self.push_key() # Z轴未Home的情况下,点击YHome并取消YHome th.msleep(500) th.clickButton(self.homewindow, "Y 轴Home") th.msleep(500) msg = th.assertActiveWindow(QtWidgets.QMessageBox) th.clickButton(msg, "否(&N)") # 勾选重启软件自动Home P[4138] = 1
def setUp(self): th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "手动") th.msleep(1000) self.win = th.assertActiveWindow(ManualOpDialog)
def test_SingleExec(self): # 加载测试NC程序 basic.loadProgram("E:/NC/自动测试程序/single_test.NC") th.msleep(500) th.clickButton(basic.mainWindow, "单段执行") th.msleep(500) th.clickButton(basic.mainWindow, "F11 开始") th.msleep(1000) # 判断是否处于单段保持状态 assert F[2] == 1 # 判断走完一行之后的坐标 assert R[101] == 100000000 and R[102] == -100000000 for i in range(basic.spindleCount()): assert R[103 + i] == -20000000 th.clickButton(basic.mainWindow, "F11 开始") th.msleep(1000) # 判断是否处于单段保持状态 assert F[2] == 1 # 判断走完一行之后的坐标 assert R[101] == 130000000 and R[102] == -100000000 for i in range(basic.spindleCount()): assert R[103 + i] == -20000000 th.clickButton(basic.mainWindow, "F11 开始") th.msleep(1000) # 判断是否处于单段保持状态 assert F[2] == 1 # 判断走完一行之后的坐标 assert R[101] == 130000000 and R[102] == -130000000 for i in range(basic.spindleCount()): assert R[103 + i] == -20000000 th.clickButton(basic.mainWindow, "F11 开始") th.msleep(1000) # 判断是否处于单段保持状态 assert F[2] == 1 # 判断走完一行之后的坐标 assert R[101] == 100000000 and R[102] == -130000000 for i in range(basic.spindleCount()): assert R[103 + i] == -20000000 th.clickButton(basic.mainWindow, "F11 开始") th.msleep(1000) # 判断是否处于单段保持状态 assert F[2] == 1 # 判断走完一行之后的坐标 assert R[101] == 100000000 and R[102] == -100000000 for i in range(basic.spindleCount()): assert R[103 + i] == -20000000 th.clickButton(basic.mainWindow, "F11 开始") th.msleep(1000) # 判断加工结束后,是否回到准备好状态 assert F[3] == 1 # 判断加工结束后,回到固定点 assert R[101] == R[102] == 0 for i in range(basic.spindleCount()): assert R[103 + i] == 0
def test_forbidden_halt(self): P[4142] = 1 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "其他功能") th.msleep(1000) # self.win = th.assertActiveWindow(basic.otherDialog) # 登录操作员 self.win = QtWidgets.QApplication.activeWindow() if self.win.windowTitle() == "其他功能": th.clickButton(self.win, "用户管理") self.win = th.assertActiveWindow(basic.UserManagementDialog) th.clickButton(self.win, "操作员登录") th.msleep(500) th.close(self.win) th.msleep(1000) assert basic.Auth_Level() == 20 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(5000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "暂停") win = QtWidgets.QApplication.activeWindow() assert win.windowTitle() == "用户登录" th.msleep(1000) # 输入技术员密码,登录技术员 th.typewrite("051280988566") th.msleep(500) th.press('enter') th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "暂停") th.msleep(500) # 判断为进给保持状态 assert F[1] th.clickButton(basic.mainWindow, "F12 停止") th.msleep(1000) # 判断为准备好状态 assert F[3] # 再次登录操作员 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "其他功能") self.win = QtWidgets.QApplication.activeWindow() if self.win.windowTitle() == "其他功能": th.clickButton(self.win, "用户管理") self.win = th.assertActiveWindow(basic.UserManagementDialog) th.clickButton(self.win, "操作员登录") th.msleep(500) th.close(self.win) assert basic.Auth_Level() == 20 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(5000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") win = QtWidgets.QApplication.activeWindow() assert win.windowTitle() == "用户登录" th.msleep(1000) th.typewrite("051280988566") th.msleep(500) th.press('enter') th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") th.msleep(1000) # 判断为准备好状态 assert F[3] P[4142] = 0 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "其他功能") self.win = QtWidgets.QApplication.activeWindow() if self.win.windowTitle() == "其他功能": th.clickButton(self.win, "用户管理") self.win = th.assertActiveWindow(basic.UserManagementDialog) th.clickButton(self.win, "操作员登录") th.msleep(500) th.close(self.win) th.msleep(1000) assert basic.Auth_Level() == 20 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(5000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "暂停") th.msleep(1000) # 判断为进给保持状态 assert F[1] th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(3000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") th.msleep(1000) # 判断为准备好状态 assert F[3]
def setUp(self): th.msleep(1000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "坐标设定") th.msleep(1000) self.win = th.assertActiveWindow(CoordinateDialog)
def test_SafeHight(self): P[4005] = 40 th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(5000) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止") th.msleep(500) # 清空仿真图形 th.clickButton(basic.mainWindow, "仿真") th.msleep(1000) win = th.assertActiveWindow(Simu3dDialog) th.moveTo(widget=win.ui.widget) th.msleep(1000) th.rightClick() th.msleep(1000) th.assertActiveMenu() th.clickMenu("清空") th.msleep(500) th.close(win) th.msleep(1000) # 从断点行开始加工 th.moveTo(widget=th._mainWindowContent.ui.tableView) th.msleep(500) th.rightClick() th.msleep(500) th.assertActiveMenu() th.clickMenu("从断点行开始加工") th.msleep(500) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F11开始") th.msleep(3000) # 查看仿真图形 th.clickButton(basic.mainWindow, "仿真") th.msleep(1000) win = th.assertActiveWindow(Simu3dDialog) th.moveTo(widget=win.ui.widget) th.msleep(1000) # 切换到前视图 th.rightClick() th.msleep(1000) th.assertActiveMenu() th.clickMenu("前视图") th.msleep(1000) # 打开标尺 win = th.assertActiveWindow(Simu3dDialog) win.ui.widget.m_isRuler = True th.msleep(1000) # 输出仿真图形 th.screenshot() th.msleep(1000) # 关闭仿真对话框 th.close(win) th.assertActiveWindow(basic.mainWindow) th.clickButton(basic.mainWindow, "F12 停止")