Hello,
I'm trying to dynamically add UDT instances inside of other UDT instances, but I'm getting the following error:
Error processing edit for tag path 'Engine/Line/Line 1/Station 1': Bad_Unsupported("The target path 'Engine/Line/Line 1' does not have item 'Station 1' for overrides, and cannot accept children tags.")
I'd appreciate some help with this. I was thinking that maybe the Station UDT needs to have the Line UDT as a parent type, but I'm really at a loss here.
import time
LOGGER = system.util.getLogger("TagCreationLogger")
def create_mcp_tags(device_name):
tag_json = {
"name": "MCP",
"typeId" : "Main/MCP",
"tagType" : "UdtInstance",
"parameters" : {
"plc" : device_name
}
}
system.tag.configure(device_name, tag_json, "o")
def create_agv_tags(device_name):
agv_count = system.tag.readBlocking(["[default]Engine/MCP/AGV_CNT"])[0].value
for i in range(agv_count):
tag_json = {
"name": "AGV {}".format(i+1),
"typeId" : "Main/AGV",
"tagType" : "UdtInstance",
"parameters" : {
"agvNumber" : i,
"plc" : device_name
}
}
system.tag.configure("{}/AGV".format(device_name), tag_json, "o")
def create_line_tags(device_name):
line_count = system.tag.readBlocking(["[default]Engine/MCP/Line_CNT"])[0].value
for i in range(line_count):
line_name = "Line {}".format(i + 1)
tag_json = {
"name": line_name,
"typeId": "Main/Line",
"tagType": "UdtInstance",
"parameters": {
"lineNumber": i,
"plc": device_name
}
}
line_path = "{}/Line/{}".format(device_name, line_name)
system.tag.configure(device_name + "/Line", [tag_json], "o")
station_count = system.tag.readBlocking(["[default]Engine/Line/{}/TotalStations".format(line_name)])[0].value
create_station_tags(line_path, i + 1, device_name, station_count)
def create_station_tags(line_path, line_number, device_name, station_count=10):
for i in range(station_count):
tag_json = {
"name": "Station {}".format(i + 1),
"typeId": "Main/Station",
"tagType": "UdtInstance",
"parameters": {
"stationNumber": i,
"plc" : device_name,
"lineNumber" : line_number
}
}
system.tag.configure(line_path, [tag_json], "m")
print("Station {} Configured at path {}".format(i+1, line_path))
LOGGER.info("Creating station tags at path: {}".format(line_path))
def create_all_tags(device_name):
create_mcp_tags(device_name)
create_agv_tags(device_name)
create_line_tags(device_name)
Thanks in advance.