Esempio n. 1
0
 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)
Esempio n. 2
0
 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]))
Esempio n. 3
0
 def send_command(socket, command):
     socket.request.sendall(command_encode(command))
Esempio n. 4
0
 def operate(line, operate, socket):
     """操作电路通断"""
     operate = operate.upper()
     if line in getattr(command, operate).keys():
         socket.request.sendall(
             command_encode(getattr(command, operate)[line]))
Esempio n. 5
0
 def get_sign_strength(socket):
     """获取信号强度"""
     socket.request.sendall(command_encode(command.BASIC["sign"]))
Esempio n. 6
0
 def get_version(socket):
     """获取版本"""
     socket.request.sendall(command_encode(command.BASIC["version"]))
Esempio n. 7
0
 def get_cloud_id(socket):
     """获取云ID"""
     socket.request.sendall(command_encode(command.BASIC["cloud_id"]))
Esempio n. 8
0
 def status(socket):
     """获取线路状态"""
     print("获取线路状态")
     socket.request.sendall(command_encode(command.BASIC["line_status"]))