Esempio n. 1
0
def eobs(obs, domain):
  def mixObsWithLoc(loc):
    newObs = copy.deepcopy(obs)
    newObs["label"] = newObs["label"].replace("%loc",loc)
    checkForAlgebraicExpressions(newObs["expression"],["%loc"],[locations[loc]],str(0))
    solveAlgebraicExpressions(newObs["expression"])
    newObs["expression"] = checkForChains(newObs["expression"])
    insertLocInExpression(newObs["expression"],loc)
    return newObs
  
  def mixObsWithOrgDst(matrixCell):
    (org, dst, r) = matrixCell
    if (options.fullMatrix == False and r == 0):
      return nullInstruction
    if (org != dst):
      newObs = copy.deepcopy(obs)
      newObs["label"] = newObs["label"].replace("%org",org)
      newObs["label"] = newObs["label"].replace("%dst",dst)
      checkForAlgebraicExpressions(newObs["expression"],["%org","%dst"],[locations[org],locations[dst]],str(r))
      solveAlgebraicExpressions(newObs["expression"])
      newObs["expression"] = checkForChains(newObs["expression"])
      insertOrgInExpression(newObs["expression"],org)
      insertDstInExpression(newObs["expression"],dst)
      return newObs
    else:
      return nullInstruction

  obsBuilder = None
  if (domain[0].__class__ == "".__class__): #if it is string, it is just loc
    obsBuilder = mixObsWithLoc
  else: #the type is tuple, it is a matrix
    obsBuilder = mixObsWithOrgDst
  for r in map(obsBuilder, domain):
    printing.printObs(r)