add deal server data

desktop
esea_info 3 years ago
parent 3684f25ef0
commit ec21261957
  1. 4
      Ramses.py
  2. 68
      app.spec
  3. 124
      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] ] ] d = [] # List [ Tuple[ it:int, sing_set:tuple[int] ] ]
print(f" ================= ") print(f" ================= ")
print(f" {self.buf.hex()} ") print(f" {self.buf.hex()} ")
# self.it = 2 << int(self.buf[1]) # integrated time self.it = 2 << int(self.buf[1]) # integrated time
self.it = 2 << int(self.buf[0]) # integrated time # self.it = 2 << int(self.buf[0]) # integrated time
self.light_int = struct.unpack( self.light_int = struct.unpack(
"<HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH \ "<HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH \
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH \ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH \

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

@ -165,14 +165,15 @@ class HandHeldBuf:
class HandHeldPath(object): class HandHeldPath(object):
'''处理一次测量''' '''处理一次测量'''
def __init__(self, ): def __init__(self, ):
self.mode = 0 self.mode = 0
self.cfg ={} self.cfg ={}
self.mydir = MyDir() self.mydir = MyDir()
self.base_path:Path = Path() self.base_path:Path = Path()
self.output_path:Path = Path() self.output_path:Path = Path()
self.data_path:Path = Path() self.data_path:Path = Path()
self.filelist = [] self.server_path:Path = Path()
self.error_result = [] self.filelist = []
self.error_result = []
pass pass
def setMode( self, mode:int = 0 ): def setMode( self, mode:int = 0 ):
@ -187,6 +188,10 @@ class HandHeldPath(object):
self.data_path = fpath self.data_path = fpath
pass pass
def setServerPath( self, fpath:Path ):
self.server_path = fpath
pass
def setOutputPath( self, fpath:Path ): def setOutputPath( self, fpath:Path ):
self.output_path = fpath self.output_path = fpath
pass pass
@ -253,7 +258,7 @@ class HandHeldPath(object):
fs = None fs = None
self.filelist = [] self.filelist = []
if self.mode == 1: if self.mode == 1:
fs = self.data_path.glob( "*/*/*/*/info.bin" ) fs = self.server_path.glob( "*/*/*/*/info.bin" )
else: else:
fs = self.data_path.glob( "*/*/info/*" ) fs = self.data_path.glob( "*/*/info/*" )
@ -262,11 +267,11 @@ class HandHeldPath(object):
if f.stat().st_size==0: if f.stat().st_size==0:
error_file.update( {"path": f } ) error_file.update( {"path": f } )
error_file.update( {"error":"info file size is zero"} ) error_file.update( {"error":"info file size is zero"} )
self.error_result.append(error_file) self.error_result.append( error_file )
continue continue
# self.info_path_fname = f # self.info_path_fname = f
sensor_path = self.getSensorPathFromInfoPath(f) sensor_path = self.getSensorPathFromInfoPath( f )
# sensor_path = Path(sensor_purepath) # sensor_path = Path(sensor_purepath)
# sensor 文件不存在 # sensor 文件不存在
if not sensor_path.exists(): if not sensor_path.exists():
@ -284,6 +289,42 @@ class HandHeldPath(object):
self.setFilelist(f,sensor_path ) self.setFilelist(f,sensor_path )
pass 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 ): # def getDataFileList_SD(self, mode:int = 0 ):
# ''' # '''
# 获得成对的info sensor 文件 # 获得成对的info sensor 文件
@ -420,11 +461,26 @@ class AWRAMS(object):
pass pass
def getDataFileList(self, ): def getDataFileList(self, ):
self.hhp.setMode()
self.hhp.filelist = []
self.hhp.getDataFileList() self.hhp.getDataFileList()
self.filelist = self.hhp.getFilelist() self.filelist = self.hhp.getFilelist()
# self.printTest(self.filelist) # self.printTest(self.filelist)
pass 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, ): def dealAllMeasurements(self, ):
log.info(f" 所有测量文件", __name__, "dealAllMeasurements", ) log.info(f" 所有测量文件", __name__, "dealAllMeasurements", )
if len(self.filelist)<1: if len(self.filelist)<1:
@ -460,6 +516,44 @@ class AWRAMS(object):
# return True,self.error_result # return True,self.error_result
pass 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): def dealOneMeasurement(self, fpath:Path):
'''handheld一次测量包含多组数据''' '''handheld一次测量包含多组数据'''
# 调用handheldbuf 处理,将一组数据提交出来 # 调用handheldbuf 处理,将一组数据提交出来
@ -468,9 +562,9 @@ class AWRAMS(object):
pass pass
# 当前文件名 # 当前文件名
self.output_path = OUTPUT_DIR self.output_path = OUTPUT_DIR
self.current_filepath = fpath self.current_filepath = fpath
self.current_measure_time = self.hhp.getCurrentMeasureTimeFromPath(fpath) self.current_measure_time = self.hhp.getCurrentMeasureTimeFromPath(fpath)
self.get_ymdhms() self.get_ymdhms()
# self.ymdhms = "20"+ str(self.info_dict['year']) + '_' \ # self.ymdhms = "20"+ str(self.info_dict['year']) + '_' \
# + str(self.info_dict['month']) + '_' \ # + str(self.info_dict['month']) + '_' \
@ -490,7 +584,7 @@ class AWRAMS(object):
self.getAvg( self.intensity_before_avg ) self.getAvg( self.intensity_before_avg )
# 波长插值 self.res esky lsky lw # 波长插值 self.res esky lsky lw
self.__do_sensor_dict_interpo() self.__do_sensor_dict_interpo()
# 获得输出目录路径 self.ymdhms self.output_path # 获得输出目录路径 self.ymdhms
self.get_ymdhms() self.get_ymdhms()
# get Lw Rs # get Lw Rs
self.getLwRs() self.getLwRs()

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

@ -27,6 +27,7 @@ from tools.mylogger import log
# -定义菜单ID,关联Event------------------------- # -定义菜单ID,关联Event-------------------------
ID_MEASURE = 1 ID_MEASURE = 1
ID_DEAL_SERVER = 2
ID_SENSOR_SETTING = 11 ID_SENSOR_SETTING = 11
ID_LOGGING_SETTING = 12 ID_LOGGING_SETTING = 12
@ -112,7 +113,7 @@ class YiwinFrame(wx.Frame):
settingMenu.AppendSeparator() settingMenu.AppendSeparator()
settingMenu.Append(ID_MEASURE, u'&处理数据', ' ') settingMenu.Append(ID_MEASURE, u'&处理数据', ' ')
settingMenu.AppendSeparator() settingMenu.AppendSeparator()
settingMenu.Append(ID_LOGGING_SETTING, u'&采集设置', ' ') settingMenu.Append(ID_DEAL_SERVER, u'&处理服务器数据', ' ')
self.menubar.Append(settingMenu, u'&系统 ') self.menubar.Append(settingMenu, u'&系统 ')
plotMenu = wx.Menu() 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.OnCalInfo, id=ID_CAL_INFO )
# self.Bind(wx.EVT_MENU, self.OnStart, id=ID_MEASURE) # 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.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.OnLoggingSetting, id=ID_LOGGING_SETTING)
self.Bind(wx.EVT_MENU, self.OnPlotLast, id=ID_PLOT_LAST ) 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() self.sensor_cfg = self.mycfg.read_yaml()
def OnDealData(self, e)-> None: def OnDealData(self, e)-> None:
''' SD卡的文件结构 '''
log.info(f"OnDealData: 处理测量数据", __name__, "", "") log.info(f"OnDealData: 处理测量数据", __name__, "", "")
if not self.calinfo_is_ok: if not self.calinfo_is_ok:
self.onNotify("Pls get the cal info, and try again" ) self.onNotify("Pls get the cal info, and try again" )
@ -255,15 +258,55 @@ class YiwinFrame(wx.Frame):
pass 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): def OnCalInfo(self,e):
'''依据传感器获取标定文件信息''' '''依据传感器获取标定文件信息'''
####################################### #######################################
self.onNotify("正在获取标定信息") self.onNotify("正在获取标定信息")
device_id = self.device_id # 多个设备 device_id = self.device_id # 多个设备
device_type = DeviceType.SURFACE.name device_type = DeviceType.SURFACE.name
self.mycfg = MyConfig() self.mycfg = MyConfig()
self.mycfg.setDeviceType(DeviceType.SURFACE) 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() init_para = self.mycfg.read_yaml()
log.info(f"Current Device: {device_type} ", __name__, "", "") log.info(f"Current Device: {device_type} ", __name__, "", "")
log.info(f"Sensor: {init_para}", __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: {self.syscfg}", __name__, "", "")
log.warning(f"self.syscfg 2: {self.syscfg[2].keys()}", __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__, "", "") log.info(f"传感器配置文件读取成功", __name__, "", "")
self.alterStatus_0("传感器配置文件读取成功") self.alterStatus_0("传感器配置文件读取成功")
self.onNotify("获取标定信息成功") self.onNotify("获取标定信息成功")

Loading…
Cancel
Save