|
|
|
|
@ -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 |
|
|
|
|
|
|
|
|
|
|