Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
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)
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
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)
def string(self, (s,)):
return HplLiteral(s, s)
def signed_number(self, (n,)):
try:
return HplLiteral(n, int(n))
except ValueError as e:
return HplLiteral(n, float(n))
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)
def boolean(self, (b,)):
if b == "True":
return HplLiteral(b, True)
assert b == "False"
return HplLiteral(b, False)
def boolean(self, (b,)):
if b == "True":
return HplLiteral(b, True)
assert b == "False"
return HplLiteral(b, False)
def string(self, (s,)):
return HplLiteral(s, str, ROS_STRING_TYPES)