def get_box_detail(socket): for e in command.ENERGY.values(): socket.request.sendall(command_encode(e)) time.sleep(0.5) for u in command.UA.values(): socket.request.sendall(command_encode(u)) time.sleep(0.5)
def operate_device_plan(device_id, line_id, operate): device = DeviceModel.objects.filter(device_id=device_id).first() if device: cloud_id = device["cloud_id"] clients = get_instance().clients if cloud_id in clients: line = Line.objects.filter(id=line_id).first() socket = clients[cloud_id] socket.request.sendall( command_encode(getattr(command, operate)[line.line]))
def send_command(socket, command): socket.request.sendall(command_encode(command))
def operate(line, operate, socket): """操作电路通断""" operate = operate.upper() if line in getattr(command, operate).keys(): socket.request.sendall( command_encode(getattr(command, operate)[line]))
def get_sign_strength(socket): """获取信号强度""" socket.request.sendall(command_encode(command.BASIC["sign"]))
def get_version(socket): """获取版本""" socket.request.sendall(command_encode(command.BASIC["version"]))
def get_cloud_id(socket): """获取云ID""" socket.request.sendall(command_encode(command.BASIC["cloud_id"]))
def status(socket): """获取线路状态""" print("获取线路状态") socket.request.sendall(command_encode(command.BASIC["line_status"]))