| 1234567891011121314151617181920212223242526272829303132333435 |
- from .BxCmd import baseBxCmd
- from .BxCmdCode import CMD_LOCK_UNLOCK
- class CmdLock(baseBxCmd):
- def __init__(self, flag, name):
- super().__init__(CMD_LOCK_UNLOCK.group, CMD_LOCK_UNLOCK.code)
- self.StoreMode = 0
- self.LockFlag = flag
- self.ProgramFileName = name
- def SetStoreMode(self, storeMode):
- self.StoreMode = storeMode
- def Build(self):
- result = bytearray()
- # 写入命令组
- result.append(self.Group())
- # 写入命令
- result.append(self.Cmd())
- # 写入响应标志
- result.append(0x01)
- # 写入保留值
- result.extend([0x00, 0x00])
- # 写入存储模式
- result.append(self.StoreMode)
- # 写入锁定标志
- result.append(self.LockFlag)
- # 写入程序文件名
- result.extend(self.ProgramFileName.encode('ascii'))
- return bytes(result)
- def NewCmdLock(flag, name):
- return CmdLock(flag, name)
|