def getdata(self): response = Method.send_method(self.method, self.url, self.head, self.data()) # self.logger.info("获取虚拟设备模版成功:模版名称{0};设备号{1};网关编号{2};模版编号{3}".format(response.json()["data"]["name"], response.json()["data"]["deviceSerialNum"], # response.json()["data"]["netSerialNum"], response.json()["data"]["templateId"])) return response.json()["data"]["name"], response.json()["data"]["deviceSerialNum"], \ response.json()["data"]["netSerialNum"], response.json()["data"]["templateId"]
def post_add_mxInstance(self, thingModelId, gateWayThingId): self.publish.post_publish(thingModelId) response = Method.send_method(self.method, self.url, self.head, self.data(thingModelId, gateWayThingId)) self.logger.info("注册物模型实例成功,物模型实例id为:{}".format(response.json()["data"])) if response.status_code == 200: dict.append("> 新建物实例接口:<font color=\"info\">通过</font> {}\n".format(response.json())) else: dict.append("> 新建物实例接口:<font color=\"comment\">失败</font> \n") return response.json()["data"]
def post_add_devices(self): response = Method.send_method(self.method, self.url, self.head, self.add_devices_param()) self.logger.info("新建虚拟设备成功,设备id为:{}".format(response.json()["data"])) if response.status_code == 200: dict.append( "> 新建虚拟设备接口:<font color=\"info\">通过</font> {}\n".format( response.json())) else: dict.append("> 新建虚拟设备接口:<font color=\"comment\">失败</font> \n") return response.json()["data"]
def startDevices(self): response = Method.send_method(self.method, self.url, self.head, self.param(self.devicesId)) self.logger.info("虚拟设备启动成功:{}".format(response.status_code)) if response.status_code == 200: dict.append( "> 启动虚拟设备接口:<font color=\"info\">通过</font> {}\n".format( response.json())) else: dict.append("> 启动虚拟设备接口:<font color=\"comment\">失败</font> \n") return response.status_code
def post_add_wg(self, gateWayModleId): self.publish.post_publish(gateWayModleId) response = Method.send_method(self.method, self.url, self.head, self.data(gateWayModleId)) self.logger.info("注册网关实例成功,网关实例id为:{}".format(response.json()["data"])) if response.status_code == 200: dict.append( "> 新建网关实例接口:<font color=\"info\">通过</font>{} \n".format( response.json())) else: dict.append("> 新建网关实例接口:<font color=\"comment\">失败</font> \n") return response.json()["data"]
def offDevices(self): devices = self.devicesObj.query(BDeviceInfo) lists = devices.filter_by(creator_true_name="定时发送", delete_flag=0, run_status=1).all() array = [] for i in lists: array.append(i.id) for j in array: self.logger.info("获取虚拟设备id:{}".format(j)) response = Method.send_method(self.method, self.url, self.head, self.param(j)) self.logger.info("请求url:{}".format(response.url)) self.logger.info("请求响应结果:{}".format(response.json())) if response.json()["code"] == 2000 and response.json( )["success"] == True: self.logger.info("虚拟设备关闭成功")
def post_publish(self, id): response = Method.send_method(self.method, self.url, self.head, self.data(id)) self.logger.info("发布模型成功:{}".format(response.status_code)) return response.status_code