コード例 #1
0
def check_VBAS_VELO_ACCL_ACCS_accEGU(self, motor, tc_no, vbas, velo, accl,
                                     accs, expAccEGU):
    # Put the values which the test case wanted
    if vbas > -1:
        capv_lib.capvput(motor + '.VBAS', vbas)
    if velo > -1:
        capv_lib.capvput(motor + '.VELO', velo)
    if accl > -1:
        capv_lib.capvput(motor + '.ACCL', accl)
    if accs > -1:
        capv_lib.capvput(motor + '.ACCS', accs)
    # Move the motor 2 mm (hardcoded)
    destination = 2.0 + capv_lib.capvget(motor + '.VAL')
    res = lib.move(motor, destination, 60)
    resAccEGU = getAccEGUfromMCU(self, motor, tc_no)
    print('%s: check_accEGU_ACCS_ACCL_VELO %s vbas=%f velo=%f accl=%f accs=%f expAccEGU=%f resAccEGU=%f' % \
           (tc_no, motor, vbas, velo, accl, accs, expAccEGU, resAccEGU))
    actVelo = capv_lib.capvget(motor + '.VELO', use_monitor=False)
    actAccl = capv_lib.capvget(motor + '.ACCL', use_monitor=False)
    actAccs = capv_lib.capvget(motor + '.ACCS', use_monitor=False)
    expAccs = actVelo / actAccl
    expAccl = actVelo / actAccs
    print('%s expAccl=%f expAccs=%f actVelo=%f actAccl=%f actAccs=%f' %
          (tc_no, expAccl, expAccs, actVelo, actAccl, actAccs))
    assert lib.calcAlmostEqual(self.motor, tc_no, expAccEGU, resAccEGU, 0.1)
    self.assertEqual(res, globals.SUCCESS, 'move returned SUCCESS')
    # Check if VELO, ACCL and ACCS are aligned
    assert lib.calcAlmostEqual(self.motor, tc_no, expAccl, actAccl, 0.1)
    assert lib.calcAlmostEqual(self.motor, tc_no, expAccs, actAccs, 0.1)
コード例 #2
0
    def jogDirection(self, motor, tc_no, direction):
        jvel = capv_lib.capvget(motor + ".JVEL")
        hlm = capv_lib.capvget(motor + ".HLM")
        llm = capv_lib.capvget(motor + ".LLM")
        rbv = capv_lib.capvget(motor + ".RBV")
        accl = capv_lib.capvget(motor + '.ACCL')
        deltah = math.fabs(hlm - rbv)
        deltal = math.fabs(llm - rbv)
        # TODO: we could use at the DIR field, which delta to use
        # This can be done in a cleanup
        if deltah > deltal:
            delta = deltah
        else:
            delta = deltal
        # TODO: add JAR to the calculation
        time_to_wait = delta / jvel + 2 * accl + 2.0
        if direction > 0:
            capv_lib.capvput(motor + '.JOGF', 1)
        else:
            capv_lib.capvput(motor + '.JOGR', 1)

        done = self.waitForStartAndDone(motor, tc_no + " jogDirection",
                                        30 + time_to_wait + 3.0)

        if direction > 0:
            capv_lib.capvput(motor + '.JOGF', 0)
        else:
            capv_lib.capvput(motor + '.JOGR', 0)
        print('%s: jogDirection done=%d' % (tc_no, done))
        return done
コード例 #3
0
    def Xtest_TC_232(self):
        motor = self.motor
        motor2 = self.motor2
        tc_no = "TC-232-NetYetStarted"
        print('%s' % tc_no)

        if (self.msta & lib.MSTA_BIT_HOMED):
            setValueOnSimulator(self, motor2, tc_no, "usleep", 1700000)

            destination = self.per90_UserPosition
            res1 = lib.move(motor, destination, 60)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per90_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            destination = self.per10_UserPosition
            res2 = lib.move(motor, destination, 60)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per10_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            setValueOnSimulator(self, motor2, tc_no, "usleep", 0)

            self.assertNotEqual(res1 == globals.SUCCESS,
                                'move returned SUCCESS')
            self.assertNotEqual(res2 == globals.SUCCESS,
                                'move returned SUCCESS')
コード例 #4
0
def setAndReadBackParam(self, motor, tc_no, pvSuffix, paramInSimu):
    pvname = motor + pvSuffix
    valRB = capv_lib.capvget(pvname)
    newVal = round(valRB + 1, 2)
    print('%s:%d %s valRB=%f newVal=%f' %
          (tc_no, lineno(), pvname, valRB, newVal))
    lib.setValueOnSimulator(motor, tc_no, paramInSimu, newVal)
    maxTime = 30  # 30 seconds maximum to poll all parameters
    testPassed = False
    maxDelta = math.fabs(newVal) * 0.02  # 2 % error tolerance margin
    while maxTime > 0:
        newValRB = capv_lib.capvget(pvname)
        print('%s:%d %s newVal=%f newValRB=%f' %
              (tc_no, lineno(), pvname, newVal, newValRB))

        if lib.calcAlmostEqual(motor, tc_no, newVal, newValRB, maxDelta):
            testPassed = True
            maxTime = 0
        else:
            time.sleep(polltime)
            maxTime = maxTime - polltime

    # restore the original value
    # Avoid overlong strings (and therefore not working with channel access)
    # like "Sim.this.fAcceleration=2.0999999046325684"
    lib.setValueOnSimulator(motor, tc_no, paramInSimu, round(valRB, 2))
    assert (testPassed)
コード例 #5
0
    def test_TC_9402(self):
        motor = self.motor
        tc_no = "TC-9402-EnabledFailed"

        capv_lib.capvput(motor + '.CNEN', 0, wait=True)
        setValueOnSimulator(self, motor, tc_no, "bAmplifierLockedToBeOff",
                            AMPLIFIER_LOCKED_TO_BE_OFF_SILENT)
        capv_lib.capvput(motor + '-PwrAuto', 0)
        time.sleep(1.0)

        capv_lib.capvput(motor + '.CNEN', 1, wait=True)
        time.sleep(4.0)
        mstaErr = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
        print('%s Error mstaErr=%s' % (tc_no, lib.getMSTAtext(mstaErr)))
        capv_lib.capvput(motor + '-ErrRst',1)

        setValueOnSimulator(self, motor, tc_no, "bAmplifierLockedToBeOff", 0)

        mstaOKagain = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
        bError   = capv_lib.capvget(motor + '-Err', use_monitor=False)
        nErrorId = capv_lib.capvget(motor + '-ErrId', use_monitor=False)
        print('%s Clean lib.MSTA_BIT_PROBLEM=%x mstaOKagain=%s bError=%d nErrorId=%d' % (tc_no, lib.MSTA_BIT_PROBLEM, lib.getMSTAtext(mstaOKagain), bError, nErrorId))

        capv_lib.capvput(motor + '.CNEN', self.saved_CNEN)
        capv_lib.capvput(motor + '-PwrAuto', self.saved_PwrAuto)

        self.assertNotEqual(0, mstaErr & lib.MSTA_BIT_PROBLEM, 'Error MSTA.Problem should be set)')
        self.assertEqual(0, mstaErr & lib.MSTA_BIT_SLIP_STALL, 'Error MSTA.Slip stall Error should not be set)')
        self.assertEqual(0, mstaErr & lib.MSTA_BIT_MOVING,     'Error MSTA.Moving)')

        self.assertEqual(0, mstaOKagain & lib.MSTA_BIT_MOVING,  'Clean MSTA.Moving)')
        self.assertEqual(0, bError,   'bError')
        self.assertEqual(0, nErrorId, 'nErrorId')
コード例 #6
0
    def test_TC_2402(self):
        motor = self.motor
        tc_no = "2402-JOGF_stopped"
        print('%s' % tc_no)

        if (self.msta & lib.MSTA_BIT_HOMED):
            capv_lib.capvput(motor + '-DbgStrToLOG', "Start " + tc_no[0:20])
            capv_lib.capvput(motor + '.DLY', 0)
            destination = self.per10_UserPosition
            done = lib.moveWait(motor, tc_no, destination)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per10_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            capv_lib.capvput(motor + '.JOGF', 1)
            ret2 = lib.waitForStart(motor, tc_no, 2.0)

            time.sleep(1)
            capv_lib.capvput(motor + '-Stop', 1)
            ret3 = lib.waitForStop(motor, tc_no, 2.0)

            val = capv_lib.capvget(motor + '.VAL')

            try:
                res4 = lib.verifyPosition(motor, val)
            except:
                e = sys.exc_info()
                print(str(e))
                res4 = globals.FAIL

            capv_lib.capvput(motor + '.DLY', self.saved_DLY)
            capv_lib.capvput(motor + '-DbgStrToLOG', "End " + tc_no[0:20])

            self.assertEqual(1, done, 'moveWait should return done')
            self.assertEqual(res4, globals.SUCCESS, 'VAL synched with RBV')
コード例 #7
0
    def setSoftLimitsOff(self, motor):
        """
        Switch off the soft limits
        """
        # switch off the controller soft limits
        try:
            capv_lib.capvput(motor + '-CfgDHLM-En', 0, wait=True, timeout=2)
            capv_lib.capvput(motor + '-CfgDLLM-En', 0, wait=True, timeout=2)
        finally:
            oldRBV = capv_lib.capvget(motor + '.RBV')

        wait_for_done = 1.0
        while wait_for_done > 0:
            if oldRBV > 0:
                capv_lib.capvput(motor + '.LLM', 0.0)
                capv_lib.capvput(motor + '.HLM', 0.0)
            else:
                capv_lib.capvput(motor + '.HLM', 0.0)
                capv_lib.capvput(motor + '.LLM', 0.0)

            llm = capv_lib.capvget(motor + '.LLM', use_monitor=False)
            hlm = capv_lib.capvget(motor + '.HLM', use_monitor=False)
            print('%s: setSoftLimitsOff llm=%f hlm=%f' % (motor, llm, hlm))
            if llm == 0.0 and hlm == 0.0:
                return
            time.sleep(polltime)
            wait_for_done -= polltime
コード例 #8
0
def do_220_autopower(self, motor, tc_no, autopower):
    lib.setCNENandWait(motor, tc_no, 0)
    capv_lib.capvput(motor + '-PwrAuto',
                     autopower,
                     wait=True,
                     timeout=globals.TIMEOUT)
    capv_lib.capvput(motor + '-PwrOnDly',
                     PwrOnDly,
                     wait=True,
                     timeout=globals.TIMEOUT)
    capv_lib.capvput(motor + '-PwrOffDly',
                     PwrOffDly,
                     wait=True,
                     timeout=globals.TIMEOUT)
    print('%s Enable move to LLM +10' % tc_no)
    res1 = lib.move(motor, self.saved_LLM + 10 + 2 * autopower,
                    globals.TIMEOUT)

    #Make sure drive is still enabled
    power1 = capv_lib.capvget(motor + '.CNEN', use_monitor=False)
    print('%s Check drive is still enabled power1=%d' % (tc_no, power1))

    time.sleep(PwrOnDly + PwrOffDly + 2.0)
    power2 = capv_lib.capvget(motor + '.CNEN', use_monitor=False)
    print('%s Wait 8s and check drive is now disabled power2=%d' %
          (tc_no, power2))
    restorePwrSettings(self, motor, tc_no, self.saved_PwrAuto,
                       self.saved_PwrOnDly, self.saved_PwrOffDly)
    assert (res1 == 0)
    assert (power1 == 1)
    assert (power2 == 0)
コード例 #9
0
    def test_TC_242(self):
        motor = self.motor
        tc_no = "TC-242-JOGF_stopped"
        print('%s' % tc_no)

        if (self.msta & lib.MSTA_BIT_HOMED):
            capv_lib.capvput(motor + '.DLY', 0)
            destination = self.per10_UserPosition
            res1 = lib.move(motor, destination, 60)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per10_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            capv_lib.capvput(motor + '.JOGF', 1)
            ret2 = lib.waitForStart(motor, tc_no, 2.0)

            time.sleep(1)
            capv_lib.capvput(motor + '-Stop', 1)
            ret3 = lib.waitForStop(motor, tc_no, 2.0)

            val = capv_lib.capvget(motor + '.VAL')

            try:
                res4 = lib.verifyPosition(motor, val)
            except:
                e = sys.exc_info()
                print(str(e))
                res4 = globals.FAIL

            capv_lib.capvput(motor + '.DLY', self.saved_DLY)

            self.assertEqual(res1, globals.SUCCESS, 'move returned SUCCESS')
            self.assertEqual(res4, globals.SUCCESS, 'VAL synched with RBV')
コード例 #10
0
    def test_TC_1318(self):
        motor = self.motor
        if (self.msta & lib.MSTA_BIT_HOMED):
            tc_no = "TC-1315-low-soft-limit JOGF DIR"
            print('%s' % tc_no)
            saved_DIR = capv_lib.capvget(motor + '.DIR')
            saved_FOFF = capv_lib.capvget(motor + '.FOFF')
            capv_lib.capvput(motor + '.FOFF', 1)
            capv_lib.capvput(motor + '.DIR', 1)
            done = lib.jogDirection(motor, tc_no, 1)

            lvio = int(capv_lib.capvget(motor + '.LVIO'))
            msta = int(capv_lib.capvget(motor + '.MSTA'))

            capv_lib.capvput(motor + '.DIR', saved_DIR)
            capv_lib.capvput(motor + '.FOFF', saved_FOFF)

            self.assertEqual(True, done,
                             'done should be True after jogDirection')
            self.assertEqual(0, msta & lib.MSTA_BIT_PROBLEM,
                             'No Error MSTA.Problem JOGF DIR')
            self.assertEqual(0, msta & lib.MSTA_BIT_MINUS_LS,
                             'Minus hard limit not reached JOGF DIR')
            self.assertEqual(0, msta & lib.MSTA_BIT_PLUS_LS,
                             'Plus hard limit not reached JOGR DIR')
コード例 #11
0
    def initializeMotorRecordSimulatorAxis(self, motor, tc_no):

        self.initializeMotorRecordOneField(motor, tc_no, '.VMAX', 50.0)
        self.initializeMotorRecordOneField(motor, tc_no, '.VELO', 20.0)
        self.initializeMotorRecordOneField(motor, tc_no, '.ACCL', 5.0)
        self.initializeMotorRecordOneField(motor, tc_no, '.JVEL', 5.0)
        self.initializeMotorRecordOneField(motor, tc_no, '.JAR', 20.0)

        self.initializeMotorRecordOneField(motor, tc_no, '.RDBD', 0.1)
        #self.initializeMotorRecordOneField(motor, tc_no, '.SPDB', 0.1)
        self.initializeMotorRecordOneField(motor, tc_no, '.BDST', 0.0)

        # If there are usful values in the controller, use them
        cfgDHLM = capv_lib.capvget(motor + '-CfgDHLM')
        cfgDLLM = capv_lib.capvget(motor + '-CfgDLLM')
        if (cfgDHLM == None or cfgDLLM == None or cfgDHLM <= cfgDLLM):
            cfgDHLM = 53.0
            cfgDLLM = -54.0
            self.setSoftLimitsOff(motor)
            self.initializeMotorRecordOneField(motor, tc_no, '-CfgDHLM',
                                               cfgDHLM)
            self.initializeMotorRecordOneField(motor, tc_no, '-CfgDLLM',
                                               cfgDLLM)
            self.initializeMotorRecordOneField(motor, tc_no, '-CfgDHLM-En', 1)
            self.initializeMotorRecordOneField(motor, tc_no, '-CfgDLLM-En', 1)
            self.initializeMotorRecordOneField(motor, tc_no, '.DHLM', cfgDHLM)
            self.initializeMotorRecordOneField(motor, tc_no, '.DLLM', cfgDLLM)
コード例 #12
0
def checkForEmergenyStop(self, motor, tc_no, wait, direction, oldRBV, TweakValue):
    outOfRange = 0
    lls = 0
    hls = 0
    outOfRange = 0
    rbv = capv_lib.capvget(motor + '.RBV', use_monitor=False)
    msta = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
    dmov = int(capv_lib.capvget(motor + '.DMOV', use_monitor=False))
    movn = int(capv_lib.capvget(motor + '.MOVN', use_monitor=False))
    if (rbv - oldRBV) > 2 * TweakValue:
        outOfRange = 1
    if (oldRBV -rbv) > 2 * TweakValue:
        outOfRange = -1
    if (msta & lib.MSTA_BIT_MINUS_LS):
        lls = 1
    if (msta & lib.MSTA_BIT_PLUS_LS):
        hls = 1

    print('%s:%d wait=%f dmov=%d movn=%d direction=%d lls=%d hls=%d OOR=%d oldRBV=%f rbv=%f' % \
        (tc_no, lineno(), wait, dmov, movn, direction, lls, hls, outOfRange, oldRBV, rbv))
    if ((hls and (direction > 0)) or
        (lls and (direction <= 0)) or
        outOfRange != 0):
        print('%s:%d  STOP=1 CNEN=0 Emergency stop' % (tc_no, lineno()))
        capv_lib.capvput(motor + '.STOP', 1)
        capv_lib.capvput(motor + '.CNEN', 0)

    return (lls, hls, movn, dmov, outOfRange)
コード例 #13
0
    def test_TC_1315(self):
        motor = self.motor
        if (self.msta & lib.MSTA_BIT_HOMED):
            tc_no = "TC-1315-low-soft-limit JOGR"
            print('%s' % tc_no)
            capv_lib.capvput(motor + '.DLY', 0.0)
            done = lib.jogDirection(motor, tc_no, 0)
            lvio = int(capv_lib.capvget(motor + '.LVIO'))
            msta = int(capv_lib.capvget(motor + '.MSTA'))
            miss = int(capv_lib.capvget(motor + '.MISS'))

            capv_lib.capvput(motor + '.DLY', self.saved_DLY)
            capv_lib.capvput(motor + '.JOGF', 0)
            resW = lib.waitForMipZero(motor, tc_no, self.saved_DLY)
            self.assertEqual(True, done,
                             'ndly JOGF should be done after jogDirection')
            self.assertEqual(0, msta & lib.MSTA_BIT_PROBLEM,
                             'ndly JOGF should not give MSTA.Problem')
            self.assertEqual(0, msta & lib.MSTA_BIT_MINUS_LS,
                             'ndly JOGF should not reach LLS')
            self.assertEqual(0, msta & lib.MSTA_BIT_PLUS_LS,
                             'ndly JOGF should not reach HLS')
            self.assertEqual(0, miss, 'ndly JOGF should not have MISS set')
            self.assertEqual(1, resW, 'ndly JOGF should have MIP = 0')
            self.assertEqual(1, lvio, 'ndly JOGF should have LVIO set')
コード例 #14
0
class Test(unittest.TestCase):
    motor = os.getenv("TESTEDMOTORAXIS")
    capv_lib.capvput(motor + '-DbgStrToLOG',
                     "Start " + os.path.basename(__file__)[0:20])

    hlm = capv_lib.capvget(motor + '.HLM')
    llm = capv_lib.capvget(motor + '.LLM')
    per10_UserPosition = round((9 * llm + 1 * hlm) / 10)

    msta = int(capv_lib.capvget(motor + '.MSTA'))

    print('llm=%f hlm=%f' % (llm, hlm))

    # Assert that motor is homed
    def test_TC_1601(self):
        motor = self.motor
        tc_no = "TC-1601"
        if not (self.msta & lib.MSTA_BIT_HOMED):
            self.assertNotEqual(0, self.msta & lib.MSTA_BIT_HOMED,
                                'MSTA.homed (Axis is not homed)')

    # per10 UserPosition
    def test_TC_1602(self):
        motor = self.motor
        if (self.msta & lib.MSTA_BIT_HOMED):
            tc_no = "TC-1602-10-percent-UserPosition"
            print('%s' % tc_no)
            done = lib.moveWait(motor, tc_no, self.per10_UserPosition)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f jog_start_pos=%f done=%s' %
                  (tc_no, UserPosition, self.per10_UserPosition, done))
            self.assertEqual(1, done, 'moveWait should return done')

    # stress test; start and stop the motor quickly..
    def test_TC_1603(self):
        motor = self.motor
        tc_no = "TC-1603"

        msta = int(capv_lib.capvget(motor + '.MSTA'))
        nErrorId = capv_lib.capvget(motor + '-ErrId')
        for i in range(1, 10):
            if not (msta & lib.MSTA_BIT_PROBLEM):
                res = capv_lib.capvput(motor + '-MoveAbs',
                                       self.per10_UserPosition + i * 10)
                time.sleep(0.01)
                res2 = capv_lib.capvput(motor + '.STOP', 1)
                time.sleep(0.01)
                msta = int(capv_lib.capvget(motor + '.MSTA'))
                nErrorId = capv_lib.capvget(motor + '-ErrId')
                print('%s i=%d nErrorId=%x msta=%s' %
                      (tc_no, i, nErrorId, lib.getMSTAtext(msta)))

        if (msta & lib.MSTA_BIT_PROBLEM):
            capv_lib.capvput(motor + '-ErrRst', 1)

        self.assertEqual(0, nErrorId, 'nErrorId must be 0')
        self.assertEqual(0, msta & lib.MSTA_BIT_PROBLEM,
                         'Problem bit must not be set')
コード例 #15
0
class Test(unittest.TestCase):
    motor = os.getenv("TESTEDMOTORAXIS")
    capv_lib.capvput(motor + '-DbgStrToLOG',
                     "Start " + os.path.basename(__file__)[0:20])
    saved_DLY = capv_lib.capvget(motor + '.DLY')
    msta = int(capv_lib.capvget(motor + '.MSTA'))

    hlm = capv_lib.capvget(motor + '.HLM')
    llm = capv_lib.capvget(motor + '.LLM')
    per10_UserPosition = round((9 * llm + 1 * hlm) / 10)
    per90_UserPosition = round((1 * llm + 9 * hlm) / 10)

    # Assert that motor is homed
    def test_TC_2401(self):
        motor = self.motor
        tc_no = "2401"

        if not (self.msta & lib.MSTA_BIT_HOMED):
            self.assertNotEqual(0, self.msta & lib.MSTA_BIT_HOMED,
                                'MSTA.homed (Axis is not homed)')

    # Jog, wait for start, stop behind MR
    def test_TC_2402(self):
        motor = self.motor
        tc_no = "2402-JOGF_stopped"
        print('%s' % tc_no)

        if (self.msta & lib.MSTA_BIT_HOMED):
            capv_lib.capvput(motor + '-DbgStrToLOG', "Start " + tc_no[0:20])
            capv_lib.capvput(motor + '.DLY', 0)
            destination = self.per10_UserPosition
            done = lib.moveWait(motor, tc_no, destination)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per10_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            capv_lib.capvput(motor + '.JOGF', 1)
            ret2 = lib.waitForStart(motor, tc_no, 2.0)

            time.sleep(1)
            capv_lib.capvput(motor + '-Stop', 1)
            ret3 = lib.waitForStop(motor, tc_no, 2.0)

            val = capv_lib.capvget(motor + '.VAL')

            try:
                res4 = lib.verifyPosition(motor, val)
            except:
                e = sys.exc_info()
                print(str(e))
                res4 = globals.FAIL

            capv_lib.capvput(motor + '.DLY', self.saved_DLY)
            capv_lib.capvput(motor + '-DbgStrToLOG', "End " + tc_no[0:20])

            self.assertEqual(1, done, 'moveWait should return done')
            self.assertEqual(res4, globals.SUCCESS, 'VAL synched with RBV')
コード例 #16
0
    def test_TC_501(self):
        motor = str(self.motor)
        tc_no = "TC_501-10-percent-dialPosition"
        print('%s' % tc_no)
        saved_HLM = capv_lib.capvget(motor + '.HLM')
        saved_LLM = capv_lib.capvget(motor + '.LLM')

        destination = (1 * saved_HLM + 9 * saved_LLM) / 10
        done = lib.moveWait(motor, tc_no, destination)
        self.assertEqual(1, done, 'moveWait should return done')
コード例 #17
0
class Test(unittest.TestCase):
    motor = os.getenv("TESTEDMOTORAXIS")
    #capv_lib.capvput(motor + '-DbgStrToLOG', "Start " + os.path.basename(__file__))

    hlm = capv_lib.capvget(motor + '.HLM')
    llm = capv_lib.capvget(motor + '.LLM')
    velo = capv_lib.capvget(motor + '.VELO')
    vmax = capv_lib.capvget(motor + '.VMAX')
    if vmax == 0.0:
        vmax = velo * 100.0
    msta = int(capv_lib.capvget(motor + '.MSTA'))
    per10_UserPosition = round((9 * llm + 1 * hlm) / 10)
    per90_UserPosition = round((1 * llm + 9 * hlm) / 10)

    def test_TC_1400(self):
        motor = self.motor
        tc_no = "TC-1400"
        if not (self.msta & lib.MSTA_BIT_HOMED):
            self.assertNotEqual(0, self.msta & lib.MSTA_BIT_HOMED,
                                'MSTA.homed (Axis is not homed)')

    def test_TC_1401(self):
        motor = self.motor
        tc_no = "TC-1401"
        motorPositionTC(self, motor, tc_no, self.llm, self.velo)

    def test_TC_1402(self):
        motor = self.motor
        tc_no = "TC-1402"
        motorPositionTC(self, motor, tc_no, self.per10_UserPosition, self.velo)

    def test_TC_1403(self):
        motor = self.motor
        tc_no = "TC-1403"
        motorPositionTC(self, motor, tc_no, self.per90_UserPosition, self.velo)

    def test_TC_1404(self):
        motor = self.motor
        tc_no = "TC-1404"
        motorPositionTC(self, motor, tc_no, self.hlm, self.velo)

    def test_TC_1405(self):
        motor = self.motor
        tc_no = "TC-1405"
        motorPositionTC(self, motor, tc_no, self.per90_UserPosition, self.vmax)

    def test_TC_1406(self):
        motor = self.motor
        tc_no = "TC-1406"
        motorPositionTC(self, motor, tc_no, self.per10_UserPosition, self.vmax)

    def test_TC_1407(self):
        motor = self.motor
        tc_no = "TC-1407"
        motorPositionTC(self, motor, tc_no, self.llm, self.vmax)
コード例 #18
0
def waitForStart(self, motor, tc_no, wait_for, direction, oldRBV):
    TweakValue = capv_lib.capvget(motor + '.TWV')
    while wait_for > 0:
        wait_for -= polltime
        (lls, hls, movn, dmov, outOfRange) = checkForEmergenyStop(
            self, motor, tc_no + 'strt', wait_for, direction, oldRBV, TweakValue)
        rbv = capv_lib.capvget(motor + '.RBV')
        if movn and not dmov:
            return True
        time.sleep(polltime)
        wait_for -= polltime
    return False
コード例 #19
0
    def test_TC_2002(self):
        motor = self.motor
        tc_no = "TC-2002-JOG-_Enable"
        capv_lib.capvput(motor + '-PwrAuto', 0)
        capv_lib.capvput(motor + '.CNEN', 0)
        lib.waitForPowerOff(motor, tc_no, 8.0)
        capv_lib.capvput(motor + '.JOGF', 1)

        ret_1 = lib.jogDirection(motor, tc_no, 1)
        msta_1 = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
        bError_2   = capv_lib.capvget(motor + '-Err', use_monitor=False)
        nErrorId_2 = capv_lib.capvget(motor + '-ErrId', use_monitor=False)
        print('%s Error bError_2=%d nErrorId_2=%d' % (tc_no, bError_2, nErrorId_2))

        capv_lib.capvput(motor + '-ErrRst',1)

        msta_3 = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
        bError_3   = capv_lib.capvget(motor + '-Err', use_monitor=False)
        nErrorId_3 = capv_lib.capvget(motor + '-ErrId', use_monitor=False)
        print('%s Clean lib.MSTA_BIT_PROBLEM=%x msta_3=%x bError_3=%d nErrorId=%d' % (tc_no, lib.MSTA_BIT_PROBLEM, msta_3, bError_3, nErrorId_3))

        # Loop until moving has stopped and error has been reseted
        counter = 7
        msta = msta_3
        nErrorId = nErrorId_3
        bError = bError_3
        while (msta & lib.MSTA_BIT_MOVING or bError != 0 or nErrorId != 0):
            time.sleep(polltime)
            print('%s sleep counter = %d' % (tc_no, counter))
            msta = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
            bError   = capv_lib.capvget(motor + '-Err', use_monitor=False)
            nErrorId = capv_lib.capvget(motor + '-ErrId', use_monitor=False)
            counter = counter - 1
            if counter == 0:
                break
        # Restore the values we had before this test started
        capv_lib.capvput(motor + '.CNEN', self.saved_CNEN)
        if self.saved_CNEN:
            lib.waitForPowerOn(motor, tc_no + "restore", 8.0)
        else:
            lib.waitForPowerOff(motor, tc_no+ "restore", 3.0)

        capv_lib.capvput(motor + '-PwrAuto', self.saved_PwrAuto)

        # Run all the asserts after we have restored the original state
        self.assertEqual(True, ret_1, 'waitForStop return True')

        print('%s Error msta_1=%s' % (tc_no, lib.getMSTAtext(msta_1)))
        self.assertNotEqual(0, msta_1 & lib.MSTA_BIT_PROBLEM, 'Error MSTA.Problem should be set)')
        self.assertEqual(0, msta_1 & lib.MSTA_BIT_SLIP_STALL, 'Error MSTA.Slip stall Error should not be set)')
        self.assertEqual(0, msta_1 & lib.MSTA_BIT_MOVING,     'Error MSTA.Moving)')

        self.assertNotEqual(0, bError_2,   'bError')
        self.assertNotEqual(0, nErrorId_2, 'nErrorId')

        self.assertEqual(0, msta & lib.MSTA_BIT_MOVING,  'Clean MSTA.Moving)')
        self.assertEqual(0, bError,   'bError')
        self.assertEqual(0, nErrorId, 'nErrorId')
コード例 #20
0
 def waitForStop(self, motor, tc_no, wait_for_stop):
     while wait_for_stop > 0:
         wait_for_stop -= polltime
         dmov = int(capv_lib.capvget(motor + '.DMOV', use_monitor=False))
         movn = int(capv_lib.capvget(motor + '.MOVN', use_monitor=False))
         rbv = capv_lib.capvget(motor + '.RBV', use_monitor=False)
         print('%s: wait_for_stop=%f dmov=%d movn=%d rbv=%f' %
               (tc_no, wait_for_stop, dmov, movn, rbv))
         if not movn and dmov:
             return True
         time.sleep(polltime)
         wait_for_stop -= polltime
     return False
コード例 #21
0
    def test_TC_1322(self):
        motor = self.motor
        if (self.msta & lib.MSTA_BIT_HOMED):
            tc_no = "TC-1322-low-limit-switch"
            print('%s' % tc_no)
            old_high_limit = capv_lib.capvget(motor + '.HLM')
            old_low_limit = capv_lib.capvget(motor + '.LLM')
            rdbd  = capv_lib.capvget(motor + '.RDBD')
            capv_lib.capvput(motor + '.STOP', 1)
            #Go away from limit switch
            done = lib.moveWait(motor, tc_no, self.jog_start_pos)
            destination = capv_lib.capvget(motor + '.HLM')
            rbv = capv_lib.capvget(motor + '.RBV')
            jvel = capv_lib.capvget(motor + '.JVEL')
            timeout = lib.calcTimeOut(motor, destination, jvel) * 2

            lib.setSoftLimitsOff(motor)

            done1 = lib.jogDirection(motor, tc_no, 0)
            # Get values, check them later
            lvio = int(capv_lib.capvget(motor + '.LVIO'))
            mstaE = int(capv_lib.capvget(motor + '.MSTA'))
            #Go away from limit switch
            done2 = lib.moveWait(motor, tc_no, old_low_limit + rdbd)
            print('%s msta=%x lvio=%d' % (tc_no, mstaE, lvio))

            lib.setSoftLimitsOn(motor, old_low_limit, old_high_limit)

            self.assertEqual(0, mstaE & lib.MSTA_BIT_PROBLEM,     'MSTA.Problem should not be set')
            self.assertNotEqual(0, mstaE & lib.MSTA_BIT_MINUS_LS, 'LLS should be active')
            self.assertEqual(0, mstaE & lib.MSTA_BIT_PLUS_LS,     'HLS should not be active')
            self.assertEqual(1, done1,                            'moveWait1 should return done')
            self.assertEqual(1, done2,                            'moveWait2 should return done')
コード例 #22
0
def setLimit(tself, motor, tc_no, field, value, expDHLM, expDLLM, expHLM, expLLM, expM3rhlm, expM3rllm):
    oldDHLM = capv_lib.capvget(motor + '.DHLM', use_monitor=False)
    oldDLLM = capv_lib.capvget(motor + '.DLLM', use_monitor=False)

    capv_lib.capvput(motor + '.DHLM', oldDHLM)
    capv_lib.capvput(motor + '.DLLM', oldDLLM)
    capv_lib.capvput(motor + '.' + field, value)

    time.sleep(0.5)

    actDHLM = capv_lib.capvget(motor + '.DHLM', use_monitor=False)
    actDLLM = capv_lib.capvget(motor + '.DLLM', use_monitor=False)
    actHLM = capv_lib.capvget(motor + '.HLM', use_monitor=False)
    actLLM = capv_lib.capvget(motor + '.LLM', use_monitor=False)

    actM3rhlm = capv_lib.capvget(motor + '-M3RHLM', use_monitor=False)
    actM3rllm = capv_lib.capvget(motor + '-M3RLLM', use_monitor=False)
    print('%s expDHLM=%g expDLLM=%g expHLM=%g expLLM=%g expM3rhlm=%g expM3rllm=%g' % \
        (tc_no, expDHLM, expDLLM, expHLM, expLLM, expM3rhlm, expM3rllm))
    print('%s actDHLM=%g actDLLM=%g actHLM=%g actLLM=%g actM3rhlm=%g actM3rllm=%g' % \
        (tc_no, actDHLM, actDLLM, actHLM, actLLM, actM3rhlm, actM3rllm))
    okDHLM   = lib.calcAlmostEqual(motor, tc_no, expDHLM,  actDHLM, maxdelta)
    okDLLM   = lib.calcAlmostEqual(motor, tc_no, expDLLM,  actDLLM, maxdelta)
    okHLM    = lib.calcAlmostEqual(motor, tc_no, expHLM,    actHLM, maxdelta)
    okLLM    = lib.calcAlmostEqual(motor, tc_no, expLLM,    actLLM, maxdelta)
    okM3rhlm = lib.calcAlmostEqual(motor, tc_no, expM3rhlm, actM3rhlm, maxdelta)
    okM3rllm = lib.calcAlmostEqual(motor, tc_no, expM3rllm, actM3rllm, maxdelta)

    assert (okDHLM and okDLLM and okHLM and okLLM and okM3rhlm and okM3rllm)
コード例 #23
0
    def test_TC_501(self):
        motor = str(self.motor)
        tc_no = "TC_501-10-percent-dialPosition"
        print('%s' % tc_no)
        saved_HLM = capv_lib.capvget(motor + '.HLM')
        saved_LLM = capv_lib.capvget(motor + '.LLM')

        destination = (1 * saved_HLM + 9 * saved_LLM) / 10

        capv_lib.capvput(motor + '.VAL', destination, wait=True)
        rbv = capv_lib.capvget(motor + '.RBV')
        inpos = lib.calcAlmostEqual(motor, tc_no, destination, rbv, 2)
        print('%s destination=%f RBV=%f inpos=%d' %
              (tc_no, destination, rbv, inpos))
        assert inpos
コード例 #24
0
class Test(unittest.TestCase):
    motor = os.getenv("TESTEDMOTORAXIS")
    capv_lib.capvput(motor + '-DbgStrToLOG',
                     "Start " + os.path.basename(__file__)[0:20])
    saved_CNEN = capv_lib.capvget(motor + '.CNEN')
    saved_PwrAuto = capv_lib.capvget(motor + '-PwrAuto')

    # Jog, wait for start, power off, check error, reset error
    def test_TC_212(self):
        motor = self.motor
        tc_no = "TC-212-EnabledFailed"

        capv_lib.capvput(motor + '.CNEN', 0, wait=True)
        setValueOnSimulator(self, motor, tc_no, "bAmplifierLockedToBeOff",
                            AMPLIFIER_LOCKED_TO_BE_OFF_SILENT)
        capv_lib.capvput(motor + '-PwrAuto', 0)
        time.sleep(1.0)

        capv_lib.capvput(motor + '.CNEN', 1, wait=True)
        time.sleep(4.0)
        mstaErr = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
        print('%s Error mstaErr=%s' % (tc_no, lib.getMSTAtext(mstaErr)))
        capv_lib.capvput(motor + '-ErrRst', 1)

        setValueOnSimulator(self, motor, tc_no, "bAmplifierLockedToBeOff", 0)

        mstaOKagain = int(capv_lib.capvget(motor + '.MSTA', use_monitor=False))
        bError = capv_lib.capvget(motor + '-Err', use_monitor=False)
        nErrorId = capv_lib.capvget(motor + '-ErrId', use_monitor=False)
        print(
            '%s Clean lib.MSTA_BIT_PROBLEM=%x mstaOKagain=%s bError=%d nErrorId=%d'
            % (tc_no, lib.MSTA_BIT_PROBLEM, lib.getMSTAtext(mstaOKagain),
               bError, nErrorId))

        capv_lib.capvput(motor + '.CNEN', self.saved_CNEN)
        capv_lib.capvput(motor + '-PwrAuto', self.saved_PwrAuto)

        self.assertNotEqual(0, mstaErr & lib.MSTA_BIT_PROBLEM,
                            'Error MSTA.Problem should be set)')
        self.assertEqual(0, mstaErr & lib.MSTA_BIT_SLIP_STALL,
                         'Error MSTA.Slip stall Error should not be set)')
        self.assertEqual(0, mstaErr & lib.MSTA_BIT_MOVING,
                         'Error MSTA.Moving)')

        self.assertEqual(0, mstaOKagain & lib.MSTA_BIT_MOVING,
                         'Clean MSTA.Moving)')
        self.assertEqual(0, bError, 'bError')
        self.assertEqual(0, nErrorId, 'nErrorId')
コード例 #25
0
class XTest(unittest.TestCase):
    motor = os.getenv("TESTEDMOTORAXIS")
    capv_lib.capvput(motor + '-DbgStrToLOG',
                     "Start " + os.path.basename(__file__)[0:20])
    motor2 = "IOC:m2"
    hlm = capv_lib.capvget(motor + '.HLM')
    llm = capv_lib.capvget(motor + '.LLM')
    msta = int(capv_lib.capvget(motor + '.MSTA'))

    per10_UserPosition = round((9 * llm + 1 * hlm) / 10)
    per90_UserPosition = round((1 * llm + 9 * hlm) / 10)

    # Assert that motor is homed
    def Xtest_TC_231(self):
        motor = self.motor
        tc_no = "TC-231"
        if not (self.msta & lib.MSTA_BIT_HOMED):
            self.assertNotEqual(0, self.msta & lib.MSTA_BIT_HOMED,
                                'MSTA.homed (Axis is not homed)')

    # Jog, wait for start, power off, check error, reset error
    def Xtest_TC_232(self):
        motor = self.motor
        motor2 = self.motor2
        tc_no = "TC-232-NetYetStarted"
        print('%s' % tc_no)

        if (self.msta & lib.MSTA_BIT_HOMED):
            setValueOnSimulator(self, motor2, tc_no, "usleep", 1700000)

            destination = self.per90_UserPosition
            res1 = lib.move(motor, destination, 60)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per90_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            destination = self.per10_UserPosition
            res2 = lib.move(motor, destination, 60)
            UserPosition = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s postion=%f per10_UserPosition=%f' %
                  (tc_no, UserPosition, self.per90_UserPosition))

            setValueOnSimulator(self, motor2, tc_no, "usleep", 0)

            self.assertNotEqual(res1 == globals.SUCCESS,
                                'move returned SUCCESS')
            self.assertNotEqual(res2 == globals.SUCCESS,
                                'move returned SUCCESS')
コード例 #26
0
 def test_TC_403(self):
     tc_no = "TC-403-20-percent"
     print('%s' % tc_no)
     motor = self.motor
     if (self.msta & lib.MSTA_BIT_HOMED):
         saved_ACCL = float(capv_lib.capvget(motor + '.ACCL'))
         saved_VELO = float(capv_lib.capvget(motor + '.VELO'))
         used_ACCL = saved_ACCL + 1.0 # Make sure we have an acceleration != 0
         capv_lib.capvput(motor + '.ACCL', used_ACCL)
         done = lib.moveWait(motor, tc_no, self.per20_UserPosition)
         resacc = self.getAcceleration(motor, tc_no)
         expacc = saved_VELO / used_ACCL
         capv_lib.capvput(motor + '.ACCL', saved_ACCL)
         print('%s ACCL=%f expacc=%f resacc=%f' % (tc_no,used_ACCL,expacc,resacc))
         assert lib.calcAlmostEqual(self.motor, tc_no, expacc, resacc, 2)
         self.assertEqual(1, done, 'moveWait should return done')
コード例 #27
0
    def moveWait(self, motor, tc_no, destination):
        timeout = 30
        acceleration = capv_lib.capvget(motor + '.ACCL')
        velocity = capv_lib.capvget(motor + '.VELO')
        timeout += 2 * acceleration + 1.0
        if velocity > 0:
            distance = math.fabs(
                capv_lib.capvget(motor + '.RBV') - destination)
            timeout += distance / velocity

        capv_lib.capvput(motor + '.VAL', destination)
        success_or_failed = self.move(motor, destination, timeout)
        if (success_or_failed == self.globals.FAIL):
            return False
        else:
            return True
コード例 #28
0
    def setPosition(self, motor, position, timeout):
        """
        Set position on motor and check it worked ok.
        """

        _set = motor + ".SET"
        _rbv = motor + ".RBV"
        _dval = motor + ".DVAL"
        _off = motor + ".OFF"

        offset = capv_lib.capvget(_off)

        capv_lib.capvput(_set, 1, wait=True, timeout=timeout)
        capv_lib.capvput(_dval, position, wait=True, timeout=timeout)
        capv_lib.capvput(_off, offset, wait=True, timeout=timeout)
        capv_lib.capvput(_set, 0, wait=True, timeout=timeout)

        if (self.postMoveCheck(motor) != self.globals.SUCCESS):
            return self.globals.FAIL

        try:
            self.verifyPosition(motor, position + offset)
        except Exception as e:
            print(str(e))
            return self.globals.FAIL
コード例 #29
0
    def setSoftLimitsOn(self, motor, low_limit, high_limit):
        """
        Set the soft limits
        """
        # switch on the controller soft limits
        try:
            capv_lib.capvput(motor + '-CfgDHLM',
                             high_limit,
                             wait=True,
                             timeout=2)
            capv_lib.capvput(motor + '-CfgDLLM',
                             low_limit,
                             wait=True,
                             timeout=2)
            capv_lib.capvput(motor + '-CfgDHLM-En', 1, wait=True, timeout=2)
            capv_lib.capvput(motor + '-CfgDLLM-En', 1, wait=True, timeout=2)
        finally:
            oldRBV = capv_lib.capvget(motor + '.RBV')

        if oldRBV < 0:
            capv_lib.capvput(motor + '.LLM', low_limit)
            capv_lib.capvput(motor + '.HLM', high_limit)
        else:
            capv_lib.capvput(motor + '.HLM', high_limit)
            capv_lib.capvput(motor + '.LLM', low_limit)
コード例 #30
0
    def doSTUPandSYNC(self, motor, tc_no):
        stup = capv_lib.capvget(motor + '.STUP', use_monitor=False)
        while stup != 0:
            stup = capv_lib.capvget(motor + '.STUP', use_monitor=False)
            print('%s .STUP=%s' % (tc_no, stup))
            time.sleep(polltime)

        capv_lib.capvput(motor + '.STUP', 1)
        capv_lib.capvput(motor + '.SYNC', 1)
        rbv = capv_lib.capvget(motor + '.RBV', use_monitor=False)
        print('%s .RBV=%f .STUP=%s' % (tc_no, rbv, stup))
        while stup != 0:
            stup = capv_lib.capvget(motor + '.STUP', use_monitor=False)
            rbv = capv_lib.capvget(motor + '.RBV', use_monitor=False)
            print('%s .RBV=%f .STUP=%s' % (tc_no, rbv, stup))
            time.sleep(polltime)