示例#1
0
def hw_control_ramp_test(target=40, tol=5, slope=2):
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    print('system info')
    print(dc.get_chamber_info())
    print('')
    curt = dc.get_real_temperature()
    dc.set_setPoint(curt)
    if curt >= target:
        dc.set_gradient_down(slope)
    else:
        dc.set_gradient_up(slope)
    dc.set_setPoint(target)
    print('get setpoint: {}'.format(dc.get_setPoint()))
    print('')
    ctrl_var_info = dc.get_control_variables_info()
    print(ctrl_var_info)
    print('')
    data = []
    setpoints = []
    timeset = []
    slopes = []
    UL = target * (1 + tol / 100)
    LL = target * (1 - tol / 100)
    dc.set_manual_mode(True)
    init = time.time()
    while True:
        curt = (time.time() - init) / 60
        value = dc.get_real_temperature()
        setp = dc.get_real_control_variable_value()
        timeset.append(curt)
        data.append(value)
        setpoints.append(setp)

        try:
            slope = get_slope(timeset, data, last=20)
        except IndexError:
            slope = 0
        slopes.append(slope)
        print('target: {}'.format(target))
        print('current time: {} mins'.format(curt))
        print('current temp: {}'.format(value))
        print('get real setpoint: {}'.format(setp))
        print('slope: {}'.format(slope))
        print('')
        time.sleep(1)
        if value >= LL and value <= UL:
            print('reached target')
            break

    dc.set_manual_mode(False)
    dc.close()
    plotAll(timeset, data, setpoints, slopes)
示例#2
0
def queryInfo():
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    print('####### Control Variables ##########')
    ret = setCmd(dc, '11018', [])
    n = ret[1].decode('utf-8', 'ignore').strip()
    print('Number of control variables: {}'.format(n))
    ret = dc.get_control_variables_info()
    print('Content of control variables: {}'.format(ret))
    print('')
    print('####### Control Values ##########')
    ret = setCmd(dc, '13007', [])
    n = ret[1].decode('utf-8', 'ignore').strip()
    print('Number of control values: {}'.format(n))
    ret = dc.get_control_values_info()
    print('Content of control values: {}'.format(ret))
    print('')
    print('####### Measrued Values ##########')
    ret = setCmd(dc, '12012', [])
    n = ret[1].decode('utf-8', 'ignore').strip()
    print('Number of measured values: {}'.format(n))
    ret = dc.get_mear_values_info()
    print('Content of measured values: {}'.format(ret))
    print('')
    print('####### Digital output ##########')
    ret = setCmd(dc, '14007', [])
    n = ret[1].decode('utf-8', 'ignore').strip()
    print('Number of digital output: {}'.format(n))
    ret = dc.get_do_info()
    print('Content of digital output: {}'.format(ret))
    print('')
    print('####### Digital input ##########')
    ret = setCmd(dc, '15004', [])
    n = ret[1].decode('utf-8', 'ignore').strip()
    print('Number of digital input: {}'.format(n))
    ret = dc.get_di_info()
    print('Content of digital input: {}'.format(ret))
    print('')
    print('####### Messages ##########')
    ret = setCmd(dc, '17002', [])
    n = ret[1].decode('utf-8', 'ignore').strip()
    print('Number of message: {}'.format(n))
    ret = dc.get_msg_info()
    print('Content of message: {}'.format(ret))
    print('')

    dc.close()
    return ret
示例#3
0
def stable_test_mode_off(min=5):
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    print('system info')
    print(dc.get_chamber_info())
    print('')
    target = dc.get_real_temperature()
    dc.set_gradient_up(0)
    dc.set_gradient_down(0)
    dc.set_setPoint(target)
    print('get setpoint: {}'.format(dc.get_setPoint()))
    print('')
    ctrl_var_info = dc.get_control_variables_info()
    print(ctrl_var_info)
    print('')
    data = []
    setpoints = []
    timeset = []
    slopes = []
    dc.set_manual_mode(False)
    init = time.time()
    while True:
        curt = (time.time() - init) / 60
        value = dc.get_real_temperature()
        setp = dc.get_real_control_variable_value()
        timeset.append(curt)
        data.append(value)
        setpoints.append(setp)

        try:
            slope = get_slope(timeset, data, last=20)
        except IndexError:
            slope = 0
        slopes.append(slope)
        print('target: {}'.format(target))
        print('current time: {} mins'.format(curt))
        print('current temp: {}'.format(value))
        print('get real setpoint: {}'.format(setp))
        print('slope: {}'.format(slope))
        print('')
        time.sleep(1)
        if curt >= min:
            print('time up')
            break

    dc.set_manual_mode(False)
    dc.close()
    plotAll(timeset, data, setpoints, slopes)
示例#4
0
def get_control_vars():
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    ret = dc.get_control_variables_info()
    dc.close()
    return ret
示例#5
0
def cmd_test(cmdid, args):
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    ret = setCmd(dc, cmdid, args)
    dc.close()
    return ret
示例#6
0
def get_hum():
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    ret = dc.get_real_humidity()
    dc.close()
    return ret
示例#7
0
def get_temp():
    dc = DigiChamber(ip='169.254.206.212')
    dc.connect()
    ret = dc.get_real_temperature()
    dc.close()
    return ret