コード例 #1
0
ファイル: RecordWaveformBIN.py プロジェクト: nEDM-TUM/HVSetup
data = np.empty(wvfm_stop-wvfm_start, dtype=np.dtype('i2'))
d_volt, d_time = np.empty(wvfm_stop-wvfm_start, dtype=np.dtype('f'+precision)), np.empty(wvfm_stop-wvfm_start, dtype=np.dtype('f'+precision))
N = 0

while not SIGINT and not SIGTERM:
	try:
		today = datetime.today()
		if (today.date() > lastday.date()):
			lastday = today
			counter = 0
		else: counter += 1
		ofile = odir + '/' + fileprefix + today.strftime('%Y-%m-%d_') + "{:0>4}".format(counter) + ".bin"

		while int(sOsci.ask("ACQ:STATE?")) != 0:
			time.sleep(0.1)
		sOsci.instrument().write('CURVE?\n')
		buf = sOsci.instrument().read_raw()
		# start new acquisition
		sOsci.cmd("ACQ:STATE ON")

		""" buf[] = 
		0 = #
		1 = N
		2..2+N-1 = n-data-bytes
		2+N..len(buf)-1 = data
		"""
		N = int(buf[1])
		data = np.frombuffer(buf[2+N:-1], np.dtype('i2'))
		
		np.copyto(d_volt, data, casting='unsafe')
		d_volt -= yoffs