add deal server data

desktop
esea_info 3 years ago
parent 3684f25ef0
commit ec21261957
  1. 4
      Ramses.py
  2. 26
      app.spec
  3. 102
      awrams.py
  4. 12
      myconfig.py
  5. 49
      yiwinframe.py

@ -127,8 +127,8 @@ class Ramses(object):
d = [] # List [ Tuple[ it:int, sing_set:tuple[int] ] ]
print(f" ================= ")
print(f" {self.buf.hex()} ")
# self.it = 2 << int(self.buf[1]) # integrated time
self.it = 2 << int(self.buf[0]) # integrated time
self.it = 2 << int(self.buf[1]) # integrated time
# self.it = 2 << int(self.buf[0]) # integrated time
self.light_int = struct.unpack(
"<HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH \
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH \

@ -1,23 +1,28 @@
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['app.py'],
pathex=['D:\\GitCode\\python\\awrams'],
a = Analysis(
['app.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
@ -30,4 +35,11 @@ exe = EXE(pyz,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon='icon.ico',
)

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

@ -18,6 +18,7 @@ COMPANY = u"奕枫仪器"
DEVICE_ID = [2]
CURRENT_DIR = Path()
SERVER_DIR = Path("server")
DATA_DIR = Path("data")
CAL_DIR = Path("calfile")
OUTPUT_DIR = Path("data", "output")
@ -128,8 +129,8 @@ class MyConfig(object):
self.current_device_id = None
self.system_cfg = {}
self.cfg_path = Path()
self.yml_cfg_file = YAML_FILE_NAME
self.retrieve_cfg_file = Path(RETRIEVE_CFG_FILE)
self.yml_cfg_file:Path = YAML_FILE_NAME
self.retrieve_cfg_file:Path = Path(RETRIEVE_CFG_FILE)
self.system_cal_cfg = {}
self.validate = { }
@ -150,6 +151,13 @@ class MyConfig(object):
self.device_type = device_type
pass
def check_config_yml(self, ) -> None:
return Path(self.yml_cfg_file).exists()
pass
def check_retrieve_yml(self, ) -> None:
return self.retrieve_cfg_file.exists()
pass
def setRetrieveCfg(self, rtv_yml:str="") -> None:
if rtv_yml =="":
return None

@ -27,6 +27,7 @@ from tools.mylogger import log
# -定义菜单ID,关联Event-------------------------
ID_MEASURE = 1
ID_DEAL_SERVER = 2
ID_SENSOR_SETTING = 11
ID_LOGGING_SETTING = 12
@ -112,7 +113,7 @@ class YiwinFrame(wx.Frame):
settingMenu.AppendSeparator()
settingMenu.Append(ID_MEASURE, u'&处理数据', ' ')
settingMenu.AppendSeparator()
settingMenu.Append(ID_LOGGING_SETTING, u'&采集设置', ' ')
settingMenu.Append(ID_DEAL_SERVER, u'&处理服务器数据', ' ')
self.menubar.Append(settingMenu, u'&系统 ')
plotMenu = wx.Menu()
@ -147,6 +148,7 @@ class YiwinFrame(wx.Frame):
self.Bind(wx.EVT_MENU, self.OnCalInfo, id=ID_CAL_INFO )
# self.Bind(wx.EVT_MENU, self.OnStart, id=ID_MEASURE)
self.Bind(wx.EVT_MENU, self.OnDealData, id=ID_MEASURE)
self.Bind(wx.EVT_MENU, self.OnDealServer, id=ID_DEAL_SERVER)
# self.Bind(wx.EVT_MENU, self.OnLoggingSetting, id=ID_LOGGING_SETTING)
self.Bind(wx.EVT_MENU, self.OnPlotLast, id=ID_PLOT_LAST )
@ -221,6 +223,7 @@ class YiwinFrame(wx.Frame):
self.sensor_cfg = self.mycfg.read_yaml()
def OnDealData(self, e)-> None:
''' SD卡的文件结构 '''
log.info(f"OnDealData: 处理测量数据", __name__, "", "")
if not self.calinfo_is_ok:
self.onNotify("Pls get the cal info, and try again" )
@ -255,15 +258,55 @@ class YiwinFrame(wx.Frame):
pass
def OnDealServer(self, e)-> None:
'''对服务器数据进行再次处理,'''
log.info(f"OnDealServer: 处理服务器数据", __name__, "", "")
if not self.calinfo_is_ok:
self.onNotify("Pls get the cal info, and try again" )
log.warning(f"Pls get the cal info, and try again", __name__, "OnDealData")
self.statusBar.SetStatusText("Pls get the cal info, and try again",0)
pass
self.awrams.getDataFileList()
self.awrams.setDeviceID(self.device_id)
self.awrams.setRetrieve(self.retrieve)
if self.syscfg != {}:
self.awrams.setSyscfg(self.syscfg)
else:
log.warning(f"Pls get the cal info, and try again", __name__, "OnDealData","setCfg")
MyException( f"System Configuration is empty." )
pass
# 处理数据
self.alterStatus_0(" 正在处理数据...." )
try:
self.mythread.set_task( self.awrams.dealAllMeasurements )
self.mythread.start()
except Exception as e:
log.error(e)
pass
pass
def OnCalInfo(self,e):
'''依据传感器获取标定文件信息'''
#######################################
self.onNotify("正在获取标定信息")
device_id = self.device_id # 多个设备
device_type = DeviceType.SURFACE.name
self.mycfg = MyConfig()
self.mycfg.setDeviceType(DeviceType.SURFACE)
# 检查配置文件是否存在,不存在报错 config.yml retrieve.yml
if not self.mycfg.check_config_yml():
self.popDialog("没有发现config.yml文件")
pass
if not self.mycfg.check_retrieve_yml():
self.popDialog("没有发现retrieve.yml文件")
pass
init_para = self.mycfg.read_yaml()
log.info(f"Current Device: {device_type} ", __name__, "", "")
log.info(f"Sensor: {init_para}", __name__, "", "")
@ -289,7 +332,7 @@ class YiwinFrame(wx.Frame):
# log.warning(f"self.syscfg: {self.syscfg}", __name__, "", "")
log.warning(f"self.syscfg 2: {self.syscfg[2].keys()}", __name__, "", "")
log.warning(f"self.syscfg 3: {self.syscfg[3].keys()}", __name__, "", "")
# log.warning(f"self.syscfg 3: {self.syscfg[3].keys()}", __name__, "", "")
log.info(f"传感器配置文件读取成功", __name__, "", "")
self.alterStatus_0("传感器配置文件读取成功")
self.onNotify("获取标定信息成功")

Loading…
Cancel
Save