Skip to content

Commit 60137a1

Browse files
committed
add a print and rework if elif else condition
1 parent c4b1bce commit 60137a1

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

device.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,14 @@ def set_command_up(self):
114114
self.image = pygame.image.load(self.img_co_up).convert_alpha()
115115
else :
116116
self.image = pygame.image.load(self.img_disco).convert_alpha()
117-
if not self.emitted_power + POWER_CONTROL_STEP > UE_MAX_EMITTED_POWER:
118-
self.emitted_power += POWER_CONTROL_STEP
119-
elif (self.emitted_power < UE_MAX_EMITTED_POWER and
120-
self.emitted_power + POWER_CONTROL_STEP > UE_MAX_EMITTED_POWER):
121-
self.emitted_power = UE_MAX_EMITTED_POWER
117+
if self.emitted_power < UE_MAX_EMITTED_POWER:
118+
if not self.emitted_power + POWER_CONTROL_STEP > UE_MAX_EMITTED_POWER:
119+
self.emitted_power += POWER_CONTROL_STEP
120+
else:
121+
self.emitted_power = UE_MAX_EMITTED_POWER
122122
else:
123123
self.set_device_disconnected()
124+
print "Device disconnected : can't command up"
124125

125126
def set_command_down(self):
126127
"""Set the command of the device to COMMAND_DOWN.

simulator.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,13 @@ def open_loop(self):
317317
print "UE target (dBm) : ", device.target
318318
print ""
319319
else:
320-
if device.emitted_power < UE_MAX_EMITTED_POWER:
321-
device.emitted_power += POWER_CONTROL_STEP
322-
device.set_command_up()
323-
else:
324-
device.set_device_disconnected()
320+
device.set_command_up()
325321
j += 1
326322
i += 1
327323
device.open_looped = True
328324
if device.status != CONNECTED:
329325
device.set_device_disconnected()
326+
print "Device disconnected : end of open loop"
330327

331328
def outer_loop(self):
332329
"""Implementation of the outer loop.

0 commit comments

Comments
 (0)