opc-ua中如何继承另一个对象
How to inherit another object in opc-ua
我的类型模型中有一个 HomeBaseObjectType 和一个 HomeRegionType:
这是我在 python 中使用 Freeopcua 库的代码:
# create a new node type we can instantiate in our address space
dev = await server.nodes.base_object_type.add_object_type(idx, "HomedBaseObjectType")
await (await dev.add_variable(idx, "BadScanCounter", 1, ua.VariantType.Int64)).set_modelling_rule(True)
await (await dev.add_variable(idx, "DetectorTemp", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "Flow", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "LaserDC", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "LaserPP", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "Pressure", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "SingleBeamAt2500", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "SingleBeamAt900", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "TempOptics", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
dev1 = await server.nodes.base_object_type.add_object_type(idx, "HomedRegionType")
await (await dev1.add_object(idx, "HomeBaseObjectType")).set_modelling_rule(True)
如何让 HomedBaseObjectType 下的变量出现在 HomedRegionType 下?
啊,添加对象时需要指定objecttype:
await (await dev1.add_object(idx, "HomedBaseObjectType", objecttype=dev)).set_modelling_rule(True)
我的类型模型中有一个 HomeBaseObjectType 和一个 HomeRegionType:
这是我在 python 中使用 Freeopcua 库的代码:
# create a new node type we can instantiate in our address space
dev = await server.nodes.base_object_type.add_object_type(idx, "HomedBaseObjectType")
await (await dev.add_variable(idx, "BadScanCounter", 1, ua.VariantType.Int64)).set_modelling_rule(True)
await (await dev.add_variable(idx, "DetectorTemp", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "Flow", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "LaserDC", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "LaserPP", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "Pressure", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "SingleBeamAt2500", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "SingleBeamAt900", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
await (await dev.add_variable(idx, "TempOptics", 0.0, ua.VariantType.Double)).set_modelling_rule(True)
dev1 = await server.nodes.base_object_type.add_object_type(idx, "HomedRegionType")
await (await dev1.add_object(idx, "HomeBaseObjectType")).set_modelling_rule(True)
如何让 HomedBaseObjectType 下的变量出现在 HomedRegionType 下?
啊,添加对象时需要指定objecttype:
await (await dev1.add_object(idx, "HomedBaseObjectType", objecttype=dev)).set_modelling_rule(True)