mirror of
https://github.com/nqrduck/nqrduck-pulseprogrammer.git
synced 2024-12-22 15:47:47 +00:00
Switched to decimals
This commit is contained in:
parent
e29fe81c44
commit
3fe8cf487f
3 changed files with 8 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
import logging
|
||||
import json
|
||||
import decimal
|
||||
from PyQt6.QtCore import pyqtSlot
|
||||
from nqrduck.module.module_controller import ModuleController
|
||||
from nqrduck_spectrometer.pulsesequence import PulseSequence
|
||||
|
@ -36,8 +37,9 @@ class PulseProgrammerController(ModuleController):
|
|||
for event in self.module.model.pulse_sequence.events:
|
||||
if event.name == event_name:
|
||||
try:
|
||||
event.duration = duration
|
||||
except ValueError:
|
||||
# The u is for microseconds
|
||||
event.duration = duration + "u"
|
||||
except decimal.InvalidOperation:
|
||||
logger.error("Duration must be a positive number")
|
||||
# Emit signal to the nqrduck core to show an error message
|
||||
self.module.nqrduck_signal.emit("notification", ["Error", "Duration must be a positive number"])
|
||||
|
|
|
@ -16,7 +16,7 @@ class PulseProgrammerModel(ModuleModel):
|
|||
self.pulse_sequence = PulseSequence("Untitled pulse sequence")
|
||||
|
||||
def add_event(self, event_name):
|
||||
self.pulse_sequence.events.append(PulseSequence.Event(event_name, 20e-6))
|
||||
self.pulse_sequence.events.append(PulseSequence.Event(event_name, "20u"))
|
||||
logger.debug("Creating event %s with object id %s", event_name, id(self.pulse_sequence.events[-1]))
|
||||
|
||||
# Create a default instance of the pulse parameter options and add it to the event
|
||||
|
|
|
@ -2,6 +2,7 @@ import logging
|
|||
import functools
|
||||
from collections import OrderedDict
|
||||
from pathlib import Path
|
||||
from decimal import Decimal
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6.QtWidgets import QMessageBox, QGroupBox, QFormLayout, QTableWidget, QVBoxLayout, QPushButton, QHBoxLayout, QLabel, QDialog, QLineEdit, QDialogButtonBox, QWidget, QCheckBox, QToolButton, QFileDialog, QSizePolicy
|
||||
from PyQt6.QtCore import pyqtSlot, pyqtSignal
|
||||
|
@ -107,7 +108,7 @@ class PulseProgrammerView(ModuleView):
|
|||
for event in self.module.model.pulse_sequence.events:
|
||||
logger.debug("Adding event to pulseprogrammer view: %s", event.name)
|
||||
# Create a label for the event
|
||||
event_label = QLabel("%s : %s µs" % (event.name, str(event.duration * 1e6)))
|
||||
event_label = QLabel("%s : %s µs" % (event.name, str(event.duration * Decimal(1e6))))
|
||||
event_layout.addWidget(event_label)
|
||||
|
||||
# Delete the old widget and create a new one
|
||||
|
@ -241,7 +242,7 @@ class EventOptionsWidget(QWidget):
|
|||
duration_label = QLabel("Duration:")
|
||||
duration_lineedit = QLineEdit()
|
||||
unit_label = QLabel("µs")
|
||||
duration_lineedit.setText(str(self.event.duration * 1e6))
|
||||
duration_lineedit.setText(str(self.event.duration * Decimal(1e6)))
|
||||
duration_layout.addWidget(duration_label)
|
||||
duration_layout.addWidget(duration_lineedit)
|
||||
duration_layout.addWidget(unit_label)
|
||||
|
|
Loading…
Reference in a new issue