def on_q(self,desc): zaddr = desc['zaddr'] did = desc['did'] with db.db_session: db.DevOnline.get(zaddr=zaddr, did=did).delete() db.commit() tornado.log.gen_log.info('写入数据库(设备 z%s d%s 退出) ',zaddr,did)
def on_o(self,desc): init = {} init['zaddr'] = desc['zaddr'] init['ChipCode'] = desc['co'] init['DevCount'] = desc['dc'] with db.db_session: db.GroupOnline(**init) db.commit() tornado.log.gen_log.info('写入数据库(控制群 z%s c%s d%s 上线) ' %(init['zaddr'],init['ChipCode'],init['DevCount']))
def on_r(self,desc): init = {} init['zaddr'] = desc['zaddr'] init['did'] = desc['did'] init['MajorNum'] = desc['ma'] init['SubNum'] = desc['su'] with db.db_session: db.DevOnline(**init) db.commit() tornado.log.gen_log.info('写入数据库(设备 z%s d%s m%s s%s 注册) ' %(init['zaddr'],init['did'],init['MajorNum'],init['SubNum']))
def on_td_trr(self,desc): #~ 设备属性设置 zaddr = desc['zaddr'] did = desc['did'] ma = None su = None with db.db_session: dev = db.DevOnline.get(zaddr=zaddr, did=did) ma = dev.MajorNum su = dev.SubNum init = {} init['zaddr'] = zaddr init['did'] = did with db.db_session: DynDb = getattr(db,'DevDyn%s%s' %(ma,su)) if (ma,su) in [(0,0),(0,1)]: init.update(self.reserve_keys(desc,'light')) DynDb(**init) db.commit() tornado.log.gen_log.info('写入数据库(%s事件,%s) ',desc['e'],init)
def on_l(self,desc): zaddr = desc['zaddr'] with db.db_session: db.GroupOnline.get(zaddr=zaddr).delete() db.commit() tornado.log.gen_log.info('写入数据库(控制群 z%s 下线) ',zaddr)