這陣子需要寫一些 Python 程式用儀器量測訊號,因此將常用的部分模組化,下面就是程式模組,因為只用了 COM 及 USB-TMC,所以僅將這兩部分模組化。
INSTRUMENT.py
# (C) 2017, Bridan Wang, CC BY-NC-SA 3.0 TW http://4rdp.blogspot.tw/
from __future__ import division, unicode_literals, print_function, absolute_import
import serial
import visa
import time
class COM:
def __init__(self):
global inst1
inst1 = serial.Serial()
def OPEN(self, pp, rate = 9600):
global inst1
inst1.close()
inst1.port = "COM"+str(pp)
inst1.baudrate = rate
inst1.timeout = 5
inst1.open()
time.sleep(1)
self.stat = 2
def CLOSE(self):
global inst1
inst1.close()
def SEND(self, ss):
global inst1
ss = str(ss) + b"\r\n"
inst1.write(ss)
def QUERY(self, ss=""):
global inst1
if ss != "":
self.SEND(ss)
#time.sleep(1)
qqx = inst1.readline()
return qqx
def QUERY_VALUE(self, q):
a = self.QUERY(q)
return float(a)
class USB:
def __init__(self):
global usb
try:
usb = visa.get_instruments_list()
#print(usb)
except:
usb = []
def OPEN(self, sel=0):
global usb
global inst
try:
inst = visa.Instrument(usb[sel], term_chars=b"\n", timeout=5)
self.stat = 2
except:
self.stat = 0
return self.stat
def CLOSE(self):
global inst
inst.close()
def SEND(self, ss):
global inst
inst.write(ss)
def QUERY(self, ss=""):
global inst
if ss != "":
self.SEND(ss)
#time.sleep(1)
qqx = inst.read()
return qqx
def QUERY_VALUE(self, q):
a = self.QUERY(q)
return float(a)
新ubuntu2404,新尹倉1120
-
Ubuntu24.04
每次ubuntu系統出新版本,我的更新都是滯後的。最新的ubuntu2404.iso已經超過6G,估計是因為加入了大量中文字體致使體積大增。我十多年來一直當作系統盤的4個G的U盤再也裝不下了,最終我決定把一個32G的U盤當系統安裝盤。
昨晚研究了multibootUSB好久,最終引導不...
2 天前
沒有留言:
張貼留言