dataclass upgrade

desktop
esea_info 2 years ago
parent 9b338558e9
commit 731a8a68ee
  1. 832
      awrams.py
  2. 789
      myRamses.py
  3. 139
      yiwinframe.py

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -16,16 +16,18 @@ from uiconfig.uiabout import About
from uiconfig.uihelp import Help from uiconfig.uihelp import Help
from uiconfig.ui_plot_setting import UI_Plot_Setting from uiconfig.ui_plot_setting import UI_Plot_Setting
from myconfig import TOKEN,DeviceType,YAML_FILE_NAME,RETRIEVE_CFG_FILE from myconfig import TOKEN,DeviceType,YAML_FILE_NAME,RETRIEVE_CFG_FILE,DATA_DIR
from myconfig import MyConfig,RamsesFunc from myconfig import MyConfig,RamsesFunc
from mythread import Mythead from mythread import Mythead
from configuration import Configuration from configuration import Configuration
from handheld import HandHeld,HandHeldBuf # from handheld import HandHeld,HandHeldBuf
from gatherdata import GatherData from gatherdata import GatherData
from tools.myexception import MyException from tools.myexception import MyException
from tools.mylogger import log from tools.mylogger import log
from awrams import AwramsHandle,HandheldHandle
# -定义菜单ID,关联Event------------------------- # -定义菜单ID,关联Event-------------------------
ID_MEASURE = 1 ID_MEASURE = 1
@ -96,7 +98,7 @@ class YiwinFrame(wx.Frame):
self.__setTimer() self.__setTimer()
log.info(f"system init....",__name__, "__init__") log.info(f"system init....",__name__, "__init__")
self.mycfg = MyConfig() self.mycfg = MyConfig()
self.hh = HandHeld() # self.hh = HandHeld()
self.mythread = Mythead() self.mythread = Mythead()
pub.subscribe( self.updateDisplay, "update") pub.subscribe( self.updateDisplay, "update")
@ -183,20 +185,14 @@ class YiwinFrame(wx.Frame):
def __update_notice(self,msg): def __update_notice(self,msg):
log.info(f" .......{msg}... ",__name__,'__update_notice') log.info(f" .......{msg}... ",__name__,'__update_notice')
self.alterStatus_0( msg) self.alterStatus_0( msg)
self.popDialog( msg ) # self.popDialog( msg )
pass pass
def __update_data(self,data ): def __update_data(self,data ):
log.info(f" .......... ",__name__,'__update_data') log.info(f" .......... ", __name__, '__update_data')
self.plotpanel.set_axes_title( data['tm']) self.plotpanel.set_axes_title( data[0])
res = data['res']
x = self.hh.wavelength.tolist()
length = len(data)
self.plotpanel.clear_past() self.plotpanel.clear_past()
for display in RamsesFunc: self.plotpanel.plot_one( "Rs", data[1], data[2], color= LineColor(1).name )
self.plotpanel.plot_one(display.name, x, res[display.name],color= LineColor(display.value).name )
pass
pass
def OnStart( self, event ): def OnStart( self, event ):
@ -226,63 +222,87 @@ class YiwinFrame(wx.Frame):
# 读取配置文件 # 读取配置文件
self.mycfg.setDeviceType(DeviceType.SURFACE) self.mycfg.setDeviceType(DeviceType.SURFACE)
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" )
log.warning(f"Pls get the cal info, and try again", __name__, "OnDealData") 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) self.statusBar.SetStatusText("Pls get the cal info, and try again",0)
pass pass
self.hh.getDataFileList() ## 调用 AwramsHandle 的函数
self.hh.setDeviceID(self.device_id) self.myhandle:HandheldHandle = self.handheld_handle[self.device_id]
self.hh.setRetrieve(self.retrieve)
if self.syscfg != {}:
self.hh.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(" 正在处理数据...." ) self.alterStatus_0(" 正在处理数据...." )
try: try:
self.mythread.set_task( self.hh.dealAllMeasurements ) self.mythread.set_task( self.read_folders_from_sd )
self.mythread.start() self.mythread.start()
except Exception as e: except Exception as e:
log.error(e) log.error(e)
pass pass
def read_folders_from_sd(self,):
# myhandle:AwramsHandle = self.awrams_handle[self.device_id]
self.myhandle.read_folders_from_SD( DATA_DIR )
pass
# if self.hh.dealAllMeasurements( ): # def OnDealData2(self, e)-> None:
# self.onNotify("正在处理数据" ) # log.info(f"OnDealData: 处理测量数据", __name__, "", "")
# self.statusBar.SetStatusText(u" 数据处理完成......", 0) # if not self.calinfo_is_ok:
# self.onNotify("处理数据已经结束" ) # self.onNotify("Pls get the cal info, and try again" )
# pass # 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.hh.getDataFileList()
# self.hh.setDeviceID(self.device_id)
# self.hh.setRetrieve(self.retrieve)
# if self.syscfg != {}:
# self.hh.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.hh.dealAllMeasurements )
# self.mythread.start()
# except Exception as e:
# log.error(e)
# pass
def OnCalInfo(self,e): def OnCalInfo(self,e):
'''依据传感器获取标定文件信息''' '''依据传感器获取标定文件信息'''
####################################### #######################################
self.onNotify("正在获取标定信息") self.onNotify("正在获取标定信息")
device_id = self.device_id # 多个设备 self.device_type = DeviceType.SURFACE.name
device_type = DeviceType.SURFACE.name self.mycfg = MyConfig() # 传入 cfg retrieve 的yml文件
self.mycfg = MyConfig()
# 配置反演需要的参数 波长 间隔 , rowFactor
self.mycfg.setDeviceType(DeviceType.SURFACE) self.retrieve = self.mycfg.get_retrieve() # 读retrieve.yml
init_para = self.mycfg.read_yaml() log.info(f"Retrieve: {self.retrieve}", __name__, "", "")
log.info(f"Current Device: {device_type} ", __name__, "", "")
log.info(f"Sensor: {init_para}", __name__, "", "") # log.info(f"syscfg: {device}", __name__, "", "")
# 配置反演需要的参数 波长 间隔 self.mycfg.setDeviceType( DeviceType.SURFACE )
self.retrieve = self.mycfg.get_retrieve() self.sensor_cfg = self.mycfg.read_yaml() # 读config.yml, 多个device_id 配置
log.warning(f"Retrieve: {self.retrieve}", __name__, "", "") log.info(f"Current Device: {self.device_type} ", __name__, "", "")
log.info(f"Sensor cfg: {self.sensor_cfg}", __name__, "", "")
self.syscfg = {}
self.cal_cfg = {}
cfgr = Configuration( ) cfgr = Configuration( )
cfgr.setDeviceType(device_type) cfgr.setDeviceType(self.device_type)
cfgr.setSystemCfgDict(init_para) cfgr.setSystemCfgDict(self.sensor_cfg)
for k,v in init_para.items(): for k,v in self.sensor_cfg.items():
cfgr.setSystemCfgDict(v) cfgr.setSystemCfgDict(v)
try: try:
cfgr.getCalConfiguration() cfgr.getCalConfiguration()
@ -290,18 +310,25 @@ class YiwinFrame(wx.Frame):
log.error(f"读取配置文件失败. \n {e}",__name__, "", "" ) log.error(f"读取配置文件失败. \n {e}",__name__, "", "" )
raise raise
log.info(f"v: {cfgr.configuration}", __name__, "", "") log.info(f"v: {cfgr.configuration}", __name__, "", "")
self.syscfg.update({k:cfgr.cal_configuration}) self.cal_cfg.update({k:cfgr.cal_configuration})
# log.warning(f"self.syscfg: {self.syscfg}", __name__, "", "") log.debug(f"cal_cfg: {self.cal_cfg}", __name__, "", "")
log.warning(f"self.syscfg 2: {self.syscfg[2].keys()}", __name__, "", "") log.warning(f"cal_cfg 2: {self.cal_cfg[2].keys()}", __name__, "", "")
log.warning(f"self.syscfg 3: {self.syscfg[3].keys()}", __name__, "", "") # log.warning(f"cal_cfg 3: {self.cal_cfg[3].keys()}", __name__, "", "")
self.init_data_process()
log.info(f"传感器配置文件读取成功", __name__, "", "") log.info(f"传感器配置文件读取成功", __name__, "", "")
self.alterStatus_0("传感器配置文件读取成功")
self.onNotify("获取标定信息成功")
self.calinfo_is_ok = True
pass pass
def init_data_process(self, mode = 0):
''' 多个handle '''
self.handheld_handle = { }
for k,v in self.cal_cfg.items():
ah = HandheldHandle( deviceid=k, cfg=self.sensor_cfg[k], calcfg=v, rtv=self.retrieve)
self.handheld_handle.update( {k:ah } )
def alterStatus_0(self,msg): def alterStatus_0(self,msg):
self.statusBar.SetStatusText( msg, 0 ) self.statusBar.SetStatusText( msg, 0 )

Loading…
Cancel
Save