I am curious as to the most efficient way to accomplish creating a custom dataset created from a UDT that comes from OPC. Currently I have created this script in a project library:
def createTable(dryer_data): # Renamed DryerType to dryer_data for clarity
# Create Header
header = ['Name','Actual', 'Set']
SetName = dryer_data['Set']['Name']
ActualName = dryer_data['Actual']['Name']
SetNumber = str(dryer_data['Set']['Number'])
ActualNumber = str(dryer_data['Actual']['Number'])
SetDryingTime = str(dryer_data['Set']['DryingTime'])
ActualDryingTime =str( dryer_data['Actual']['DryingTime'])
SetCoolingTime = str(dryer_data['Set']['CoolingTime'])
ActualCoolingTime =str( dryer_data['Actual']['CoolingTime'])
SetInletTemp = str(dryer_data['Set']['InletTemp'])
ActualInletTemp =str( dryer_data['Actual']['InletTemp'])
SetOutletTemp = str(dryer_data['Set']['OutletTemp'])
ActualOutletTemp =str( dryer_data['Actual']['OutletTemp'])
SetCoolingTemp = str(dryer_data['Set']['CoolingTemp'])
ActualCoolingTemp =str( dryer_data['Actual']['CoolingTemp'])
SetReversingTime = str(dryer_data['Set']['ReversingTime'])
ActualReversingTime =str( dryer_data['Actual']['ReversingTime'])
SetUnloadingTime = str(dryer_data['Set']['UnloadingTime'])
ActualUnloadingTime =str( dryer_data['Actual']['UnloadingTime'])
SetInfaredTemp = str(dryer_data['Set']['InfaredTemp'])
ActualInfaredTemp =str( dryer_data['Actual']['InfaredTemp'])
SetInfaredTime = str(dryer_data['Set']['InfaredTime'])
ActualInfaredTime =str( dryer_data['Actual']['InfaredTime'])
SetAfterDryingTime = str(dryer_data['Set']['AfterDryingTime'])
ActualAfterDryingTime =str( dryer_data['Actual']['AfterDryingTime'])
# Create Rows
rows = [
['Program Name', SetName, ActualName],
['Program Number', SetNumber, ActualNumber],
['Drying Time', SetDryingTime, ActualDryingTime],
['Cooling Time', SetCoolingTime, ActualCoolingTime],
['Inlet Temp', SetInletTemp, ActualInletTemp],
['Outlet Temp', SetOutletTemp, ActualOutletTemp],
['Cooling Temp', SetCoolingTemp, ActualCoolingTemp],
['Reversing Time', SetReversingTime, ActualReversingTime],
['Unloading Time', SetUnloadingTime, ActualUnloadingTime],
['Infared Temp', SetInfaredTemp, ActualInfaredTemp],
['Infared Time', SetInfaredTime, ActualInfaredTime],
['After Drying Time', SetAfterDryingTime, ActualAfterDryingTime]
]
# Create PyDataset
dataset = system.dataset.toDataSet(header, rows)
# Write the dataset to a tag
return dataset
I then call this through a Historical Tag binding on a table like this:
I was wondering is this the most efficient way to do this or is there something better like a transaction group that could accomplish this. The idea is to have this visualized in realitime in perpsective and stored to a database in way that is easily read. Also keep in mind that in in this UDT there are a lot of different data types that I am converting to a string so that the table structure can look like this: