src/order2checker.py
def odrLevelingOhm(
        recipe: list,
        mcu: object,
        res: object,
        boxRes: list
    ) -> float:
    """
    Order Leveling Ohm to checker and Resistor

    Parameters
    ----------
        recipe: list
            0: LEVEL-(timing)-(mode)
            1: relay number
            2: dtc
        mcu: object
            comm2checker.Serial2Mcu
        res: object
            comm2resistor.Res
        boxRes:
            box's each SQ ohms

    Returns
    ----------
        receipt: float
            ohm at detected dtc
    """
    if res.statusRes==False:
        return 'error'
    # take in recipe
    timing = recipe[0][6:10]
    mode = recipe[0][11:]
    rNum = recipe[1]
    dtc = recipe[2]
    # take in initial ohm
    initOhm = INIT_OHM.copy()
    if os.path.exists(INI_FILE_PATH):
        with open(INI_FILE_PATH, 'rb') as ini:
            line = ini.readline().decode('utf-8')
            if line.split('=')[0] == mode:
                initOhm[mode] = float(line.split('=')[1].strip(' '))
    else:
        return 'error'
    # set relay
    if _setResMode(mode, mcu) == ba.negRes:
        return 'set res mode error'
    _ = odrRYON(['RYON', rNum], mcu)
    # main
    count = 0
    ohm = initOhm[mode]
    digit = int(math.log10(ohm))
    receipt = 0.0
    while count<50:
        _ = odrCAN(['CAN', 'DTCCLEAR'], mcu)
        # if initial, igoff and igon
        if timing == 'INIT':
            _ = odrIGOFF(['IGOFF',], mcu)
            _ = odrWAIT(['WAIT', 30], mcu)
            _ = odrIGON(['IGON',], mcu)
            _ = odrWAIT(['WAIT', 80], mcu)
        # set resistor
        res.setRes(ohm)
        # check dtc
        _ = odrWAIT(['WAIT', 25], mcu)
        dtcread = odrCAN(['CAN', 'DTCREAD'], mcu)
        if dtc in dtcread:
            # if detect dtc, down digit
            receipt = ohm
            if digit < -2:
                break
            else:
                if mode=='OPEN':
                    ohm = (ohm - 1 * (10**digit)) + 1 * (10**(digit-1))
                    digit -= 1
                else:
                    digit -= 1
                    ohm = (ohm + 9 * (10**digit))
        else:
            # if not detect dtc, down ohm of this digit
            ohm = (ohm - 1 * (10**digit)) if not mode == 'OPEN' else (ohm + 1 * (10**digit))
        # levelize
        if ohm <= 0:
            return 'no detected.'
        count += 1
    else:
        return 'timeout (over 50 times)'
    # undo relay
    _ = odrRYOFF(['RYOFF', rNum])
    _ = _setResMode('default', mcu)
    # dtc clear
    _ = odrCAN(['CAN', 'DTCCLEAR'], mcu)
    # return
    if mode=='OPEN' or mode=='SHORT':
        int_rNum = int(rNum, 16) - 8
        receipt = receipt + boxRes[int_rNum-1]
    return str(receipt)

    Order Leveling Ohm to checker and Resistor

    Parameters
    ----------
        recipe: list
            0: LEVEL-(timing)-(mode)
            1: relay number
            2: dtc
        mcu: object
            comm2checker.Serial2Mcu
        res: object
            comm2resistor.Res
        boxRes:
            box's each SQ ohms

    Returns
    ----------
        receipt: float
            ohm at detected dtc
    
Order Leveling Ohm to checker and Resistor
Parameters



Returns

float
ohm at detected dtc
Order Leveling Ohm to checker and Resistor Parameters Returns float ohm at detected dtc
def odrLevelingOhm(
        recipe: list,
        mcu: object,
        res: object,
        boxRes: list
    ) -> float:
    if res.statusRes==False:
        return 'error'
    timing = recipe[0][6:10]
    mode = recipe[0][11:]
    rNum = recipe[1]
    dtc = recipe[2]
    initOhm = INIT_OHM.copy()
    if os.path.exists(INI_FILE_PATH):
        with open(INI_FILE_PATH, 'rb') as ini:
            line = ini.readline().decode('utf-8')
            if line.split('=')[0] == mode:
                initOhm[mode] = float(line.split('=')[1].strip(' '))
    else:
        return 'error'
    if _setResMode(mode, mcu) == ba.negRes:
        return 'set res mode error'
    _ = odrRYON(['RYON', rNum], mcu)
    count = 0
    ohm = initOhm[mode]
    digit = int(math.log10(ohm))
    receipt = 0.0
    while count<50:
        _ = odrCAN(['CAN', 'DTCCLEAR'], mcu)
        if timing == 'INIT':
            _ = odrIGOFF(['IGOFF',], mcu)
            _ = odrWAIT(['WAIT', 30], mcu)
            _ = odrIGON(['IGON',], mcu)
            _ = odrWAIT(['WAIT', 80], mcu)
        res.setRes(ohm)
        _ = odrWAIT(['WAIT', 25], mcu)
        dtcread = odrCAN(['CAN', 'DTCREAD'], mcu)
        if dtc in dtcread:
            receipt = ohm
            if digit < -2:
                break
            else:
                if mode=='OPEN':
                    ohm = (ohm - 1 * (10**digit)) + 1 * (10**(digit-1))
                    digit -= 1
                else:
                    digit -= 1
                    ohm = (ohm + 9 * (10**digit))
        else:
            ohm = (ohm - 1 * (10**digit)) if not mode == 'OPEN' else (ohm + 1 * (10**digit))
        if ohm <= 0:
            return 'no detected.'
        count += 1
    else:
        return 'timeout (over 50 times)'
    _ = odrRYOFF(['RYOFF', rNum])
    _ = _setResMode('default', mcu)
    _ = odrCAN(['CAN', 'DTCCLEAR'], mcu)
    if mode=='OPEN' or mode=='SHORT':
        int_rNum = int(rNum, 16) - 8
        receipt = receipt + boxRes[int_rNum-1]
    return str(receipt)
def odrLevelingOhm ( recipe : list , mcu : object , res : object , boxRes : list ) -> float : if res . statusRes == False : return 'error' timing = recipe [ 0 ] [ 6 : 10 ] mode = recipe [ 0 ] [ 11 : ] rNum = recipe [ 1 ] dtc = recipe [ 2 ] initOhm = INIT_OHM . copy ( ) if os . path . exists ( INI_FILE_PATH ) : with open ( INI_FILE_PATH , 'rb' ) as ini : line = ini . readline ( ) . decode ( 'utf-8' ) if line . split ( '=' ) [ 0 ] == mode : initOhm [ mode ] = float ( line . split ( '=' ) [ 1 ] . strip ( ' ' ) ) else : return 'error' if _setResMode ( mode , mcu ) == ba . negRes : return 'set res mode error' _ = odrRYON ( [ 'RYON' , rNum ] , mcu ) count = 0 ohm = initOhm [ mode ] digit = int ( math . log10 ( ohm ) ) receipt = 0.0 while count < 50 : _ = odrCAN ( [ 'CAN' , 'DTCCLEAR' ] , mcu ) if timing == 'INIT' : _ = odrIGOFF ( [ 'IGOFF' , ] , mcu ) _ = odrWAIT ( [ 'WAIT' , 30 ] , mcu ) _ = odrIGON ( [ 'IGON' , ] , mcu ) _ = odrWAIT ( [ 'WAIT' , 80 ] , mcu ) res . setRes ( ohm ) _ = odrWAIT ( [ 'WAIT' , 25 ] , mcu ) dtcread = odrCAN ( [ 'CAN' , 'DTCREAD' ] , mcu ) if dtc in dtcread : receipt = ohm if digit < - 2 : break else : if mode == 'OPEN' : ohm = ( ohm - 1 * ( 10 ** digit ) ) + 1 * ( 10 ** ( digit - 1 ) ) digit -= 1 else : digit -= 1 ohm = ( ohm + 9 * ( 10 ** digit ) ) else : ohm = ( ohm - 1 * ( 10 ** digit ) ) if not mode == 'OPEN' else ( ohm + 1 * ( 10 ** digit ) ) if ohm <= 0 : return 'no detected.' count += 1 else : return 'timeout (over 50 times)' _ = odrRYOFF ( [ 'RYOFF' , rNum ] ) _ = _setResMode ( 'default' , mcu ) _ = odrCAN ( [ 'CAN' , 'DTCCLEAR' ] , mcu ) if mode == 'OPEN' or mode == 'SHORT' : int_rNum = int ( rNum , 16 ) - 8 receipt = receipt + boxRes [ int_rNum - 1 ] return str ( receipt )
Order Leveling Ohm to checker and Resistor
Parameters
Order Leveling Ohm to checker and Resistor Parameters
"""
    Order Leveling Ohm to checker and Resistor

    Parameters
    ----------
        recipe: list
            0: LEVEL-(timing)-(mode)
            1: relay number
            2: dtc
        mcu: object
            comm2checker.Serial2Mcu
        res: object
            comm2resistor.Res
        boxRes:
            box's each SQ ohms

    Returns
    ----------
        receipt: float
            ohm at detected dtc
    """ # take in recipe # take in initial ohm # set relay # main # if initial, igoff and igon # set resistor # check dtc # if detect dtc, down digit # if not detect dtc, down ohm of this digit # levelize # undo relay # dtc clear # return
recipe
list
mcu
object
res
object
boxRes
list