Beispiel #1
0
def domainInterface2dict(semObj):
    out = a3t.gen2dict(semObj)

    da = a3t.inTwo(semObj, "domainAdapter2domainInterface")
    if da == None:
        reportError("Domain interface must take a domain adapter on input.", semObj)
        ## Have to short-circuit to prevent weird errors from happening.
        return out
    else:
        attributes = a3t.getAttributes(da)
        out["parameters"] = attributes

    iCall = a3t.outOne(semObj, "domainInterface2Interface")
    i = a3t.outTwo(semObj, "domainInterface2Interface")
    if i == None:
        reportError("Domain interface must call a local interface.", semObj)
    else:
        name = a3t.evalAtom3Type(i.name)
        calls = a3t.gen2dict(iCall)
        iParameters = a3t.evalAtom3Type(i.parameters)
        calls["name"] = name
        out["calls"] = calls

        ## Constraints on interface call.
        testCall(calls["arguments"], out["parameters"], iParameters, iCall)

    deleteEmptyKeys(out)

    testValidName(out.get("name"), semObj)

    return out
Beispiel #2
0
Datei: rosc.py Projekt: OEP/rdis
def getType(rosTopic):
  """
  Gets the ATOM3 ROS type for a topic.
  """
  topicType = a3t.outTwo(rosTopic, "ROSType")
  if topicType == None:
    reportError("ROS topic must have a type.", rosTopic)
  return topicType
Beispiel #3
0
Datei: rosc.py Projekt: OEP/rdis
def getInterface(rosTopic):
  """
  Gets domain interface associated with topic.
  """
  di = a3t.outTwo(rosTopic, "GenericGraphEdge")
  if di == None:
    reportError("ROS subscribed topic must be connected to RDIS domain interface!", rosTopic)
    return None
  return di
Beispiel #4
0
def addThreading(obj, connectionSem):
    threadingSem = a3t.outTwo(connectionSem, "connection2threading")

    if threadingSem == None:
        reportError("Connections must have a threading object.", connectionSem)
    else:
        threadObj = a3t.gen2dict(threadingSem)
        deleteEmptyKeys(threadObj)

        if isinstance(threadingSem, SingleThreading):
            testSingleThreading(threadObj, threadingSem)
            obj["singleThreading"] = threadObj
        else:
            reportError("Unbound threading type: {}".format(repr(threadingSem.__class__)), threading)
Beispiel #5
0
def interface2dict(interface):
    """
  Converts interface semantic object into a Python dict.
  """
    out = a3t.gen2dict(interface)
    out["primitiveCalls"] = getPrimitiveCalls(interface, out["parameters"])

    do = a3t.outTwo(interface, "interface2domainOutput")

    if do != None:
        outputName = a3t.evalAtom3Type(do.name)
        out["triggers"] = outputName

    deleteEmptyKeys(out)

    testValidName(out.get("name"), interface)

    return out
Beispiel #6
0
def getReturns(interface):
    domainAdapter = a3t.outTwo(interface, "interface2domainAdapter")
    if domainAdapter == None:
        return None
    returns = a3t.gen2dict(domainAdapter)
    return returns