Skip to content

Commit

Permalink
try to only get missing hash data on each sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mikey0000 committed Sep 28, 2024
1 parent 366d0dd commit 851cd80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions pymammotion/data/model/hash_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ def update_hash_lists(self, hashlist: list[int]) -> None:
def hashlist(self) -> list[int]:
return [i for obj in self.root_hash_list.data for i in obj.data_couple]

@property
def missing_hashlist(self) -> list[int]:
return [
i
for obj in self.root_hash_list.data
for i in obj.data_couple
if i not in set(self.area.keys()).union(self.path.keys(), self.obstacle.keys())
]

def update_root_hash_list(self, hash_list: NavGetHashListAck) -> None:
self.root_hash_list.total_frame = hash_list.total_frame

Expand Down
6 changes: 3 additions & 3 deletions pymammotion/mammotion/devices/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def commdata_response(self, common_data: NavGetCommDataAck) -> None:
if len(missing_frames) == 0:
# get next in hash ack list

data_hash = find_next_integer(self.mower.map.hashlist, common_data.hash)
data_hash = self.mower.map.missing_hashlist.pop()
if data_hash is None:
return

Expand Down Expand Up @@ -216,8 +216,8 @@ async def start_map_sync(self) -> None:

await self.queue_command("get_all_boundary_hash_list", sub_cmd=0)
await self.queue_command("get_hash_response", total_frame=1, current_frame=1)
for data_hash in self.mower.map.hashlist:
await self.queue_command("synchronize_hash_data", hash_num=data_hash)
data_hash = self.mower.map.missing_hashlist.pop()
await self.queue_command("synchronize_hash_data", hash_num=data_hash)

# sub_cmd 3 is job hashes??
# sub_cmd 4 is dump location (yuka)
Expand Down

0 comments on commit 851cd80

Please sign in to comment.