From 644e8b698faf50dcc86d88834675d6adf1281b10 Mon Sep 17 00:00:00 2001 From: cygnushan Date: Tue, 7 Jun 2016 22:18:57 +0800 Subject: [PATCH] modify keithley2400 range paraments --- HMT_S48.py | 264 -------------------------------------------------- qmdz_const.py | 8 +- setup.py | 4 +- 3 files changed, 6 insertions(+), 270 deletions(-) delete mode 100644 HMT_S48.py diff --git a/HMT_S48.py b/HMT_S48.py deleted file mode 100644 index 6e7430d..0000000 --- a/HMT_S48.py +++ /dev/null @@ -1,264 +0,0 @@ -# -*- coding: utf-8 -*- -''' -Created on 2015-7-18 - -@author: Administrator -''' -import minimalmodbus -from mylog import logger -from init_op import read_config -from qmdz_const import SYS_CONF_PATH - -inst_addr = 1 -baud_rate = 9600 -frame_delay = 28*1000/9600.0 - -REG_CLOSE = 0 -REG_CONTROL = 1 -REG_CLEN = 2 -REG_STA = 3 -REG_AUTOZERO = 4 -REG_UNIT = 6 -REG_ALRAM = 7 -REG_DISPFLOW = 16 -REG_SETFLOW = 17 -REG_FLOW_RANGE = 48 -REG_OFFSET = 49 -REG_COEF = 50 -REG_ADDR = 51 -REG_BAUD = 53 -REG_ERR = 60 -REG_VER = 61 -REG_SN1 = 62 -REG_SN2 = 63 -ENABLE_PWD = 57 - -REG_DICT = { -0 :REG_CLOSE, -1 :REG_CONTROL, -2 :REG_CLEN, -3 :REG_STA, -4 :REG_AUTOZERO, -5 :REG_UNIT, -6 :REG_DISPFLOW, -7 :REG_SETFLOW, -8 :REG_FLOW_RANGE, -9 :REG_OFFSET -} - -BAUD = read_config(SYS_CONF_PATH, 'HMTS48', 'baud') - -class C_S48(): - - def __init__(self, port, addr): - - self.port = port - self.addr = int(addr) - minimalmodbus.BAUDRATE = BAUD - minimalmodbus.CLOSE_PORT_AFTER_EACH_CALL = True - - def comm_connect(self): - try: - self.S48 = minimalmodbus.Instrument(self.port,self.addr) - return True - except: - logger.error("HMT_S48 com port %s addr %s has already opened!" % (self.port,self.addr)) - return False - - def read_para(self,para_reg,dp_num=0): - result = self.comm_connect() - if result: - if para_reg <= 7: - para_value = self.S48.read_bit(para_reg, 1) - else: - para_value = self.S48.read_register(para_reg,dp_num) - self.comm_close() - return para_value - else: - return "NA" - - def write_para(self,para_reg,para_value,dp_num=0):#dp_num锛屽皬鏁扮偣浣嶆暟 - result = self.comm_connect() - if result: - if para_reg <= 7: - if para_value: - para_value = 1 # 开关量,只写0/1 - self.S48.write_bit(para_reg, para_value) - else: - self.S48.write_register(para_reg, para_value, dp_num) - self.comm_close() - - def set_flow(self,flow_value,dp_num=0):#dp_num锛屽皬鏁扮偣浣嶆暟 0x0FFF浠h〃婊″害4095 - - self.write_para(REG_SETFLOW, flow_value, dp_num) - - def read_setflow(self,dp_num=0): - - flow = self.read_para(REG_SETFLOW, dp_num) - return flow - - def read_dispflow(self,dp_num=0): - - flow = self.read_para(REG_DISPFLOW, dp_num) - return flow - - def read_range(self): - addr = self.read_para(REG_FLOW_RANGE) - return addr - - def set_valve_close(self): - try: - self.comm_connect() - self.S48.write_bit(0, 1, 5) - self.comm_close() - except: - self.comm_close() - logger.error("set_valve_close failed!") - - def set_valve_ctrl(self): - try: - self.comm_connect() - self.S48.write_bit(1, 1, 5) - self.comm_close() - except: - self.comm_close() - logger.error("set_valve_ctrl failed!") - - def set_valve_clen(self): - try: - self.comm_connect() - self.S48.write_bit(2, 1, 5) - self.comm_close() - except: - self.comm_close() - logger.error("set_valve_clen failed!") - - def set_sta_analog(self): - try: - self.comm_connect() - self.S48.write_bit(3, 0, 5) - self.comm_close() - except: - self.comm_close() - logger.error("set_sta_analog failed!") - - def set_sta_digital(self): - try: - self.comm_connect() - self.S48.write_bit(3, 1, 5) - self.comm_close() - except: - self.comm_close() - logger.error("set_sta_digital failed!") - - def set_autozero_on(self): - try: - self.comm_connect() - self.S48.write_bit(4,1,5) - self.comm_close() - except: - self.comm_close() - logger.error("set_autozero_on failed!") - - def set_autozero_off(self): - try: - self.comm_connect() - self.S48.write_bit(4,0,5) - self.comm_close() - except: - self.comm_close() - logger.error("set_autozero_off failed!") - - def read_valve_close(self): - try: - self.comm_connect() - state = self.S48.read_bit(0, 1) - self.comm_close() - return state - except: - logger.error("read_valve_close failed!") - self.comm_close() - return 0 - - def read_valve_ctrl(self): - try: - self.comm_connect() - state = self.S48.read_bit(1, 1) - self.comm_close() - return state - except: - logger.error("read_valve_ctrl failed!") - self.comm_close() - return 0 - - def read_valve_clen(self): - try: - self.comm_connect() - state = self.S48.read_bit(2, 1) - self.comm_close() - return state - except: - logger.error("read_valve_clen failed!") - self.comm_close() - return 0 - - def read_sta(self): - try: - self.comm_connect() - sta = self.S48.read_bit(3, 1) - self.comm_close() - return sta - except: - logger.error("read_sta failed!") - self.comm_close() - return 0 - - def read_autozero(self): - try: - self.comm_connect() - autozero = self.S48.read_bit(4, 1) - self.comm_close() - return autozero - except: - logger.error("read_autozero failed!") - self.comm_close() - return 0 - - def read_unit(self): # 0:ml/min 1:L/min - try: - self.comm_connect() - unit = self.S48.read_bit(6, 1) - self.comm_close() - return unit - except: - logger.error("read_unit failed!") - self.comm_close() - return 0 - - def comm_close(self): - try: - self.S48.serial.close() - # logger.info("HMT_S48 com port %s addr %s closed!" % (self.port,self.addr)) - except: - logger.info("HMT_S48 com port %s addr %s close failed!" % (self.port,self.addr)) - -#llj = C_S48('COM1',3) - -if __name__ == "__main__": - port = 'COM1' - llj = C_S48(port,3) - # llj.comm_connect() - #no = llj.set_valve_close() - no = llj.read_range() - #llj.set_flow(1638) - # llj.set_valve_ctrl() - #time.sleep(2) - #llj.set_valve_close() - #llj.set_sta_analog() - #llj.set_sta_digital() - # no = llj.read_dispflow() - #no = llj.read_valve_ctrl() - print "no=",no - # llj.comm_close() - # llj.disp_flow() - diff --git a/qmdz_const.py b/qmdz_const.py index ef42c05..a2315dd 100644 --- a/qmdz_const.py +++ b/qmdz_const.py @@ -20,11 +20,11 @@ SYS_CONF_PATH = ROOT_DIR + "\conf\SYS_CONF.ini" -vrange_dict = {0:"1e-6", 1:"10e-6", 2:"100e-6",3:"1e-3", 4:"10e-3", - 5:"100e-3", 6:"1", 7:"10", 8:"210"} +vrange_dict = {0:"AUTO", 1:"1e-6", 2:"10e-6", 3:"100e-6",4:"1e-3", 5:"10e-3", + 6:"100e-3", 7:"1", 8:"10", 9:"210"} -irange_dict= {0:"10e-9", 1:"100e-9", 2:"1e-6", 3:"10e-6", 4:"100e-6", - 5:"1e-3", 6:"10e-3", 7:"100e-3", 8:"1"} +irange_dict= {0:"AUTO", 1:"10e-9", 2:"100e-9", 3:"1e-6", 4:"10e-6", 5:"100e-6", + 6:"1e-3", 7:"10e-3", 8:"100e-3", 9:"1"} gas_coef = {0:1.000, 1:1.400, 2:0.446, 3:0.785, 4:0.515, 5:0.610, 6:0.500, 7:0.250, 8:0.410, 9:0.350, 10:0.300, 11:0.250, 12:0.260, 13:1.000, diff --git a/setup.py b/setup.py index 7f22274..c7cf10c 100644 --- a/setup.py +++ b/setup.py @@ -18,13 +18,13 @@ copyDependentFiles=True, appendScriptToExe=True, appendScriptToLibrary=False, - icon="icons/324263.ico", + icon="icons/GRMS.ico", shortcutName="gas-sensing_resistors measurement system", shortcutDir="DesktopFolder" ) setup( - name = "qmdz", + name = "GRMS2", version = "0.1", author="cygnushan", description = "gas-sensing_resistors measurement software",