From 1833d2c6c2db6250c65238aad44782c554ba90dd Mon Sep 17 00:00:00 2001 From: esea_info Date: Wed, 12 Apr 2023 08:49:20 +0800 Subject: [PATCH] bug --- mypanel.py | 6 +++--- viper.py | 10 ++++++---- yiwinframe.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mypanel.py b/mypanel.py index 7cd18b1..590ddd6 100644 --- a/mypanel.py +++ b/mypanel.py @@ -56,13 +56,13 @@ class Plot(wx.Panel): self.SetSizer(self.TopBoxSizer) - self.purewater_legend = ("Pure Water Attenuation Coefficient" + self.purewater_legend = ("Pure Water Attenuation Coefficience" ,"Wavelength (nm)" - ,"Attenuation Coefficient m(-1)" ) + ,"Attenuation Coefficience m(-1)" ) self.measure_legend = (" Attenuation Coefficient" ,"Wavelength (nm)" - ,"Attenuation Coefficient m(-1)" ) + ,"Attenuation Coefficience m(-1)" ) def set_axes_title(self,title): self.axes.set_title(title) diff --git a/viper.py b/viper.py index beda618..3aa9f37 100644 --- a/viper.py +++ b/viper.py @@ -17,6 +17,8 @@ from uart import Uart from pathlib import Path, PurePath from wx.lib.pubsub import pub +FLOAT_RESERVE_BIT = 8 + class Viper(object): def __init__(self,): self.cfg = {} @@ -318,7 +320,7 @@ class Viper(object): self.uart_thread.sequently_execute_tasks() self.uart_thread.remove_tasks() 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 = self.correction_turbidity( np.array(data) ) @@ -361,7 +363,7 @@ class Viper(object): tmp = self.uart.OneMeasure() 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 = [] log.debug(f" === {len(buff)}== {buff}", __name__, 'convert_buf_2_float') len_ = len(buff) @@ -370,11 +372,11 @@ class Viper(object): if byteOrder == "big": for i in range( int(len_/4) ): tmp = struct.unpack(">f", buff[i*4: i*4+4] ) - res.append( round(tmp[0],3) ) + res.append( round(tmp[0],bit) ) else: for i in range( int(len_/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 pass diff --git a/yiwinframe.py b/yiwinframe.py index 8fc7f10..cdc34b9 100644 --- a/yiwinframe.py +++ b/yiwinframe.py @@ -389,7 +389,7 @@ class YiwinFrame( wx.Frame ): def get_device_data( self,tm, data_buf ): 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.plot_one( tm