Skip to content

Commit

Permalink
pytest36: Return values for AxisMr/jogDirectionTimeout()
Browse files Browse the repository at this point in the history
Start to add checks for "DMOV" blinking feature.
Equip jogDirectionTimeout() with a return value (True/False) and use it.
Some more changes to allow waitForStartAndDone() to either throw an
exception when things fail, or just to return False.
This needs to ripple into more test cases in the next commits

Changes to be committed:
    modified:   110_Ethercat_HOMF_-ProcHom.py
    modified:   121_Record-JOGF_DIR_DLY_HLM.py
    modified:   131_Record-JOGR_DIR_DLY_LLM.py
    modified:   AxisMr.py
  • Loading branch information
tboegi committed Nov 11, 2024
1 parent fac02a0 commit f9a5b4a
Show file tree
Hide file tree
Showing 4 changed files with 233 additions and 158 deletions.
7 changes: 4 additions & 3 deletions test/pytests36/110_Ethercat_HOMF_-ProcHom.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def homeTheMotor(self, tc_no, homProc, jogToLSBefore, homeViaDriver):
old_low_limit = self.axisCom.get(".LLM")
old_HomProc = 0 # default
old_HomPos = 0.0 # default
passed = True

if jogToLSBefore != 0:
msta = int(self.axisCom.get(".MSTA"))
Expand All @@ -51,7 +52,9 @@ def homeTheMotor(self, tc_no, homProc, jogToLSBefore, homeViaDriver):
accl = self.axisCom.get(".ACCL")
time_to_wait = 1.5 * (old_high_limit - old_low_limit) / jvel + 2 * accl

self.axisMr.jogDirectionTimeout(tc_no, jogToLSBefore, time_to_wait)
passed = passed and self.axisMr.jogDirectionTimeout(
tc_no, jogToLSBefore, time_to_wait
)
self.axisCom.put(".LLM", old_low_limit)
self.axisCom.put(".HLM", old_high_limit)
else:
Expand Down Expand Up @@ -127,8 +130,6 @@ def homeTheMotor(self, tc_no, homProc, jogToLSBefore, homeViaDriver):
)
if msta2 & self.axisMr.MSTA_BIT_SLIP_STALL:
passed = False
else:
passed = True
if not msta2 & self.axisMr.MSTA_BIT_HOMED:
passed = False
if msta2 & self.axisMr.MSTA_BIT_PROBLEM:
Expand Down
165 changes: 92 additions & 73 deletions test/pytests36/121_Record-JOGF_DIR_DLY_HLM.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,32 @@ def test_TC_1213(self):
if self.msta & self.axisMr.MSTA_BIT_HOMED:
print(f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no}")
self.axisCom.put(".DLY", 1.0)
self.axisMr.jogDirection(tc_no, 1)
testPassed = self.axisMr.jogDirection(tc_no, 1)
lvio = int(self.axisCom.get(".LVIO"))
msta = int(self.axisCom.get(".MSTA"))
miss = int(self.axisCom.get(".MISS"))

self.axisCom.put(".DLY", self.saved_DLY)
self.axisMr.waitForMipZero(tc_no, self.saved_DLY)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_PROBLEM,
"DLY JOGF should not give MSTA.Problem",
)
self.assertEqual(
0, msta & self.axisMr.MSTA_BIT_MINUS_LS, "DLY JOGF should not reach LLS"
)
self.assertEqual(
0, msta & self.axisMr.MSTA_BIT_PLUS_LS, "DLY JOGF should not reach HLS"

if msta & self.axisMr.MSTA_BIT_PROBLEM:
testPassed = False
if msta & self.axisMr.MSTA_BIT_MINUS_LS:
testPassed = False
if msta & self.axisMr.MSTA_BIT_PLUS_LS:
testPassed = False
if miss != 0:
testPassed = False
if lvio != 1:
testPassed = False
print(
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no} testPassed={testPassed} lvio={lvio} miss={miss} msta={self.axisMr.getMSTAtext(msta)}"
)
self.assertEqual(0, miss, "DLY JOGF should not have MISS set")
self.assertEqual(1, lvio, "DLY JOGF should have LVIO set")
if testPassed:
self.axisCom.putDbgStrToLOG("passed " + str(tc_no), wait=True)
else:
self.axisCom.putDbgStrToLOG("Failed " + str(tc_no), wait=True)
assert testPassed

# close-toHLM
def test_TC_1214(self):
Expand All @@ -96,41 +102,49 @@ def test_TC_1214(self):

if self.msta & self.axisMr.MSTA_BIT_HOMED:
print(f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no}")
self.axisMr.moveWait(tc_no, self.jog_start_pos)
testPassed = self.axisMr.moveWait(tc_no, self.jog_start_pos)
UserPosition = self.axisCom.get(".RBV", use_monitor=False)
print(
f"{tc_no} postion={UserPosition:f} jog_start_pos={self.jog_start_pos:f}"
f"{tc_no} testPassed={testPassed} postion={UserPosition:.2f} jog_start_pos={self.jog_start_pos:.2f}"
)
if testPassed:
self.axisCom.putDbgStrToLOG("passed " + str(tc_no), wait=True)
else:
self.axisCom.putDbgStrToLOG("Failed " + str(tc_no), wait=True)
assert testPassed

def test_TC_1215(self):
tc_no = "1215"
self.axisCom.putDbgStrToLOG("Start " + str(int(tc_no)), wait=True)
if self.msta & self.axisMr.MSTA_BIT_HOMED:
print(f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no}")
self.axisCom.put(".DLY", 0.0)
self.axisMr.jogDirection(tc_no, 1)
testPassed = self.axisMr.jogDirection(tc_no, 1)
lvio = int(self.axisCom.get(".LVIO"))
msta = int(self.axisCom.get(".MSTA"))
miss = int(self.axisCom.get(".MISS"))

self.axisCom.put(".DLY", self.saved_DLY)
self.axisCom.put(".JOGF", 0)
self.axisMr.waitForMipZero(tc_no, self.saved_DLY)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_PROBLEM,
"ndly JOGF should not give MSTA.Problem",
)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_MINUS_LS,
"ndly JOGF should not reach LLS",
)
self.assertEqual(
0, msta & self.axisMr.MSTA_BIT_PLUS_LS, "ndly JOGF should not reach HLS"
if msta & self.axisMr.MSTA_BIT_PROBLEM:
testPassed = False
if msta & self.axisMr.MSTA_BIT_MINUS_LS:
testPassed = False
if msta & self.axisMr.MSTA_BIT_PLUS_LS:
testPassed = False
if miss != 0:
testPassed = False
if lvio != 1:
testPassed = False
print(
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no} testPassed={testPassed} lvio={lvio} miss={miss} msta={self.axisMr.getMSTAtext(msta)}"
)
self.assertEqual(0, miss, "ndly JOGF should not have MISS set")
self.assertEqual(1, lvio, "ndly JOGF should have LVIO set")
if testPassed:
self.axisCom.putDbgStrToLOG("passed " + str(tc_no), wait=True)
else:
self.axisCom.putDbgStrToLOG("Failed " + str(tc_no), wait=True)
assert testPassed

# High soft limt JOGF
def test_TC_1216(self):
Expand All @@ -140,40 +154,37 @@ def test_TC_1216(self):
print(f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no}")
self.axisCom.put(".DLY", 0.0)
mip1 = int(self.axisCom.get(".MIP"))
self.axisMr.jogDirection(tc_no, 1)
testPassed = self.axisMr.jogDirection(tc_no, 1)

lvio = int(self.axisCom.get(".LVIO"))
msta = int(self.axisCom.get(".MSTA"))
miss = int(self.axisCom.get(".MISS"))
self.axisMr.waitForMipZero(tc_no, self.saved_DLY)
mip2 = int(self.axisCom.get(".MIP"))
jogf = int(self.axisCom.get(".JOGF"))

self.axisCom.put(".DLY", self.saved_DLY)
print(
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no} mip1={mip1:x} mip2={mip2:x}"
)

self.assertEqual(
0, msta & self.axisMr.MSTA_BIT_PROBLEM, "ndly2 No MSTA.Problem JOGF"
)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_MINUS_LS,
"ndly2 Minus hard limit not reached JOGF",
)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_PLUS_LS,
"ndly2 Plus hard limit not reached JOGF",
)
self.assertEqual(0, miss, "ndly2 MISS not set JOGF")
self.assertEqual(0, mip1, "ndly2 MIP1 not set JOGF")
self.assertEqual(
0, mip2 & self.axisMr.MIP_BIT_JOGF, "ndly2 MIP2.JOGF not set JOGF"
if msta & self.axisMr.MSTA_BIT_PROBLEM:
testPassed = False
if msta & self.axisMr.MSTA_BIT_MINUS_LS:
testPassed = False
if msta & self.axisMr.MSTA_BIT_PLUS_LS:
testPassed = False
if miss != 0:
testPassed = False
if mip2 != 0:
testPassed = False
if lvio != 1:
testPassed = False
print(
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no} testPassed={testPassed} lvio={lvio} miss={miss} msta={self.axisMr.getMSTAtext(msta)}"
)
self.assertEqual(0, jogf, "ndly2 MIP1 not set JOGF")
self.assertEqual(1, lvio, "ndly2 should have LVIO set")
if testPassed:
self.axisCom.putDbgStrToLOG("passed " + str(tc_no), wait=True)
else:
self.axisCom.putDbgStrToLOG("Failed " + str(tc_no), wait=True)
assert testPassed

# close-toHLM UserPosition
def test_TC_1217(self):
Expand All @@ -193,31 +204,39 @@ def test_TC_1218(self):
self.axisCom.putDbgStrToLOG("Start " + str(int(tc_no)), wait=True)
if self.msta & self.axisMr.MSTA_BIT_HOMED:
print(f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no}")
saved_DIR = self.axisCom.get(".DIR")
saved_FOFF = self.axisCom.get(".FOFF")
self.axisCom.put(".FOFF", 1)
self.axisCom.put(".DIR", 1)
self.axisMr.jogDirection(tc_no, 0)
testPassed = self.axisMr.jogDirection(tc_no, 0)

lvio = int(self.axisCom.get(".LVIO"))
msta = int(self.axisCom.get(".MSTA"))

self.axisCom.put(".JOGF", 0)
self.axisCom.put(".DIR", saved_DIR)
self.axisCom.put(".FOFF", saved_FOFF)

self.assertEqual(
0, msta & self.axisMr.MSTA_BIT_PROBLEM, "No Error MSTA.Problem JOGF DIR"
)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_MINUS_LS,
"Minus hard limit not reached JOGF DIR",
)
self.assertEqual(
0,
msta & self.axisMr.MSTA_BIT_PLUS_LS,
"Plus hard limit not reached JOGF DIR",
miss = int(self.axisCom.get(".MISS"))
self.axisMr.waitForMipZero(tc_no, self.saved_DLY)
mip2 = int(self.axisCom.get(".MIP"))
self.axisCom.put(".DLY", self.saved_DLY)
print(
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no} mip2={mip2:x}"
)
if msta & self.axisMr.MSTA_BIT_PROBLEM:
testPassed = False
if msta & self.axisMr.MSTA_BIT_MINUS_LS:
testPassed = False
if msta & self.axisMr.MSTA_BIT_PLUS_LS:
testPassed = False
if miss != 0:
testPassed = False
if mip2 != 0:
testPassed = False
if lvio != 1:
testPassed = False
print(
f"{datetime.datetime.now():%Y-%m-%d %H:%M:%S} {filnam} {tc_no} testPassed={testPassed} lvio={lvio} miss={miss} msta={self.axisMr.getMSTAtext(msta)}"
)
if testPassed:
self.axisCom.putDbgStrToLOG("passed " + str(tc_no), wait=True)
else:
self.axisCom.putDbgStrToLOG("Failed " + str(tc_no), wait=True)
assert testPassed

def teardown_class(self):
tc_no = int(filnam) * 10000 + 9999
Expand Down
Loading

0 comments on commit f9a5b4a

Please sign in to comment.