Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Aug 28, 2024
1 parent 5806948 commit 1313473
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
6 changes: 3 additions & 3 deletions gui/CAEN-N1471H/caen_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import random


# class that simulates the channel of the caen by giving a random value to its attriutes vmon, imon and
# class that simulates the channel of the caen by giving a random value to its attributes vmon, imon and
class ChannelSimulator:
def __init__(self, trip_probability=0.02):
# private attributes (they do not exist in the real device)
Expand Down Expand Up @@ -104,9 +104,9 @@ def turn_off(self):


class ModuleSimulator:
def __init__(self, nChannels, trip_probability=0.05):
def __init__(self, n_channels, trip_probability=0.05):
self.name = "N1471H SIMULATOR"
self.number_of_channels = nChannels
self.number_of_channels = n_channels
self.channels = [
ChannelSimulator(
1 - (1 - trip_probability) ** (1.0 / self.number_of_channels)
Expand Down
18 changes: 8 additions & 10 deletions gui/CAEN-N1471H/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,19 +530,17 @@ def update_alarm_indicators(self):

args = parser.parse_args()

if args.test:
from caen_simulator import *
if not args.test:
caen = hvps.Caen(port=args.port)

m = ModuleSimulator(4)
print("port:", caen.port)
print("baudrate:", caen.baudrate)

CaenHVPSGUI(module=m, channel_names=CHANNEL_NAMES)
exit(0)
m = caen.module(0)

caen = hvps.Caen(port=args.port)
else:
from caen_simulator import * # noqa: F403

print("port:", caen.port)
print("baudrate:", caen.baudrate)

m = caen.module(0)
m = ModuleSimulator(4) # noqa: F405

CaenHVPSGUI(module=m, channel_names=CHANNEL_NAMES)

0 comments on commit 1313473

Please sign in to comment.