Compare commits

..

2 Commits

  1. 6
      mypanel.py
  2. 10
      viper.py
  3. 2
      yiwinframe.py

@ -56,13 +56,13 @@ class Plot(wx.Panel):
self.SetSizer(self.TopBoxSizer) self.SetSizer(self.TopBoxSizer)
self.purewater_legend = ("Pure Water Attenuation Coefficient" self.purewater_legend = ("Pure Water Attenuation Coefficience"
,"Wavelength (nm)" ,"Wavelength (nm)"
,"Attenuation Coefficient m(-1)" ) ,"Attenuation Coefficience m(-1)" )
self.measure_legend = (" Attenuation Coefficient" self.measure_legend = (" Attenuation Coefficient"
,"Wavelength (nm)" ,"Wavelength (nm)"
,"Attenuation Coefficient m(-1)" ) ,"Attenuation Coefficience m(-1)" )
def set_axes_title(self,title): def set_axes_title(self,title):
self.axes.set_title(title) self.axes.set_title(title)

@ -17,6 +17,8 @@ from uart import Uart
from pathlib import Path, PurePath from pathlib import Path, PurePath
from wx.lib.pubsub import pub from wx.lib.pubsub import pub
FLOAT_RESERVE_BIT = 8
class Viper(object): class Viper(object):
def __init__(self,): def __init__(self,):
self.cfg = {} self.cfg = {}
@ -318,7 +320,7 @@ class Viper(object):
self.uart_thread.sequently_execute_tasks() self.uart_thread.sequently_execute_tasks()
self.uart_thread.remove_tasks() self.uart_thread.remove_tasks()
pass pass
data = self.convert_buf_2_float(self.res) data = self.convert_buf_2_float(self.res,FLOAT_RESERVE_BIT )
data = data[self.begin:self.end] data = data[self.begin:self.end]
# 浊度校正 # 浊度校正
data = self.correction_turbidity( np.array(data) ) data = self.correction_turbidity( np.array(data) )
@ -361,7 +363,7 @@ class Viper(object):
tmp = self.uart.OneMeasure() tmp = self.uart.OneMeasure()
self.res = self.res + tmp[3:len(tmp)-2] self.res = self.res + tmp[3:len(tmp)-2]
def convert_buf_2_float(self, buff, byteOrder= "big" )-> None: def convert_buf_2_float(self, buff, bit = 3 ,byteOrder= "big" )-> None:
res = [] res = []
log.debug(f" === {len(buff)}== {buff}", __name__, 'convert_buf_2_float') log.debug(f" === {len(buff)}== {buff}", __name__, 'convert_buf_2_float')
len_ = len(buff) len_ = len(buff)
@ -370,11 +372,11 @@ class Viper(object):
if byteOrder == "big": if byteOrder == "big":
for i in range( int(len_/4) ): for i in range( int(len_/4) ):
tmp = struct.unpack(">f", buff[i*4: i*4+4] ) tmp = struct.unpack(">f", buff[i*4: i*4+4] )
res.append( round(tmp[0],3) ) res.append( round(tmp[0],bit) )
else: else:
for i in range( int(len_/4) ): for i in range( int(len_/4) ):
tmp = struct.unpack(">f", buff[i*4: i*4+4] ) tmp = struct.unpack(">f", buff[i*4: i*4+4] )
res.append(round(tmp[0],3)) res.append(round(tmp[0],bit))
return res return res
pass pass

@ -389,7 +389,7 @@ class YiwinFrame( wx.Frame ):
def get_device_data( self,tm, data_buf ): def get_device_data( self,tm, data_buf ):
if len(data_buf) != 0: if len(data_buf) != 0:
self.device_data = self.viper.convert_buf_2_float( data_buf ) self.device_data = self.viper.convert_buf_2_float( data_buf,8 )
self.plotpanel.clear_past() self.plotpanel.clear_past()
self.plotpanel.plot_one( self.plotpanel.plot_one(
tm tm

Loading…
Cancel
Save