2280s-32-6 python读取buffer脚本

使用python脚本读取直流电源2280s-32-6仪器的buffer记录。
效果图:
前提:
1、配置2280s 配置网口使能。
2、电脑安装ni-visa pyvisa 使用此驱动。
在这里插入图片描述

    def msg_func(self):
        while True:
            msg = self.msg_func_hd.get()
            main_app_wdbg.info('rec msg:{}'.format(msg))
            if msg[0] == MSG_ID_STOP:
                return
            elif msg[0] == MSG_ID_GET_POWER_2280_BUFFER://读取buffer请求
                try:
                    self.power_2280s_handle = pyvisa.ResourceManager().open_resource(msg[1])
                    data1 = self.power_2280s_handle.query(msg[2])
                    file_name = './%s.csv'%(get_time1_str())
                    self.ui.lineEdit_14.setText(file_name)
                    head_list = ['时间','电流(A)','电压(V)']
                    with open(file_name,'w',newline='')as f:
                        f_csv = csv.writer(f)
                        f_csv.writerow(head_list)
                        temp = get_list(data1)
                        if temp != None:
                            f_csv.writerows(temp)
                        self.power_2280s_handle.close()
                except Exception as e:
                    printf_except_info(e)
            elif msg[0] == MSG_ID_GET_POWER_2280_BUFFER_CLEAR or \
                msg[0] == MSG_ID_GET_POWER_2280_TRIGGER_SET or\
                msg[0] == MSG_ID_GET_POWER_2280_TRIGGER or\
                msg[0] == MSG_ID_GET_POWER_2280_OUT_CTRL:
                try:
                    self.power_2280s_handle = pyvisa.ResourceManager().open_resource(msg[1])
                    data1 = self.power_2280s_handle.write(msg[2])
                    self.power_2280s_handle.close()
                except Exception as e:
                    printf_except_info(e)
  清除buffer操作:
  self.msg_func_hd.put((MSG_ID_GET_POWER_2280_BUFFER_CLEAR, self.ui.comboBox_17.currentText(),':TRAC1:CLE;'))
  获取buf指令:
  self.msg_func_hd.put((MSG_ID_GET_POWER_2280_BUFFER, self.ui.comboBox_17.currentText(),':TRAC1:DATA? \"READ,SOUR,TST,MODE\";'))
  控制buf输出功能:
  def slot_power_out_ctrl(self):
        try:
            if self.ui.comboBox_17.currentText() == '刷新' or self.ui.comboBox_17.currentText() == '':
                self.alarm('警告','未选择设备')
                return
            msg = ':OUTP:STAT %s,CH1'%(self.ui.comboBox_21.currentText())
            self.msg_func_hd.put((MSG_ID_GET_POWER_2280_OUT_CTRL, self.ui.comboBox_17.currentText(), msg))
        except Exception as e:
            printf_except_info(e)

个人微信: wzdhh991
邮箱: wzd991@126.com
个人比较懒,CSDN更新缓慢,有相关问题可发邮箱或个人微信交流!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

魏振东991

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值