BxCmdDelDynamicArea.py 924 B

123456789101112131415161718192021222324252627282930313233343536
  1. from .BxCmd import baseBxCmd
  2. from .BxCmdCode import CMD_DEL_DYNAMIC_AREA
  3. class CmdDelDynamicArea(baseBxCmd):
  4. def __init__(self, numbers):
  5. super().__init__(CMD_DEL_DYNAMIC_AREA.group, CMD_DEL_DYNAMIC_AREA.code)
  6. self.numbers = numbers if numbers else []
  7. def Build(self):
  8. result = bytearray()
  9. # 写入命令组
  10. result.append(self.Group())
  11. # 写入命令
  12. result.append(self.Cmd())
  13. # 写入响应标志
  14. result.append(0x01)
  15. # 写入保留值
  16. result.extend([0x00, 0x00])
  17. # 写入数量
  18. l = len(self.numbers)
  19. if l == 0:
  20. result.append(0xff)
  21. else:
  22. result.append(l)
  23. # 写入编号
  24. for n in self.numbers:
  25. result.append(n)
  26. return bytes(result)
  27. def NewCmdDelDynamicArea(numbers):
  28. return CmdDelDynamicArea(numbers)