def setUp(self): self.custom_type = parser.CompoundType( "CustomType", parser.CompoundType.KIND_MESSAGE, "source.uavcan", 0, "" ) self.custom_type.fields = [ parser.Field( parser.PrimitiveType( parser.PrimitiveType.KIND_FLOAT, 16, parser.PrimitiveType.CAST_MODE_SATURATED ), "a" ), parser.Field(parser.VoidType(3), None), parser.Field( parser.PrimitiveType( parser.PrimitiveType.KIND_UNSIGNED_INT, 1, parser.PrimitiveType.CAST_MODE_SATURATED ), "b" ) ] def custom_type_factory(*args, **kwargs): return transport.CompoundValue(self.custom_type, _tao=True, *args, **kwargs) self.custom_type._instantiate = custom_type_factory
def setUp(self): self.custom_type = parser.CompoundType( "CustomType", parser.CompoundType.KIND_MESSAGE, "source.uavcan", 0, "") self.custom_type.union = True self.custom_type.fields = [ parser.Field( parser.PrimitiveType(parser.PrimitiveType.KIND_FLOAT, 16, parser.PrimitiveType.CAST_MODE_SATURATED), "a"), parser.Field( parser.ArrayType( parser.PrimitiveType( parser.PrimitiveType.KIND_UNSIGNED_INT, 8, parser.PrimitiveType.CAST_MODE_SATURATED), parser.ArrayType.MODE_STATIC, 2), "b") ] def custom_type_factory(*args, **kwargs): return transport.CompoundValue(self.custom_type, tao=True, *args, **kwargs) self.custom_type.__call__ = custom_type_factory
def setUp(self): custom_type = parser.CompoundType("CustomType", parser.CompoundType.KIND_MESSAGE, "source.uavcan", 0, "") custom_type.fields = [ parser.Field( parser.PrimitiveType(parser.PrimitiveType.KIND_SIGNED_INT, 8, parser.PrimitiveType.CAST_MODE_TRUNCATED), "a"), parser.Field( parser.PrimitiveType(parser.PrimitiveType.KIND_FLOAT, 16, parser.PrimitiveType.CAST_MODE_SATURATED), "b"), parser.Field( parser.ArrayType( parser.PrimitiveType( parser.PrimitiveType.KIND_UNSIGNED_INT, 1, parser.PrimitiveType.CAST_MODE_SATURATED), parser.ArrayType.MODE_DYNAMIC, 5), "c") ] def custom_type_factory(*args, **kwargs): return transport.CompoundValue(custom_type, *args, **kwargs) custom_type._instantiate = custom_type_factory self.a1_type = parser.ArrayType( parser.PrimitiveType(parser.PrimitiveType.KIND_SIGNED_INT, 8, parser.PrimitiveType.CAST_MODE_TRUNCATED), parser.ArrayType.MODE_STATIC, 4) self.a2_type = parser.ArrayType( parser.PrimitiveType(parser.PrimitiveType.KIND_FLOAT, 16, parser.PrimitiveType.CAST_MODE_SATURATED), parser.ArrayType.MODE_STATIC, 2) self.a3_type = parser.ArrayType(custom_type, parser.ArrayType.MODE_STATIC, 2)