def get_function(self, fid): cols = [ "id", "var", "operation", "parameters", "process", "trigger", "trigger_field" ] q_fn = "select {cols} from ems_process_function where id = ?" fns = self.get_col_dict(q_fn, cols, (fid, )) return dbfn.DictClass(fns)
def get_slave_info(self, slave): cols = ["slave", "zmq_command_port", "process", "query_interval"] q_sel = "SELECT {cols} from ems_mb_slave where slave = ?" d = self.get_col_dict(q_sel, cols, (slave, )) print(d) p = self.get_process_info(d["process"]) d["zmq_process_port"] = p["zmq_process_port"] return dbfn.DictClass(d)
def get_msg_params(self, msg): cols = [ "msg", "message_type", "topic", "event_type", "event_on", "flg_clear", "zmq_msg_port" ] q_msg = "select {cols} from ems_msg where msg = ?" param = self.get_col_dict(q_msg, cols, (msg, )) return dbfn.DictClass(param)
def get_mb_field(self, name, section): cols = [ "field", "section", "fmt", "encoding", "scale", "offset", "seq" ] q_sel = "SELECT {cols} from ems_mb_field where seq = ? and section = ?" d = self.get_col_dict(q_sel, cols, (name, section)) if d["fmt"] in ["uint16", "int16"]: d["length"] = 1 elif d["fmt"] in ["float32", "uint32", "sint32"]: d["length"] = 2 elif d["fmt"] == "str16": d["length"] = 16 elif d["fmt"] == "str20": d["length"] = 20 else: print("Unknown fmt", d) return dbfn.DictClass(d)
def x_get_site_info_class(self, site_name): d = self.x_get_site_info_by_name(site_name) return dbfn.DictClass(d)
def x_get_server_address_class(self, server_name): d = self.x_get_address(server_name) return dbfn.DictClass(d)
def x_get_address(self, server_name): q_sel = "SELECT {cols} FROM emsrouter_serveraddress WHERE name = ?" cols = ["id", "name", "address", "port"] server = self.get_col_dict(q_sel, cols, (server_name, )) return dbfn.DictClass(server)
def get_mb_device(self, device, query): cols = ["device", "section", "query"] q_sel = "SELECT {cols} from ems_mb_device where device = ? and query = ?" d = self.get_col_dict(q_sel, cols, (device, query)) return dbfn.DictClass(d)
def get_mb_query(self, query): cols = ["query", "unit", "start_address", "slave", "length"] q_sel = "SELECT {cols} from ems_mb_query where query = ?" d = self.get_col_dict(q_sel, cols, (query, )) return dbfn.DictClass(d)