Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make message pause configurable in simulator #478

Merged
merged 2 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/urh/simulator/Simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def resend_last_message(self):

def send_message(self, message, repeat, sender, modulator_index):
modulator = self.modulators[modulator_index]
modulated = modulator.modulate(message.encoded_bits, pause=0)
modulated = modulator.modulate(message.encoded_bits, pause=message.pause)

curr_repeat = 0

Expand Down
13 changes: 12 additions & 1 deletion src/urh/ui/views/SimulatorGraphicsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def add_empty_message(self, num_bits):
position = QAbstractItemView.BelowItem

message = self.scene().add_message(plain_bits=[0] * num_bits,
pause=1000000,
pause=0,
message_type=message_type,
ref_item=ref_item,
position=position)
Expand Down Expand Up @@ -285,6 +285,9 @@ def create_context_menu(self):
swap_part_action.triggered.connect(self.on_swap_part_action_triggered)
swap_part_action.setIcon(QIcon.fromTheme("object-flip-horizontal"))

pause_action = menu.addAction("Set pause ({} samples)".format(self.context_menu_item.model_item.pause))
pause_action.triggered.connect(self.on_pause_action_triggered)

menu.addSeparator()

if len(self.scene().get_all_message_items()) > 1:
Expand Down Expand Up @@ -344,6 +347,14 @@ def keyPressEvent(self, event):
else:
super().keyPressEvent(event)

@pyqtSlot()
def on_pause_action_triggered(self):
p = self.context_menu_item.model_item.pause if isinstance(self.context_menu_item, MessageItem) else 0
pause, ok = QInputDialog.getInt(self, self.tr("Enter new Pause Length"), self.tr("Pause Length:"), p, 0)
if ok:
for msg in self.scene().get_selected_messages():
msg.pause = pause

@classmethod
def add_select_actions_to_menu(cls, menu, scene: SimulatorScene, select_to_trigger, select_from_trigger):
if len(scene.visible_participants) == 0:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_performance(self):
simulator = Simulator(self.stc.simulator_config, self.gtc.modulators, self.stc.sim_expression_parser,
self.form.project_manager, sniffer=sniffer, sender=sender)

pause = 100000
pause = 100
msg_a = SimulatorMessage(part_b,
[1, 0] * 16 + [1, 1, 0, 0] * 8 + [0, 0, 1, 1] * 8 + [1, 0, 1, 1, 1, 0, 0, 1, 1, 1] * 4,
pause=pause, message_type=MessageType("empty_message_type"), source=part_a)
Expand All @@ -122,7 +122,7 @@ def test_performance(self):

current_index = Value("L")
elapsed = Value("f")
target_num_samples = 113600 - pause
target_num_samples = 13600 + pause
receive_process = Process(target=receive, args=(port, current_index, target_num_samples, elapsed))
receive_process.daemon = True
receive_process.start()
Expand Down