import json from heat import heat,wire_ntc,center_ntc from work_time import wt class Module(): # 用于更新用户界面,被 class controller 调用 # 基类,只能被上层继承和调用 def __init__(self) -> None: self.heat = heat self.center_ntc = center_ntc self.wire_ntc = wire_ntc self.work_time = wt self.dat = {} def register(self, name, obj): self.obj.update({name: obj}) def get_dat(self): self.dat.update({'heat': {"status": heat.status, 'pwr_percent': heat.duty}}) self.dat.update({'ntc': {"wire_temp": self.wire_ntc.get_temperature(), 'center_temp':self.center_ntc.get_temperature()}}) if not heat.status: self.work_time.init() self.dat.update({'time':{'start_time': self.work_time.start_time, 'run_time': self.work_time.get_run_time(), 'now_time': self.work_time.now_time}}) return json.dumps(self.dat) def heat_on(self): self.heat.on() wt.init() # print('on') def heat_off(self): self.heat.off() # print('off') mod = Module() # print(mod.get_dat())