-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
7,025 additions
and
1,410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
numpy; sys_platform != 'win32' | ||
numpy!=1.16.0; sys_platform == 'win32' | ||
numpy>=1.9; sys_platform != 'win32' | ||
numpy>=1.9,!=1.16.0; sys_platform == 'win32' | ||
pyqt5; sys_platform != 'win32' and sys_platform != 'linux' | ||
pyqt5!=5.11.1,!=5.11.2,!=5.11.3; sys_platform == 'win32' | ||
pyqt5!=5.12,!=5.12.1; sys_platform == 'linux' | ||
pyqt5!=5.12,!=5.12.1,!=5.12.2; sys_platform == 'linux' | ||
psutil | ||
pyzmq | ||
cython |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import numpy as np | ||
|
||
from urh.cythonext import util | ||
from urh.signalprocessing.Message import Message | ||
|
||
|
||
def auto_assign_participants(messages, participants): | ||
""" | ||
:type messages: list of Message | ||
:type participants: list of Participant | ||
:return: | ||
""" | ||
if len(participants) == 0: | ||
return | ||
|
||
if len(participants) == 1: | ||
for message in messages: # type: Message | ||
message.participant = participants[0] | ||
return | ||
|
||
# Try to assign participants based on SRC_ADDRESS label and participant address | ||
for msg in filter(lambda m: m.participant is None, messages): | ||
src_address = msg.get_src_address_from_data() | ||
if src_address: | ||
try: | ||
msg.participant = next(p for p in participants if p.address_hex == src_address) | ||
except StopIteration: | ||
pass | ||
|
||
# Assign remaining participants based on RSSI of messages | ||
rssis = np.array([msg.rssi for msg in messages], dtype=np.float32) | ||
min_rssi, max_rssi = util.minmax(rssis) | ||
center_spacing = (max_rssi - min_rssi) / (len(participants) - 1) | ||
centers = [min_rssi + i * center_spacing for i in range(0, len(participants))] | ||
rssi_assigned_centers = [] | ||
|
||
for rssi in rssis: | ||
center_index = np.argmin(np.abs(rssi - centers)) | ||
rssi_assigned_centers.append(int(center_index)) | ||
|
||
participants.sort(key=lambda participant: participant.relative_rssi) | ||
for message, center_index in zip(messages, rssi_assigned_centers): | ||
if message.participant is None: | ||
message.participant = participants[center_index] | ||
|
||
|
||
def auto_assign_participant_addresses(messages, participants): | ||
""" | ||
:type messages: list of Message | ||
:type participants: list of Participant | ||
:return: | ||
""" | ||
participants_without_address = [p for p in participants if not p.address_hex] | ||
|
||
if len(participants_without_address) == 0: | ||
return | ||
|
||
for msg in messages: | ||
if msg.participant in participants_without_address: | ||
src_address = msg.get_src_address_from_data() | ||
if src_address: | ||
participants_without_address.remove(msg.participant) | ||
msg.participant.address_hex = src_address |
Oops, something went wrong.