def input_voltage(self, *names, **values): """ 设置和查询电压测量的相关设置 @param names: (type tuple) 可选值如下: range: 电压量程 auto: 自动电压量程状态 conf: 有效电压量程值 poj: 出现电压峰值超范围时使用的跳转目标范围 @param values: (type dict) 字典说明如下: range: (type float) 设置电压量程值 • 当波峰因数(crest factor)设置为3时 电压量程可选值 15, 30, 60, 150, 300, 600(V) • 当波峰因数(crest factor)设置为6或6A时 电压量程可选值 7.5, 15, 30, 75, 150, 300(V) auto: (type str) 自动电压量程 可选值 {ON|1|OFF|0} conf: (type str) 有效电压量程设置 如此格式的字符串 {ALL|<Voltage>[,<Voltage>][,<Voltage>]...} poj: (type str) 出现电压峰值超范围时使用的跳转目标范围 可选值 {OFF|<Voltage>}, <Voltage>范围参考range return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INPUT_VOLTAGE_SET.get(key), value) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INPUT_VOLTAGE_GET.get(name)) return self.query(query_cmd)
def status_group(self, *names, **values): """ 设置和查询用于进行与状态报告有关的参数 @param names: (type tuple) 可选值说明如下: cond: 查询条件寄存器的内容 eese: 查询扩展事件寄存器 eesr: 查询扩展事件寄存器的内容并清除该寄存器 err: 查询发生的最后一个错误的错误代码和消息(错误队列的顶部) qenable: 查询是否将错误消息以外的消息存储到错误队列中(ON)或不存储(OFF) qmsg: 查询是否将消息附加到STATus:ERRor?查询的响应 spoll: 执行串行轮询 filter<x>: 查询传输过滤器, <x> = 1 to 16 @param values: (type dict) 字典说明如下: eese: (type int) 设置启用扩展事件寄存器 值范围: <Register> = 0 to 65535 qenable: (type str) 设置是否将错误消息以外的消息存储到错误队列中(ON)或不存储(OFF) 可选值 <Boolean> = {ON|1|OFF|0} qmsg: (type str) 设置是否将消息附加到STATus:ERRor?查询的响应 可选值 <Boolean> = {ON|1|OFF|0} filter<x>: (type str) 设置传输过滤器. <x> = 1 to 16 可选值 {RISE|FALL|BOTH|NEVer} @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values: write_cmd = utils.contact_spci_cmd( Wt300eCmd.DICT_STATUS_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( Wt300eCmd.DICT_STATUS_GET.get(name)) return self.query(query_cmd)
def communicate_group(self, *names, **values): """ 仪器通讯参数的查询与设置 @param names: (type tuple): 可选值如下: header: 是否在查询值前添加头 lockout: 本地操作锁定 remote: 本地操作模式和远程操作模式 status: 返回特定行的状态 返回值位的含义如下: bit0: RS-232通讯校验错误 bit1: RS-232通讯帧错误 bit2: RS-232断字符错误 bit3 and higher: 始终为0 verbose: 响应是否以完全拼写形式或缩写形式返回 wait: 等待指定的扩展事件发生 @param values: (type dict): 键值说明如下: header: (type str) 是否在查询值前添加头, 可选值 {ON|1|OFF|0} lockout: (type str) 是否本地操作锁定, 可选值 {ON|1|OFF|0} remote: (type str) 本地操作模式和远程操作模式切换, 可选值 {ON|1|OFF|0} verbose: (type str) 响应是否以完全拼写形式或缩写形式返回, 可选值 {ON|1|OFF|0} wait: (type int) 等待指定的扩展事件发生, 选值范围 0 to 65535, 详细参考官方文档 @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_COMMUNICATE_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_COMMUNICATE_GET.get(name)) return self.query(query_cmd)
def system_group(self, *names, **values): """ 设置和查询系统参数 @params names: (type tuple) 可选值说明如下: model: 查询型号代码 suffix: 查询后缀代码 serial: 查询序列号 firmware: 查询固件版本 key_lock: 查询按键保护的开/关状态 resolution: 查询数字数据显示分辨率 commd: 查询命令类型 mac_addr: 查询以太网MAC地址 @params values: (type dict) 字典说明如下: key_lock: (type str) 查询按键保护的开/关状态 可选值 {ON|1|OFF|0} resolution: (type int) 设置数字数据显示分辨率 可选值范围 <NRf> = 4, 5 (digit) commd: 设置指令类型 可选值 {WT300E|WT300|WT200} @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_SYSTEM_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_SYSTEM_GET.get(name)) return self.query(query_cmd)
def rate_group(self, *names, **values): """ 设置和查询处理数据更新间隔 @param names: (type tuple) 可选值说明如下: time: 数据更新间隔 auto: 数据更新间隔的状态设置为"auto" timeout: 数据更新间隔设置为"auto"的超时时间 sync: 数据更新间隔设置为"auto"时的同步源 @param values: (type dict) 字典说明如下: time: (type str or float) 数据更新间隔 可选值/格式 {AUTO|<NRf>(MS|S)} timeout: 数据更新间隔设置为"auto"的超时时间, 单位为(S) sync: 数据更新间隔设置为"auto"时的同步源 可选值 {U<1-3>|I<1-3>} @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_RATE_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_RATE_GET.get(name)) return self.query(query_cmd)
def harmonics_group(self, *names, **values): """ 谐波测量相关操作设置查询 @param names: (type tuple) 可选值如下: measures: 所有谐波测量相关值, 包含PLL源, 分析的最大和最小谐波阶数, 用于计算THD(总谐波失真)的方程式, display: 所有显示谐波测量设置值, 包含显示状态和显示屏B中显示的谐波分量谐波测量数据的谐波阶次 @param values: (type dict) 字典说明如下: harm_plls: (type str) 设置PLL源,可选值 {U1|U2|U3|I1|I2|I3} harm_order: (type str) 析的最大和最小谐波阶数 应为如 value1,value2的字符串, value1和value2范围1 to 50 harm_thd: (type str) 用于计算THD(总谐波失真)的方程式 可选值 {TOTal|FUNDamental} disp_state: (type str) 显示状态 可选值 {ON|1|OFF|0} disp_order: (type int) 显示屏B中显示的谐波分量谐波测量数据的谐波阶次 范围 1 to 50 (harmonic order) @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_HARMONIC_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_HARMONIC_GET.get(name)) return self.query(query_cmd)
def input_scaling(self, *names, **values): """ 设置和查询扫描设置相关参数 @param names: (type tuple) 可选值如下: state: 扫描状态开关 vt: 所有元素VT(电压与时间)比 ct: 所有元素CT(电流与时间)比 factor: 所有元素的功率系数 vt_el1: 元素1的VT(电压与时间)比 vt_el2: 元素2的VT(电压与时间)比 vt_el3: 元素3的VT(电压与时间)比 ct_el1: 元素1的CT(电流与时间)比 ct_el2: 元素2的CT(电流与时间)比 ct_el3: 元素3的CT(电流与时间)比 factor_el1: 元素1的功率系数 factor_el2: 元素2的功率系数 factor_el3: 元素3的功率系数 @param values: (type dict) 字典说明如下: state: (type str) 扫描状态开关 可选值 {ON|1|OFF|0} vt: (type float) 所有元素VT(电压与时间)比 可选范围 0.001 to 9999. ct: 所有元素CT(电流与时间)比 可选范围 0.001 to 9999. factor: 所有元素的功率系数 可选范围 0.001 to 9999. vt_el1: 元素1的VT(电压与时间)比 optional value range 0.001 to 9999. vt_el2: 元素2的VT(电压与时间)比 可选范围 0.001 to 9999. vt_el3: 元素3的VT(电压与时间)比 可选范围 0.001 to 9999. ct_el1: 元素1的CT(电流与时间)比 可选范围 0.001 to 9999. ct_el2: 元素2的CT(电流与时间)比 可选范围 0.001 to 9999. ct_el3: 元素3的CT(电流与时间)比 可选范围 0.001 to 9999. factor_el1: 元素1的功率系数 可选范围 0.001 to 9999. factor_el2: 元素2的功率系数 可选范围 0.001 to 9999. factor_el3: 元素3的功率系数 可选范围 0.001 to 9999. @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INPUT_SCALING_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INPUT_SCALING_GET.get(name)) return self.query(query_cmd)
def input_others(self, *names, **values): """ 查询和设置其他输入参数 @param names: (type tuple) crest_fac: 波峰因数 wiring: 接线系统 mode: 电压和电流测量模式 rconf: 范围配置(有效范围选择)功能的开/关状态 sync: 同步源 peak_over: 峰值超范围信息, 返回值每位含义如下: ----------------------------------------- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | | | I3 | U3 | I2 | U2 | I1 | U1 | ----------------------------------------- check_range: 量程状态, 返回值每位含义如下: ----------------------------------------- | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | AP | AO | AH | AL | VP | VO | VH | VL | ----------------------------------------- VL : 电压处于减小自动量程或更小的条件 VH : 电压超出了提高自动量程的条件 VO : 电压超量程 VP : 电压峰值超量程 AL : 电流处于减小自动量程或更小的条件 AH : 电流超出了提高自动量程的条件 AO : 电流超量程 AP : 电流峰值超量程 @param values: (type dict) 字典说明如下: crest_fac: (type str) 波峰因数 可选值 {3|6|A6} wiring: 接线系统 可选值 {(P1W2|P1W3|P3W3|P3W4|V3A3)} mode: 电压和电流测量模式 可选值 {RMS|VMEan|DC} rconf: 范围配置(有效范围选择)功能的开/关状态 可选值 {ON|1|OFF|0} sync: 同步源 可选值 {VOLTage|CURRent|OFF} @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INPUT_OTHERS_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INPUT_OTHERS_GET.get(name)) return self.query(query_cmd)
def trigger_mode(self, *names, **values): """ 设置或查询触发参数 :param names: (type tuple): 查询的触发参数名 source: 测量时使用的触发源 inter: 自动触发积分时间 hold: 自动触发保持功能, 单位ms sens: 自动触发延迟灵敏度 count: 单次触发的采样数目 ext: 外部触发的触发类型 polar: VMC 输出极性 w_pulse: VMC 输出脉宽 :param values: (type dict): 设置的触发参数名, 字典说明 source (type str): 测量时使用的触发源, 可选值为{AUTO|SINGLE|EXT}, 分别表示“自动触发”, “单次触发”, “外部触发” inter (type int): 自动触发积分时间 不同的测量速率下自动触发<value>取值不同: 快速测量时, 积分时间默认是 8 ms,可设置的范围是 8 ms~2000 ms; 中速测量时,积分时间默认是 50 ms,可设置的范围是 50 ms~2000 ms; 慢速测量时,积分时间默认是 400 ms,可设置的范围是 400 ms~2000 ms。 hold (type str): 自动触发保持功能, 可选值 {ON|OFF|1|0} sens (type int): 自动触发延迟灵敏度, 参数说明如下: ------------------------- | 参数 | 灵敏度 | | :-----: | :-----: | | 0(MIN) | 0.01% | | 1 | 0.1% | | 2(DEF) | 1% | | 3(MAX) | 10% | ------------------------- count: 单次触发的采样数目 ext: 外部触发的触发类型 polar: VMC 输出极性 w_pulse: VMC 输出脉宽 :return: (type str): 依次返回names中的查询参数值, 以分号(;)分割, 注意后面有换行字符'\n' """ write_cmd = None query_cmd = None for key, cmd in Md3058RigolCmd.DICT_TRIGGER_SET.items(): value = values.get(key) if value is not None: write_cmd = utils.contact_spci_cmd(write_cmd, cmd.format(value)) if len(names) == 0: query_cmd = utils.contact_spci_cmd(query_cmd, Md3058RigolCmd.DICT_TRIGGER_GET.get(key)) self.write(write_cmd) for name in names: query_cmd = utils.contact_spci_cmd(query_cmd, Md3058RigolCmd.DICT_TRIGGER_GET.get(name)) return self.query(query_cmd)
def numeric_list(self, *names, **values): """ 设置和查询谐波测量数字列表数据输出相关参数 Sets or queries harmonic measurement numeric list data output settings. @param names: (type tuple), 可选值说明如下: number: 查询由:NUMeric:LIST:VALue?命令传送的数字列表数据项的数量 order: 查询谐波测量数字列表数据的最大输出谐波阶数 select: 查询谐波测量数字列表数据的输出分量 item<x>: 查询指定谐波测量数字列表数据项的输出项(功能和元素), <x> = 1 to 32 (item number) @param values: (type dict) 字典说明如下: number: (type str or int) 设置由:NUMeric:LIST:VALue?命令传送的数字列表数据项的数量 可选值/范围: 1 to 32 or (ALL) order: (type str or int) 设置谐波测量数字列表数据的最大输出谐波阶数 可选值/范围: 1 to 50 or (ALL) select: (type str) 查询谐波测量数字列表数据的输出分量 可选值: {EVEN|ODD|ALL} preset: (type int) 预设谐波测量数值列表数据输出项目匹配 可选值范围: 1 to 4 clear: (type str) 清除谐波测量数字列表数据输出项目(将项目设置为NONE) 可选值/格式: {ALL|<NRf>[,<NRf>]} ALL = Clear all items First <NRf> = 1 to 32 (the number of the first item to clear) Second <NRf> = 1 to 32 (the number of the last item to clear) delete: (type str) 删除谐波测量数字列表数据输出项目 可选值/格式: {<NRf>[,<NRf>]} First <NRf> = 1 to 32 (the number of the first item to delete) Second <NRf> = 1 to 32 (the number of the last item to delete) item<x>: (type str) 指定谐波测量数字列表数据项的输出项功能和元素, <x> = 1 to 32 (item number) 可选值/格式: {NONE|<Function>,<Element>} NONE = No output item <Function> = {U|I|P|PHIU|PHII|UHDF|IHDF|PHDF} <Element> = {<NRf>}(<NRf> = 1 to 3) @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_NUMERIC_LIST_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_NUMERIC_LIST_GET.get(name)) return self.query(query_cmd)
def integrate_group(self, *names, **values): """ 设置和查询积分相关参数 @param names: (type tuple) 可选值说明如下: mode: 积分模式 timer: 积分计时器 state: 积分状态 @param values: (type tuple) 字典说明如下: mode: (type str) 积分模式, 可选值 {NORMal|CONTinuous} timer: (type dict) 字典说明如下: hour: (type int) 小时位, 范围 0~10000, 默认0 minute: (type int) 分钟位, 范围 0~59, 默认0 second: (type int) 秒位, 范围 0~59, 默认0 state: (type str) 积分状态 可选值 {start|stop|reset} @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None mode = values.get('mode', None) if mode is not None: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INTEGRATE_SET.get('mode'), mode) timer = values.get('timer', None) if timer is not None: assert isinstance(timer, dict), 'timer must be a dict' write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INTEGRATE_SET.get('timer'), timer.get('hour', 0), timer.get('minute', 0), timer.get('second', 0)) state = values.get('state', None) if state is not None: if 'start' == state: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INTEGRATE.get('start')) elif 'stop' == state: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INTEGRATE.get('stop')) elif 'reset' == state: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INTEGRATE.get('reset')) else: self._logger.warn( 'the state "%s" expect "start", "stop" or "reset"', state) self.write(write_cmd) query_cmd = None if 'mode' in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INTEGRATE.get('mode')) if 'timer' in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INTEGRATE.get('timer')) if 'state' in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INTEGRATE.get('state')) return self.query(query_cmd)
def display_group(self, *names, **values): """ 显示相关操作设置和查询 @param names: (type tuple) 可选值如下: normals: 所有通用测量数据显示设置信息 harmonics: 所有谐波测量数据显示设置信息 @param values: (type dict), 字典说明如下: normal1: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P|S|Q|TIME} el: (type int), 当func为TIME时, el必须为None normal2: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P|LAMB|PHI} normal3: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P|UPP|UMP|IPP|IMP|PPP|PMP|WH|WHP|WHM|AH|AHP|AHM|MATH} el: (type int), 当func为MATH时, el必须为None normal4: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P|LAMB|FU|FI|UTHD|ITHD} harmonic1: (type dict), 字典说明如下: func: (type str), 可选值 {ORD|U|I|P} el: (type int), 当func为ORD时, el必须为None harmonic2: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P|PHIU|PHII|UHDLF|IHDF|PHDF} harmonic3: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P} harmonic4: (type dict), 字典说明如下: func: (type str), 可选值 {U|I|P|LAMB|FU|FI|UTHD|ITHD} @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ for key, value in values.items(): func = value.get('func') el = value.get('el') assert func is not None write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_DISPLAY_SET.get(key), func, COMMAS if el is not None else EMPTY, el if el is not None else EMPTY) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_DISPLAY_GET.get(name)) return self.query(query_cmd)
def numeric_normal(self, *names, **values): """ 设置和查询数字输出相关参数 @param names: (type tuple): number: 查询由:NUMeric[:NORMal]:VALue?命令传输的数字数据项 item<x>: 查询指定的数值数据输出项(功能,元素和谐波次数), <x>值为1-255 @param values: (type dict): number: (type str or int) 设置由:NUMeric[:NORMal]:VALue?命令传输的数字数据项 可选值: {<NRf>|ALL} <NRf> = 1 to 255(ALL) clear: (type str) 清除数字数据输出项目(将项目设置为NONE). 可选值/数据格式: {ALL|<NRf>[,<NRf>]} ALL = Clear all items First <NRf> = 1 to 255 (the number of the first item to clear) Second <NRf> = 1 to 255 (the number of the last item to clear) delete: (type str) 删除数字数据输出项 数据格式: {<NRf>[,<NRf>]} First <NRf> = 1 to 255 (the number of the first item to delete) Second <NRf> = 1 to 255 (the number of the last item to delete) preset: (type int) 预设数值数据输出项目匹配 范围 1 to 4 item<x>: (type str) 设置指定的数值数据输出项(功能,元素和谐波次数), <x>值为1-255 可选值/数据格式: {NONE|<Function>[,<Element>][,<Order>]} NONE = No output item <Function> = {U|I|P|S|Q|...} <Element> = {<NRf>|SIGMa} (<NRf> = 1 to 3) <Order> = {TOTal|DC|<NRf>} (<NRf> = 1 to 50) @return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_NUMERIC_NORMAL_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_NUMERIC_NORMAL_GET.get(name)) return self.query(query_cmd)
def numeric_normal_value(self, nrf=1): """ 查询数字数据头和数据值 @param nrf: (type int) <NRf> = 1 to 255 (item number) @return: 数字数据头和数据值, 以分号(;)分割, 注意后面的换行字符'\n' """ # return self.query(':NUMeric:NORMal:HEADer? {};:NUMeric:NORMal:VALue? {}'.format(nrf, nrf)) return self.query( utils.contact_spci_cmd( Wt300eCmd.DICT_NUMERIC_NORMAL_GET.get('header').format(nrf), Wt300eCmd.DICT_NUMERIC_NORMAL_GET.get('value').format(nrf)))
def input_filter(self, **values): """ 设置和查询输入过滤开关 @param values: (type dict) 字典说明如下: line: (type str) 线性过滤开关 可选值 {ON|1|OFF|0} freq: (type str) 频率过滤开关 可选值 {ON|1|OFF|0} @return: 依次返回线性过滤和频率过滤开关状态, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INPUT_FILTER_SET.get(key), value) self.write(write_cmd) return self.query(':INPut:FILTer?')
def measure_group(self, **values): """ 设置和查询所有测量和数据输出计算相关参数 @param values: (type dict) 字典说明如下: 'state': 平均计算开关状态, 可选值 {ON|1|OFF|0} 'type': 平均类型, 可选值 {LINear|EXPonent} 注意: 谐波测量功能(选件)的平均仅在类型设置为EXPonent(指数)时有效 'count': 平均系数, 可选值 8, 16, 32, 64 'max_hold': 最大值保持开关状态, 可选值 {ON|1|OFF|0} @return: 依次返回state, type, count, max hold相关参数或状态值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values.items(): write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_MEASURE_SET.get(key), value) self.write(write_cmd) return self.query(':MEASure?')
def calculate(self, *names, **values): """ 设置或查询仪器运算功能的相关参数或查询运算值 :param names: (type tuple): 可选值 func: 数学运算功能 st_min: 最小值 st_max: 最大值 st_avg: 平均值 st_count: 当前计算所进行测量的次数 st_stat: 统计运算功能的使能状态 rel_offset: 相对运算的偏移值 rel_stat: 相对运算功能的使能状态 db_value: dB 值 db_ref: dB 参考值 db_stat: dB 运算的使能状态 dbm_value: dBm 值 dbm_ref: dBm 参考电阻值 dbm_stat: dBm 运算的使能状态 pf_value: P/F值 pf_low: P/F 运算下限值 pf_up: P/F 运算上限值 pf_stat: P/F 运算的使能状态 :param values: (type dict): 设置字典说明 func (type str): 数学运算功能, 可选值 {NONE|REL|DB|DBM|MIN|MAX|AVERAGE|TOTAL|PF} st_stat (type str): 统计运算功能的使能状态, 可选值 {ON|OFF|1|0} rel_offset (type float): 相对运算的偏移值, 取值范围如下: ---------------------------------------- | 测量类型 | 取值范围 | DEF对应值 | 单位 | | :-----: | :-----: | :-----: | :--: | | 直流电压 | ±1200 | 0 | V | | 交流电压 | 0~900 | 0 | V | | 直流电流 | ±12 | 0 | A | | 交流电流 | 0~12 | 0 | A | | 电阻 | 0~1.2e+08 | 0 | Ω | | 电容 | 0~1.2e-02 | 0 | F | | 频率 | 0~1.2e+06 | 0 | Hz | ----------------------------------------- rel_stat (type str): 相对运算功能的使能状态, 可选值 {ON|OFF|1|0} db_ref (type float): dB 参考值, 取值范围 -120 dBm~+120 dBm db_stat (type str): dB 运算的使能状态, 可选值 {ON|OFF|1|0} dbm_ref (type float): dBm 参考电阻值, 取值范围 2~8000 Ω dbm_stat (type str): dBm 运算的使能状态, 可选值 {ON|OFF|1|0} pf_low (type float): P/F 运算下限值, 取值范围如下: ----------------------------- | 测量类型 | 取值范围 | 单位 | | :-----: | :-----: | :--: | | 直流电压 | ±1200 | V | | 交流电压 | 0~900 | V | | 直流电流 | ±12 | A | | 交流电流 | 0~12 | A | | 电阻 | 0~1.2e+08 | Ω | | 电容 | 0~1.2e-02 | F | | 周期 | 1.0e-06~100 | s | | 频率 | 0~1.2e+06 | Hz | ----------------------------- pf_up (type float): P/F 运算上限值, 值范围参考pf_low并大于pf_low pf_stat (type str): P/F 运算的使能状态, {ON|OFF|1|0} :return: (type str): 依次返回names中的查询参数值, 以分号(;)分割, 注意后面有换行字符'\n' """ write_cmd = None query_cmd = None for key, cmd in Md3058RigolCmd.DICT_CALC_SET.items(): value = values.get(key) if value is not None: write_cmd = utils.contact_spci_cmd(write_cmd, cmd.format(value)) if len(names) == 0: query_cmd = utils.contact_spci_cmd(query_cmd, Md3058RigolCmd.DICT_CALC_GET.get(key)) self.write(write_cmd) for name in names: query_cmd = utils.contact_spci_cmd(query_cmd, Md3058RigolCmd.DICT_CALC_GET.get(name)) return self.query(query_cmd)
def input_current(self, *names, **values): """ 设置和查询电流测量的相关设置 注意: ext_conf, ext_poj, ratio, ratio_el1, ratio_el2, ratio_el3等几个参数仅安装了可选外部电流传感器(/EX1 or /EX2)时有效 @param names: (type tuple) 可选值说明如下: range: 电流量程 auto: 自动电流量程状态 conf: 有效电流量程 poj: 发生当前峰值超范围时使用的跳转目标范围 ext_conf: 外部电流传感器有效量程 ext_poj: 外部电流传感器发生当前峰值超范围时使用的跳转目标范围 ratio: 外部电流传感器所有元件的转换率 ratio_el1: 指定元素1的外部电流传感器转换率 ratio_el2: 指定元素2的外部电流传感器转换率 ratio_el3: 指定元素3的外部电流传感器转换率 @param values: (type dict) 字典说明如下: range: (type float) 电流量程 • 对于内部电流表而言 • 当波峰因数(crest factor)设置为3时, 范围说明如下: <Current> = 5, 10, 20, 50, 100, 200, 500(mA), 1, 2, 5, 10, 20(A) (WT310E) <Current> = 1, 2, 5, 10, 20, 40(A) (WT310EH) <Current> = 0.5, 1, 2, 5, 10, 20(A) (WT332E, WT333E) • 当波峰因数(crest factor)设置为6或6A时, 范围说明如下: <Current> = 2.5, 5, 10, 25, 50, 100, 250(mA), 0.5, 1, 2.5, 5, 10(A) (WT310E) <Current> = 0.5, 1, 2.5, 5, 10, 20(A) (WT310EH) <Current> = 0.25, 0.5, 1, 2.5, 5, 10(A) (WT332E, WT333E) • 对于内部电流表而言 • 当波峰因数(crest factor)设置为3时, 范围说明如下: <Voltage> = 2.5, 5, 10(V) (/EX1) <Voltage> = 50, 100, 200, 500(mV), 1, 2(V) (/EX2) • 当波峰因数(crest factor)设置为6或6A时, 范围说明如下: <Voltage> = 1.25, 2.5, 5(V) (/EX1) <Voltage> = 25, 50, 100, 250(mV), 0.5, 1(V) (/EX2) auto: (type str) 自动电流量程状态 可选值 {ON|1|OFF|0} conf: (type str) 有效电流量程(内部电流表) 如此格式的字符串 {ALL|<Current>[,<Current>][,<Current>]...} poj: (type str or float) 发生当前峰值超范围时使用的跳转目标范围 可选值 {OFF|<Current>}, <Current>参考range参数 ext_conf: (type str) 有效电流量程(外部电流表) 如此格式的字符串 {ALL|<Current>[,<Current>][,<Current>]...}, <Current>参考range参数 ext_poj: (type str) 发生当前峰值超范围时使用的跳转目标范围(外部电流表) 可选值 {OFF|<Current>}, <Current>参考range参数 ratio: (type float) 外部电流传感器所有元件的转换率 值范围 0.001 to 9999. ratio_el1: (type float) 指定元素1的外部电流传感器转换率 值范围 0.001 to 9999. ratio_el2: (type float) 指定元素2的外部电流传感器转换率 值范围 0.001 to 9999. ratio_el3: (type float) 指定元素3的外部电流传感器转换率 值范围 0.001 to 9999. return: 返回names中指定的查询值, 以分号(;)分割, 注意后面的换行字符'\n' """ write_cmd = None for key, value in values: write_cmd = utils.contact_spci_cmd( write_cmd, Wt300eCmd.DICT_INPUT_CURRENT_SET.get(key), value) self.write(write_cmd) query_cmd = None for name in names: query_cmd = utils.contact_spci_cmd( query_cmd, Wt300eCmd.DICT_INPUT_CURRENT_GET.get(name)) return self.query(query_cmd)