Hello all,
I'm working on a project where I will need to loop through our unit info database and input data into a UDT on the PLC so the Engineers can look through it and do different things with the tags on the PLC side of things. The database will be changing, so I will need to use some for loops to accomplish this and plan to just run this script every 15 minutes from the gateway. There is a max of 500 in the UDT; however, we only have 87 entries currently.
The way the tags are separated is "Unit_BOM_x/Unit_BOM_000/../..", where Unit_BOM_000 goes all the way to "Unit_BOM_499" and within each of these folders are 15 different named folders named "Base_Model", "Base_Platform", "Basket_Model", "Basket_Platform", "Cab_Model", "Cab_Platform", "Drive_Model", "Drive_Platform", "Model_Number", "Platform", "Spare1_Model", "Spare1_Platform", "Spare2_Model" and "Spare2_Platform" for different parts model/platform. Inside of those folders is DATA and LEN, I will only be using the DATA bit. The folders are in the same order and follow the same naming conventions for all 500 UDT entries.
I'm pretty stuck on this one, I'm not too experienced with writing to this many tags at once and spreading them out to other addresses. I'm lost on how I can sparse out the info to the specific tags for all 87 units we currently have. I am currently only going to be writing to "Basket_Model/DATA", "Basket_Platform/DATA", "Drive_Model/DATA" and "Drive_Platform/DATA". The rest is for expansion in the future.
I created a script to loop through all of the "Unit_BOM_xxx" records to create a path for the tag writing inside of the for loop but get stuck when having to dig further, as the other folders have different names, then I have to dig into that for the DATA bit.
def onScheduledEvent():
for tagPath in range(500):
title = "Unit_BOM_x/Unit_BOM_"
digit = str(tagPath)
title = title + digit
I guess I'm basically just asking for help on if anyone knows how I would proceed. I need to run a for loop on my query then disperse that data to these paths. For that loop, I have the following query:
def onScheduledEvent():
for row in range(returnedDataset.getRowCount()):
ModelNumber = returnedDataset.getValueAt(row, "ModelNum")
DrivePlatform = returnedDataset.getValueAt(row, "DrivePlatform")
BasketPlatform = returnedDataset.getValueAt(row, "BasketPlatform")
Any help or pointing in the right direction is highly appreciated. Thank you in advance.