How to use the haros.hpl.hpl_ast.HplLiteral function in haros

To help you get started, we’ve selected a few haros examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github git-afsantos / haros / haros / hpl / test_generator.py View on Github external
)
    left = HplFieldExpression("nested_array[all].int", fields, "m", "pkg/Nested")

    fields = (
        HplFieldReference("int", TEST_DATA["pkg/Nested"]["int"], "pkg/Nested"),
    )
    right = HplFieldExpression("int", fields, "m", "pkg/Nested")

    cond1 = HplMsgFieldCondition(left, OPERATOR_EQ, right)
    msg_filter = HplMsgFilter((cond1,))

    hpl_receive = HplReceiveStatement("m", "/topic",
        msg_filter=msg_filter, msg_type="pkg/Nested")

    hpl_publish = HplPublishStatement("out", "/topic2",
        time_bound=HplTimeBound("<", HplLiteral("100", int, ()), "ms"),
        msg_filter=None, mult=None, msg_type="pkg/Nested")

    hpl_property = HplProperty(hpl_publish, receive_stmt=hpl_receive)

    publishers = {"/topic2": "pkg/Nested"}
    subscribers = {"/topic": "pkg/Nested"}
    test_gen = HplTestGenerator(
        ["pkg/launch/minimal.launch"],
        ["/node1", "/node2"],
        publishers, subscribers, TEST_DATA)
    print test_gen.gen(hpl_property)
github git-afsantos / haros / haros / hpl / test_generator.py View on Github external
def _python(self, value):
        if isinstance(value, self.Reference):
            # this must come before check for tuple
            name = value.expr.last_name
            return value.root + "." + name if name else value.root
        if isinstance(value, HplLiteral):
            return repr(value.value)
        if isinstance(value, tuple):
            return "({})".format(", ".join(self._python(v) for v in value))
        assert isinstance(value, HplFieldExpression), "found: " + repr(value)
        return self._var_prefix + value.full_name
github git-afsantos / haros / haros / hpl / parser.py View on Github external
def time_bound(self, (op, value, unit)):
        assert isinstance(value, HplLiteral)
        assert value.value_type is int or value.value_type is float
        return HplTimeBound(op, value, unit)
github git-afsantos / haros / haros / hpl / hpl_parser.py View on Github external
def string(self, (s,)):
        return HplLiteral(s, s)
github git-afsantos / haros / haros / hpl / hpl_parser.py View on Github external
def signed_number(self, (n,)):
        try:
            return HplLiteral(n, int(n))
        except ValueError as e:
            return HplLiteral(n, float(n))
github git-afsantos / haros / haros / hpl / parser.py View on Github external
def number(self, (n,)):
        try:
            value = int(n)
            return HplLiteral(n, int, ROS_NUMBER_TYPES)
        except ValueError as e:
            return HplLiteral(n, float, ROS_NUMBER_TYPES)
github git-afsantos / haros / haros / hpl / hpl_parser.py View on Github external
def boolean(self, (b,)):
        if b == "True":
            return HplLiteral(b, True)
        assert b == "False"
        return HplLiteral(b, False)
github git-afsantos / haros / haros / hpl / hpl_parser.py View on Github external
def boolean(self, (b,)):
        if b == "True":
            return HplLiteral(b, True)
        assert b == "False"
        return HplLiteral(b, False)
github git-afsantos / haros / haros / hpl / parser.py View on Github external
def string(self, (s,)):
        return HplLiteral(s, str, ROS_STRING_TYPES)