bugfix dealserver output_path

desktop
esea_info 3 years ago
parent 5d9f8ada09
commit 456ea8e674
  1. 30
      Ramses.py
  2. 28
      awrams.py
  3. 5
      tools/mypath.py

@ -26,17 +26,16 @@ class Ramses(object):
@param : 23 ..07 .... 06 05 04 03 02 01 00
ip信息不包含
@Returns : realWavelength Intensity
@ 积分时间 04 07 , 07
@ 积分时间 04 07 ,后一位高位 07
"""
self.buf = b''
self.mode = 0 # 默认0 空气中,1:水中
self.buf = b''
self.buf_ip = b''
self.it = None
self.light_int = None # 未标定的整数值
self.spectrum = None # 光谱强度
self.ip = []
self.cal_cfg = {} # 单个传感器标定文件还是多个传感器的?
# self.current_cal = {} # 当前传感器的序列号
pass
def setBuf( self, buf: bytes ):
@ -74,15 +73,7 @@ class Ramses(object):
self.spectrum = None # 光谱强度
pass
def printPara(self, ):
print(f"**************Ramses printPara*******************")
print(f"{self.buf}")
print(f"{self.cal_cfg}")
print(f"{self.it}")
print(f"{self.light_int}")
print(f"{self.spectrum}")
print(f"**************Ramses printPara*******************")
pass
def dealBuf(self, ip_included:bool=False):
"""
@ -110,10 +101,6 @@ class Ramses(object):
self.buf[295:359] + self.buf[367:431] + \
self.buf[439:503] + self.buf[511:575]
self.ConvertAndCalibrate( temp_buf )
# print(len(temp_buf))
# temp = self.__ConvertBytesToInt(temp_buf)
# res.update( { i+1: temp } )
# print(res)
pass
def ConvertAndCalibrate(self,) -> None:
@ -126,8 +113,6 @@ class Ramses(object):
# 转换一个传感器的部分
def __ConvertBytesToInt(self ) -> None:
res = {}
d = [] # List [ Tuple[ it:int, sing_set:tuple[int] ] ]
self.it = 2 << int(self.buf[1]) # integrated time
# self.it = 2 << int(self.buf[0]) # integrated time
@ -259,6 +244,15 @@ class Ramses(object):
return ret
pass
def printPara(self, ):
print(f"**************Ramses printPara*******************")
print(f"{self.buf}")
print(f"{self.cal_cfg}")
print(f"{self.it}")
print(f"{self.light_int}")
print(f"{self.spectrum}")
print(f"**************Ramses printPara*******************")
pass
if __name__ == "__main__":
log.info(f"******** Awarms server initiate *********", __name__, "", "")

@ -496,7 +496,7 @@ class AWRAMS(object):
except:
log.error( f"处理信息文件"
+ "/" +self.info_path_fname.stem
+ "出现错误", __name__, "dealAllMeasurements" )
+ "出现错误", __name__, "dealAllMeasurements_Server" )
raise MyException( "处理文件"+ self.info_path_fname + "出现错误")
pass
@ -522,13 +522,14 @@ class AWRAMS(object):
self.get_ymdhms()
# get Lw Rs
self.getLwRs()
# 设置保存路径 self.output_path
self.get_save_csv_path()
# 保存 data info
self.saveOnefileForLskyEskyLwaterLwRS()
# 通知ui
self.__set_msg("data", {"tm":self.ymdhms, "res":self.res} )
pub.sendMessage("update" , msg=self.msg)
self.__set_msg( 'notice', '处理文件完成' )
pub.sendMessage( 'update' , msg=self.msg )
log.info(f"Finished !! ", __name__, "dealAllMeasurements")
@ -582,10 +583,26 @@ class AWRAMS(object):
+ f"{self.info_dict['hour']:02d}" + '_' \
+ f"{self.info_dict['minute']:02d}" + '_' \
+ f"{self.info_dict['second']:02d}"
# self.output_path = self.output_path.joinpath( self.ymdhms )
# print(self.output_path)
# time.sleep(30)save_csv_path
def get_save_csv_path(self, ):
if self.mode == 0:
self.mydir.setBaseDir(DATA_DIR)
else:
self.mydir.setBaseDir(SERVER_DIR)
dir_tuple = ( "output", self.info_dict['year'],self.info_dict['month'],self.info_dict['day'])
self.mydir.setDir( t = dir_tuple)
self.mydir.newDirIfNot()
self.mydir.newFileIfNot( self.ymdhms+SAVE_EXT_NAME)
self.output_path = self.mydir.current_filepath
# self.output_path = self.output_path.joinpath( self.ymdhms )
# print(self.output_path)
# time.sleep(30)
def decode_sensor_buf(self,) :
# 处理Buf,对多组数据取平均
self.intensity_before_avg = []
@ -825,7 +842,6 @@ class AWRAMS(object):
Rs = self.res["Lw"] / self.res["Esky"]
self.res.update({ "Rs" : Rs })
def getLwRsAndSave(self, ) -> bool:
"""
并计算Lw Rs并保存
@ -872,8 +888,10 @@ class AWRAMS(object):
except Exception as e:
return ret
log.debug(temp,__name__,"decode_info")
time_ = "20"+str(temp[0]) + "-" + str(temp[1]) + "-" + str(temp[2]) + " " \
+ str(temp[3]) + ":" + str(temp[4]) + ":" + str(temp[5])
# time_ = "20"+str(temp[0]) + "-" + str(temp[1]) + "-" + str(temp[2]) + " " \
# + str(temp[3]) + ":" + str(temp[4]) + ":" + str(temp[5])
time_ = "20" + f"{str(temp[0])}" + "-" + f"{str(temp[1])}" + "-" + f"{str(temp[2])}" + " " \
+ f"{str(temp[3])}" + ":" + f"{str(temp[4])}" + ":" + f"{str(temp[5])}"
ret.update({"time": time_})
ret.update({"year": temp[0]})
ret.update({"month": temp[1]})

@ -30,6 +30,7 @@ class MyDir(object):
pass
def setDir(self, t:tuple=()):
''' set'''
self.dir_tuple = t
if len(self.dir_tuple) == 0 :
self.current_dir = self.base_dir
@ -167,7 +168,7 @@ class MyDir(object):
'''fmt: * */* */*/*'''
ret = []
tmp_dir = self.current_dir.glob(fmt)
print(tmp_dir)
# print(tmp_dir)
for td in tmp_dir:
if td.is_file():
ret.append(td)
@ -228,8 +229,6 @@ class MyDir(object):
# dirs_lst.sort()
def check_dirs(self, dirs:list, begin:int =0, step:int=1):
'''检查目录是否从begin开始递增'''
len_dirs = len(dirs)

Loading…
Cancel
Save