|
|
|
@ -171,6 +171,7 @@ class HandHeldPath(object): |
|
|
|
|
self.base_path:Path = Path() |
|
|
|
|
self.output_path:Path = Path() |
|
|
|
|
self.data_path:Path = Path() |
|
|
|
|
self.server_path:Path = Path() |
|
|
|
|
self.filelist = [] |
|
|
|
|
self.error_result = [] |
|
|
|
|
pass |
|
|
|
@ -187,6 +188,10 @@ class HandHeldPath(object): |
|
|
|
|
self.data_path = fpath |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def setServerPath( self, fpath:Path ): |
|
|
|
|
self.server_path = fpath |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def setOutputPath( self, fpath:Path ): |
|
|
|
|
self.output_path = fpath |
|
|
|
|
pass |
|
|
|
@ -253,7 +258,7 @@ class HandHeldPath(object): |
|
|
|
|
fs = None |
|
|
|
|
self.filelist = [] |
|
|
|
|
if self.mode == 1: |
|
|
|
|
fs = self.data_path.glob( "*/*/*/*/info.bin" ) |
|
|
|
|
fs = self.server_path.glob( "*/*/*/*/info.bin" ) |
|
|
|
|
else: |
|
|
|
|
fs = self.data_path.glob( "*/*/info/*" ) |
|
|
|
|
|
|
|
|
@ -262,11 +267,11 @@ class HandHeldPath(object): |
|
|
|
|
if f.stat().st_size==0: |
|
|
|
|
error_file.update( {"path": f } ) |
|
|
|
|
error_file.update( {"error":"info file size is zero"} ) |
|
|
|
|
self.error_result.append(error_file) |
|
|
|
|
self.error_result.append( error_file ) |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
# self.info_path_fname = f |
|
|
|
|
sensor_path = self.getSensorPathFromInfoPath(f) |
|
|
|
|
sensor_path = self.getSensorPathFromInfoPath( f ) |
|
|
|
|
# sensor_path = Path(sensor_purepath) |
|
|
|
|
# sensor 文件不存在 |
|
|
|
|
if not sensor_path.exists(): |
|
|
|
@ -284,6 +289,42 @@ class HandHeldPath(object): |
|
|
|
|
self.setFilelist(f,sensor_path ) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def getDataFileList_SERVER(self, ): |
|
|
|
|
''' |
|
|
|
|
获得成对的info sensor 文件 |
|
|
|
|
[目录名,文件名,年月日,时间] |
|
|
|
|
''' |
|
|
|
|
self.filelist = [] |
|
|
|
|
fs = self.server_path.glob( "*/*/*/*/info.bin" ) |
|
|
|
|
for f in fs: |
|
|
|
|
error_file = {} |
|
|
|
|
if f.stat().st_size==0: |
|
|
|
|
error_file.update( {"path": f } ) |
|
|
|
|
error_file.update( {"error":"info file size is zero"} ) |
|
|
|
|
self.error_result.append( error_file ) |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
## 获得全部bin文件 (info.bin (num).bin),不含 pic.bin |
|
|
|
|
current_path = f.parent |
|
|
|
|
bin_files = current_path.glob('*.bin') |
|
|
|
|
bin_len = len(bin_files) |
|
|
|
|
res_files = [] |
|
|
|
|
res_files.append( f) |
|
|
|
|
|
|
|
|
|
# 检查(num).bin 是否有遗漏 |
|
|
|
|
for i in range(bin_len-1): |
|
|
|
|
tmp_fpath = current_path.joinpath(str(i)+".bin") |
|
|
|
|
if tmp_fpath.exists(): |
|
|
|
|
res_files.append( tmp_fpath ) |
|
|
|
|
else: |
|
|
|
|
res_files =[] |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
if res_files != []: |
|
|
|
|
self.filelist.append(res_files) |
|
|
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
# def getDataFileList_SD(self, mode:int = 0 ): |
|
|
|
|
# ''' |
|
|
|
|
# 获得成对的info sensor 文件 |
|
|
|
@ -420,11 +461,26 @@ class AWRAMS(object): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def getDataFileList(self, ): |
|
|
|
|
self.hhp.setMode() |
|
|
|
|
self.hhp.filelist = [] |
|
|
|
|
self.hhp.getDataFileList() |
|
|
|
|
self.filelist = self.hhp.getFilelist() |
|
|
|
|
# self.printTest(self.filelist) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def getDataFiles_server(self, ): |
|
|
|
|
''' |
|
|
|
|
服务器数据二次处理 server/id/year/month/day/measure_id/*.bin |
|
|
|
|
判断是否存在上面样式文件夹,文件夹下是否 *.bin文件 |
|
|
|
|
"server/*/*/*/*/*/info.bin" |
|
|
|
|
''' |
|
|
|
|
log.info(f" 服务器数据下载,二次处理", __name__, "getDataFiles_server", ) |
|
|
|
|
self.hhp.setMode( 1 ) |
|
|
|
|
self.hhp.filelist = [] |
|
|
|
|
self.hhp.getDataFileList_SERVER( ) |
|
|
|
|
self.filelist = self.hhp.getFilelist() |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def dealAllMeasurements(self, ): |
|
|
|
|
log.info(f" 所有测量文件", __name__, "dealAllMeasurements", ) |
|
|
|
|
if len(self.filelist)<1: |
|
|
|
@ -460,6 +516,44 @@ class AWRAMS(object): |
|
|
|
|
# return True,self.error_result |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def dealAllMeasurements_Server(self, ): |
|
|
|
|
log.info(f" 所有服务器文件", __name__, "dealAllMeasurements_Server", ) |
|
|
|
|
if len(self.filelist)<1: |
|
|
|
|
pass |
|
|
|
|
# 前面已经考虑各种文件错误 |
|
|
|
|
for df in self.filelist: |
|
|
|
|
# 处理信息帧 |
|
|
|
|
self.info_dict = {} |
|
|
|
|
self.info_path_fname:Path = df[-1] |
|
|
|
|
# self.sensor_path_fname:Path = df["sensor_path"] |
|
|
|
|
hex_info = self.read_bin( self.info_path_fname ) |
|
|
|
|
try: |
|
|
|
|
self.info_dict = self.decode_info( hex_info ) |
|
|
|
|
except: |
|
|
|
|
log.error( f"处理信息文件" |
|
|
|
|
+ "/" +self.info_path_fname.stem |
|
|
|
|
+ "出现错误", __name__, "dealAllMeasurements" ) |
|
|
|
|
raise MyException( "处理文件"+ self.info_path_fname + "出现错误") |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
for i in range(len(df)-1): |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
try: # awrams每次只有一组数据 |
|
|
|
|
self.dealOneMeasurement( self.sensor_path_fname ) |
|
|
|
|
# self.measurement_interval = int(self.info_dict['Measure_Interval']) |
|
|
|
|
# self.measurement_repeat = int(self.info_dict['Measure_Repeat']) |
|
|
|
|
# self.dealOneHandheldMeasurement(self.sensor_path_fname ) |
|
|
|
|
except Exception as e: |
|
|
|
|
log.error( "处理传感器文件" + self.sensor_path_fname.name + " 出现错误",__name__,"dealAllMeasurements") |
|
|
|
|
raise MyException( "处理传感器文件" + self.sensor_path_fname.name + " 出现错误" ) |
|
|
|
|
pass |
|
|
|
|
self.__set_msg('notice', '处理文件完成') |
|
|
|
|
pub.sendMessage('update' , msg=self.msg) |
|
|
|
|
log.info(f"Finished !! ", __name__, "dealAllMeasurements") |
|
|
|
|
# return True,self.error_result |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
def dealOneMeasurement(self, fpath:Path): |
|
|
|
|
'''handheld一次测量包含多组数据''' |
|
|
|
|
# 调用handheldbuf 处理,将一组数据提交出来 |
|
|
|
@ -490,7 +584,7 @@ class AWRAMS(object): |
|
|
|
|
self.getAvg( self.intensity_before_avg ) |
|
|
|
|
# 波长插值 self.res esky lsky lw |
|
|
|
|
self.__do_sensor_dict_interpo() |
|
|
|
|
# 获得输出目录路径 self.ymdhms self.output_path |
|
|
|
|
# 获得输出目录路径 self.ymdhms |
|
|
|
|
self.get_ymdhms() |
|
|
|
|
# get Lw Rs |
|
|
|
|
self.getLwRs() |
|
|
|
|