Add some tests to support partial per degree target power definition

Signed-off-by: EstherLerouzic <esther.lerouzic@orange.com>
This commit is contained in:
EstherLerouzic
2019-10-30 16:10:02 +00:00
committed by Jan Kundrát
parent 3481ba8ee3
commit fa826391f6
2 changed files with 17 additions and 13 deletions

View File

@@ -160,9 +160,15 @@ class Roadm(Node):
#but add channels are not, so we define an effective loss
#in the case of add channels
if self.per_degree_target_pch_out_db:
# find the target power on this degree
try:
temp = next(el['target_pch_out_db'] \
for el in self.per_degree_target_pch_out_db if el['to_node']==degree)
except StopIteration:
# if no target power is defined on this degree use the global one
temp = self.params.target_pch_out_db
else:
# if no per degree target power are defined, use the global one
temp = self.params.target_pch_out_db
self.effective_pch_out_db = min(pref.p_spani, temp)
self.effective_loss = pref.p_spani - self.effective_pch_out_db

View File

@@ -316,19 +316,17 @@ def set_egress_amplifier(network, roadm, equipment, pref_total_db):
# next_node = next(n for n in network.successors(node))
# next_node = find_last_node(next_node)
if node.per_degree_target_pch_out_db:
# find the target power on this degree
try:
if node.params.per_degree_target_pch_out_db:
#find the target power on this degree
# need to change this ! #############################
prev_dp = next(el["target_pch_out_db"] for el in node.params.per_degree_target_pch_out_db if el["to_node"]==next_node.uid)
node.params = node.params._replace(target_pch_out_db=prev_dp)
prev_dp = next(el["target_pch_out_db"] for el in \
node.per_degree_target_pch_out_db if el["to_node"]==next_node.uid)
except StopIteration:
# if no target power is defined on this degree use the global one
prev_dp = getattr(node.params, 'target_pch_out_db', 0)
else:
# if no per degree target power is given use the global one
prev_dp = getattr(node.params, 'target_pch_out_db', 0)
node.params = node.params._replace(target_pch_out_db=prev_dp)
except AttributeError:
prev_dp = getattr(node.params, 'target_pch_out_db', 0)
####### en fait change pas les elements !, faudrait plusieurs pchtarget dans le roadm
dp = prev_dp
prev_voa = 0
voa = 0